expo-linking 5.0.2 → 6.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 CHANGED
@@ -10,6 +10,24 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 6.1.0 — 2023-09-15
14
+
15
+ ### 🛠 Breaking changes
16
+
17
+ - Remove deprecated `makeUrl` function. ([#24300](https://github.com/expo/expo/pull/24300) by [@EvanBacon](https://github.com/EvanBacon))
18
+
19
+ ### 🐛 Bug fixes
20
+
21
+ - Fix parsing web URLs with `+` symbols in the pathname. ([#24300](https://github.com/expo/expo/pull/24300) by [@EvanBacon](https://github.com/EvanBacon))
22
+
23
+ ### 💡 Others
24
+
25
+ - Reduce bundle size on web. ([#24300](https://github.com/expo/expo/pull/24300) by [@EvanBacon](https://github.com/EvanBacon))
26
+
27
+ ## 6.0.0 — 2023-08-02
28
+
29
+ _This version does not introduce any user-facing changes._
30
+
13
31
  ## 5.0.2 — 2023-06-24
14
32
 
15
33
  _This version does not introduce any user-facing changes._
@@ -4,7 +4,7 @@ declare const _default: {
4
4
  remove(): void;
5
5
  };
6
6
  removeEventListener(type: 'url', listener: URLListener): void;
7
- canOpenURL(url: string): Promise<boolean>;
7
+ canOpenURL(): Promise<boolean>;
8
8
  getInitialURL(): Promise<string>;
9
9
  openURL(url: string): Promise<void>;
10
10
  };
@@ -1 +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"}
1
+ {"version":3,"file":"ExpoLinking.web.d.ts","sourceRoot":"","sources":["../src/ExpoLinking.web.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,WAAW,EAAE,MAAM,iBAAiB,CAAC;;2BAKxC,KAAK,YAAY,WAAW,GAAG;QAAE,MAAM,IAAI,IAAI,CAAA;KAAE;8BAkB9C,KAAK,YAAY,WAAW,GAAG,IAAI;kBAgBzC,QAAQ,OAAO,CAAC;qBAKb,QAAQ,MAAM,CAAC;iBAKnB,MAAM,GAAG,QAAQ,IAAI,CAAC;;AA7C3C,wBAmDE"}
@@ -1,14 +1,12 @@
1
- import { Platform } from 'expo-modules-core';
2
1
  import invariant from 'invariant';
3
- const EventTypes = ['url'];
4
2
  const listeners = [];
5
3
  export default {
6
4
  addEventListener(type, listener) {
7
5
  // Do nothing in Node.js environments
8
- if (!Platform.isDOMAvailable) {
6
+ if (typeof window === 'undefined') {
9
7
  return { remove() { } };
10
8
  }
11
- invariant(EventTypes.indexOf(type) !== -1, `Linking.addEventListener(): ${type} is not a valid event`);
9
+ invariant(type === 'url', `Linking.addEventListener(): ${type} is not a valid event`);
12
10
  const nativeListener = (nativeEvent) => listener({ url: window.location.href, nativeEvent });
13
11
  listeners.push({ listener, nativeListener });
14
12
  window.addEventListener('message', nativeListener, false);
@@ -20,27 +18,27 @@ export default {
20
18
  },
21
19
  removeEventListener(type, listener) {
22
20
  // Do nothing in Node.js environments
23
- if (!Platform.isDOMAvailable) {
21
+ if (typeof window === 'undefined') {
24
22
  return;
25
23
  }
26
- invariant(EventTypes.indexOf(type) !== -1, `Linking.removeEventListener(): ${type} is not a valid event.`);
24
+ invariant(type === 'url', `Linking.addEventListener(): ${type} is not a valid event`);
27
25
  const listenerIndex = listeners.findIndex((pair) => pair.listener === listener);
28
26
  invariant(listenerIndex !== -1, 'Linking.removeEventListener(): cannot remove an unregistered event listener.');
29
27
  const nativeListener = listeners[listenerIndex].nativeListener;
30
28
  window.removeEventListener('message', nativeListener, false);
31
29
  listeners.splice(listenerIndex, 1);
32
30
  },
33
- async canOpenURL(url) {
31
+ async canOpenURL() {
34
32
  // In reality this should be able to return false for links like `chrome://` on chrome.
35
33
  return true;
36
34
  },
37
35
  async getInitialURL() {
38
- if (!Platform.isDOMAvailable)
36
+ if (typeof window === 'undefined')
39
37
  return '';
40
38
  return window.location.href;
41
39
  },
42
40
  async openURL(url) {
43
- if (Platform.isDOMAvailable) {
41
+ if (typeof window !== 'undefined') {
44
42
  // @ts-ignore
45
43
  window.location = new URL(url, window.location).toString();
46
44
  }
@@ -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;AAIlC,MAAM,UAAU,GAAG,CAAC,KAAK,CAAC,CAAC;AAE3B,MAAM,SAAS,GAAmE,EAAE,CAAC;AAErF,eAAe;IACb,gBAAgB,CAAC,IAAW,EAAE,QAAqB;QACjD,qCAAqC;QACrC,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE;YAC5B,OAAO,EAAE,MAAM,KAAI,CAAC,EAAE,CAAC;SACxB;QAED,SAAS,CACP,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAC/B,+BAA+B,IAAI,uBAAuB,CAC3D,CAAC;QACF,MAAM,cAAc,GAAsB,CAAC,WAAW,EAAE,EAAE,CACxD,QAAQ,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;QACvD,SAAS,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC,CAAC;QAC7C,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;QAC1D,OAAO;YACL,MAAM,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ules-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"]}
1
+ {"version":3,"file":"ExpoLinking.web.js","sourceRoot":"","sources":["../src/ExpoLinking.web.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAIlC,MAAM,SAAS,GAAmE,EAAE,CAAC;AAErF,eAAe;IACb,gBAAgB,CAAC,IAAW,EAAE,QAAqB;QACjD,qCAAqC;QACr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AuF;QACvF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,IAAI,OAAO,MAAM,KAAK,WAAW;YAAE,OAAO,EAAE,CAAC;QAC7C,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAW;QACvB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YACjC,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 invariant from 'invariant';\n\nimport { NativeURLListener, URLListener } from './Linking.types';\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 (typeof window === 'undefined') {\n return { remove() {} };\n }\n\n invariant(type === 'url', `Linking.addEventListener(): ${type} is not a valid event`);\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 (typeof window === 'undefined') {\n return;\n }\n invariant(type === 'url', `Linking.addEventListener(): ${type} is not a valid event`);\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(): 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 (typeof window === 'undefined') return '';\n return window.location.href;\n },\n\n async openURL(url: string): Promise<void> {\n if (typeof window !== 'undefined') {\n // @ts-ignore\n window.location = new URL(url, window.location).toString();\n }\n },\n};\n"]}
@@ -1,54 +1,5 @@
1
1
  import { EmitterSubscription } from 'react-native';
2
- import { CreateURLOptions, ParsedURL, QueryParams, SendIntentExtras, URLListener } from './Linking.types';
3
- /**
4
- * Create a URL that works for the environment the app is currently running in.
5
- * The scheme in bare and standalone must be defined in the app.json under `expo.scheme`.
6
- *
7
- * # Examples
8
- * - Bare: empty string
9
- * - Standalone, Custom: `yourscheme:///path`
10
- * - Web (dev): `https://localhost:19006/path`
11
- * - Web (prod): `https://myapp.com/path`
12
- * - Expo Client (dev): `exp://128.0.0.1:8081/--/path`
13
- * - Expo Client (prod): `exp://exp.host/@yourname/your-app/--/path`
14
- *
15
- * @param path addition path components to append to the base URL.
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.
24
- */
25
- export declare function makeUrl(path?: string, queryParams?: QueryParams, scheme?: string): string;
26
- /**
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.
29
- *
30
- * The scheme in bare and standalone must be defined in the Expo config (`app.config.js` or `app.json`)
31
- * under `expo.scheme`.
32
- *
33
- * # Examples
34
- * - Bare: `<scheme>://path` - uses provided scheme or scheme from Expo config `scheme`.
35
- * - Standalone, Custom: `yourscheme://path`
36
- * - Web (dev): `https://localhost:19006/path`
37
- * - Web (prod): `https://myapp.com/path`
38
- * - Expo Client (dev): `exp://128.0.0.1:8081/--/path`
39
- * - Expo Client (prod): `exp://exp.host/@yourname/your-app/--/path`
40
- *
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.
44
- */
45
- export declare function createURL(path: string, { scheme, queryParams, isTripleSlashed }?: CreateURLOptions): string;
46
- /**
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.
50
- */
51
- export declare function parse(url: string): ParsedURL;
2
+ import { ParsedURL, SendIntentExtras, URLListener } from './Linking.types';
52
3
  /**
53
4
  * Add a handler to `Linking` changes by listening to the `url` event type and providing the handler.
54
5
  * It is recommended to use the [`useURL()`](#useurl) hook instead.
@@ -110,4 +61,5 @@ export declare function canOpenURL(url: string): Promise<boolean>;
110
61
  export declare function useURL(): string | null;
111
62
  export * from './Linking.types';
112
63
  export * from './Schemes';
64
+ export { parse, createURL } from './createURL';
113
65
  //# sourceMappingURL=Linking.d.ts.map
@@ -1 +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;AAkEzB;;;;;;;;;;;;;;;;;;;;;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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,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;AAC1B,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
package/build/Linking.js CHANGED
@@ -1,213 +1,9 @@
1
- import Constants from 'expo-constants';
2
- import { Platform, UnavailabilityError } from 'expo-modules-core';
3
- import invariant from 'invariant';
4
- import qs from 'qs';
1
+ import { UnavailabilityError } from 'expo-modules-core';
5
2
  import { useEffect, useState } from 'react';
6
- import URL from 'url-parse';
3
+ import { Platform } from 'react-native';
7
4
  import NativeLinking from './ExpoLinking';
8
- import { hasCustomScheme, resolveScheme } from './Schemes';
9
- function validateURL(url) {
10
- invariant(typeof url === 'string', 'Invalid URL: should be a string. Was: ' + url);
11
- invariant(url, 'Invalid URL: cannot be empty');
12
- }
13
- function getHostUri() {
14
- if (Constants.expoConfig?.hostUri) {
15
- return Constants.expoConfig.hostUri;
16
- }
17
- else if (!hasCustomScheme()) {
18
- // we're probably not using up-to-date xdl, so just fake it for now
19
- // we have to remove the /--/ on the end since this will be inserted again later
20
- return removeScheme(Constants.linkingUri).replace(/\/--($|\/.*$)/, '');
21
- }
22
- else {
23
- return null;
24
- }
25
- }
26
- function isExpoHosted() {
27
- const hostUri = getHostUri();
28
- return !!(hostUri &&
29
- (/^(.*\.)?(expo\.io|exp\.host|exp\.direct|expo\.test|expo\.dev)(:.*)?(\/.*)?$/.test(hostUri) ||
30
- Constants.expoGoConfig?.developer));
31
- }
32
- function removeScheme(url) {
33
- return url.replace(/^[a-zA-Z0-9+.-]+:\/\//, '');
34
- }
35
- function removePort(url) {
36
- return url.replace(/(?=([a-zA-Z0-9+.-]+:\/\/)?[^/]):\d+/, '');
37
- }
38
- function removeLeadingSlash(url) {
39
- return url.replace(/^\//, '');
40
- }
41
- function removeTrailingSlashAndQueryString(url) {
42
- return url.replace(/\/?\?.*$/, '');
43
- }
44
- function ensureTrailingSlash(input, shouldAppend) {
45
- const hasSlash = input.endsWith('/');
46
- if (hasSlash && !shouldAppend) {
47
- return input.substring(0, input.length - 1);
48
- }
49
- else if (!hasSlash && shouldAppend) {
50
- return `${input}/`;
51
- }
52
- return input;
53
- }
54
- function ensureLeadingSlash(input, shouldAppend) {
55
- const hasSlash = input.startsWith('/');
56
- if (hasSlash && !shouldAppend) {
57
- return input.substring(1);
58
- }
59
- else if (!hasSlash && shouldAppend) {
60
- return `/${input}`;
61
- }
62
- return input;
63
- }
64
- // @needsAudit
65
- /**
66
- * Create a URL that works for the environment the app is currently running in.
67
- * The scheme in bare and standalone must be defined in the app.json under `expo.scheme`.
68
- *
69
- * # Examples
70
- * - Bare: empty string
71
- * - Standalone, Custom: `yourscheme:///path`
72
- * - Web (dev): `https://localhost:19006/path`
73
- * - Web (prod): `https://myapp.com/path`
74
- * - Expo Client (dev): `exp://128.0.0.1:8081/--/path`
75
- * - Expo Client (prod): `exp://exp.host/@yourname/your-app/--/path`
76
- *
77
- * @param path addition path components to append to the base URL.
78
- * @param queryParams An object with a set of query parameters. These will be merged with any
79
- * Expo-specific parameters that are needed (e.g. release channel) and then appended to the URL
80
- * as a query string.
81
- * @param scheme Optional URI protocol to use in the URL `<scheme>:///`, when `undefined` the scheme
82
- * will be chosen from the Expo config (`app.config.js` or `app.json`).
83
- * @return A URL string which points to your app with the given deep link information.
84
- * @deprecated An alias for [`createURL()`](#linkingcreateurlpath-namedparameters). This method is
85
- * deprecated and will be removed in a future SDK version.
86
- */
87
- export function makeUrl(path = '', queryParams, scheme) {
88
- return createURL(path, { queryParams, scheme, isTripleSlashed: true });
89
- }
90
- // @needsAudit
91
- /**
92
- * Helper method for constructing a deep link into your app, given an optional path and set of query
93
- * parameters. Creates a URI scheme with two slashes by default.
94
- *
95
- * The scheme in bare and standalone must be defined in the Expo config (`app.config.js` or `app.json`)
96
- * under `expo.scheme`.
97
- *
98
- * # Examples
99
- * - Bare: `<scheme>://path` - uses provided scheme or scheme from Expo config `scheme`.
100
- * - Standalone, Custom: `yourscheme://path`
101
- * - Web (dev): `https://localhost:19006/path`
102
- * - Web (prod): `https://myapp.com/path`
103
- * - Expo Client (dev): `exp://128.0.0.1:8081/--/path`
104
- * - Expo Client (prod): `exp://exp.host/@yourname/your-app/--/path`
105
- *
106
- * @param path Addition path components to append to the base URL.
107
- * @param namedParameters Additional options object.
108
- * @return A URL string which points to your app with the given deep link information.
109
- */
110
- export function createURL(path, { scheme, queryParams = {}, isTripleSlashed = false } = {}) {
111
- if (Platform.OS === 'web') {
112
- if (!Platform.isDOMAvailable)
113
- return '';
114
- const origin = ensureTrailingSlash(window.location.origin, false);
115
- let queryString = qs.stringify(queryParams);
116
- if (queryString) {
117
- queryString = `?${queryString}`;
118
- }
119
- let outputPath = path;
120
- if (outputPath)
121
- outputPath = ensureLeadingSlash(path, true);
122
- return encodeURI(`${origin}${outputPath}${queryString}`);
123
- }
124
- const resolvedScheme = resolveScheme({ scheme });
125
- let hostUri = getHostUri() || '';
126
- if (hasCustomScheme() && isExpoHosted()) {
127
- hostUri = '';
128
- }
129
- if (path) {
130
- if (isExpoHosted() && hostUri) {
131
- path = `/--/${removeLeadingSlash(path)}`;
132
- }
133
- if (isTripleSlashed && !path.startsWith('/')) {
134
- path = `/${path}`;
135
- }
136
- }
137
- else {
138
- path = '';
139
- }
140
- // merge user-provided query params with any that were already in the hostUri
141
- // e.g. release-channel
142
- let queryString = '';
143
- const queryStringMatchResult = hostUri.match(/(.*)\?(.+)/);
144
- if (queryStringMatchResult) {
145
- hostUri = queryStringMatchResult[1];
146
- queryString = queryStringMatchResult[2];
147
- let paramsFromHostUri = {};
148
- try {
149
- const parsedParams = qs.parse(queryString);
150
- if (typeof parsedParams === 'object') {
151
- paramsFromHostUri = parsedParams;
152
- }
153
- }
154
- catch { }
155
- queryParams = {
156
- ...queryParams,
157
- ...paramsFromHostUri,
158
- };
159
- }
160
- queryString = qs.stringify(queryParams);
161
- if (queryString) {
162
- queryString = `?${queryString}`;
163
- }
164
- hostUri = ensureLeadingSlash(hostUri, !isTripleSlashed);
165
- return encodeURI(`${resolvedScheme}:${isTripleSlashed ? '/' : ''}/${hostUri}${path}${queryString}`);
166
- }
167
- // @needsAudit
168
- /**
169
- * Helper method for parsing out deep link information from a URL.
170
- * @param url A URL that points to the currently running experience (e.g. an output of `Linking.createURL()`).
171
- * @return A `ParsedURL` object.
172
- */
173
- export function parse(url) {
174
- validateURL(url);
175
- const parsed = URL(url, /* parseQueryString */ true);
176
- for (const param in parsed.query) {
177
- parsed.query[param] = decodeURIComponent(parsed.query[param]);
178
- }
179
- const queryParams = parsed.query;
180
- const hostUri = getHostUri() || '';
181
- const hostUriStripped = removePort(removeTrailingSlashAndQueryString(hostUri));
182
- let path = parsed.pathname || null;
183
- let hostname = parsed.hostname || null;
184
- let scheme = parsed.protocol || null;
185
- if (scheme) {
186
- // Remove colon at end
187
- scheme = scheme.substring(0, scheme.length - 1);
188
- }
189
- if (path) {
190
- path = removeLeadingSlash(path);
191
- let expoPrefix = null;
192
- if (hostUriStripped) {
193
- const parts = hostUriStripped.split('/');
194
- expoPrefix = parts.slice(1).concat(['--/']).join('/');
195
- }
196
- if (isExpoHosted() && !hasCustomScheme() && expoPrefix && path.startsWith(expoPrefix)) {
197
- path = path.substring(expoPrefix.length);
198
- hostname = null;
199
- }
200
- else if (path.indexOf('+') > -1) {
201
- path = path.substring(path.indexOf('+') + 1);
202
- }
203
- }
204
- return {
205
- hostname,
206
- path,
207
- queryParams,
208
- scheme,
209
- };
210
- }
5
+ import { parse } from './createURL';
6
+ import { validateURL } from './validateURL';
211
7
  // @needsAudit
212
8
  /**
213
9
  * Add a handler to `Linking` changes by listening to the `url` event type and providing the handler.
@@ -322,4 +118,5 @@ export function useURL() {
322
118
  }
323
119
  export * from './Linking.types';
324
120
  export * from './Schemes';
121
+ export { parse, createURL } from './createURL';
325
122
  //# sourceMappingURL=Linking.js.map
@@ -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;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,UAAU,EAAE,OAAO,EAAE;QACjC,OAAO,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC;KACrC;SAAM,IAAI,CAAC,eAAe,EAAE,EAAE;QAC7B,mEAAmE;QACnE,g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AAS,CAAC,GAAG,EAAE;QACb,aAAa,EAAE,CAAC,IAAI,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.expoConfig?.hostUri) {\n return Constants.expoConfig.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|expo\\.dev)(:.*)?(\\/.*)?$/.test(hostUri) ||\n Constants.expoGoConfig?.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:8081/--/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:8081/--/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// @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 */\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#linking-from-your-app).\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"]}
1
+ {"version":3,"file":"Linking.js","sourceRoot":"","sources":["../src/Linking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAuB,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,aAAa,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,cAAc;AACd;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAW,EAAE,OAAoB;IAChE,OAAO,aAAa,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACvD,CAAC;AAED,cAAc;AACd;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACxC,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,aAAa,EAAE,CAAC;IAC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,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,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;AAC1B,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\nimport { useEffect, useState } from 'react';\nimport { EmitterSubscription, Platform } from 'react-native';\n\nimport NativeLinking from './ExpoLinking';\nimport { ParsedURL, SendIntentExtras, URLListener } from './Linking.types';\nimport { parse } from './createURL';\nimport { validateURL } from './validateURL';\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// @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 */\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#linking-from-your-app).\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';\nexport { parse, createURL } from './createURL';\n"]}
@@ -1 +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,CAajD;AAeD;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAGD,wBAAgB,aAAa,CAAC,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAiGtF"}
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,CAYjD;AAeD;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;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,5 +1,5 @@
1
1
  import Constants, { ExecutionEnvironment } from 'expo-constants';
2
- import { Platform } from 'expo-modules-core';
2
+ import { Platform } from 'react-native';
3
3
  const LINKING_GUIDE_URL = `https://docs.expo.dev/guides/linking/`;
4
4
  // @docsMissing
5
5
  export function hasCustomScheme() {
@@ -59,7 +59,6 @@ export function collectManifestSchemes() {
59
59
  const platformManifest = Platform.select({
60
60
  ios: Constants.expoConfig?.ios,
61
61
  android: Constants.expoConfig?.android,
62
- web: {},
63
62
  }) ?? {};
64
63
  return getSchemes(Constants.expoConfig).concat(getSchemes(platformManifest));
65
64
  }
@@ -101,7 +100,7 @@ export function resolveScheme(options) {
101
100
  if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {
102
101
  if (options.scheme) {
103
102
  // This enables users to use the fb or google redirects on iOS in the Expo client.
104
- if (EXPO_CLIENT_SCHEMES.includes(options.scheme)) {
103
+ if (EXPO_CLIENT_SCHEMES?.includes(options.scheme)) {
105
104
  return options.scheme;
106
105
  }
107
106
  // Silently ignore to make bare workflow development easier.
@@ -1 +1 @@
1
- {"version":3,"file":"Schemes.js","sourceRoot":"","sources":["../src/Schemes.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,iBAAiB,GAAG,uCAAuC,CAAC;AAElE,eAAe;AACf,MAAM,UAAU,eAAe;IAC7B,IAAI,SAAS,CAAC,oBAAoB,KAAK,oBAAoB,CAAC,IAAI,EAAE;QAChE,oCAAoC;Q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AA+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,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.expoConfig?.ios,\n android: Constants.expoConfig?.android,\n web: {},\n }) as SchemeConfig) ?? {};\n\n return getSchemes(Constants.expoConfig).concat(getSchemes(platformManifest));\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: Constants.expoConfig?.ios?.bundleIdentifier,\n // TODO: This may change to android.applicationId in the future.\n android: Constants.expoConfig?.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 !!Object.keys(Constants.expoConfig ?? {}).length;\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"]}
1
+ {"version":3,"file":"Schemes.js","sourceRoot":"","sources":["../src/Schemes.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,MAAM,iBAAiB,GAAG,uCAAuC,CAAC;AAElE,eAAe;AACf,MAAM,UAAU,eAAe;IAC7B,IAAI,SAAS,CAAC,oBAAoB,KAAK,oBAAoB,CAAC,IAAI,EAAE;QAChE,oCAAoC;QACpC,OAAO,IAAI,CAAC;KACb;SAAM,IAAI,SAAS,CAAC,oBAAoB,KAAK,oBAAoB,CAAC,UAAU,EAAE;QAC7E,uDAAuD;QACvD,MAAM,eAAe,GAAG,sBAAsB,EAAE,CAAC;QACjD,OAAO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AI,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 'react-native';\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.expoConfig?.ios,\n android: Constants.expoConfig?.android,\n }) as SchemeConfig) ?? {};\n\n return getSchemes(Constants.expoConfig).concat(getSchemes(platformManifest));\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: Constants.expoConfig?.ios?.bundleIdentifier,\n // TODO: This may change to android.applicationId in the future.\n android: Constants.expoConfig?.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 !!Object.keys(Constants.expoConfig ?? {}).length;\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"]}
@@ -0,0 +1,5 @@
1
+ export declare function hasCustomScheme(): boolean;
2
+ export declare function collectManifestSchemes(): string[];
3
+ export declare function hasConstantsManifest(): boolean;
4
+ export declare function resolveScheme(): string;
5
+ //# sourceMappingURL=Schemes.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Schemes.web.d.ts","sourceRoot":"","sources":["../src/Schemes.web.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AACD,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAEjD;AACD,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AACD,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
@@ -0,0 +1,13 @@
1
+ export function hasCustomScheme() {
2
+ return true;
3
+ }
4
+ export function collectManifestSchemes() {
5
+ return [];
6
+ }
7
+ export function hasConstantsManifest() {
8
+ return false;
9
+ }
10
+ export function resolveScheme() {
11
+ return 'https';
12
+ }
13
+ //# sourceMappingURL=Schemes.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Schemes.web.js","sourceRoot":"","sources":["../src/Schemes.web.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe;IAC7B,OAAO,IAAI,CAAC;AACd,CAAC;AACD,MAAM,UAAU,sBAAsB;IACpC,OAAO,EAAE,CAAC;AACZ,CAAC;AACD,MAAM,UAAU,oBAAoB;IAClC,OAAO,KAAK,CAAC;AACf,CAAC;AACD,MAAM,UAAU,aAAa;IAC3B,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["export function hasCustomScheme(): boolean {\n return true;\n}\nexport function collectManifestSchemes(): string[] {\n return [];\n}\nexport function hasConstantsManifest(): boolean {\n return false;\n}\nexport function resolveScheme(): string {\n return 'https';\n}\n"]}
@@ -0,0 +1,28 @@
1
+ import { CreateURLOptions, ParsedURL } from './Linking.types';
2
+ /**
3
+ * Helper method for constructing a deep link into your app, given an optional path and set of query
4
+ * parameters. Creates a URI scheme with two slashes by default.
5
+ *
6
+ * The scheme in bare and standalone must be defined in the Expo config (`app.config.js` or `app.json`)
7
+ * under `expo.scheme`.
8
+ *
9
+ * # Examples
10
+ * - Bare: `<scheme>://path` - uses provided scheme or scheme from Expo config `scheme`.
11
+ * - Standalone, Custom: `yourscheme://path`
12
+ * - Web (dev): `https://localhost:19006/path`
13
+ * - Web (prod): `https://myapp.com/path`
14
+ * - Expo Client (dev): `exp://128.0.0.1:8081/--/path`
15
+ * - Expo Client (prod): `exp://exp.host/@yourname/your-app/--/path`
16
+ *
17
+ * @param path Addition path components to append to the base URL.
18
+ * @param namedParameters Additional options object.
19
+ * @return A URL string which points to your app with the given deep link information.
20
+ */
21
+ export declare function createURL(path: string, { scheme, queryParams, isTripleSlashed }?: CreateURLOptions): string;
22
+ /**
23
+ * Helper method for parsing out deep link information from a URL.
24
+ * @param url A URL that points to the currently running experience (e.g. an output of `Linking.createURL()`).
25
+ * @return A `ParsedURL` object.
26
+ */
27
+ export declare function parse(url: string): ParsedURL;
28
+ //# sourceMappingURL=createURL.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createURL.d.ts","sourceRoot":"","sources":["../src/createURL.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAoD9D;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,EAAE,MAAM,EAAE,WAAgB,EAAE,eAAuB,EAAE,GAAE,gBAAqB,GAC3E,MAAM,CAiDR;AAGD;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CA6C5C"}