@cleya/contributor-react-navigation 0.0.0-stage → 1.0.0-next.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/README.md +136 -2
- package/dist/ast.d.ts +64 -0
- package/dist/blank.d.ts +97 -0
- package/dist/census.d.ts +43 -0
- package/dist/collect.d.ts +113 -0
- package/dist/dialect.d.ts +58 -0
- package/dist/graph-reader.d.ts +55 -0
- package/dist/nav-calls.d.ts +93 -0
- package/dist/payload.d.ts +21 -0
- package/dist/react-navigation.contributor.d.ts +49 -0
- package/dist/react-navigation.index.d.ts +2 -0
- package/dist/react-navigation.index.js +1522 -0
- package/dist/react-navigation.types.d.ts +42 -0
- package/dist/registrations.d.ts +95 -0
- package/dist/route-names.d.ts +135 -0
- package/dist/type-index.d.ts +92 -0
- package/package.json +37 -5
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Domain } from "@cleya/domain";
|
|
2
|
+
import type { regionNavigation } from "@cleya/region-navigation";
|
|
3
|
+
import type { NavigationModel } from "./collect";
|
|
4
|
+
/** The rows the engine loads into the navigation region's tables. */
|
|
5
|
+
export type NavigationPayload = Domain.Region.Payload<typeof regionNavigation>;
|
|
6
|
+
/**
|
|
7
|
+
* Turn a {@link NavigationModel} into the navigation region's payload. The
|
|
8
|
+
* engine stages and loads it, nodes before edges, so no ordering is needed
|
|
9
|
+
* here, and a `RENDERS` edge whose `Symbol` the code indexer never declared is
|
|
10
|
+
* dropped with a diagnostic rather than pointing at a placeholder.
|
|
11
|
+
*
|
|
12
|
+
* `SERVES` is derived rather than carried in the model: a screen already knows
|
|
13
|
+
* its route, so a separate list could only disagree with it.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* toPayload(model);
|
|
17
|
+
* // { nodes: [{ _label: "Route", id: "app|Home", … }, { _label: "Screen", id: "app|root|Home", … }],
|
|
18
|
+
* // edges: [{ _label: "SERVES", fromId: "app|Home", toId: "app|root|Home", … }, …] }
|
|
19
|
+
* toPayload(emptyModel); // { nodes: [], edges: [] }
|
|
20
|
+
*/
|
|
21
|
+
export declare const toPayload: (model: NavigationModel) => NavigationPayload;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Navigation indexer.
|
|
3
|
+
*
|
|
4
|
+
* DOMAIN MODEL (the navigation region's tables, `@cleya/region-navigation`)
|
|
5
|
+
*
|
|
6
|
+
* Route — an addressable destination name. Pure identity: a route is
|
|
7
|
+
* *named* at each registration site, never declared.
|
|
8
|
+
* Screen — one registration: this route, in this navigator, rendered by this
|
|
9
|
+
* component, under these options/guards, at this source position.
|
|
10
|
+
* Component — the code symbol rendering it. Declared by the TS indexer.
|
|
11
|
+
*
|
|
12
|
+
* (Route)-[:SERVES]->(Screen)-[:RENDERS]->(Symbol)
|
|
13
|
+
* (Screen)-[:NAVIGATES_TO]->(Route)
|
|
14
|
+
*
|
|
15
|
+
* Route and Screen are separate because a route can be registered more than once
|
|
16
|
+
* (two navigators, or a deeplink alias): collapsing Screen into an edge would
|
|
17
|
+
* lose the options, the guard and the position, and make the registrations
|
|
18
|
+
* indistinguishable.
|
|
19
|
+
*
|
|
20
|
+
* `NAVIGATES_TO` starts at Screen, not Route: you navigate *from the screen you
|
|
21
|
+
* are on*. Traversal is (Route)-[:SERVES]->(Screen)-[:NAVIGATES_TO]->(Route).
|
|
22
|
+
*
|
|
23
|
+
* ASSUMPTION: route names are globally unique. React Navigation scopes them per
|
|
24
|
+
* navigator; when two registrations share a name they become two Screens under
|
|
25
|
+
* one Route and the contributor emits a diagnostic.
|
|
26
|
+
*
|
|
27
|
+
* This module orchestrates and reports; it decides nothing. `collect` works out
|
|
28
|
+
* the navigation graph as a value, `toPayload` shapes it for the engine to load.
|
|
29
|
+
*/
|
|
30
|
+
import type { Contributor } from "@cleya/config";
|
|
31
|
+
import { regionNavigation } from "@cleya/region-navigation";
|
|
32
|
+
import type { ReactNavigationDialect } from "./react-navigation.types";
|
|
33
|
+
/**
|
|
34
|
+
* Build the React Navigation contributor.
|
|
35
|
+
*
|
|
36
|
+
* The dialect is resolved and validated here, so a regex with no capture group
|
|
37
|
+
* throws when `cleya.config.ts` loads rather than midway through an indexing run.
|
|
38
|
+
*
|
|
39
|
+
* The contributor must run **after** a code indexer in the same workspace:
|
|
40
|
+
* routes link to the symbols it declares, and with no `Symbol` tagged with its
|
|
41
|
+
* workspace it returns an `error` diagnostic and no payload rather than an
|
|
42
|
+
* empty graph.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* reactNavigationContributor(); // core dialect only
|
|
46
|
+
* reactNavigationContributor().region.id; // "navigation"
|
|
47
|
+
* reactNavigationContributor({ routeAliasFiles: ["linking.ts"] }); // project navigating by URL
|
|
48
|
+
*/
|
|
49
|
+
export declare const reactNavigationContributor: (dialect?: ReactNavigationDialect) => Contributor<typeof regionNavigation>;
|