expo-router 0.0.1

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.
Files changed (132) hide show
  1. package/README.md +3 -0
  2. package/assets/file.png +0 -0
  3. package/assets/forward.png +0 -0
  4. package/assets/pkg.png +0 -0
  5. package/babel.js +77 -0
  6. package/build/ContextNavigationContainer.d.ts +33 -0
  7. package/build/ContextNavigationContainer.d.ts.map +1 -0
  8. package/build/ContextNavigationContainer.js +59 -0
  9. package/build/ContextNavigationContainer.js.map +1 -0
  10. package/build/ContextNavigator.d.ts +6 -0
  11. package/build/ContextNavigator.d.ts.map +1 -0
  12. package/build/ContextNavigator.js +52 -0
  13. package/build/ContextNavigator.js.map +1 -0
  14. package/build/Route.d.ts +34 -0
  15. package/build/Route.d.ts.map +1 -0
  16. package/build/Route.js +56 -0
  17. package/build/Route.js.map +1 -0
  18. package/build/aasa.d.ts +2 -0
  19. package/build/aasa.d.ts.map +1 -0
  20. package/build/aasa.js +25 -0
  21. package/build/aasa.js.map +1 -0
  22. package/build/context.d.ts +5 -0
  23. package/build/context.d.ts.map +1 -0
  24. package/build/context.js +14 -0
  25. package/build/context.js.map +1 -0
  26. package/build/fork/getPathFromState.d.ts +39 -0
  27. package/build/fork/getPathFromState.d.ts.map +1 -0
  28. package/build/fork/getPathFromState.js +209 -0
  29. package/build/fork/getPathFromState.js.map +1 -0
  30. package/build/fork/getStateFromPath.d.ts +33 -0
  31. package/build/fork/getStateFromPath.d.ts.map +1 -0
  32. package/build/fork/getStateFromPath.js +415 -0
  33. package/build/fork/getStateFromPath.js.map +1 -0
  34. package/build/getDevServer/index.d.ts +7 -0
  35. package/build/getDevServer/index.d.ts.map +1 -0
  36. package/build/getDevServer/index.js +30 -0
  37. package/build/getDevServer/index.js.map +1 -0
  38. package/build/getDevServer/index.native.d.ts +2 -0
  39. package/build/getDevServer/index.native.d.ts.map +1 -0
  40. package/build/getDevServer/index.native.js +2 -0
  41. package/build/getDevServer/index.native.js.map +1 -0
  42. package/build/getLinkingConfig.d.ts +5 -0
  43. package/build/getLinkingConfig.d.ts.map +1 -0
  44. package/build/getLinkingConfig.js +62 -0
  45. package/build/getLinkingConfig.js.map +1 -0
  46. package/build/getRoutes.d.ts +12 -0
  47. package/build/getRoutes.d.ts.map +1 -0
  48. package/build/getRoutes.js +165 -0
  49. package/build/getRoutes.js.map +1 -0
  50. package/build/index.d.ts +14 -0
  51. package/build/index.d.ts.map +1 -0
  52. package/build/index.js +13 -0
  53. package/build/index.js.map +1 -0
  54. package/build/layouts/Drawer.d.ts +132 -0
  55. package/build/layouts/Drawer.d.ts.map +1 -0
  56. package/build/layouts/Drawer.js +5 -0
  57. package/build/layouts/Drawer.js.map +1 -0
  58. package/build/layouts/NativeStack.d.ts +132 -0
  59. package/build/layouts/NativeStack.d.ts.map +1 -0
  60. package/build/layouts/NativeStack.js +5 -0
  61. package/build/layouts/NativeStack.js.map +1 -0
  62. package/build/layouts/Stack.d.ts +156 -0
  63. package/build/layouts/Stack.d.ts.map +1 -0
  64. package/build/layouts/Stack.js +6 -0
  65. package/build/layouts/Stack.js.map +1 -0
  66. package/build/layouts/Tabs.d.ts +136 -0
  67. package/build/layouts/Tabs.d.ts.map +1 -0
  68. package/build/layouts/Tabs.js +6 -0
  69. package/build/layouts/Tabs.js.map +1 -0
  70. package/build/layouts/withLayoutContext.d.ts +16 -0
  71. package/build/layouts/withLayoutContext.d.ts.map +1 -0
  72. package/build/layouts/withLayoutContext.js +73 -0
  73. package/build/layouts/withLayoutContext.js.map +1 -0
  74. package/build/matchers.d.ts +8 -0
  75. package/build/matchers.d.ts.map +1 -0
  76. package/build/matchers.js +25 -0
  77. package/build/matchers.js.map +1 -0
  78. package/build/onboard/Tutorial.d.ts +3 -0
  79. package/build/onboard/Tutorial.d.ts.map +1 -0
  80. package/build/onboard/Tutorial.js +129 -0
  81. package/build/onboard/Tutorial.js.map +1 -0
  82. package/build/onboard/createEntryFile.d.ts +3 -0
  83. package/build/onboard/createEntryFile.d.ts.map +1 -0
  84. package/build/onboard/createEntryFile.js +54 -0
  85. package/build/onboard/createEntryFile.js.map +1 -0
  86. package/build/primitives.d.ts +19 -0
  87. package/build/primitives.d.ts.map +1 -0
  88. package/build/primitives.js +5 -0
  89. package/build/primitives.js.map +1 -0
  90. package/build/types.d.ts +11 -0
  91. package/build/types.d.ts.map +1 -0
  92. package/build/types.js +2 -0
  93. package/build/types.js.map +1 -0
  94. package/build/useScreens.d.ts +10 -0
  95. package/build/useScreens.d.ts.map +1 -0
  96. package/build/useScreens.js +60 -0
  97. package/build/useScreens.js.map +1 -0
  98. package/build/views/Directory.d.ts +3 -0
  99. package/build/views/Directory.d.ts.map +1 -0
  100. package/build/views/Directory.js +142 -0
  101. package/build/views/Directory.js.map +1 -0
  102. package/build/views/ErrorBoundary.d.ts +4 -0
  103. package/build/views/ErrorBoundary.d.ts.map +1 -0
  104. package/build/views/ErrorBoundary.js +53 -0
  105. package/build/views/ErrorBoundary.js.map +1 -0
  106. package/build/views/Layout.d.ts +19 -0
  107. package/build/views/Layout.d.ts.map +1 -0
  108. package/build/views/Layout.js +48 -0
  109. package/build/views/Layout.js.map +1 -0
  110. package/build/views/Link.d.ts +26 -0
  111. package/build/views/Link.d.ts.map +1 -0
  112. package/build/views/Link.js +47 -0
  113. package/build/views/Link.js.map +1 -0
  114. package/build/views/Root.d.ts +6 -0
  115. package/build/views/Root.d.ts.map +1 -0
  116. package/build/views/Root.js +20 -0
  117. package/build/views/Root.js.map +1 -0
  118. package/build/views/Screen.d.ts +7 -0
  119. package/build/views/Screen.d.ts.map +1 -0
  120. package/build/views/Screen.js +19 -0
  121. package/build/views/Screen.js.map +1 -0
  122. package/build/views/Try.d.ts +24 -0
  123. package/build/views/Try.d.ts.map +1 -0
  124. package/build/views/Try.js +24 -0
  125. package/build/views/Try.js.map +1 -0
  126. package/build/views/Unmatched.d.ts +4 -0
  127. package/build/views/Unmatched.d.ts.map +1 -0
  128. package/build/views/Unmatched.js +46 -0
  129. package/build/views/Unmatched.js.map +1 -0
  130. package/entry.js +103 -0
  131. package/metro-config.js +14 -0
  132. package/package.json +62 -0
@@ -0,0 +1,415 @@
1
+ import escape from "escape-string-regexp";
2
+ import * as queryString from "query-string";
3
+ import { findFocusedRoute, validatePathConfig, } from "@react-navigation/core";
4
+ /**
5
+ * Utility to parse a path string to initial state object accepted by the container.
6
+ * This is useful for deep linking when we need to handle the incoming URL.
7
+ *
8
+ * @example
9
+ * ```js
10
+ * getStateFromPath(
11
+ * '/chat/jane/42',
12
+ * {
13
+ * screens: {
14
+ * Chat: {
15
+ * path: 'chat/:author/:id',
16
+ * parse: { id: Number }
17
+ * }
18
+ * }
19
+ * }
20
+ * )
21
+ * ```
22
+ * @param path Path string to parse and convert, e.g. /foo/bar?count=42.
23
+ * @param options Extra options to fine-tune how to parse the path.
24
+ */
25
+ export default function getStateFromPath(path, options) {
26
+ if (options) {
27
+ validatePathConfig(options);
28
+ }
29
+ let initialRoutes = [];
30
+ if (options?.initialRouteName) {
31
+ initialRoutes.push({
32
+ initialRouteName: options.initialRouteName,
33
+ parentScreens: [],
34
+ });
35
+ }
36
+ const screens = options?.screens;
37
+ let remaining = path
38
+ .replace(/\/+/g, "/") // Replace multiple slash (//) with single ones
39
+ .replace(/^\//, "") // Remove extra leading slash
40
+ .replace(/\?.*$/, ""); // Remove query params which we will handle later
41
+ // Make sure there is a trailing slash
42
+ remaining = remaining.endsWith("/") ? remaining : `${remaining}/`;
43
+ if (screens === undefined) {
44
+ // When no config is specified, use the path segments as route names
45
+ const routes = remaining
46
+ .split("/")
47
+ .filter(Boolean)
48
+ .map((segment) => {
49
+ const name = decodeURIComponent(segment);
50
+ return { name };
51
+ });
52
+ if (routes.length) {
53
+ return createNestedStateObject(path, routes, initialRoutes);
54
+ }
55
+ return undefined;
56
+ }
57
+ // Create a normalized configs array which will be easier to use
58
+ const configs = []
59
+ .concat(...Object.keys(screens).map((key) => createNormalizedConfigs(key, screens, [], initialRoutes, [])))
60
+ .sort((a, b) => {
61
+ // Sort config so that:
62
+ // - the most exhaustive ones are always at the beginning
63
+ // - patterns with wildcard are always at the end
64
+ // If 2 patterns are same, move the one with less route names up
65
+ // This is an error state, so it's only useful for consistent error messages
66
+ if (a.pattern === b.pattern) {
67
+ return b.routeNames.join(">").localeCompare(a.routeNames.join(">"));
68
+ }
69
+ // If one of the patterns starts with the other, it's more exhaustive
70
+ // So move it up
71
+ if (a.pattern.startsWith(b.pattern) &&
72
+ // NOTE(EvanBacon): This is a hack to make sure that `*` is always at the end
73
+ b.screen !== "index") {
74
+ return -1;
75
+ }
76
+ if (b.pattern.startsWith(a.pattern) && a.screen !== "index") {
77
+ return 1;
78
+ }
79
+ // NOTE(EvanBacon): Here we append `index` if the screen was `index` so the length is the same
80
+ // as a slug or wildcard when nested more than one level deep.
81
+ // This is so we can compare the length of the pattern, e.g. `foo/*` > `foo` vs `*` < ``.
82
+ const aParts = a.pattern.split("/");
83
+ if (a.screen === "index") {
84
+ aParts.push("index");
85
+ }
86
+ const bParts = b.pattern.split("/");
87
+ if (b.screen === "index") {
88
+ bParts.push("index");
89
+ }
90
+ for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {
91
+ // if b is longer, b get higher priority
92
+ if (aParts[i] == null) {
93
+ return 1;
94
+ }
95
+ // if a is longer, a get higher priority
96
+ if (bParts[i] == null) {
97
+ return -1;
98
+ }
99
+ const aWildCard = aParts[i] === "*";
100
+ const bWildCard = bParts[i] === "*";
101
+ // if both are wildcard we compare next component
102
+ if (aWildCard && bWildCard) {
103
+ continue;
104
+ }
105
+ // if only a is wild card, b get higher priority
106
+ if (aWildCard) {
107
+ return 1;
108
+ }
109
+ // if only b is wild card, a get higher priority
110
+ if (bWildCard) {
111
+ return -1;
112
+ }
113
+ const aSlug = aParts[i].startsWith(":");
114
+ const bSlug = bParts[i].startsWith(":");
115
+ // if both are wildcard we compare next component
116
+ if (aSlug && bSlug) {
117
+ continue;
118
+ }
119
+ // if only a is wild card, b get higher priority
120
+ if (aSlug) {
121
+ return 1;
122
+ }
123
+ // if only b is wild card, a get higher priority
124
+ if (bSlug) {
125
+ return -1;
126
+ }
127
+ }
128
+ return bParts.length - aParts.length;
129
+ });
130
+ // Match full paths
131
+ // Check for duplicate patterns in the config
132
+ configs.reduce((acc, config) => {
133
+ // NOTE(EvanBacon): Uses the regex pattern as key to detect duplicate slugs.
134
+ const indexedKey = config.regex?.toString() ?? config.pattern;
135
+ const alpha = acc[indexedKey];
136
+ // NOTE(EvanBacon): Skips checking nodes that have children.
137
+ if (alpha && !alpha.hasChildren && !config.hasChildren) {
138
+ const a = alpha.routeNames;
139
+ const b = config.routeNames;
140
+ // It's not a problem if the path string omitted from a inner most screen
141
+ // For example, it's ok if a path resolves to `A > B > C` or `A > B`
142
+ const intersects = a.length > b.length
143
+ ? b.every((it, i) => a[i] === it)
144
+ : a.every((it, i) => b[i] === it);
145
+ if (!intersects) {
146
+ // NOTE(EvanBacon): Adds more context to the error message since we know about the
147
+ // file system-based routing.
148
+ const last = config.pattern.split("/").pop();
149
+ const routeType = last?.startsWith(":")
150
+ ? "dynamic route"
151
+ : last === "*"
152
+ ? "deep dynamic route"
153
+ : "route";
154
+ throw new Error(`The ${routeType} pattern '${config.pattern || "/"}' resolves to both '${alpha.userReadableName}' and '${config.userReadableName}'. Patterns must be unique and cannot resolve to more than one route.`);
155
+ }
156
+ }
157
+ return Object.assign(acc, {
158
+ [indexedKey]: config,
159
+ });
160
+ }, {});
161
+ if (remaining === "/") {
162
+ // We need to add special handling of empty path so navigation to empty path also works
163
+ // When handling empty path, we should only look at the root level config
164
+ // NOTE(EvanBacon): We only care about matching leaf nodes.
165
+ const leafNodes = configs.filter((config) => !config.hasChildren);
166
+ const match = leafNodes.find((config) =>
167
+ // NOTE(EvanBacon): Test leaf node index routes that either don't have a regex or match an empty string.
168
+ config.path === "" && (!config.regex || config.regex.test(""))) ??
169
+ leafNodes.find((config) =>
170
+ // NOTE(EvanBacon): Test leaf node dynamic routes that match an empty string.
171
+ config.path.startsWith(":") && config.regex.test("")) ??
172
+ // NOTE(EvanBacon): Test leaf node deep dynamic routes that match a slash.
173
+ // This should be done last to enable dynamic routes having a higher priority.
174
+ leafNodes.find((config) => config.path === "*" && config.regex.test("/"));
175
+ if (match) {
176
+ return createNestedStateObject(path, match.routeNames.map((name) => ({ name })), initialRoutes, configs);
177
+ }
178
+ return undefined;
179
+ }
180
+ let result;
181
+ let current;
182
+ // We match the whole path against the regex instead of segments
183
+ // This makes sure matches such as wildcard will catch any unmatched routes, even if nested
184
+ const { routes, remainingPath } = matchAgainstConfigs(remaining, configs.map((c) => ({
185
+ ...c,
186
+ // Add `$` to the regex to make sure it matches till end of the path and not just beginning
187
+ regex: c.regex ? new RegExp(c.regex.source + "$") : undefined,
188
+ })));
189
+ if (routes !== undefined) {
190
+ // This will always be empty if full path matched
191
+ current = createNestedStateObject(path, routes, initialRoutes, configs);
192
+ remaining = remainingPath;
193
+ result = current;
194
+ }
195
+ if (current == null || result == null) {
196
+ return undefined;
197
+ }
198
+ return result;
199
+ }
200
+ const joinPaths = (...paths) => []
201
+ .concat(...paths.map((p) => p.split("/")))
202
+ .filter(Boolean)
203
+ .join("/");
204
+ const matchAgainstConfigs = (remaining, configs) => {
205
+ let routes;
206
+ let remainingPath = remaining;
207
+ // Go through all configs, and see if the next path segment matches our regex
208
+ for (const config of configs) {
209
+ if (!config.regex) {
210
+ continue;
211
+ }
212
+ const match = remainingPath.match(config.regex);
213
+ // If our regex matches, we need to extract params from the path
214
+ if (match) {
215
+ // TODO: Add support for wildcard routes
216
+ const matchedParams = config.pattern
217
+ ?.split("/")
218
+ .filter((p) => p.startsWith(":"))
219
+ .reduce((acc, p, i) => Object.assign(acc, {
220
+ // The param segments appear every second item starting from 2 in the regex match result
221
+ [p]: match[(i + 1) * 2].replace(/\//, ""),
222
+ }), {});
223
+ routes = config.routeNames.map((name) => {
224
+ const config = configs.find((c) => c.screen === name);
225
+ const params = config?.path
226
+ ?.split("/")
227
+ .filter((p) => p.startsWith(":"))
228
+ .reduce((acc, p) => {
229
+ const paramName = p;
230
+ const value = matchedParams[paramName];
231
+ if (value) {
232
+ const key = paramName.replace(/^:/, "").replace(/\?$/, "");
233
+ acc[key] = config.parse?.[key] ? config.parse[key](value) : value;
234
+ }
235
+ return acc;
236
+ }, {});
237
+ if (params && Object.keys(params).length) {
238
+ return { name, params };
239
+ }
240
+ return { name };
241
+ });
242
+ remainingPath = remainingPath.replace(match[1], "");
243
+ break;
244
+ }
245
+ }
246
+ return { routes, remainingPath };
247
+ };
248
+ const createNormalizedConfigs = (screen, routeConfig, routeNames = [], initials, parentScreens, parentPattern) => {
249
+ const configs = [];
250
+ routeNames.push(screen);
251
+ parentScreens.push(screen);
252
+ const config = routeConfig[screen];
253
+ if (typeof config === "string") {
254
+ // If a string is specified as the value of the key(e.g. Foo: '/path'), use it as the pattern
255
+ const pattern = parentPattern ? joinPaths(parentPattern, config) : config;
256
+ configs.push(createConfigItem(screen, routeNames, pattern, config, false));
257
+ }
258
+ else if (typeof config === "object") {
259
+ let pattern;
260
+ // if an object is specified as the value (e.g. Foo: { ... }),
261
+ // it can have `path` property and
262
+ // it could have `screens` prop which has nested configs
263
+ if (typeof config.path === "string") {
264
+ if (config.exact && config.path === undefined) {
265
+ throw new Error("A 'path' needs to be specified when specifying 'exact: true'. If you don't want this screen in the URL, specify it as empty string, e.g. `path: ''`.");
266
+ }
267
+ pattern =
268
+ config.exact !== true
269
+ ? joinPaths(parentPattern || "", config.path || "")
270
+ : config.path || "";
271
+ configs.push(createConfigItem(screen, routeNames, pattern, config.path, config.screens ? !!Object.keys(config.screens)?.length : false, config.parse));
272
+ }
273
+ if (config.screens) {
274
+ // property `initialRouteName` without `screens` has no purpose
275
+ if (config.initialRouteName) {
276
+ initials.push({
277
+ initialRouteName: config.initialRouteName,
278
+ parentScreens,
279
+ });
280
+ }
281
+ Object.keys(config.screens).forEach((nestedConfig) => {
282
+ const result = createNormalizedConfigs(nestedConfig, config.screens, routeNames, initials, [...parentScreens], pattern ?? parentPattern);
283
+ configs.push(...result);
284
+ });
285
+ }
286
+ }
287
+ routeNames.pop();
288
+ return configs;
289
+ };
290
+ const createConfigItem = (screen, routeNames, pattern, path, hasChildren, parse) => {
291
+ // Normalize pattern to remove any leading, trailing slashes, duplicate slashes etc.
292
+ pattern = pattern.split("/").filter(Boolean).join("/");
293
+ const regex = pattern
294
+ ? new RegExp(`^(${pattern
295
+ .split("/")
296
+ .map((it) => {
297
+ if (it.startsWith(":")) {
298
+ return `(([^/]+\\/)${it.endsWith("?") ? "?" : ""})`;
299
+ }
300
+ return `${it === "*" ? ".*" : escape(it)}\\/`;
301
+ })
302
+ .join("")})`)
303
+ : undefined;
304
+ return {
305
+ screen,
306
+ regex,
307
+ pattern,
308
+ path,
309
+ // The routeNames array is mutated, so copy it to keep the current state
310
+ routeNames: [...routeNames],
311
+ parse,
312
+ userReadableName: [...routeNames.slice(0, -1), path || screen].join("/"),
313
+ hasChildren: !!hasChildren,
314
+ };
315
+ };
316
+ const findParseConfigForRoute = (routeName, flatConfig) => {
317
+ for (const config of flatConfig) {
318
+ if (routeName === config.routeNames[config.routeNames.length - 1]) {
319
+ return config.parse;
320
+ }
321
+ }
322
+ return undefined;
323
+ };
324
+ // Try to find an initial route connected with the one passed
325
+ const findInitialRoute = (routeName, parentScreens, initialRoutes) => {
326
+ for (const config of initialRoutes) {
327
+ if (parentScreens.length === config.parentScreens.length) {
328
+ let sameParents = true;
329
+ for (let i = 0; i < parentScreens.length; i++) {
330
+ if (parentScreens[i].localeCompare(config.parentScreens[i]) !== 0) {
331
+ sameParents = false;
332
+ break;
333
+ }
334
+ }
335
+ if (sameParents) {
336
+ return routeName !== config.initialRouteName
337
+ ? config.initialRouteName
338
+ : undefined;
339
+ }
340
+ }
341
+ }
342
+ return undefined;
343
+ };
344
+ // returns state object with values depending on whether
345
+ // it is the end of state and if there is initialRoute for this level
346
+ const createStateObject = (initialRoute, route, isEmpty) => {
347
+ if (isEmpty) {
348
+ if (initialRoute) {
349
+ return {
350
+ index: 1,
351
+ routes: [{ name: initialRoute }, route],
352
+ };
353
+ }
354
+ else {
355
+ return {
356
+ routes: [route],
357
+ };
358
+ }
359
+ }
360
+ else {
361
+ if (initialRoute) {
362
+ return {
363
+ index: 1,
364
+ routes: [{ name: initialRoute }, { ...route, state: { routes: [] } }],
365
+ };
366
+ }
367
+ else {
368
+ return {
369
+ routes: [{ ...route, state: { routes: [] } }],
370
+ };
371
+ }
372
+ }
373
+ };
374
+ const createNestedStateObject = (path, routes, initialRoutes, flatConfig) => {
375
+ let state;
376
+ let route = routes.shift();
377
+ const parentScreens = [];
378
+ let initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);
379
+ parentScreens.push(route.name);
380
+ state = createStateObject(initialRoute, route, routes.length === 0);
381
+ if (routes.length > 0) {
382
+ let nestedState = state;
383
+ while ((route = routes.shift())) {
384
+ initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);
385
+ const nestedStateIndex = nestedState.index || nestedState.routes.length - 1;
386
+ nestedState.routes[nestedStateIndex].state = createStateObject(initialRoute, route, routes.length === 0);
387
+ if (routes.length > 0) {
388
+ nestedState = nestedState.routes[nestedStateIndex]
389
+ .state;
390
+ }
391
+ parentScreens.push(route.name);
392
+ }
393
+ }
394
+ route = findFocusedRoute(state);
395
+ route.path = path;
396
+ const params = parseQueryParams(path, flatConfig ? findParseConfigForRoute(route.name, flatConfig) : undefined);
397
+ if (params) {
398
+ route.params = { ...route.params, ...params };
399
+ }
400
+ return state;
401
+ };
402
+ const parseQueryParams = (path, parseConfig) => {
403
+ const query = path.split("?")[1];
404
+ const params = queryString.parse(query);
405
+ if (parseConfig) {
406
+ Object.keys(params).forEach((name) => {
407
+ if (Object.hasOwnProperty.call(parseConfig, name) &&
408
+ typeof params[name] === "string") {
409
+ params[name] = parseConfig[name](params[name]);
410
+ }
411
+ });
412
+ }
413
+ return Object.keys(params).length ? params : undefined;
414
+ };
415
+ //# sourceMappingURL=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;IACF,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAExC,IAAI,WAAW,EAAE;QACf,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACnC,IACE,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC;gBAC7C,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,QAAQ,EAChC;gBACA,MAAM,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAW,CAAC,CAAC;aAC1D;QACH,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC,CAAC","sourcesContent":["import type {\n InitialState,\n NavigationState,\n PartialState,\n} from \"@react-navigation/routers\";\nimport escape from \"escape-string-regexp\";\nimport * as queryString from \"query-string\";\n\nimport {\n PathConfigMap,\n findFocusedRoute,\n validatePathConfig,\n} from \"@react-navigation/core\";\n\n// import findFocusedRoute from './findFocusedRoute';\n// import type { PathConfigMap } from './types';\n// import validatePathConfig from './validatePathConfig';\n\ntype Options<ParamList extends {}> = {\n initialRouteName?: string;\n screens: PathConfigMap<ParamList>;\n};\n\ntype ParseConfig = Record<string, (value: string) => any>;\n\ntype RouteConfig = {\n screen: string;\n regex?: RegExp;\n path: string;\n pattern: string;\n routeNames: string[];\n parse?: ParseConfig;\n hasChildren: boolean;\n userReadableName: string;\n};\n\ntype InitialRouteConfig = {\n initialRouteName: string;\n parentScreens: string[];\n};\n\ntype ResultState = PartialState<NavigationState> & {\n state?: ResultState;\n};\n\ntype ParsedRoute = {\n name: string;\n path?: string;\n params?: Record<string, any> | undefined;\n};\n\n/**\n * Utility to parse a path string to initial state object accepted by the container.\n * This is useful for deep linking when we need to handle the incoming URL.\n *\n * @example\n * ```js\n * getStateFromPath(\n * '/chat/jane/42',\n * {\n * screens: {\n * Chat: {\n * path: 'chat/:author/:id',\n * parse: { id: Number }\n * }\n * }\n * }\n * )\n * ```\n * @param path Path string to parse and convert, e.g. /foo/bar?count=42.\n * @param options Extra options to fine-tune how to parse the path.\n */\nexport default function getStateFromPath<ParamList extends {}>(\n path: string,\n options?: Options<ParamList>\n): ResultState | undefined {\n if (options) {\n validatePathConfig(options);\n }\n\n let initialRoutes: InitialRouteConfig[] = [];\n\n if (options?.initialRouteName) {\n initialRoutes.push({\n initialRouteName: options.initialRouteName,\n parentScreens: [],\n });\n }\n\n const screens = options?.screens;\n\n let remaining = path\n .replace(/\\/+/g, \"/\") // Replace multiple slash (//) with single ones\n .replace(/^\\//, \"\") // Remove extra leading slash\n .replace(/\\?.*$/, \"\"); // Remove query params which we will handle later\n\n // Make sure there is a trailing slash\n remaining = remaining.endsWith(\"/\") ? remaining : `${remaining}/`;\n\n if (screens === undefined) {\n // When no config is specified, use the path segments as route names\n const routes = remaining\n .split(\"/\")\n .filter(Boolean)\n .map((segment) => {\n const name = decodeURIComponent(segment);\n return { name };\n });\n\n if (routes.length) {\n return createNestedStateObject(path, routes, initialRoutes);\n }\n\n return undefined;\n }\n\n // Create a normalized configs array which will be easier to use\n const configs = ([] as RouteConfig[])\n .concat(\n ...Object.keys(screens).map((key) =>\n createNormalizedConfigs(\n key,\n screens as PathConfigMap<object>,\n [],\n initialRoutes,\n []\n )\n )\n )\n .sort((a, b) => {\n // Sort config so that:\n // - the most exhaustive ones are always at the beginning\n // - patterns with wildcard are always at the end\n\n // If 2 patterns are same, move the one with less route names up\n // This is an error state, so it's only useful for consistent error messages\n if (a.pattern === b.pattern) {\n return b.routeNames.join(\">\").localeCompare(a.routeNames.join(\">\"));\n }\n\n // If one of the patterns starts with the other, it's more exhaustive\n // So move it up\n if (\n a.pattern.startsWith(b.pattern) &&\n // NOTE(EvanBacon): This is a hack to make sure that `*` is always at the end\n b.screen !== \"index\"\n ) {\n return -1;\n }\n\n if (b.pattern.startsWith(a.pattern) && a.screen !== \"index\") {\n return 1;\n }\n\n // NOTE(EvanBacon): Here we append `index` if the screen was `index` so the length is the same\n // as a slug or wildcard when nested more than one level deep.\n // This is so we can compare the length of the pattern, e.g. `foo/*` > `foo` vs `*` < ``.\n const aParts = a.pattern.split(\"/\");\n if (a.screen === \"index\") {\n aParts.push(\"index\");\n }\n\n const bParts = b.pattern.split(\"/\");\n if (b.screen === \"index\") {\n bParts.push(\"index\");\n }\n\n for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {\n // if b is longer, b get higher priority\n if (aParts[i] == null) {\n return 1;\n }\n // if a is longer, a get higher priority\n if (bParts[i] == null) {\n return -1;\n }\n const aWildCard = aParts[i] === \"*\";\n const bWildCard = bParts[i] === \"*\";\n // if both are wildcard we compare next component\n if (aWildCard && bWildCard) {\n continue;\n }\n // if only a is wild card, b get higher priority\n if (aWildCard) {\n return 1;\n }\n // if only b is wild card, a get higher priority\n if (bWildCard) {\n return -1;\n }\n\n const aSlug = aParts[i].startsWith(\":\");\n const bSlug = bParts[i].startsWith(\":\");\n // if both are wildcard we compare next component\n if (aSlug && bSlug) {\n continue;\n }\n // if only a is wild card, b get higher priority\n if (aSlug) {\n return 1;\n }\n // if only b is wild card, a get higher priority\n if (bSlug) {\n return -1;\n }\n }\n return bParts.length - aParts.length;\n });\n\n // Match full paths\n\n // Check for duplicate patterns in the config\n configs.reduce<Record<string, RouteConfig>>((acc, config) => {\n // NOTE(EvanBacon): Uses the regex pattern as key to detect duplicate slugs.\n const indexedKey = config.regex?.toString() ?? config.pattern;\n const alpha = acc[indexedKey];\n // NOTE(EvanBacon): Skips checking nodes that have children.\n if (alpha && !alpha.hasChildren && !config.hasChildren) {\n const a = alpha.routeNames;\n const b = config.routeNames;\n\n // It's not a problem if the path string omitted from a inner most screen\n // For example, it's ok if a path resolves to `A > B > C` or `A > B`\n const intersects =\n a.length > b.length\n ? b.every((it, i) => a[i] === it)\n : a.every((it, i) => b[i] === it);\n\n if (!intersects) {\n // NOTE(EvanBacon): Adds more context to the error message since we know about the\n // file system-based routing.\n const last = config.pattern.split(\"/\").pop();\n const routeType = last?.startsWith(\":\")\n ? \"dynamic route\"\n : last === \"*\"\n ? \"deep dynamic route\"\n : \"route\";\n throw new Error(\n `The ${routeType} pattern '${\n config.pattern || \"/\"\n }' resolves to both '${alpha.userReadableName}' and '${\n config.userReadableName\n }'. Patterns must be unique and cannot resolve to more than one route.`\n );\n }\n }\n\n return Object.assign(acc, {\n [indexedKey]: config,\n });\n }, {});\n\n if (remaining === \"/\") {\n // We need to add special handling of empty path so navigation to empty path also works\n // When handling empty path, we should only look at the root level config\n\n // NOTE(EvanBacon): We only care about matching leaf nodes.\n const leafNodes = configs.filter((config) => !config.hasChildren);\n\n const match =\n leafNodes.find(\n (config) =>\n // NOTE(EvanBacon): Test leaf node index routes that either don't have a regex or match an empty string.\n config.path === \"\" && (!config.regex || config.regex.test(\"\"))\n ) ??\n leafNodes.find(\n (config) =>\n // NOTE(EvanBacon): Test leaf node dynamic routes that match an empty string.\n config.path.startsWith(\":\") && config.regex!.test(\"\")\n ) ??\n // NOTE(EvanBacon): Test leaf node deep dynamic routes that match a slash.\n // This should be done last to enable dynamic routes having a higher priority.\n leafNodes.find(\n (config) => config.path === \"*\" && config.regex!.test(\"/\")\n );\n\n if (match) {\n return createNestedStateObject(\n path,\n match.routeNames.map((name) => ({ name })),\n initialRoutes,\n configs\n );\n }\n\n return undefined;\n }\n\n let result: PartialState<NavigationState> | undefined;\n let current: PartialState<NavigationState> | undefined;\n\n // We match the whole path against the regex instead of segments\n // This makes sure matches such as wildcard will catch any unmatched routes, even if nested\n const { routes, remainingPath } = matchAgainstConfigs(\n remaining,\n configs.map((c) => ({\n ...c,\n // Add `$` to the regex to make sure it matches till end of the path and not just beginning\n regex: c.regex ? new RegExp(c.regex.source + \"$\") : undefined,\n }))\n );\n\n if (routes !== undefined) {\n // This will always be empty if full path matched\n current = createNestedStateObject(path, routes, initialRoutes, configs);\n remaining = remainingPath;\n result = current;\n }\n\n if (current == null || result == null) {\n return undefined;\n }\n\n return result;\n}\n\nconst joinPaths = (...paths: string[]): string =>\n ([] as string[])\n .concat(...paths.map((p) => p.split(\"/\")))\n .filter(Boolean)\n .join(\"/\");\n\nconst matchAgainstConfigs = (remaining: string, configs: RouteConfig[]) => {\n let routes: ParsedRoute[] | undefined;\n let remainingPath = remaining;\n\n // Go through all configs, and see if the next path segment matches our regex\n for (const config of configs) {\n if (!config.regex) {\n continue;\n }\n\n const match = remainingPath.match(config.regex);\n\n // If our regex matches, we need to extract params from the path\n if (match) {\n // TODO: Add support for wildcard routes\n const matchedParams = config.pattern\n ?.split(\"/\")\n .filter((p) => p.startsWith(\":\"))\n .reduce<Record<string, any>>(\n (acc, p, i) =>\n Object.assign(acc, {\n // The param segments appear every second item starting from 2 in the regex match result\n [p]: match![(i + 1) * 2].replace(/\\//, \"\"),\n }),\n {}\n );\n\n routes = config.routeNames.map((name) => {\n const config = configs.find((c) => c.screen === name);\n const params = config?.path\n ?.split(\"/\")\n .filter((p) => p.startsWith(\":\"))\n .reduce<Record<string, any>>((acc, p) => {\n const paramName = p;\n const value = matchedParams[paramName];\n\n if (value) {\n const key = paramName.replace(/^:/, \"\").replace(/\\?$/, \"\");\n acc[key] = config.parse?.[key] ? config.parse[key](value) : value;\n }\n\n return acc;\n }, {});\n\n if (params && Object.keys(params).length) {\n return { name, params };\n }\n\n return { name };\n });\n\n remainingPath = remainingPath.replace(match[1], \"\");\n\n break;\n }\n }\n\n return { routes, remainingPath };\n};\n\nconst createNormalizedConfigs = (\n screen: string,\n routeConfig: PathConfigMap<object>,\n routeNames: string[] = [],\n initials: InitialRouteConfig[],\n parentScreens: string[],\n parentPattern?: string\n): RouteConfig[] => {\n const configs: RouteConfig[] = [];\n\n routeNames.push(screen);\n\n parentScreens.push(screen);\n\n const config = routeConfig[screen];\n\n if (typeof config === \"string\") {\n // If a string is specified as the value of the key(e.g. Foo: '/path'), use it as the pattern\n const pattern = parentPattern ? joinPaths(parentPattern, config) : config;\n\n configs.push(createConfigItem(screen, routeNames, pattern, config, false));\n } else if (typeof config === \"object\") {\n let pattern: string | undefined;\n\n // if an object is specified as the value (e.g. Foo: { ... }),\n // it can have `path` property and\n // it could have `screens` prop which has nested configs\n if (typeof config.path === \"string\") {\n if (config.exact && config.path === undefined) {\n throw new Error(\n \"A 'path' needs to be specified when specifying 'exact: true'. If you don't want this screen in the URL, specify it as empty string, e.g. `path: ''`.\"\n );\n }\n\n pattern =\n config.exact !== true\n ? joinPaths(parentPattern || \"\", config.path || \"\")\n : config.path || \"\";\n\n configs.push(\n createConfigItem(\n screen,\n routeNames,\n pattern!,\n config.path,\n config.screens ? !!Object.keys(config.screens)?.length : false,\n config.parse\n )\n );\n }\n\n if (config.screens) {\n // property `initialRouteName` without `screens` has no purpose\n if (config.initialRouteName) {\n initials.push({\n initialRouteName: config.initialRouteName,\n parentScreens,\n });\n }\n\n Object.keys(config.screens).forEach((nestedConfig) => {\n const result = createNormalizedConfigs(\n nestedConfig,\n config.screens as PathConfigMap<object>,\n routeNames,\n initials,\n [...parentScreens],\n pattern ?? parentPattern\n );\n\n configs.push(...result);\n });\n }\n }\n\n routeNames.pop();\n\n return configs;\n};\n\nconst createConfigItem = (\n screen: string,\n routeNames: string[],\n pattern: string,\n path: string,\n hasChildren?: boolean,\n parse?: ParseConfig\n): RouteConfig => {\n // Normalize pattern to remove any leading, trailing slashes, duplicate slashes etc.\n pattern = pattern.split(\"/\").filter(Boolean).join(\"/\");\n\n const regex = pattern\n ? new RegExp(\n `^(${pattern\n .split(\"/\")\n .map((it) => {\n if (it.startsWith(\":\")) {\n return `(([^/]+\\\\/)${it.endsWith(\"?\") ? \"?\" : \"\"})`;\n }\n\n return `${it === \"*\" ? \".*\" : escape(it)}\\\\/`;\n })\n .join(\"\")})`\n )\n : undefined;\n\n return {\n screen,\n regex,\n pattern,\n path,\n // The routeNames array is mutated, so copy it to keep the current state\n routeNames: [...routeNames],\n parse,\n userReadableName: [...routeNames.slice(0, -1), path || screen].join(\"/\"),\n hasChildren: !!hasChildren,\n };\n};\n\nconst findParseConfigForRoute = (\n routeName: string,\n flatConfig: RouteConfig[]\n): ParseConfig | undefined => {\n for (const config of flatConfig) {\n if (routeName === config.routeNames[config.routeNames.length - 1]) {\n return config.parse;\n }\n }\n\n return undefined;\n};\n\n// Try to find an initial route connected with the one passed\nconst findInitialRoute = (\n routeName: string,\n parentScreens: string[],\n initialRoutes: InitialRouteConfig[]\n): string | undefined => {\n for (const config of initialRoutes) {\n if (parentScreens.length === config.parentScreens.length) {\n let sameParents = true;\n for (let i = 0; i < parentScreens.length; i++) {\n if (parentScreens[i].localeCompare(config.parentScreens[i]) !== 0) {\n sameParents = false;\n break;\n }\n }\n if (sameParents) {\n return routeName !== config.initialRouteName\n ? config.initialRouteName\n : undefined;\n }\n }\n }\n return undefined;\n};\n\n// returns state object with values depending on whether\n// it is the end of state and if there is initialRoute for this level\nconst createStateObject = (\n initialRoute: string | undefined,\n route: ParsedRoute,\n isEmpty: boolean\n): InitialState => {\n if (isEmpty) {\n if (initialRoute) {\n return {\n index: 1,\n routes: [{ name: initialRoute }, route],\n };\n } else {\n return {\n routes: [route],\n };\n }\n } else {\n if (initialRoute) {\n return {\n index: 1,\n routes: [{ name: initialRoute }, { ...route, state: { routes: [] } }],\n };\n } else {\n return {\n routes: [{ ...route, state: { routes: [] } }],\n };\n }\n }\n};\n\nconst createNestedStateObject = (\n path: string,\n routes: ParsedRoute[],\n initialRoutes: InitialRouteConfig[],\n flatConfig?: RouteConfig[]\n) => {\n let state: InitialState;\n let route = routes.shift() as ParsedRoute;\n const parentScreens: string[] = [];\n\n let initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);\n\n parentScreens.push(route.name);\n\n state = createStateObject(initialRoute, route, routes.length === 0);\n\n if (routes.length > 0) {\n let nestedState = state;\n\n while ((route = routes.shift() as ParsedRoute)) {\n initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);\n\n const nestedStateIndex =\n nestedState.index || nestedState.routes.length - 1;\n\n nestedState.routes[nestedStateIndex].state = createStateObject(\n initialRoute,\n route,\n routes.length === 0\n );\n\n if (routes.length > 0) {\n nestedState = nestedState.routes[nestedStateIndex]\n .state as InitialState;\n }\n\n parentScreens.push(route.name);\n }\n }\n\n route = findFocusedRoute(state) as ParsedRoute;\n route.path = path;\n\n const params = parseQueryParams(\n path,\n flatConfig ? findParseConfigForRoute(route.name, flatConfig) : undefined\n );\n\n if (params) {\n route.params = { ...route.params, ...params };\n }\n\n return state;\n};\n\nconst parseQueryParams = (\n path: string,\n parseConfig?: Record<string, (value: string) => any>\n) => {\n const query = path.split(\"?\")[1];\n const params = queryString.parse(query);\n\n if (parseConfig) {\n Object.keys(params).forEach((name) => {\n if (\n Object.hasOwnProperty.call(parseConfig, name) &&\n typeof params[name] === \"string\"\n ) {\n params[name] = parseConfig[name](params[name] as string);\n }\n });\n }\n\n return Object.keys(params).length ? params : undefined;\n};\n"]}
@@ -0,0 +1,7 @@
1
+ export declare const getDevServer: () => {
2
+ bundleLoadedFromServer: boolean;
3
+ /** URL but ensures that platform query param is added. */
4
+ readonly fullBundleUrl: string;
5
+ url: string;
6
+ };
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/getDevServer/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY;;IAcrB,0DAA0D;;;CAmB7D,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { Platform } from "expo-modules-core";
2
+ import qs from "qs";
3
+ export const getDevServer = () => {
4
+ // Disable for SSR
5
+ if (!Platform.isDOMAvailable) {
6
+ return {
7
+ bundleLoadedFromServer: true,
8
+ fullBundleUrl: "",
9
+ url: "",
10
+ };
11
+ }
12
+ return {
13
+ // The bundle is always loaded from a server in the browser.
14
+ bundleLoadedFromServer: true,
15
+ /** URL but ensures that platform query param is added. */
16
+ get fullBundleUrl() {
17
+ if (document?.currentScript && "src" in document.currentScript) {
18
+ return document.currentScript.src;
19
+ }
20
+ const url = window.location.toString();
21
+ const query = qs.parse(url);
22
+ return (location.origin +
23
+ location.pathname +
24
+ "?" +
25
+ qs.stringify({ ...query, platform: Platform.OS }));
26
+ },
27
+ url: location.origin + "/",
28
+ };
29
+ };
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/getDevServer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE;IAC/B,kBAAkB;IAClB,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE;QAC5B,OAAO;YACL,sBAAsB,EAAE,IAAI;YAC5B,aAAa,EAAE,EAAE;YACjB,GAAG,EAAE,EAAE;SACR,CAAC;KACH;IAED,OAAO;QACL,4DAA4D;QAC5D,sBAAsB,EAAE,IAAI;QAE5B,0DAA0D;QAC1D,IAAI,aAAa;YACf,IAAI,QAAQ,EAAE,aAAa,IAAI,KAAK,IAAI,QAAQ,CAAC,aAAa,EAAE;gBAC9D,OAAO,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC;aACnC;YAED,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YACvC,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAE5B,OAAO,CACL,QAAQ,CAAC,MAAM;gBACf,QAAQ,CAAC,QAAQ;gBACjB,GAAG;gBACH,EAAE,CAAC,SAAS,CAAC,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAClD,CAAC;QACJ,CAAC;QAED,GAAG,EAAE,QAAQ,CAAC,MAAM,GAAG,GAAG;KAC3B,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { Platform } from \"expo-modules-core\";\nimport qs from \"qs\";\n\nexport const getDevServer = () => {\n // Disable for SSR\n if (!Platform.isDOMAvailable) {\n return {\n bundleLoadedFromServer: true,\n fullBundleUrl: \"\",\n url: \"\",\n };\n }\n\n return {\n // The bundle is always loaded from a server in the browser.\n bundleLoadedFromServer: true,\n\n /** URL but ensures that platform query param is added. */\n get fullBundleUrl() {\n if (document?.currentScript && \"src\" in document.currentScript) {\n return document.currentScript.src;\n }\n\n const url = window.location.toString();\n const query = qs.parse(url);\n\n return (\n location.origin +\n location.pathname +\n \"?\" +\n qs.stringify({ ...query, platform: Platform.OS })\n );\n },\n\n url: location.origin + \"/\",\n };\n};\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const getDevServer: any;
2
+ //# sourceMappingURL=index.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.native.d.ts","sourceRoot":"","sources":["../../src/getDevServer/index.native.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,KAA+D,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const getDevServer = require("react-native/Libraries/Core/Devtools/getDevServer");
2
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.native.js","sourceRoot":"","sources":["../../src/getDevServer/index.native.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC,mDAAmD,CAAC,CAAC","sourcesContent":["export const getDevServer = require(\"react-native/Libraries/Core/Devtools/getDevServer\");\n"]}
@@ -0,0 +1,5 @@
1
+ import { LinkingOptions, PathConfigMap } from "@react-navigation/native";
2
+ import { RouteNode } from "./Route";
3
+ export declare function treeToReactNavigationLinkingRoutes(nodes: RouteNode[], parents?: string[]): PathConfigMap<{}>;
4
+ export declare function getLinkingConfig(routes: RouteNode[]): LinkingOptions<{}>;
5
+ //# sourceMappingURL=getLinkingConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLinkingConfig.d.ts","sourceRoot":"","sources":["../src/getLinkingConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAWzE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAqBpC,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,SAAS,EAAE,EAClB,OAAO,GAAE,MAAM,EAAO,GACrB,aAAa,CAAC,EAAE,CAAC,CA0BnB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,CAAC,EAAE,CAAC,CAgBxE"}
@@ -0,0 +1,62 @@
1
+ import * as Linking from "expo-linking";
2
+ import { getAllWebRedirects } from "./aasa";
3
+ import getPathFromState from "./fork/getPathFromState";
4
+ import getStateFromPath from "./fork/getStateFromPath";
5
+ import { matchDeepDynamicRouteName, matchDynamicName, matchFragmentName, } from "./matchers";
6
+ // `[page]` -> `:page`
7
+ // `page` -> `page`
8
+ function convertDynamicRouteToReactNavigation(name) {
9
+ if (matchDeepDynamicRouteName(name)) {
10
+ return "*";
11
+ }
12
+ const dynamicName = matchDynamicName(name);
13
+ if (dynamicName) {
14
+ return `:${dynamicName}`;
15
+ }
16
+ if (name === "index" || matchFragmentName(name)) {
17
+ return "";
18
+ }
19
+ return name;
20
+ }
21
+ export function treeToReactNavigationLinkingRoutes(nodes, parents = []) {
22
+ // TODO: Intercept errors, strip invalid routes, and warn instead.
23
+ // Our warnings can be more helpful than upstream since we know the associated file name.
24
+ const firstPass = nodes
25
+ .map((node) => {
26
+ let path = convertDynamicRouteToReactNavigation(node.route);
27
+ return [
28
+ node.screenName,
29
+ {
30
+ path: path,
31
+ screens: node.children.length
32
+ ? treeToReactNavigationLinkingRoutes(node.children, [
33
+ ...parents,
34
+ path,
35
+ ])
36
+ : undefined,
37
+ },
38
+ ];
39
+ })
40
+ .reduce((acc, [screenName, current]) => {
41
+ acc[screenName] = current;
42
+ return acc;
43
+ }, {});
44
+ return firstPass;
45
+ }
46
+ export function getLinkingConfig(routes) {
47
+ return {
48
+ prefixes: [
49
+ /* your linking prefixes */
50
+ Linking.createURL("/"),
51
+ // This ensures that we can redirect correctly when the user comes from an associated domain
52
+ // i.e. iOS Safari banner.
53
+ ...getAllWebRedirects(),
54
+ ],
55
+ config: {
56
+ screens: treeToReactNavigationLinkingRoutes(routes),
57
+ },
58
+ getStateFromPath,
59
+ getPathFromState,
60
+ };
61
+ }
62
+ //# sourceMappingURL=getLinkingConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLinkingConfig.js","sourceRoot":"","sources":["../src/getLinkingConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AACvD,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAGpB,sBAAsB;AACtB,mBAAmB;AACnB,SAAS,oCAAoC,CAAC,IAAY;IACxD,IAAI,yBAAyB,CAAC,IAAI,CAAC,EAAE;QACnC,OAAO,GAAG,CAAC;KACZ;IACD,MAAM,WAAW,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAE3C,IAAI,WAAW,EAAE;QACf,OAAO,IAAI,WAAW,EAAE,CAAC;KAC1B;IAED,IAAI,IAAI,KAAK,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,EAAE;QAC/C,OAAO,EAAE,CAAC;KACX;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,kCAAkC,CAChD,KAAkB,EAClB,UAAoB,EAAE;IAEtB,kEAAkE;IAClE,yFAAyF;IACzF,MAAM,SAAS,GAAG,KAAK;SACpB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,IAAI,IAAI,GAAG,oCAAoC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAE5D,OAAO;YACL,IAAI,CAAC,UAAU;YACf;gBACE,IAAI,EAAE,IAAI;gBACV,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM;oBAC3B,CAAC,CAAC,kCAAkC,CAAC,IAAI,CAAC,QAAQ,EAAE;wBAChD,GAAG,OAAO;wBACV,IAAI;qBACL,CAAC;oBACJ,CAAC,CAAC,SAAS;aACd;SACO,CAAC;IACb,CAAC,CAAC;SACD,MAAM,CAAoB,CAAC,GAAG,EAAE,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE;QACxD,GAAG,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC;QAC1B,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;IAET,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAmB;IAClD,OAAO;QACL,QAAQ,EAAE;YACR,2BAA2B;YAC3B,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC;YAEtB,4FAA4F;YAC5F,0BAA0B;YAC1B,GAAG,kBAAkB,EAAE;SACxB;QACD,MAAM,EAAE;YACN,OAAO,EAAE,kCAAkC,CAAC,MAAM,CAAC;SACpD;QACD,gBAAgB;QAChB,gBAAgB;KACjB,CAAC;AACJ,CAAC","sourcesContent":["import { LinkingOptions, PathConfigMap } from \"@react-navigation/native\";\nimport * as Linking from \"expo-linking\";\n\nimport { getAllWebRedirects } from \"./aasa\";\nimport getPathFromState from \"./fork/getPathFromState\";\nimport getStateFromPath from \"./fork/getStateFromPath\";\nimport {\n matchDeepDynamicRouteName,\n matchDynamicName,\n matchFragmentName,\n} from \"./matchers\";\nimport { RouteNode } from \"./Route\";\n\n// `[page]` -> `:page`\n// `page` -> `page`\nfunction convertDynamicRouteToReactNavigation(name: string) {\n if (matchDeepDynamicRouteName(name)) {\n return \"*\";\n }\n const dynamicName = matchDynamicName(name);\n\n if (dynamicName) {\n return `:${dynamicName}`;\n }\n\n if (name === \"index\" || matchFragmentName(name)) {\n return \"\";\n }\n\n return name;\n}\n\nexport function treeToReactNavigationLinkingRoutes(\n nodes: RouteNode[],\n parents: string[] = []\n): PathConfigMap<{}> {\n // TODO: Intercept errors, strip invalid routes, and warn instead.\n // Our warnings can be more helpful than upstream since we know the associated file name.\n const firstPass = nodes\n .map((node) => {\n let path = convertDynamicRouteToReactNavigation(node.route);\n\n return [\n node.screenName,\n {\n path: path,\n screens: node.children.length\n ? treeToReactNavigationLinkingRoutes(node.children, [\n ...parents,\n path,\n ])\n : undefined,\n },\n ] as const;\n })\n .reduce<PathConfigMap<{}>>((acc, [screenName, current]) => {\n acc[screenName] = current;\n return acc;\n }, {});\n\n return firstPass;\n}\n\nexport function getLinkingConfig(routes: RouteNode[]): LinkingOptions<{}> {\n return {\n prefixes: [\n /* your linking prefixes */\n Linking.createURL(\"/\"),\n\n // This ensures that we can redirect correctly when the user comes from an associated domain\n // i.e. iOS Safari banner.\n ...getAllWebRedirects(),\n ],\n config: {\n screens: treeToReactNavigationLinkingRoutes(routes),\n },\n getStateFromPath,\n getPathFromState,\n };\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { PickPartial, RouteNode } from "./Route";
2
+ import { RequireContext } from "./types";
3
+ export declare function createRouteNode(route: PickPartial<RouteNode, "screenName" | "dynamic" | "children">): RouteNode;
4
+ /** Given a Metro context module, return an array of nested routes. */
5
+ export declare function getRoutes(contextModule: RequireContext): RouteNode[];
6
+ export declare function recurseAndAddMissingNavigators(routes: RouteNode[], parents: string[]): RouteNode[];
7
+ /**
8
+ * Exposed for testing.
9
+ * @returns a top-level deep dynamic route if it exists, otherwise null.
10
+ */
11
+ export declare function getUserDefinedDeepDynamicRoute(routes: RouteNode[]): RouteNode | null;
12
+ //# sourceMappingURL=getRoutes.d.ts.map