@sigx/lynx-navigation 0.2.0 → 0.4.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 +128 -8
- package/dist/components/EntryScope.d.ts +1 -1
- package/dist/components/EntryScope.d.ts.map +1 -1
- package/dist/components/Layer.d.ts +34 -0
- package/dist/components/Layer.d.ts.map +1 -0
- package/dist/components/Link.d.ts +2 -2
- package/dist/components/Link.d.ts.map +1 -1
- package/dist/components/NavigationRoot.d.ts +2 -2
- package/dist/components/NavigationRoot.d.ts.map +1 -1
- package/dist/components/Screen.d.ts +6 -6
- package/dist/components/Screen.d.ts.map +1 -1
- package/dist/components/Stack.d.ts +41 -16
- package/dist/components/Stack.d.ts.map +1 -1
- package/dist/components/TabBar.d.ts +19 -20
- package/dist/components/TabBar.d.ts.map +1 -1
- package/dist/components/Tabs.d.ts.map +1 -1
- package/dist/define-routes.d.ts +1 -1
- package/dist/define-routes.d.ts.map +1 -1
- package/dist/hooks/use-linking-nav.d.ts +3 -3
- package/dist/hooks/use-linking-nav.d.ts.map +1 -1
- package/dist/hooks/use-nav-internal.d.ts +21 -3
- package/dist/hooks/use-nav-internal.d.ts.map +1 -1
- package/dist/hooks/use-nav-serializer.d.ts +1 -1
- package/dist/hooks/use-nav-serializer.d.ts.map +1 -1
- package/dist/hooks/use-nav.d.ts +2 -2
- package/dist/hooks/use-nav.d.ts.map +1 -1
- package/dist/hooks/use-params.d.ts +1 -1
- package/dist/hooks/use-params.d.ts.map +1 -1
- package/dist/hooks/use-screen-chrome.d.ts +19 -0
- package/dist/hooks/use-screen-chrome.d.ts.map +1 -0
- package/dist/hooks/use-screen-options.d.ts +1 -1
- package/dist/hooks/use-screen-options.d.ts.map +1 -1
- package/dist/hooks/use-search.d.ts +1 -1
- package/dist/hooks/use-search.d.ts.map +1 -1
- package/dist/href.d.ts +2 -2
- package/dist/href.d.ts.map +1 -1
- package/dist/index.d.ts +33 -31
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1160 -29
- package/dist/index.js.map +1 -1
- package/dist/internal/layer-plan.d.ts +69 -0
- package/dist/internal/layer-plan.d.ts.map +1 -0
- package/dist/internal/screen-registry.d.ts +1 -1
- package/dist/internal/screen-registry.d.ts.map +1 -1
- package/dist/internal/screen-width.d.ts +9 -7
- package/dist/internal/screen-width.d.ts.map +1 -1
- package/dist/navigator/core.d.ts +5 -4
- package/dist/navigator/core.d.ts.map +1 -1
- package/dist/register.d.ts +1 -1
- package/dist/register.d.ts.map +1 -1
- package/dist/url/index.d.ts +6 -6
- package/dist/url/index.d.ts.map +1 -1
- package/dist/url/parse.d.ts +1 -1
- package/dist/url/parse.d.ts.map +1 -1
- package/dist/url/registry.d.ts +2 -2
- package/dist/url/registry.d.ts.map +1 -1
- package/dist/url/validate.d.ts +1 -1
- package/dist/url/validate.d.ts.map +1 -1
- package/package.json +11 -10
- package/src/components/Drawer.d.ts +55 -0
- package/src/components/EdgeBackHandle.d.ts +1 -0
- package/src/components/EdgeBackHandle.tsx +2 -2
- package/{dist/components/EntryScope.js → src/components/EntryScope.d.ts} +7 -15
- package/src/components/EntryScope.tsx +15 -4
- package/src/components/Header.d.ts +6 -0
- package/src/components/Header.tsx +3 -3
- package/src/components/Layer.d.ts +33 -0
- package/src/components/Layer.tsx +96 -0
- package/src/components/Link.d.ts +60 -0
- package/src/components/Link.tsx +4 -4
- package/src/components/NavigationRoot.d.ts +36 -0
- package/src/components/NavigationRoot.tsx +6 -6
- package/src/components/Screen.d.ts +97 -0
- package/src/components/Screen.tsx +13 -11
- package/src/components/Stack.d.ts +90 -0
- package/src/components/Stack.tsx +142 -98
- package/src/components/TabBar.d.ts +38 -0
- package/src/components/TabBar.tsx +22 -22
- package/src/components/Tabs.d.ts +109 -0
- package/src/components/Tabs.tsx +15 -1
- package/{dist/define-routes.js → src/define-routes.d.ts} +2 -4
- package/src/define-routes.ts +1 -1
- package/src/hooks/use-focus.d.ts +45 -0
- package/src/hooks/use-focus.ts +2 -2
- package/src/hooks/use-hardware-back.d.ts +37 -0
- package/src/hooks/use-hardware-back.ts +1 -1
- package/src/hooks/use-linking-nav.d.ts +91 -0
- package/src/hooks/use-linking-nav.ts +4 -4
- package/src/hooks/use-nav-internal.d.ts +91 -0
- package/src/hooks/use-nav-internal.ts +24 -3
- package/src/hooks/use-nav-serializer.d.ts +82 -0
- package/src/hooks/use-nav-serializer.ts +3 -3
- package/src/hooks/use-nav.d.ts +111 -0
- package/src/hooks/use-nav.ts +2 -2
- package/{dist/hooks/use-params.js → src/hooks/use-params.d.ts} +2 -6
- package/src/hooks/use-params.ts +2 -2
- package/src/hooks/use-screen-chrome.d.ts +18 -0
- package/src/hooks/use-screen-chrome.ts +122 -0
- package/src/hooks/use-screen-options.d.ts +2 -0
- package/src/hooks/use-screen-options.ts +3 -3
- package/{dist/hooks/use-search.js → src/hooks/use-search.d.ts} +2 -6
- package/src/hooks/use-search.ts +2 -2
- package/src/href.d.ts +54 -0
- package/src/href.ts +6 -6
- package/src/index.d.ts +39 -0
- package/src/index.ts +33 -31
- package/src/internal/layer-plan.d.ts +68 -0
- package/src/internal/layer-plan.ts +187 -0
- package/{dist/internal/screen-registry.js → src/internal/screen-registry.d.ts} +21 -32
- package/src/internal/screen-registry.ts +1 -1
- package/src/internal/screen-width.d.ts +17 -0
- package/src/internal/screen-width.ts +22 -14
- package/src/navigator/core.d.ts +96 -0
- package/src/navigator/core.ts +17 -6
- package/src/register.d.ts +37 -0
- package/src/register.ts +1 -1
- package/src/types.d.ts +217 -0
- package/src/url/build.d.ts +15 -0
- package/src/url/build.ts +2 -2
- package/src/url/compile.d.ts +34 -0
- package/src/url/format.d.ts +28 -0
- package/src/url/index.ts +6 -6
- package/src/url/parse.d.ts +20 -0
- package/src/url/parse.ts +6 -6
- package/{dist/url/registry.js → src/url/registry.d.ts} +12 -28
- package/src/url/registry.ts +3 -3
- package/src/url/validate.d.ts +23 -0
- package/src/url/validate.ts +1 -1
- package/dist/components/Drawer.js +0 -74
- package/dist/components/Drawer.js.map +0 -1
- package/dist/components/EdgeBackHandle.js +0 -144
- package/dist/components/EdgeBackHandle.js.map +0 -1
- package/dist/components/EntryScope.js.map +0 -1
- package/dist/components/Header.js +0 -103
- package/dist/components/Header.js.map +0 -1
- package/dist/components/Link.js +0 -51
- package/dist/components/Link.js.map +0 -1
- package/dist/components/NavigationRoot.js +0 -67
- package/dist/components/NavigationRoot.js.map +0 -1
- package/dist/components/Screen.js +0 -94
- package/dist/components/Screen.js.map +0 -1
- package/dist/components/ScreenContainer.d.ts +0 -18
- package/dist/components/ScreenContainer.d.ts.map +0 -1
- package/dist/components/ScreenContainer.js +0 -77
- package/dist/components/ScreenContainer.js.map +0 -1
- package/dist/components/Stack.js +0 -221
- package/dist/components/Stack.js.map +0 -1
- package/dist/components/TabBar.js +0 -63
- package/dist/components/TabBar.js.map +0 -1
- package/dist/components/Tabs.js +0 -154
- package/dist/components/Tabs.js.map +0 -1
- package/dist/define-routes.js.map +0 -1
- package/dist/hooks/use-focus.js +0 -87
- package/dist/hooks/use-focus.js.map +0 -1
- package/dist/hooks/use-hardware-back.js +0 -84
- package/dist/hooks/use-hardware-back.js.map +0 -1
- package/dist/hooks/use-linking-nav.js +0 -109
- package/dist/hooks/use-linking-nav.js.map +0 -1
- package/dist/hooks/use-nav-internal.js +0 -44
- package/dist/hooks/use-nav-internal.js.map +0 -1
- package/dist/hooks/use-nav-serializer.js +0 -181
- package/dist/hooks/use-nav-serializer.js.map +0 -1
- package/dist/hooks/use-nav.js +0 -11
- package/dist/hooks/use-nav.js.map +0 -1
- package/dist/hooks/use-params.js.map +0 -1
- package/dist/hooks/use-screen-options.js +0 -43
- package/dist/hooks/use-screen-options.js.map +0 -1
- package/dist/hooks/use-search.js.map +0 -1
- package/dist/href.js +0 -57
- package/dist/href.js.map +0 -1
- package/dist/internal/screen-registry.js.map +0 -1
- package/dist/internal/screen-width.js +0 -30
- package/dist/internal/screen-width.js.map +0 -1
- package/dist/navigator/core.js +0 -383
- package/dist/navigator/core.js.map +0 -1
- package/dist/register.js +0 -2
- package/dist/register.js.map +0 -1
- package/dist/types.js +0 -9
- package/dist/types.js.map +0 -1
- package/dist/url/build.js +0 -30
- package/dist/url/build.js.map +0 -1
- package/dist/url/compile.js +0 -83
- package/dist/url/compile.js.map +0 -1
- package/dist/url/format.js +0 -102
- package/dist/url/format.js.map +0 -1
- package/dist/url/index.js +0 -13
- package/dist/url/index.js.map +0 -1
- package/dist/url/parse.js +0 -94
- package/dist/url/parse.js.map +0 -1
- package/dist/url/registry.js.map +0 -1
- package/dist/url/validate.js +0 -37
- package/dist/url/validate.js.map +0 -1
- package/src/components/ScreenContainer.tsx +0 -114
package/dist/url/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* URL bridge — internal barrel.
|
|
3
|
-
*
|
|
4
|
-
* Not re-exported from the package root. Public surface is `hrefFor` /
|
|
5
|
-
* `parseHref` in ../href.ts plus `_setRouteRegistry` for tests/bootstrap.
|
|
6
|
-
*/
|
|
7
|
-
export { compilePath } from './compile.js';
|
|
8
|
-
export { buildUrl } from './build.js';
|
|
9
|
-
export { parseHrefImpl } from './parse.js';
|
|
10
|
-
export { formatSearch, parseSearch } from './format.js';
|
|
11
|
-
export { _setRouteRegistry, _clearRouteRegistry, getRouteRegistry, getCompiledPath, } from './registry.js';
|
|
12
|
-
export { validateSync } from './validate.js';
|
|
13
|
-
//# sourceMappingURL=index.js.map
|
package/dist/url/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/url/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAqB,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EACH,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAwB,MAAM,eAAe,CAAC"}
|
package/dist/url/parse.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* URL → typed Href parser.
|
|
3
|
-
*
|
|
4
|
-
* Walks every registered route with a `path`, tries to match its compiled
|
|
5
|
-
* regex against the URL's pathname, and on a hit validates the extracted
|
|
6
|
-
* params + search through the route's Standard Schema. First match wins;
|
|
7
|
-
* iteration order follows `Object.keys` of the registered routes map.
|
|
8
|
-
*
|
|
9
|
-
* Validation failures return `null` rather than throwing — deep-link handlers
|
|
10
|
-
* fall back to the initial route on a bad URL instead of crashing the app.
|
|
11
|
-
*/
|
|
12
|
-
import { parse as parseUrl } from '@sigx/lynx-linking';
|
|
13
|
-
import { parseSearch } from './format.js';
|
|
14
|
-
import { getCompiledPath, getRouteRegistry } from './registry.js';
|
|
15
|
-
import { validateSync } from './validate.js';
|
|
16
|
-
/**
|
|
17
|
-
* Parse a URL string against the active route registry.
|
|
18
|
-
*
|
|
19
|
-
* Accepts both absolute URLs (`myapp://host/users/42?tab=about`) and
|
|
20
|
-
* pathname-only forms (`/users/42?tab=about`). Returns `null` if no route's
|
|
21
|
-
* `path` matches the URL or if schema validation rejects the extracted bits.
|
|
22
|
-
*/
|
|
23
|
-
export function parseHrefImpl(url) {
|
|
24
|
-
if (typeof url !== 'string' || url.length === 0)
|
|
25
|
-
return null;
|
|
26
|
-
// Use lynx-linking's parser for the scheme/host split — but accept paths
|
|
27
|
-
// that don't have a scheme too (raw `/users/42` is the common case from
|
|
28
|
-
// in-app routing).
|
|
29
|
-
const { pathname, query } = splitPathAndQuery(url);
|
|
30
|
-
if (!pathname)
|
|
31
|
-
return null;
|
|
32
|
-
const registry = getRouteRegistry();
|
|
33
|
-
const rawSearch = parseSearch(query);
|
|
34
|
-
for (const name of Object.keys(registry.routes)) {
|
|
35
|
-
const compiled = getCompiledPath(registry, name);
|
|
36
|
-
if (!compiled)
|
|
37
|
-
continue;
|
|
38
|
-
const match = compiled.regex.exec(pathname);
|
|
39
|
-
if (!match)
|
|
40
|
-
continue;
|
|
41
|
-
const rawParams = extractParams(compiled, match);
|
|
42
|
-
const def = registry.routes[name];
|
|
43
|
-
const paramsOutcome = validateSync(def.params, rawParams);
|
|
44
|
-
if (!paramsOutcome.ok)
|
|
45
|
-
continue;
|
|
46
|
-
const searchOutcome = validateSync(def.search, rawSearch);
|
|
47
|
-
if (!searchOutcome.ok)
|
|
48
|
-
continue;
|
|
49
|
-
return {
|
|
50
|
-
route: name,
|
|
51
|
-
params: paramsOutcome.value,
|
|
52
|
-
search: searchOutcome.value,
|
|
53
|
-
url,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
function extractParams(compiled, match) {
|
|
59
|
-
const out = {};
|
|
60
|
-
for (let i = 0; i < compiled.paramNames.length; i++) {
|
|
61
|
-
const raw = match[i + 1];
|
|
62
|
-
try {
|
|
63
|
-
out[compiled.paramNames[i]] = decodeURIComponent(raw);
|
|
64
|
-
}
|
|
65
|
-
catch {
|
|
66
|
-
out[compiled.paramNames[i]] = raw;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return out;
|
|
70
|
-
}
|
|
71
|
-
function splitPathAndQuery(url) {
|
|
72
|
-
// Drop the fragment before any path/query work — `#…` is a client-side
|
|
73
|
-
// anchor that must not leak into the route pathname or query values.
|
|
74
|
-
const hashIdx = url.indexOf('#');
|
|
75
|
-
const noHash = hashIdx >= 0 ? url.slice(0, hashIdx) : url;
|
|
76
|
-
// If the URL has a scheme, defer to lynx-linking's parser — handles
|
|
77
|
-
// `myapp://host/path?q` correctly. Otherwise treat the whole thing as
|
|
78
|
-
// pathname+query.
|
|
79
|
-
const hasScheme = /^[a-zA-Z][a-zA-Z0-9+.\-]*:/.test(noHash);
|
|
80
|
-
if (hasScheme) {
|
|
81
|
-
const parsed = parseUrl(noHash);
|
|
82
|
-
// Reconstruct the query string from the already-parsed bag. We have
|
|
83
|
-
// to do this because parseUrl decoded keys/values, but parseSearch
|
|
84
|
-
// expects encoded form. Simpler: split the original ourselves.
|
|
85
|
-
const qIdx = noHash.indexOf('?');
|
|
86
|
-
const query = qIdx >= 0 ? noHash.slice(qIdx + 1) : '';
|
|
87
|
-
return { pathname: parsed.path, query };
|
|
88
|
-
}
|
|
89
|
-
const qIdx = noHash.indexOf('?');
|
|
90
|
-
if (qIdx === -1)
|
|
91
|
-
return { pathname: noHash, query: '' };
|
|
92
|
-
return { pathname: noHash.slice(0, qIdx), query: noHash.slice(qIdx + 1) };
|
|
93
|
-
}
|
|
94
|
-
//# sourceMappingURL=parse.js.map
|
package/dist/url/parse.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/url/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACrC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAE7D,yEAAyE;IACzE,wEAAwE;IACxE,mBAAmB;IACnB,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACnD,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;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AAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACjC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC"}
|
package/dist/url/validate.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Standard Schema validation helper (sync only).
|
|
3
|
-
*
|
|
4
|
-
* `hrefFor` and `parseHref` run on hot paths (link rendering, deep-link
|
|
5
|
-
* resolution) so we restrict to sync validators. Zod/Valibot/ArkType are all
|
|
6
|
-
* sync, which covers the common case. Async validators throw a clear error.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Run a Standard Schema's `validate` synchronously. When the schema lacks a
|
|
10
|
-
* `validate` function (e.g. our test `fakeSchema`), passthrough — assume the
|
|
11
|
-
* input is already in the correct shape. This is a deliberate ergonomic
|
|
12
|
-
* choice so the type-spike fixtures stay terse.
|
|
13
|
-
*/
|
|
14
|
-
export function validateSync(schema, input) {
|
|
15
|
-
if (!schema)
|
|
16
|
-
return { ok: true, value: input };
|
|
17
|
-
const validate = schema['~standard']?.validate;
|
|
18
|
-
if (!validate)
|
|
19
|
-
return { ok: true, value: input };
|
|
20
|
-
const result = validate(input);
|
|
21
|
-
if (isPromiseLike(result)) {
|
|
22
|
-
throw new Error('[lynx-navigation] Async schema validation is not supported on the URL bridge — use a sync validator (Zod/Valibot/ArkType are all sync).');
|
|
23
|
-
}
|
|
24
|
-
if (result.issues !== undefined && result.issues.length > 0) {
|
|
25
|
-
return {
|
|
26
|
-
ok: false,
|
|
27
|
-
issues: result.issues.map((i) => i.message),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
return { ok: true, value: result.value };
|
|
31
|
-
}
|
|
32
|
-
function isPromiseLike(v) {
|
|
33
|
-
return (v !== null
|
|
34
|
-
&& typeof v === 'object'
|
|
35
|
-
&& typeof v.then === 'function');
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=validate.js.map
|
package/dist/url/validate.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/url/validate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA0BH;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CACxB,MAAoC,EACpC,KAAc;IAEd,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC/C,MAAM,QAAQ,GAAI,MAAgC,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC;IAC1E,IAAI,CAAC,QAAQ;QAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IACjD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC/B,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACX,yIAAyI,CAC5I,CAAC;IACN,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1D,OAAO;YACH,EAAE,EAAE,KAAK;YACT,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;SAC9C,CAAC;IACN,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAG,MAA6B,CAAC,KAAK,EAAE,CAAC;AACrE,CAAC;AAED,SAAS,aAAa,CAAI,CAAU;IAChC,OAAO,CACH,CAAC,KAAK,IAAI;WACP,OAAO,CAAC,KAAK,QAAQ;WACrB,OAAQ,CAAwB,CAAC,IAAI,KAAK,UAAU,CAC1D,CAAC;AACN,CAAC"}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
component,
|
|
3
|
-
useMainThreadRef,
|
|
4
|
-
useAnimatedStyle,
|
|
5
|
-
type ComponentFactory,
|
|
6
|
-
type Define,
|
|
7
|
-
type MainThread,
|
|
8
|
-
type SharedValue,
|
|
9
|
-
} from '@sigx/lynx';
|
|
10
|
-
import { Suspense, isLazyComponent } from '@sigx/lynx';
|
|
11
|
-
import type { MapperParams } from '@sigx/lynx';
|
|
12
|
-
import { SCREEN_WIDTH } from '../internal/screen-width.js';
|
|
13
|
-
import type { RouteMap, StackEntry, TransitionKind, TransitionRole } from '../types.js';
|
|
14
|
-
import { EntryScope } from './EntryScope.js';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Slide-from-right transition geometry. `SCREEN_WIDTH` is read from
|
|
18
|
-
* `lynx.SystemInfo` at module load so the animation lands the screen at
|
|
19
|
-
* exactly translateX=0 (centered) at progress=1, rather than overshooting
|
|
20
|
-
* into the parent's clip region. `<EdgeBackHandle>` reads the same
|
|
21
|
-
* constant — they have to agree, otherwise the gesture commit threshold
|
|
22
|
-
* and the animation geometry don't line up.
|
|
23
|
-
*/
|
|
24
|
-
const PARALLAX_FACTOR = 0.3;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Compute the `translateX` range for a given (role, kind) pair. Progress
|
|
28
|
-
* always runs 0 → 1; the role and kind decide what visual state each end of
|
|
29
|
-
* the progress represents.
|
|
30
|
-
*
|
|
31
|
-
* Slide-from-right semantics:
|
|
32
|
-
* - PUSH: new top slides in from the right; old top parallaxes left.
|
|
33
|
-
* - POP: current top slides out to the right; underneath returns from the
|
|
34
|
-
* parallax-left position.
|
|
35
|
-
*/
|
|
36
|
-
function getRangeParams(
|
|
37
|
-
role: TransitionRole,
|
|
38
|
-
kind: TransitionKind,
|
|
39
|
-
): MapperParams['translateX'] {
|
|
40
|
-
if (kind === 'push') {
|
|
41
|
-
if (role === 'top') {
|
|
42
|
-
return { inputRange: [0, 1], outputRange: [SCREEN_WIDTH, 0] };
|
|
43
|
-
}
|
|
44
|
-
return { inputRange: [0, 1], outputRange: [0, -PARALLAX_FACTOR * SCREEN_WIDTH] };
|
|
45
|
-
}
|
|
46
|
-
// pop
|
|
47
|
-
if (role === 'top') {
|
|
48
|
-
return { inputRange: [0, 1], outputRange: [0, SCREEN_WIDTH] };
|
|
49
|
-
}
|
|
50
|
-
return { inputRange: [0, 1], outputRange: [-PARALLAX_FACTOR * SCREEN_WIDTH, 0] };
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
type ScreenContainerProps =
|
|
54
|
-
& Define.Prop<'entry', StackEntry, true>
|
|
55
|
-
& Define.Prop<'routes', RouteMap, true>
|
|
56
|
-
& Define.Prop<'role', TransitionRole, true>
|
|
57
|
-
& Define.Prop<'kind', TransitionKind, true>
|
|
58
|
-
& Define.Prop<'progress', SharedValue<number>, true>;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Animated screen slot — absolutely positioned, MT-bound translateX driven by
|
|
62
|
-
* the navigator's progress SharedValue. Used during transitions to render the
|
|
63
|
-
* top + underneath entries together.
|
|
64
|
-
*
|
|
65
|
-
* Each instance is keyed by `${entry.key}-${role}-${kind}` in the parent so a
|
|
66
|
-
* role/kind change forces a fresh mount with a fresh `useAnimatedStyle`
|
|
67
|
-
* binding (the binding is set at setup and can't be re-keyed mid-life). State
|
|
68
|
-
* loss across transition boundaries is accepted in v0.2; persistent screen
|
|
69
|
-
* state (scroll position, input fields surviving navigations) is a polish
|
|
70
|
-
* item for Phase 0.5+.
|
|
71
|
-
*/
|
|
72
|
-
export const ScreenContainer = component<ScreenContainerProps>(({ props }) => {
|
|
73
|
-
const ref = useMainThreadRef<MainThread.Element | null>(null);
|
|
74
|
-
const params = getRangeParams(props.role, props.kind);
|
|
75
|
-
useAnimatedStyle(ref, props.progress, 'translateX', params);
|
|
76
|
-
|
|
77
|
-
return () => {
|
|
78
|
-
const route = props.routes[props.entry.route];
|
|
79
|
-
if (!route) return null;
|
|
80
|
-
const Comp = route.component as unknown as ComponentFactory<
|
|
81
|
-
Record<string, unknown>,
|
|
82
|
-
unknown,
|
|
83
|
-
unknown
|
|
84
|
-
>;
|
|
85
|
-
if (typeof Comp !== 'function') return null;
|
|
86
|
-
const entryParams = props.entry.params as Record<string, unknown>;
|
|
87
|
-
// Wrap lazy screens that declare a fallback in Suspense — see Stack.tsx
|
|
88
|
-
// for rationale.
|
|
89
|
-
const body = isLazyComponent(Comp) && route.fallback
|
|
90
|
-
? (
|
|
91
|
-
<Suspense fallback={route.fallback as never}>
|
|
92
|
-
<Comp {...entryParams} />
|
|
93
|
-
</Suspense>
|
|
94
|
-
)
|
|
95
|
-
: <Comp {...entryParams} />;
|
|
96
|
-
return (
|
|
97
|
-
<view
|
|
98
|
-
main-thread:ref={ref}
|
|
99
|
-
style={{
|
|
100
|
-
position: 'absolute',
|
|
101
|
-
top: '0',
|
|
102
|
-
left: '0',
|
|
103
|
-
right: '0',
|
|
104
|
-
bottom: '0',
|
|
105
|
-
backgroundColor: '#0f172a',
|
|
106
|
-
}}
|
|
107
|
-
>
|
|
108
|
-
<EntryScope key={props.entry.key} entry={props.entry}>
|
|
109
|
-
{body}
|
|
110
|
-
</EntryScope>
|
|
111
|
-
</view>
|
|
112
|
-
);
|
|
113
|
-
};
|
|
114
|
-
});
|