@mapples/types 1.6.0-beta.20260921105308 → 1.6.0-beta.20260929074057
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 +4 -1
- package/dist/api.d.ts +19 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +8 -1
- package/dist/api.js.map +1 -1
- package/dist/apiValidator.d.ts +10 -1
- package/dist/apiValidator.d.ts.map +1 -1
- package/dist/apiValidator.js +35 -2
- package/dist/apiValidator.js.map +1 -1
- package/dist/navigation.d.ts +83 -4
- package/dist/navigation.d.ts.map +1 -1
- package/dist/navigation.js +33 -0
- package/dist/navigation.js.map +1 -1
- package/dist/navigationValidator.d.ts +6 -2
- package/dist/navigationValidator.d.ts.map +1 -1
- package/dist/navigationValidator.js +29 -1
- package/dist/navigationValidator.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
# @mapples/types
|
|
2
2
|
|
|
3
|
-
## 1.6.0-beta.
|
|
3
|
+
## 1.6.0-beta.20260929074057
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
|
+
- 132e4a8: Header options now apply to every navigator type, and their default is explicit. A tabs or drawer navigator draws a header of its own, but only a stack's options were mapped — so a navigator nested in a stack always stacked a second header under its parent's with nothing that could turn it off. `resolveNavigatorHeader` and `navigatorHeaderVisible` expose the navigator default (`visible` unset means shown), so an editor can present a plain on/off instead of a tri-state that reads "off" while the header is up; route-level `visible` stays tri-state, because unset there means "inherit the navigator". `NavigationDocument.canvas` carries editor-only canvas preferences, ignored by the runtime the same way `NavigatorNode.canvas` is.
|
|
8
|
+
- 517b1d4: API responses move to their own `@mapples/state` context (`ApiStateContextProvider`, `useApiState`), so `api.*` bindings resolve inside a nested `StateProvider` — a list row, a scoped data state — the way `vars.*` does; `validateApiDocument` now rejects a state key outside the `api.` namespace (`STATE_KEY_NAMESPACE`, `API_NAMESPACE`) and no longer reads an environment variable's `{{name}}` as the path token `{name`; it also rejects a request name that can't be a binding-path segment (`REQUEST_NAME_INVALID`, `API_REQUEST_NAME_PATTERN`) and an empty path (`PATH_EMPTY`). `@mapples/request` performs calls through a pluggable `RequestTransport` (`transport` prop, `createFetchTransport`), which receives `auth` unresolved so a forwarding transport never holds a secret. The runtime no longer fails silently: an unknown `requestId`, a path token that resolves to nothing, an undefined `{{variable}}`, a relative path without a base URL and an unconfigured secret all throw (`onRequestError` receives the resolution errors), an unresolved `state` source is no longer sent as the string `N/A`, and `event` sources read the event's first argument instead of the `staticData`-merged payload. `RequestProvider` drops its `state` prop.
|
|
9
|
+
- 132e4a8: Routes carry a flow of their own: a `path` with `:token` params (`/product/:id`), an `onEnter` action emitted on every focus, and an access `guard` with a fallback route. Params travel on the navigate action as literals or value sources (`data` reads the pressed list row, `state` any binding), land in a new `route.*` state namespace the screen binds, and reach root-mounted handlers through `ActiveRouteProvider` — so a request bound to `route.id` loads the product page. `resolveValueSource` is shared by the request and navigation runtimes, and the new `data` source kind reads an action's resolved data. The navigate action form gets one source field per route param, the AI catalog `set_route_path` / `set_route_guard` / `set_route_on_enter` and `add_connection` params.
|
|
7
10
|
- a6c5872: All `@mapples/*` runtime packages now share one version and are versioned and published together from `mapplesorg/mapples-kit`; `mapples-open-kit` is a read-only mirror of the source.
|
|
8
11
|
|
|
9
12
|
## 1.3.0
|
package/dist/api.d.ts
CHANGED
|
@@ -25,6 +25,18 @@ export type ApiValueSource =
|
|
|
25
25
|
| {
|
|
26
26
|
kind: 'event';
|
|
27
27
|
path?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A value from the triggering action's resolved data (`Action.payload.data`):
|
|
31
|
+
* what the element's `dataProp` resolved in its own scope — a list row's
|
|
32
|
+
* item when the element binds `(this)` — merged with its `staticData`, or a
|
|
33
|
+
* route's params for an on-enter action. `path` narrows into it; omitted =
|
|
34
|
+
* the whole value. The way a row-scoped value reaches a request, which a
|
|
35
|
+
* `state` source (resolved where the runtime is mounted) cannot see.
|
|
36
|
+
*/
|
|
37
|
+
| {
|
|
38
|
+
kind: 'data';
|
|
39
|
+
path?: string;
|
|
28
40
|
};
|
|
29
41
|
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
30
42
|
export interface ApiEnvironment {
|
|
@@ -88,6 +100,13 @@ export interface ApiDocument {
|
|
|
88
100
|
environments: Record<string, ApiEnvironment>;
|
|
89
101
|
requests: Record<string, ApiRequest>;
|
|
90
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Root of every request state key. Responses live in their own context, which
|
|
105
|
+
* scope providers (a frame's data state, a list row) never shadow, so
|
|
106
|
+
* `api.*` bindings resolve the same anywhere in the tree — the way `vars.*`
|
|
107
|
+
* does. `validateApiDocument` rejects a state key outside this namespace.
|
|
108
|
+
*/
|
|
109
|
+
export declare const API_NAMESPACE = "api";
|
|
91
110
|
/** The default state key a request's responses are stored under. */
|
|
92
111
|
export declare const apiRequestStateKey: (request: ApiRequest) => string;
|
|
93
112
|
//# sourceMappingURL=api.d.ts.map
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,yEAAyE;AACzE,MAAM,MAAM,cAAc;AACxB,wBAAwB;AACtB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AACnC,gEAAgE;GAC9D;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE;AACrC;;;GAGG;GACD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;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AC,CAAC;IACjC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACxC,sEAAsE;IACtE,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IAC3C,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,CAAC,CAAC;IACX,kDAAkD;IAClD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC7C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACtC;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,QAAQ,CAAC;AAEnC,oEAAoE;AACpE,eAAO,MAAM,kBAAkB,GAAI,SAAS,UAAU,KAAG,MACD,CAAC"}
|
package/dist/api.js
CHANGED
|
@@ -6,6 +6,13 @@
|
|
|
6
6
|
* Persisted as one opaque row per project (mirroring the navigation
|
|
7
7
|
* document); validated client-side by `validateApiDocument`.
|
|
8
8
|
*/
|
|
9
|
+
/**
|
|
10
|
+
* Root of every request state key. Responses live in their own context, which
|
|
11
|
+
* scope providers (a frame's data state, a list row) never shadow, so
|
|
12
|
+
* `api.*` bindings resolve the same anywhere in the tree — the way `vars.*`
|
|
13
|
+
* does. `validateApiDocument` rejects a state key outside this namespace.
|
|
14
|
+
*/
|
|
15
|
+
export const API_NAMESPACE = 'api';
|
|
9
16
|
/** The default state key a request's responses are stored under. */
|
|
10
|
-
export const apiRequestStateKey = (request) => request.stateKey ||
|
|
17
|
+
export const apiRequestStateKey = (request) => request.stateKey || `${API_NAMESPACE}.${request.name}`;
|
|
11
18
|
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAuFH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC;AAEnC,oEAAoE;AACpE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAmB,EAAU,EAAE,CAChE,OAAO,CAAC,QAAQ,IAAI,GAAG,aAAa,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC"}
|
package/dist/apiValidator.d.ts
CHANGED
|
@@ -2,14 +2,17 @@ import { ApiDocument } from './api';
|
|
|
2
2
|
/**
|
|
3
3
|
* Codes for the invariants enforced by {@link validateApiDocument}.
|
|
4
4
|
*
|
|
5
|
+
* - `REQUEST_NAME_INVALID` — a name that can't be a segment of a binding path.
|
|
5
6
|
* - `REQUEST_NAME_DUPLICATE` — two requests share a name.
|
|
7
|
+
* - `PATH_EMPTY` — a request has no path.
|
|
6
8
|
* - `ENVIRONMENT_MISSING` — `activeEnvironmentId` has no matching environment.
|
|
7
9
|
* - `PATH_PARAM_UNBOUND` — a `{token}` in a request path has no params entry.
|
|
8
10
|
* - `BODY_ON_GET` — a GET request declares a body.
|
|
9
11
|
* - `STATE_KEY_COLLISION` — two requests resolve to the same state key.
|
|
12
|
+
* - `STATE_KEY_NAMESPACE` — a state key sits outside the `api.` namespace.
|
|
10
13
|
* - `SECRET_REF_EMPTY` — auth requires a secret but `secretRef` is empty.
|
|
11
14
|
*/
|
|
12
|
-
export type ApiValidationCode = 'REQUEST_NAME_DUPLICATE' | 'ENVIRONMENT_MISSING' | 'PATH_PARAM_UNBOUND' | 'BODY_ON_GET' | 'STATE_KEY_COLLISION' | 'SECRET_REF_EMPTY';
|
|
15
|
+
export type ApiValidationCode = 'REQUEST_NAME_INVALID' | 'REQUEST_NAME_DUPLICATE' | 'PATH_EMPTY' | 'ENVIRONMENT_MISSING' | 'PATH_PARAM_UNBOUND' | 'BODY_ON_GET' | 'STATE_KEY_COLLISION' | 'STATE_KEY_NAMESPACE' | 'SECRET_REF_EMPTY';
|
|
13
16
|
export interface ApiValidationError {
|
|
14
17
|
code: ApiValidationCode;
|
|
15
18
|
message: string;
|
|
@@ -19,6 +22,12 @@ export interface ApiValidationResult {
|
|
|
19
22
|
valid: boolean;
|
|
20
23
|
errors: ApiValidationError[];
|
|
21
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* A request's name is the last segment of its default state key
|
|
27
|
+
* (`api.<name>`), so it has to be one binding-path segment: a dot or a space
|
|
28
|
+
* would break every binding that reads the response.
|
|
29
|
+
*/
|
|
30
|
+
export declare const API_REQUEST_NAME_PATTERN: RegExp;
|
|
22
31
|
/**
|
|
23
32
|
* Validate the structural invariants of an {@link ApiDocument}. Collects
|
|
24
33
|
* every violation (same shape as `validateNavigationDocument`).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiValidator.d.ts","sourceRoot":"","sources":["../src/apiValidator.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"apiValidator.d.ts","sourceRoot":"","sources":["../src/apiValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,WAAW,EAAsB,MAAM,OAAO,CAAC;AAEvE;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,iBAAiB,GACzB,sBAAsB,GACtB,wBAAwB,GACxB,YAAY,GACZ,qBAAqB,GACrB,oBAAoB,GACpB,aAAa,GACb,qBAAqB,GACrB,qBAAqB,GACrB,kBAAkB,CAAC;AAEvB,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,kBAAkB,EAAE,CAAC;CAC9B;AAUD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,QAA6B,CAAC;AAEnE;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAC9B,UAAU,WAAW,KACpB,mBAoGF,CAAC"}
|
package/dist/apiValidator.js
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import { apiRequestStateKey } from './api';
|
|
2
|
-
|
|
1
|
+
import { API_NAMESPACE, apiRequestStateKey } from './api';
|
|
2
|
+
/**
|
|
3
|
+
* A single-brace `{token}`. The lookarounds keep an environment variable's
|
|
4
|
+
* `{{name}}` from reading as the path token `{name`.
|
|
5
|
+
*/
|
|
6
|
+
const PATH_TOKEN_PATTERN = /(?<!\{)\{([^{}]+)\}(?!\})/g;
|
|
7
|
+
const STATE_KEY_PREFIX = `${API_NAMESPACE}.`;
|
|
8
|
+
/**
|
|
9
|
+
* A request's name is the last segment of its default state key
|
|
10
|
+
* (`api.<name>`), so it has to be one binding-path segment: a dot or a space
|
|
11
|
+
* would break every binding that reads the response.
|
|
12
|
+
*/
|
|
13
|
+
export const API_REQUEST_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
3
14
|
/**
|
|
4
15
|
* Validate the structural invariants of an {@link ApiDocument}. Collects
|
|
5
16
|
* every violation (same shape as `validateNavigationDocument`).
|
|
@@ -16,6 +27,20 @@ export const validateApiDocument = (document) => {
|
|
|
16
27
|
const namesSeen = new Map();
|
|
17
28
|
const stateKeysSeen = new Map();
|
|
18
29
|
for (const request of Object.values(document.requests)) {
|
|
30
|
+
if (!API_REQUEST_NAME_PATTERN.test(request.name)) {
|
|
31
|
+
errors.push({
|
|
32
|
+
code: 'REQUEST_NAME_INVALID',
|
|
33
|
+
message: `Request name "${request.name}" must start with a letter or "_" and contain only letters, digits and "_"`,
|
|
34
|
+
requestId: request.id,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (request.path.trim() === '') {
|
|
38
|
+
errors.push({
|
|
39
|
+
code: 'PATH_EMPTY',
|
|
40
|
+
message: `Request "${request.name}" has no path`,
|
|
41
|
+
requestId: request.id,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
19
44
|
const existingName = namesSeen.get(request.name);
|
|
20
45
|
if (existingName) {
|
|
21
46
|
errors.push({
|
|
@@ -28,6 +53,14 @@ export const validateApiDocument = (document) => {
|
|
|
28
53
|
namesSeen.set(request.name, request.id);
|
|
29
54
|
}
|
|
30
55
|
const stateKey = apiRequestStateKey(request);
|
|
56
|
+
if (!stateKey.startsWith(STATE_KEY_PREFIX) ||
|
|
57
|
+
stateKey.length === STATE_KEY_PREFIX.length) {
|
|
58
|
+
errors.push({
|
|
59
|
+
code: 'STATE_KEY_NAMESPACE',
|
|
60
|
+
message: `State key "${stateKey}" must live under "${STATE_KEY_PREFIX}"`,
|
|
61
|
+
requestId: request.id,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
31
64
|
const existingStateKey = stateKeysSeen.get(stateKey);
|
|
32
65
|
if (existingStateKey) {
|
|
33
66
|
errors.push({
|
package/dist/apiValidator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiValidator.js","sourceRoot":"","sources":["../src/apiValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,kBAAkB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"apiValidator.js","sourceRoot":"","sources":["../src/apiValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAe,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAqCvE;;;GAGG;AACH,MAAM,kBAAkB,GAAG,4BAA4B,CAAC;AAExD,MAAM,gBAAgB,GAAG,GAAG,aAAa,GAAG,CAAC;AAE7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,0BAA0B,CAAC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AAO,EAAE,gBAAgB,KAAK,UAAU,OAAO,CAAC,IAAI,uBAAuB;oBAC3E,SAAS,EAAE,OAAO,CAAC,EAAE;iBACtB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,IAAI,OAAO,CAAC,MAAM,KAAK,KAAK,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YAC7C,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,aAAa;gBACnB,OAAO,EAAE,gBAAgB,OAAO,CAAC,IAAI,2BAA2B;gBAChE,SAAS,EAAE,OAAO,CAAC,EAAE;aACtB,CAAC,CAAC;QACL,CAAC;QAED,IACE,OAAO,CAAC,IAAI;YACZ,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM;YAC5B,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EACvB,CAAC;YACD,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,kBAAkB;gBACxB,OAAO,EAAE,YAAY,OAAO,CAAC,IAAI,6BAA6B;gBAC9D,SAAS,EAAE,OAAO,CAAC,EAAE;aACtB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;AAChD,CAAC,CAAC"}
|
package/dist/navigation.d.ts
CHANGED
|
@@ -32,6 +32,25 @@ export interface NavigationDocument {
|
|
|
32
32
|
rootNavigatorId: string;
|
|
33
33
|
/** Flat map of every navigator in the document, keyed by {@link NavigatorNode.id}. */
|
|
34
34
|
navigators: Record<string, NavigatorNode>;
|
|
35
|
+
/** Editor-only canvas preferences. Ignored by the runtime. */
|
|
36
|
+
canvas?: NavigationCanvasSettings;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Editor-only preferences about how the navigation is *drawn on the canvas*.
|
|
40
|
+
* The runtime never reads this, the same way it never reads
|
|
41
|
+
* {@link NavigatorNode.canvas} — it lives here so the choice travels with the
|
|
42
|
+
* project rather than with one editor.
|
|
43
|
+
*
|
|
44
|
+
* @interface NavigationCanvasSettings
|
|
45
|
+
*/
|
|
46
|
+
export interface NavigationCanvasSettings {
|
|
47
|
+
/**
|
|
48
|
+
* Draw each screen's navigator chrome (headers, and the tab bar of a tabs
|
|
49
|
+
* navigator it belongs to) on its canvas frame, inset from the design area
|
|
50
|
+
* exactly as the running app insets it. Unset means on: a frame that hides
|
|
51
|
+
* the chrome is claiming space the screen will not actually have.
|
|
52
|
+
*/
|
|
53
|
+
chrome?: boolean;
|
|
35
54
|
}
|
|
36
55
|
/**
|
|
37
56
|
* Editor-only world-space rectangle of a navigator's section on the Creator
|
|
@@ -94,11 +113,62 @@ export interface RouteNode {
|
|
|
94
113
|
presentation?: 'card' | 'modal' | 'transparentModal';
|
|
95
114
|
/** Per-screen option overrides (header, tab/drawer label & icon). */
|
|
96
115
|
options?: ScreenOptions;
|
|
97
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* The route's path segment under its navigator — the exported app's
|
|
118
|
+
* expo-router file segment (`profile`, `(auth)` for a group, `send-money`),
|
|
119
|
+
* which the CLI reads and writes on sync. A `:token` (or `[token]`) segment
|
|
120
|
+
* is a param — `product/:id` — that every navigate action to the route must
|
|
121
|
+
* supply (see {@link routePathParams}) and the screen reads as
|
|
122
|
+
* `route.<token>`. Absent: derived from the route name, no params.
|
|
123
|
+
*/
|
|
98
124
|
path?: string;
|
|
99
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* Access guard: a condition in the grammar element visibility uses
|
|
127
|
+
* (`dataProp::condition::value`, e.g. `vars.session.token::isNotEmpty::`)
|
|
128
|
+
* that must hold for the screen to show. When it fails the navigator sends
|
|
129
|
+
* the user to {@link guardFallbackRouteId} instead. Meant for "signed in"
|
|
130
|
+
* style checks — a screen waiting for its data binds `api.<name>.loading`,
|
|
131
|
+
* a guard on the response would bounce the user before the request settles.
|
|
132
|
+
*/
|
|
100
133
|
guard?: string;
|
|
134
|
+
/** Id of the route shown when {@link guard} fails. Required with a guard. */
|
|
135
|
+
guardFallbackRouteId?: string;
|
|
136
|
+
/**
|
|
137
|
+
* An action emitted each time the screen gains focus, with the route's
|
|
138
|
+
* params as its event value and merged into its data — typically a
|
|
139
|
+
* `mapples:request` so the screen loads what it shows
|
|
140
|
+
* (`/product/:id` → `GET /products/{id}` with `{id}` bound to `route.id`).
|
|
141
|
+
*/
|
|
142
|
+
onEnter?: RouteEnterAction;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The action a route emits on focus. The same shape an element's action prop
|
|
146
|
+
* carries: the type, plus the literal payload the runtime merges into
|
|
147
|
+
* `Action.payload.data` (a request's `requestId` and follow-ups).
|
|
148
|
+
*
|
|
149
|
+
* @interface RouteEnterAction
|
|
150
|
+
*/
|
|
151
|
+
export interface RouteEnterAction {
|
|
152
|
+
type: string;
|
|
153
|
+
staticData?: Record<string, unknown>;
|
|
101
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Root of every route-param binding (`route.id`). Params live in their own
|
|
157
|
+
* `@mapples/state` context, like `vars.*` and `api.*`, so a nested data-state
|
|
158
|
+
* provider never shadows them.
|
|
159
|
+
*/
|
|
160
|
+
export declare const ROUTE_NAMESPACE = "route";
|
|
161
|
+
/**
|
|
162
|
+
* The param names a route path declares, in order of first appearance —
|
|
163
|
+
* `shop/:category/:id` → `['category', 'id']`. Empty without a path.
|
|
164
|
+
*/
|
|
165
|
+
export declare const routePathParams: (path?: string) => string[];
|
|
166
|
+
/**
|
|
167
|
+
* Whether a route path is well-formed: one or more segments, each a literal
|
|
168
|
+
* (`[A-Za-z0-9._-]+`), a `(group)`, or a `:name` / `[name]` param. A leading
|
|
169
|
+
* or trailing slash is tolerated (the CLI strips them).
|
|
170
|
+
*/
|
|
171
|
+
export declare const isValidRoutePath: (path: string) => boolean;
|
|
102
172
|
/**
|
|
103
173
|
* Navigator-level presentation options. Only the field matching the
|
|
104
174
|
* navigator's {@link NavigatorType} is meaningful at runtime.
|
|
@@ -106,7 +176,11 @@ export interface RouteNode {
|
|
|
106
176
|
* @interface NavigatorOptions
|
|
107
177
|
*/
|
|
108
178
|
export interface NavigatorOptions {
|
|
109
|
-
/**
|
|
179
|
+
/**
|
|
180
|
+
* Header options. Every navigator type draws a header, so these apply to
|
|
181
|
+
* all three — turning `visible` off is how a nested navigator stops
|
|
182
|
+
* stacking a second header under its parent's.
|
|
183
|
+
*/
|
|
110
184
|
header?: HeaderOptions;
|
|
111
185
|
/** Tab bar options — applies to `tabs` navigators. */
|
|
112
186
|
tabBar?: TabBarOptions;
|
|
@@ -122,7 +196,12 @@ export interface NavigatorOptions {
|
|
|
122
196
|
* @interface HeaderOptions
|
|
123
197
|
*/
|
|
124
198
|
export interface HeaderOptions {
|
|
125
|
-
/**
|
|
199
|
+
/**
|
|
200
|
+
* Whether the header is shown. Unset means shown — that is the navigator
|
|
201
|
+
* default, and `resolveNavigatorHeader` in `@mapples/navigation` makes it
|
|
202
|
+
* explicit so editors can present a plain on/off rather than a tri-state
|
|
203
|
+
* that reads "off" while the header is up.
|
|
204
|
+
*/
|
|
126
205
|
visible?: boolean;
|
|
127
206
|
/** Header title text. */
|
|
128
207
|
title?: string;
|
package/dist/navigation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../src/navigation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAExD;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IACjC,wDAAwD;IACxD,OAAO,EAAE,CAAC,CAAC;IACX,gEAAgE;IAChE,eAAe,EAAE,MAAM,CAAC;IACxB,sFAAsF;IACtF,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../src/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c,SAAQ,OAAO,CAAC,aAAa,CAAC;IAC3D,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6BAA6B;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
|
package/dist/navigation.js
CHANGED
|
@@ -8,4 +8,37 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @module navigation
|
|
10
10
|
*/
|
|
11
|
+
/**
|
|
12
|
+
* Root of every route-param binding (`route.id`). Params live in their own
|
|
13
|
+
* `@mapples/state` context, like `vars.*` and `api.*`, so a nested data-state
|
|
14
|
+
* provider never shadows them.
|
|
15
|
+
*/
|
|
16
|
+
export const ROUTE_NAMESPACE = 'route';
|
|
17
|
+
/**
|
|
18
|
+
* Param segments of a {@link RouteNode.path}: `:token` as authored in the
|
|
19
|
+
* Creator, or `[token]` as an expo-router file the CLI adopted.
|
|
20
|
+
*/
|
|
21
|
+
const ROUTE_PATH_TOKEN_PATTERN = /(?:^|\/):([A-Za-z_][A-Za-z0-9_]*)(?=\/|$)|(?:^|\/)\[([A-Za-z_][A-Za-z0-9_]*)\](?=\/|$)/g;
|
|
22
|
+
/**
|
|
23
|
+
* The param names a route path declares, in order of first appearance —
|
|
24
|
+
* `shop/:category/:id` → `['category', 'id']`. Empty without a path.
|
|
25
|
+
*/
|
|
26
|
+
export const routePathParams = (path) => {
|
|
27
|
+
const names = [];
|
|
28
|
+
for (const match of (path ?? '').matchAll(ROUTE_PATH_TOKEN_PATTERN)) {
|
|
29
|
+
const name = match[1] ?? match[2];
|
|
30
|
+
if (!names.includes(name))
|
|
31
|
+
names.push(name);
|
|
32
|
+
}
|
|
33
|
+
return names;
|
|
34
|
+
};
|
|
35
|
+
/** One path segment: a literal, an expo-router `(group)`, or a param. */
|
|
36
|
+
const ROUTE_SEGMENT = '(?:[A-Za-z0-9._-]+|\\([A-Za-z0-9._-]+\\)|:[A-Za-z_][A-Za-z0-9_]*|\\[[A-Za-z_][A-Za-z0-9_]*\\])';
|
|
37
|
+
const ROUTE_PATH_PATTERN = new RegExp(`^\\/?${ROUTE_SEGMENT}(?:\\/${ROUTE_SEGMENT})*\\/?$`);
|
|
38
|
+
/**
|
|
39
|
+
* Whether a route path is well-formed: one or more segments, each a literal
|
|
40
|
+
* (`[A-Za-z0-9._-]+`), a `(group)`, or a `:name` / `[name]` param. A leading
|
|
41
|
+
* or trailing slash is tolerated (the CLI strips them).
|
|
42
|
+
*/
|
|
43
|
+
export const isValidRoutePath = (path) => ROUTE_PATH_PATTERN.test(path);
|
|
11
44
|
//# sourceMappingURL=navigation.js.map
|
package/dist/navigation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.js","sourceRoot":"","sources":["../src/navigation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
|
|
1
|
+
{"version":3,"file":"navigation.js","sourceRoot":"","sources":["../src/navigation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAqJH;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AAEvC;;;GAGG;AACH,MAAM,wBAAwB,GAC5B,yFAAyF,CAAC;AAE5F;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAa,EAAY,EAAE;IACzD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,KAAK,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,CAAC;QACpE,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,yEAAyE;AACzE,MAAM,aAAa,GACjB,gGAAgG,CAAC;AAEnG,MAAM,kBAAkB,GAAG,IAAI,MAAM,CACnC,QAAQ,aAAa,SAAS,aAAa,SAAS,CACrD,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAW,EAAE,CACxD,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -8,8 +8,10 @@ import { NavigationDocument } from './navigation';
|
|
|
8
8
|
* - `INITIAL_ROUTE_INVALID` — `initialRouteId` is not one of the navigator's routes.
|
|
9
9
|
* - `DUPLICATE_ROUTE_NAME` — two routes share a name within one navigator.
|
|
10
10
|
* - `PRESENTATION_NOT_STACK` — a `presentation` is set on a non-stack navigator's route.
|
|
11
|
+
* - `ROUTE_PATH_INVALID` — a route `path` has a malformed segment.
|
|
12
|
+
* - `GUARD_FALLBACK_INVALID` — a guarded route names no fallback, itself, or an absent route.
|
|
11
13
|
*/
|
|
12
|
-
export type NavigationValidationCode = 'ROOT_MISSING' | 'NAVIGATOR_TARGET_MISSING' | 'NAVIGATOR_CYCLE' | 'INITIAL_ROUTE_INVALID' | 'DUPLICATE_ROUTE_NAME' | 'PRESENTATION_NOT_STACK';
|
|
14
|
+
export type NavigationValidationCode = 'ROOT_MISSING' | 'NAVIGATOR_TARGET_MISSING' | 'NAVIGATOR_CYCLE' | 'INITIAL_ROUTE_INVALID' | 'DUPLICATE_ROUTE_NAME' | 'PRESENTATION_NOT_STACK' | 'ROUTE_PATH_INVALID' | 'GUARD_FALLBACK_INVALID';
|
|
13
15
|
/**
|
|
14
16
|
* A single validation failure produced by {@link validateNavigationDocument}.
|
|
15
17
|
*
|
|
@@ -46,7 +48,9 @@ export interface NavigationValidationResult {
|
|
|
46
48
|
* most one parent);
|
|
47
49
|
* - each navigator's `initialRouteId`, when set, names one of its routes;
|
|
48
50
|
* - route names are unique within their parent navigator;
|
|
49
|
-
* - `presentation` is only set on routes whose parent navigator is a `stack
|
|
51
|
+
* - `presentation` is only set on routes whose parent navigator is a `stack`;
|
|
52
|
+
* - a route `path`, when set, is made of literal, `(group)` or `:param` segments;
|
|
53
|
+
* - a guarded route names a fallback route that exists and is not itself.
|
|
50
54
|
*
|
|
51
55
|
* The check is exhaustive: all violations are collected rather than failing on
|
|
52
56
|
* the first.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigationValidator.d.ts","sourceRoot":"","sources":["../src/navigationValidator.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"navigationValidator.d.ts","sourceRoot":"","sources":["../src/navigationValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAEnB,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,wBAAwB,GAChC,cAAc,GACd,0BAA0B,GAC1B,iBAAiB,GACjB,uBAAuB,GACvB,sBAAsB,GACtB,wBAAwB,GACxB,oBAAoB,GACpB,wBAAwB,CAAC;AAE7B;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,uCAAuC;IACvC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IACzC,2CAA2C;IAC3C,KAAK,EAAE,OAAO,CAAC;IACf,uCAAuC;IACvC,MAAM,EAAE,yBAAyB,EAAE,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,kBAAkB,GACtB,0BAA0B,CA2B5B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isValidRoutePath, } from './navigation';
|
|
1
2
|
/**
|
|
2
3
|
* Validate the structural invariants of a {@link NavigationDocument}.
|
|
3
4
|
*
|
|
@@ -8,7 +9,9 @@
|
|
|
8
9
|
* most one parent);
|
|
9
10
|
* - each navigator's `initialRouteId`, when set, names one of its routes;
|
|
10
11
|
* - route names are unique within their parent navigator;
|
|
11
|
-
* - `presentation` is only set on routes whose parent navigator is a `stack
|
|
12
|
+
* - `presentation` is only set on routes whose parent navigator is a `stack`;
|
|
13
|
+
* - a route `path`, when set, is made of literal, `(group)` or `:param` segments;
|
|
14
|
+
* - a guarded route names a fallback route that exists and is not itself.
|
|
12
15
|
*
|
|
13
16
|
* The check is exhaustive: all violations are collected rather than failing on
|
|
14
17
|
* the first.
|
|
@@ -63,6 +66,31 @@ function validateNavigator(navigator, navigators, parentCount, errors) {
|
|
|
63
66
|
routeId: route.id,
|
|
64
67
|
});
|
|
65
68
|
}
|
|
69
|
+
// A path is the exported app's deep link and the source of the params
|
|
70
|
+
// the screen reads: a malformed one would generate a broken route file.
|
|
71
|
+
if (route.path !== undefined && !isValidRoutePath(route.path)) {
|
|
72
|
+
errors.push({
|
|
73
|
+
code: 'ROUTE_PATH_INVALID',
|
|
74
|
+
message: `Route "${route.name}" has an invalid path "${route.path}" — expected segments like "product/:id"`,
|
|
75
|
+
navigatorId: navigator.id,
|
|
76
|
+
routeId: route.id,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
// A guard with nowhere to go, or one that sends the user back to the
|
|
80
|
+
// guarded screen, loops the navigator.
|
|
81
|
+
if (route.guard !== undefined) {
|
|
82
|
+
const fallback = route.guardFallbackRouteId;
|
|
83
|
+
const exists = !!fallback &&
|
|
84
|
+
Object.values(navigators).some((candidate) => (candidate.routes ?? []).some((other) => other.id === fallback));
|
|
85
|
+
if (!fallback || fallback === route.id || !exists) {
|
|
86
|
+
errors.push({
|
|
87
|
+
code: 'GUARD_FALLBACK_INVALID',
|
|
88
|
+
message: `Guarded route "${route.name}" needs a fallback route other than itself`,
|
|
89
|
+
navigatorId: navigator.id,
|
|
90
|
+
routeId: route.id,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
66
94
|
// navigator targets must resolve, and contribute to the parent count.
|
|
67
95
|
if (route.target.kind === 'navigator') {
|
|
68
96
|
const targetId = route.target.navigatorId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigationValidator.js","sourceRoot":"","sources":["../src/navigationValidator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"navigationValidator.js","sourceRoot":"","sources":["../src/navigationValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,GAGjB,MAAM,cAAc,CAAC;AAoDtB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,0BAA0B,CACxC,GAAuB;IAEvB,MAAM,MAAM,GAAgC,EAAE,CAAC;IAC/C,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC;IAExC,gCAAgC;IAChC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC;QACrC,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,oBAAoB,GAAG,CAAC,eAAe,gCAAgC;YAChF,WAAW,EAAE,GAAG,CAAC,eAAe;SACjC,CAAC,CAAC;IACL,CAAC;IAED,0EAA0E;IAC1E,MAAM,WAAW,GAA2B,EAAE,CAAC;IAE/C,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;QAClD,iBAAiB,CAAC,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IAChE,CAAC;IAED,wEAAwE;IACxE,wEAAwE;IACxE,+BAA+B;IAC/B,oBAAoB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAC1C,YAAY,CAAC,GAAG,EAAE,UAAU,EAAE,M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