expo-linking 2.4.2 → 3.2.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 +31 -2
- package/README.md +4 -4
- package/build/ExpoLinking.d.ts +1 -0
- package/build/ExpoLinking.d.ts.map +1 -0
- package/build/ExpoLinking.web.d.ts +4 -1
- package/build/ExpoLinking.web.d.ts.map +1 -0
- package/build/ExpoLinking.web.js +13 -0
- package/build/ExpoLinking.web.js.map +1 -1
- package/build/Linking.d.ts +65 -41
- package/build/Linking.d.ts.map +1 -0
- package/build/Linking.js +80 -42
- package/build/Linking.js.map +1 -1
- package/build/Linking.types.d.ts +11 -0
- package/build/Linking.types.d.ts.map +1 -0
- package/build/Linking.types.js.map +1 -1
- 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 +5 -5
- package/src/ExpoLinking.web.ts +15 -1
- package/src/Linking.ts +91 -52
- package/src/Linking.types.ts +19 -1
- package/src/Schemes.ts +19 -14
package/CHANGELOG.md
CHANGED
|
@@ -10,9 +10,38 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
-
## 2.
|
|
13
|
+
## 3.2.0 — 2022-07-07
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Fix bug in isExpoHosted for new manifests. ([#17402](https://github.com/expo/expo/pull/17402) by [@wschurman](https://github.com/wschurman))
|
|
18
|
+
- Fix `addEventListener` not returning a subscription on web. ([#17925](https://github.com/expo/expo/pull/17925) by [@EvanBacon](https://github.com/EvanBacon))
|
|
19
|
+
|
|
20
|
+
## 3.1.0 — 2022-04-18
|
|
21
|
+
|
|
22
|
+
### 🎉 New features
|
|
23
|
+
|
|
24
|
+
- `addEventListener` returns `EmitterSubscription` rather than `void` ([#17014](https://github.com/expo/expo/pull/17014) by [@frankcalise](https://github.com/frankcalise))
|
|
25
|
+
|
|
26
|
+
### 🐛 Bug fixes
|
|
27
|
+
|
|
28
|
+
- `addEventListener` and `removeEventListener` only accept `'url'` as `type` param, rather than `string`
|
|
29
|
+
- `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))
|
|
30
|
+
|
|
31
|
+
### 💡 Others
|
|
32
|
+
|
|
33
|
+
- Export public `Schemes` methods in main file. ([#17058](https://github.com/expo/expo/pull/17058) by [@Simek](https://github.com/Simek))
|
|
34
|
+
|
|
35
|
+
## 3.0.0 — 2021-12-03
|
|
36
|
+
|
|
37
|
+
### 🛠 Breaking changes
|
|
38
|
+
|
|
39
|
+
- Remove deprecated `useUrl` method. ([#15226](https://github.com/expo/expo/pull/15226) by [@Simek](https://github.com/Simek))
|
|
40
|
+
|
|
41
|
+
### 💡 Others
|
|
42
|
+
|
|
43
|
+
- Update `qs` dependency. ([#15069](https://github.com/expo/expo/pull/15069) by [@Simek](https://github.com/Simek))
|
|
44
|
+
- Extract `sendIntent` method `extras` parameter to the separate type named `SendIntentExtras`. ([#15226](https://github.com/expo/expo/pull/15226) by [@Simek](https://github.com/Simek))
|
|
16
45
|
|
|
17
46
|
## 2.4.1 — 2021-10-01
|
|
18
47
|
|
package/README.md
CHANGED
|
@@ -4,16 +4,16 @@ 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
|
|
|
16
|
-
For bare React Native projects, you must ensure that you have [installed and configured the `
|
|
16
|
+
For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
|
|
17
17
|
|
|
18
18
|
### Add the package to your npm dependencies
|
|
19
19
|
|
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"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { URLListener } from './Linking.types';
|
|
2
2
|
declare const _default: {
|
|
3
|
-
addEventListener(type: 'url', listener: URLListener):
|
|
3
|
+
addEventListener(type: 'url', listener: URLListener): {
|
|
4
|
+
remove(): void;
|
|
5
|
+
};
|
|
4
6
|
removeEventListener(type: 'url', listener: URLListener): void;
|
|
5
7
|
canOpenURL(url: string): Promise<boolean>;
|
|
6
8
|
getInitialURL(): Promise<string>;
|
|
7
9
|
openURL(url: string): Promise<void>;
|
|
8
10
|
};
|
|
9
11
|
export default _default;
|
|
12
|
+
//# sourceMappingURL=ExpoLinking.web.d.ts.map
|
|
@@ -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;QAAE,MAAM,IAAI,IAAI,CAAA;KAAE;8BAqB9C,KAAK,YAAY,WAAW,GAAG,IAAI;oBAmBvC,MAAM,GAAG,QAAQ,OAAO,CAAC;qBAKxB,QAAQ,MAAM,CAAC;iBAKnB,MAAM,GAAG,QAAQ,IAAI,CAAC;;AAnD3C,wBAyDE"}
|
package/build/ExpoLinking.web.js
CHANGED
|
@@ -4,12 +4,25 @@ const EventTypes = ['url'];
|
|
|
4
4
|
const listeners = [];
|
|
5
5
|
export default {
|
|
6
6
|
addEventListener(type, listener) {
|
|
7
|
+
// Do nothing in Node.js environments
|
|
8
|
+
if (!Platform.isDOMAvailable) {
|
|
9
|
+
return { remove() { } };
|
|
10
|
+
}
|
|
7
11
|
invariant(EventTypes.indexOf(type) !== -1, `Linking.addEventListener(): ${type} is not a valid event`);
|
|
8
12
|
const nativeListener = (nativeEvent) => listener({ url: window.location.href, nativeEvent });
|
|
9
13
|
listeners.push({ listener, nativeListener });
|
|
10
14
|
window.addEventListener('message', nativeListener, false);
|
|
15
|
+
return {
|
|
16
|
+
remove: () => {
|
|
17
|
+
this.removeEventListener(type, listener);
|
|
18
|
+
},
|
|
19
|
+
};
|
|
11
20
|
},
|
|
12
21
|
removeEventListener(type, listener) {
|
|
22
|
+
// Do nothing in Node.js environments
|
|
23
|
+
if (!Platform.isDOMAvailable) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
13
26
|
invariant(EventTypes.indexOf(type) !== -1, `Linking.removeEventListener(): ${type} is not a valid event.`);
|
|
14
27
|
const listenerIndex = listeners.findIndex((pair) => pair.listener === listener);
|
|
15
28
|
invariant(listenerIndex !== -1, 'Linking.removeEventListener(): cannot remove an unregistered event listener.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoLinking.web.js","sourceRoot":"","sources":["../src/ExpoLinking.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,SAAS,MAAM,WAAW,CAAC;AAIl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3B,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 'expo-modules-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): { remove(): void } {\n // Do nothing in Node.js environments\n if (!Platform.isDOMAvailable) {\n return { remove() {} };\n }\n\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 return {\n remove: () => {\n this.removeEventListener(type, listener);\n },\n };\n },\n\n removeEventListener(type: 'url', listener: URLListener): void {\n // Do nothing in Node.js environments\n if (!Platform.isDOMAvailable) {\n return;\n }\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"]}
|
package/build/Linking.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EmitterSubscription } from 'react-native';
|
|
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.
|
|
4
5
|
* The scheme in bare and standalone must be defined in the app.json under `expo.scheme`.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
7
|
+
* # Examples
|
|
8
8
|
* - Bare: empty string
|
|
9
9
|
* - Standalone, Custom: `yourscheme:///path`
|
|
10
10
|
* - Web (dev): `https://localhost:19006/path`
|
|
@@ -13,87 +13,111 @@ import { CreateURLOptions, ParsedURL, QueryParams, URLListener } from './Linking
|
|
|
13
13
|
* - Expo Client (prod): `exp://exp.host/@yourname/your-app/--/path`
|
|
14
14
|
*
|
|
15
15
|
* @param path addition path components to append to the base URL.
|
|
16
|
-
* @param queryParams An object of parameters
|
|
16
|
+
* @param queryParams An object with a set of query parameters. These will be merged with any
|
|
17
|
+
* Expo-specific parameters that are needed (e.g. release channel) and then appended to the URL
|
|
18
|
+
* as a query string.
|
|
19
|
+
* @param scheme Optional URI protocol to use in the URL `<scheme>:///`, when `undefined` the scheme
|
|
20
|
+
* will be chosen from the Expo config (`app.config.js` or `app.json`).
|
|
21
|
+
* @return A URL string which points to your app with the given deep link information.
|
|
22
|
+
* @deprecated An alias for [`createURL()`](#linkingcreateurlpath-namedparameters). This method is
|
|
23
|
+
* deprecated and will be removed in a future SDK version.
|
|
17
24
|
*/
|
|
18
25
|
export declare function makeUrl(path?: string, queryParams?: QueryParams, scheme?: string): string;
|
|
19
26
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
27
|
+
* Helper method for constructing a deep link into your app, given an optional path and set of query
|
|
28
|
+
* parameters. Creates a URI scheme with two slashes by default.
|
|
22
29
|
*
|
|
23
|
-
*
|
|
30
|
+
* The scheme in bare and standalone must be defined in the Expo config (`app.config.js` or `app.json`)
|
|
31
|
+
* under `expo.scheme`.
|
|
24
32
|
*
|
|
25
|
-
*
|
|
33
|
+
* # Examples
|
|
34
|
+
* - Bare: `<scheme>://path` - uses provided scheme or scheme from Expo config `scheme`.
|
|
26
35
|
* - Standalone, Custom: `yourscheme://path`
|
|
27
36
|
* - Web (dev): `https://localhost:19006/path`
|
|
28
37
|
* - Web (prod): `https://myapp.com/path`
|
|
29
38
|
* - Expo Client (dev): `exp://128.0.0.1:19000/--/path`
|
|
30
39
|
* - Expo Client (prod): `exp://exp.host/@yourname/your-app/--/path`
|
|
31
40
|
*
|
|
32
|
-
* @param path
|
|
33
|
-
* @param
|
|
34
|
-
* @
|
|
41
|
+
* @param path Addition path components to append to the base URL.
|
|
42
|
+
* @param namedParameters Additional options object.
|
|
43
|
+
* @return A URL string which points to your app with the given deep link information.
|
|
35
44
|
*/
|
|
36
45
|
export declare function createURL(path: string, { scheme, queryParams, isTripleSlashed }?: CreateURLOptions): string;
|
|
37
46
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* @
|
|
47
|
+
* Helper method for parsing out deep link information from a URL.
|
|
48
|
+
* @param url A URL that points to the currently running experience (e.g. an output of `Linking.createURL()`).
|
|
49
|
+
* @return A `ParsedURL` object.
|
|
41
50
|
*/
|
|
42
51
|
export declare function parse(url: string): ParsedURL;
|
|
43
52
|
/**
|
|
44
|
-
* Add a handler to Linking changes by listening to the `url` event type
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
53
|
+
* Add a handler to `Linking` changes by listening to the `url` event type and providing the handler.
|
|
54
|
+
* It is recommended to use the [`useURL()`](#useurl) hook instead.
|
|
55
|
+
* @param type The only valid type is `'url'`.
|
|
56
|
+
* @param handler An [`URLListener`](#urllistener) function that takes an `event` object of the type
|
|
57
|
+
* [`EventType`](#eventype).
|
|
58
|
+
* @return An EmitterSubscription that has the remove method from EventSubscription
|
|
59
|
+
* @see [React Native Docs Linking page](https://reactnative.dev/docs/linking#addeventlistener).
|
|
48
60
|
*/
|
|
49
|
-
export declare function addEventListener(type:
|
|
61
|
+
export declare function addEventListener(type: 'url', handler: URLListener): EmitterSubscription;
|
|
50
62
|
/**
|
|
51
63
|
* Remove a handler by passing the `url` event type and the handler.
|
|
64
|
+
* @param type The only valid type is `'url'`.
|
|
65
|
+
* @param handler An [`URLListener`](#urllistener) function that takes an `event` object of the type
|
|
66
|
+
* [`EventType`](#eventype).
|
|
67
|
+
* @see [React Native Docs Linking page](https://reactnative.dev/docs/linking#removeeventlistener).
|
|
52
68
|
*
|
|
53
|
-
*
|
|
69
|
+
* @deprecated Call `remove()` on the return value of `addEventListener()` instead.
|
|
54
70
|
*/
|
|
55
|
-
export declare function removeEventListener(type:
|
|
71
|
+
export declare function removeEventListener(type: 'url', handler: URLListener): void;
|
|
56
72
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
73
|
+
* Helper method which wraps React Native's `Linking.getInitialURL()` in `Linking.parse()`.
|
|
74
|
+
* Parses the deep link information out of the URL used to open the experience initially.
|
|
75
|
+
* If no link opened the app, all the fields will be `null`.
|
|
76
|
+
* > On the web it parses the current window URL.
|
|
77
|
+
* @return A promise that resolves with `ParsedURL` object.
|
|
59
78
|
*/
|
|
60
79
|
export declare function parseInitialURLAsync(): Promise<ParsedURL>;
|
|
61
80
|
/**
|
|
62
|
-
* Launch an Android intent with
|
|
63
|
-
*
|
|
81
|
+
* Launch an Android intent with extras.
|
|
82
|
+
* > Use [IntentLauncher](./intent-launcher) instead, `sendIntent` is only included in
|
|
83
|
+
* > `Linking` for API compatibility with React Native's Linking API.
|
|
64
84
|
* @platform android
|
|
65
85
|
*/
|
|
66
|
-
export declare function sendIntent(action: string, extras?:
|
|
67
|
-
key: string;
|
|
68
|
-
value: string | number | boolean;
|
|
69
|
-
}[]): Promise<void>;
|
|
86
|
+
export declare function sendIntent(action: string, extras?: SendIntentExtras[]): Promise<void>;
|
|
70
87
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* @platform ios
|
|
88
|
+
* Open the operating system settings app and displays the app’s custom settings, if it has any.
|
|
74
89
|
*/
|
|
75
90
|
export declare function openSettings(): Promise<void>;
|
|
76
91
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
92
|
+
* Get the URL that was used to launch the app if it was launched by a link.
|
|
93
|
+
* @return The URL string that launched your app, or `null`.
|
|
79
94
|
*/
|
|
80
95
|
export declare function getInitialURL(): Promise<string | null>;
|
|
81
96
|
/**
|
|
82
|
-
*
|
|
97
|
+
* Attempt to open the given URL with an installed app. See the [Linking guide](/guides/linking)
|
|
98
|
+
* for more information.
|
|
99
|
+
* @param url A URL for the operating system to open, eg: `tel:5555555`, `exp://`.
|
|
100
|
+
* @return A `Promise` that is fulfilled with `true` if the link is opened operating system
|
|
101
|
+
* automatically or the user confirms the prompt to open the link. The `Promise` rejects if there
|
|
102
|
+
* are no applications registered for the URL or the user cancels the dialog.
|
|
83
103
|
*/
|
|
84
104
|
export declare function openURL(url: string): Promise<true>;
|
|
85
105
|
/**
|
|
86
106
|
* Determine whether or not an installed app can handle a given URL.
|
|
87
|
-
* On web this always returns true because there is no API for detecting what URLs can be opened.
|
|
107
|
+
* On web this always returns `true` because there is no API for detecting what URLs can be opened.
|
|
108
|
+
* @param url The URL that you want to test can be opened.
|
|
109
|
+
* @return A `Promise` object that is fulfilled with `true` if the URL can be handled, otherwise it
|
|
110
|
+
* `false` if not.
|
|
111
|
+
*
|
|
112
|
+
* The `Promise` will reject on Android if it was impossible to check if the URL can be opened, and
|
|
113
|
+
* on iOS if you didn't [add the specific scheme in the `LSApplicationQueriesSchemes` key inside **Info.plist**](/guides/linking#opening-links-to-other-apps).
|
|
88
114
|
*/
|
|
89
115
|
export declare function canOpenURL(url: string): Promise<boolean>;
|
|
90
116
|
/**
|
|
91
117
|
* Returns the initial URL followed by any subsequent changes to the URL.
|
|
118
|
+
* @return Returns the initial URL or `null`.
|
|
92
119
|
*/
|
|
93
120
|
export declare function useURL(): string | null;
|
|
94
|
-
/**
|
|
95
|
-
* Returns the initial URL followed by any subsequent changes to the URL.
|
|
96
|
-
* @deprecated Use `useURL` instead.
|
|
97
|
-
*/
|
|
98
|
-
export declare function useUrl(): string | null;
|
|
99
121
|
export * from './Linking.types';
|
|
122
|
+
export * from './Schemes';
|
|
123
|
+
//# 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;AAyEzB;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;GAQG;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;;GAEG;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
|
@@ -13,8 +13,12 @@ function validateURL(url) {
|
|
|
13
13
|
function getHostUri() {
|
|
14
14
|
if (Constants.manifest?.hostUri) {
|
|
15
15
|
return Constants.manifest.hostUri;
|
|
16
|
+
// @ts-ignore: hostUri isn't defined on the expoClient type, because
|
|
17
|
+
// Constants.manifest is of type AppManifest while
|
|
18
|
+
// Constants.manifest2.extra.expoClient is of type ExpoConfig
|
|
16
19
|
}
|
|
17
20
|
else if (Constants.manifest2?.extra?.expoClient?.hostUri) {
|
|
21
|
+
// @ts-ignore
|
|
18
22
|
return Constants.manifest2.extra.expoClient.hostUri;
|
|
19
23
|
}
|
|
20
24
|
else if (!hasCustomScheme()) {
|
|
@@ -30,7 +34,8 @@ function isExpoHosted() {
|
|
|
30
34
|
const hostUri = getHostUri();
|
|
31
35
|
return !!(hostUri &&
|
|
32
36
|
(/^(.*\.)?(expo\.io|exp\.host|exp\.direct|expo\.test)(:.*)?(\/.*)?$/.test(hostUri) ||
|
|
33
|
-
Constants.manifest?.developer
|
|
37
|
+
Constants.manifest?.developer ||
|
|
38
|
+
Constants.manifest2?.extra?.expoGo?.developer));
|
|
34
39
|
}
|
|
35
40
|
function removeScheme(url) {
|
|
36
41
|
return url.replace(/^[a-zA-Z0-9+.-]+:\/\//, '');
|
|
@@ -64,12 +69,12 @@ function ensureLeadingSlash(input, shouldAppend) {
|
|
|
64
69
|
}
|
|
65
70
|
return input;
|
|
66
71
|
}
|
|
72
|
+
// @needsAudit
|
|
67
73
|
/**
|
|
68
74
|
* Create a URL that works for the environment the app is currently running in.
|
|
69
75
|
* The scheme in bare and standalone must be defined in the app.json under `expo.scheme`.
|
|
70
76
|
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
77
|
+
* # Examples
|
|
73
78
|
* - Bare: empty string
|
|
74
79
|
* - Standalone, Custom: `yourscheme:///path`
|
|
75
80
|
* - Web (dev): `https://localhost:19006/path`
|
|
@@ -78,27 +83,37 @@ function ensureLeadingSlash(input, shouldAppend) {
|
|
|
78
83
|
* - Expo Client (prod): `exp://exp.host/@yourname/your-app/--/path`
|
|
79
84
|
*
|
|
80
85
|
* @param path addition path components to append to the base URL.
|
|
81
|
-
* @param queryParams An object of parameters
|
|
86
|
+
* @param queryParams An object with a set of query parameters. These will be merged with any
|
|
87
|
+
* Expo-specific parameters that are needed (e.g. release channel) and then appended to the URL
|
|
88
|
+
* as a query string.
|
|
89
|
+
* @param scheme Optional URI protocol to use in the URL `<scheme>:///`, when `undefined` the scheme
|
|
90
|
+
* will be chosen from the Expo config (`app.config.js` or `app.json`).
|
|
91
|
+
* @return A URL string which points to your app with the given deep link information.
|
|
92
|
+
* @deprecated An alias for [`createURL()`](#linkingcreateurlpath-namedparameters). This method is
|
|
93
|
+
* deprecated and will be removed in a future SDK version.
|
|
82
94
|
*/
|
|
83
95
|
export function makeUrl(path = '', queryParams, scheme) {
|
|
84
96
|
return createURL(path, { queryParams, scheme, isTripleSlashed: true });
|
|
85
97
|
}
|
|
98
|
+
// @needsAudit
|
|
86
99
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
100
|
+
* Helper method for constructing a deep link into your app, given an optional path and set of query
|
|
101
|
+
* parameters. Creates a URI scheme with two slashes by default.
|
|
89
102
|
*
|
|
90
|
-
*
|
|
103
|
+
* The scheme in bare and standalone must be defined in the Expo config (`app.config.js` or `app.json`)
|
|
104
|
+
* under `expo.scheme`.
|
|
91
105
|
*
|
|
92
|
-
*
|
|
106
|
+
* # Examples
|
|
107
|
+
* - Bare: `<scheme>://path` - uses provided scheme or scheme from Expo config `scheme`.
|
|
93
108
|
* - Standalone, Custom: `yourscheme://path`
|
|
94
109
|
* - Web (dev): `https://localhost:19006/path`
|
|
95
110
|
* - Web (prod): `https://myapp.com/path`
|
|
96
111
|
* - Expo Client (dev): `exp://128.0.0.1:19000/--/path`
|
|
97
112
|
* - Expo Client (prod): `exp://exp.host/@yourname/your-app/--/path`
|
|
98
113
|
*
|
|
99
|
-
* @param path
|
|
100
|
-
* @param
|
|
101
|
-
* @
|
|
114
|
+
* @param path Addition path components to append to the base URL.
|
|
115
|
+
* @param namedParameters Additional options object.
|
|
116
|
+
* @return A URL string which points to your app with the given deep link information.
|
|
102
117
|
*/
|
|
103
118
|
export function createURL(path, { scheme, queryParams = {}, isTripleSlashed = false } = {}) {
|
|
104
119
|
if (Platform.OS === 'web') {
|
|
@@ -144,7 +159,7 @@ export function createURL(path, { scheme, queryParams = {}, isTripleSlashed = fa
|
|
|
144
159
|
paramsFromHostUri = parsedParams;
|
|
145
160
|
}
|
|
146
161
|
}
|
|
147
|
-
catch
|
|
162
|
+
catch { }
|
|
148
163
|
queryParams = {
|
|
149
164
|
...queryParams,
|
|
150
165
|
...paramsFromHostUri,
|
|
@@ -157,10 +172,11 @@ export function createURL(path, { scheme, queryParams = {}, isTripleSlashed = fa
|
|
|
157
172
|
hostUri = ensureLeadingSlash(hostUri, !isTripleSlashed);
|
|
158
173
|
return encodeURI(`${resolvedScheme}:${isTripleSlashed ? '/' : ''}/${hostUri}${path}${queryString}`);
|
|
159
174
|
}
|
|
175
|
+
// @needsAudit
|
|
160
176
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
* @
|
|
177
|
+
* Helper method for parsing out deep link information from a URL.
|
|
178
|
+
* @param url A URL that points to the currently running experience (e.g. an output of `Linking.createURL()`).
|
|
179
|
+
* @return A `ParsedURL` object.
|
|
164
180
|
*/
|
|
165
181
|
export function parse(url) {
|
|
166
182
|
validateURL(url);
|
|
@@ -200,26 +216,38 @@ export function parse(url) {
|
|
|
200
216
|
scheme,
|
|
201
217
|
};
|
|
202
218
|
}
|
|
219
|
+
// @needsAudit
|
|
203
220
|
/**
|
|
204
|
-
* Add a handler to Linking changes by listening to the `url` event type
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
221
|
+
* Add a handler to `Linking` changes by listening to the `url` event type and providing the handler.
|
|
222
|
+
* It is recommended to use the [`useURL()`](#useurl) hook instead.
|
|
223
|
+
* @param type The only valid type is `'url'`.
|
|
224
|
+
* @param handler An [`URLListener`](#urllistener) function that takes an `event` object of the type
|
|
225
|
+
* [`EventType`](#eventype).
|
|
226
|
+
* @return An EmitterSubscription that has the remove method from EventSubscription
|
|
227
|
+
* @see [React Native Docs Linking page](https://reactnative.dev/docs/linking#addeventlistener).
|
|
208
228
|
*/
|
|
209
229
|
export function addEventListener(type, handler) {
|
|
210
|
-
NativeLinking.addEventListener(type, handler);
|
|
230
|
+
return NativeLinking.addEventListener(type, handler);
|
|
211
231
|
}
|
|
212
232
|
/**
|
|
213
233
|
* Remove a handler by passing the `url` event type and the handler.
|
|
234
|
+
* @param type The only valid type is `'url'`.
|
|
235
|
+
* @param handler An [`URLListener`](#urllistener) function that takes an `event` object of the type
|
|
236
|
+
* [`EventType`](#eventype).
|
|
237
|
+
* @see [React Native Docs Linking page](https://reactnative.dev/docs/linking#removeeventlistener).
|
|
214
238
|
*
|
|
215
|
-
*
|
|
239
|
+
* @deprecated Call `remove()` on the return value of `addEventListener()` instead.
|
|
216
240
|
*/
|
|
217
241
|
export function removeEventListener(type, handler) {
|
|
218
242
|
NativeLinking.removeEventListener(type, handler);
|
|
219
243
|
}
|
|
244
|
+
// @needsAudit
|
|
220
245
|
/**
|
|
221
|
-
*
|
|
222
|
-
*
|
|
246
|
+
* Helper method which wraps React Native's `Linking.getInitialURL()` in `Linking.parse()`.
|
|
247
|
+
* Parses the deep link information out of the URL used to open the experience initially.
|
|
248
|
+
* If no link opened the app, all the fields will be `null`.
|
|
249
|
+
* > On the web it parses the current window URL.
|
|
250
|
+
* @return A promise that resolves with `ParsedURL` object.
|
|
223
251
|
*/
|
|
224
252
|
export async function parseInitialURLAsync() {
|
|
225
253
|
const initialUrl = await NativeLinking.getInitialURL();
|
|
@@ -233,9 +261,11 @@ export async function parseInitialURLAsync() {
|
|
|
233
261
|
}
|
|
234
262
|
return parse(initialUrl);
|
|
235
263
|
}
|
|
264
|
+
// @needsAudit
|
|
236
265
|
/**
|
|
237
|
-
* Launch an Android intent with
|
|
238
|
-
*
|
|
266
|
+
* Launch an Android intent with extras.
|
|
267
|
+
* > Use [IntentLauncher](./intent-launcher) instead, `sendIntent` is only included in
|
|
268
|
+
* > `Linking` for API compatibility with React Native's Linking API.
|
|
239
269
|
* @platform android
|
|
240
270
|
*/
|
|
241
271
|
export async function sendIntent(action, extras) {
|
|
@@ -244,10 +274,9 @@ export async function sendIntent(action, extras) {
|
|
|
244
274
|
}
|
|
245
275
|
throw new UnavailabilityError('Linking', 'sendIntent');
|
|
246
276
|
}
|
|
277
|
+
// @needsAudit
|
|
247
278
|
/**
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
* @platform ios
|
|
279
|
+
* Open the operating system settings app and displays the app’s custom settings, if it has any.
|
|
251
280
|
*/
|
|
252
281
|
export async function openSettings() {
|
|
253
282
|
if (Platform.OS === 'web') {
|
|
@@ -258,30 +287,46 @@ export async function openSettings() {
|
|
|
258
287
|
}
|
|
259
288
|
await openURL('app-settings:');
|
|
260
289
|
}
|
|
290
|
+
// @needsAudit
|
|
261
291
|
/**
|
|
262
|
-
*
|
|
263
|
-
*
|
|
292
|
+
* Get the URL that was used to launch the app if it was launched by a link.
|
|
293
|
+
* @return The URL string that launched your app, or `null`.
|
|
264
294
|
*/
|
|
265
295
|
export async function getInitialURL() {
|
|
266
296
|
return (await NativeLinking.getInitialURL()) ?? null;
|
|
267
297
|
}
|
|
298
|
+
// @needsAudit
|
|
268
299
|
/**
|
|
269
|
-
*
|
|
300
|
+
* Attempt to open the given URL with an installed app. See the [Linking guide](/guides/linking)
|
|
301
|
+
* for more information.
|
|
302
|
+
* @param url A URL for the operating system to open, eg: `tel:5555555`, `exp://`.
|
|
303
|
+
* @return A `Promise` that is fulfilled with `true` if the link is opened operating system
|
|
304
|
+
* automatically or the user confirms the prompt to open the link. The `Promise` rejects if there
|
|
305
|
+
* are no applications registered for the URL or the user cancels the dialog.
|
|
270
306
|
*/
|
|
271
307
|
export async function openURL(url) {
|
|
272
308
|
validateURL(url);
|
|
273
309
|
return await NativeLinking.openURL(url);
|
|
274
310
|
}
|
|
311
|
+
// @needsAudit
|
|
275
312
|
/**
|
|
276
313
|
* Determine whether or not an installed app can handle a given URL.
|
|
277
|
-
* On web this always returns true because there is no API for detecting what URLs can be opened.
|
|
314
|
+
* On web this always returns `true` because there is no API for detecting what URLs can be opened.
|
|
315
|
+
* @param url The URL that you want to test can be opened.
|
|
316
|
+
* @return A `Promise` object that is fulfilled with `true` if the URL can be handled, otherwise it
|
|
317
|
+
* `false` if not.
|
|
318
|
+
*
|
|
319
|
+
* The `Promise` will reject on Android if it was impossible to check if the URL can be opened, and
|
|
320
|
+
* on iOS if you didn't [add the specific scheme in the `LSApplicationQueriesSchemes` key inside **Info.plist**](/guides/linking#opening-links-to-other-apps).
|
|
278
321
|
*/
|
|
279
322
|
export async function canOpenURL(url) {
|
|
280
323
|
validateURL(url);
|
|
281
324
|
return await NativeLinking.canOpenURL(url);
|
|
282
325
|
}
|
|
326
|
+
// @needsAudit
|
|
283
327
|
/**
|
|
284
328
|
* Returns the initial URL followed by any subsequent changes to the URL.
|
|
329
|
+
* @return Returns the initial URL or `null`.
|
|
285
330
|
*/
|
|
286
331
|
export function useURL() {
|
|
287
332
|
const [url, setLink] = useState(null);
|
|
@@ -290,18 +335,11 @@ export function useURL() {
|
|
|
290
335
|
}
|
|
291
336
|
useEffect(() => {
|
|
292
337
|
getInitialURL().then((url) => setLink(url));
|
|
293
|
-
addEventListener('url', onChange);
|
|
294
|
-
return () =>
|
|
338
|
+
const subscription = addEventListener('url', onChange);
|
|
339
|
+
return () => subscription.remove();
|
|
295
340
|
}, []);
|
|
296
341
|
return url;
|
|
297
342
|
}
|
|
298
|
-
/**
|
|
299
|
-
* Returns the initial URL followed by any subsequent changes to the URL.
|
|
300
|
-
* @deprecated Use `useURL` instead.
|
|
301
|
-
*/
|
|
302
|
-
export function useUrl() {
|
|
303
|
-
console.warn(`Linking.useUrl has been deprecated in favor of Linking.useURL. This API will be removed in SDK 44.`);
|
|
304
|
-
return useURL();
|
|
305
|
-
}
|
|
306
343
|
export * from './Linking.types';
|
|
344
|
+
export * from './Schemes';
|
|
307
345
|
//# sourceMappingURL=Linking.js.map
|