@oxyhq/bloom 0.6.20 → 0.6.22
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/lib/commonjs/scroll/index.js +39 -0
- package/lib/commonjs/scroll/index.js.map +1 -0
- package/lib/commonjs/scroll/index.web.js +143 -0
- package/lib/commonjs/scroll/index.web.js.map +1 -0
- package/lib/commonjs/scroll/scrollable.web.js +64 -0
- package/lib/commonjs/scroll/scrollable.web.js.map +1 -0
- package/lib/commonjs/scroll/store.js +90 -0
- package/lib/commonjs/scroll/store.js.map +1 -0
- package/lib/commonjs/scroll/types.js +6 -0
- package/lib/commonjs/scroll/types.js.map +1 -0
- package/lib/commonjs/theme/color-scope/index.web.js +18 -5
- package/lib/commonjs/theme/color-scope/index.web.js.map +1 -1
- package/lib/module/scroll/index.js +34 -0
- package/lib/module/scroll/index.js.map +1 -0
- package/lib/module/scroll/index.web.js +137 -0
- package/lib/module/scroll/index.web.js.map +1 -0
- package/lib/module/scroll/scrollable.web.js +60 -0
- package/lib/module/scroll/scrollable.web.js.map +1 -0
- package/lib/module/scroll/store.js +84 -0
- package/lib/module/scroll/store.js.map +1 -0
- package/lib/module/scroll/types.js +4 -0
- package/lib/module/scroll/types.js.map +1 -0
- package/lib/module/theme/color-scope/index.web.js +18 -5
- package/lib/module/theme/color-scope/index.web.js.map +1 -1
- package/lib/typescript/commonjs/scroll/index.d.ts +27 -0
- package/lib/typescript/commonjs/scroll/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/scroll/index.web.d.ts +22 -0
- package/lib/typescript/commonjs/scroll/index.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/scroll/scrollable.web.d.ts +17 -0
- package/lib/typescript/commonjs/scroll/scrollable.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/scroll/store.d.ts +46 -0
- package/lib/typescript/commonjs/scroll/store.d.ts.map +1 -0
- package/lib/typescript/commonjs/scroll/types.d.ts +46 -0
- package/lib/typescript/commonjs/scroll/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/color-scope/index.web.d.ts.map +1 -1
- package/lib/typescript/module/scroll/index.d.ts +27 -0
- package/lib/typescript/module/scroll/index.d.ts.map +1 -0
- package/lib/typescript/module/scroll/index.web.d.ts +22 -0
- package/lib/typescript/module/scroll/index.web.d.ts.map +1 -0
- package/lib/typescript/module/scroll/scrollable.web.d.ts +17 -0
- package/lib/typescript/module/scroll/scrollable.web.d.ts.map +1 -0
- package/lib/typescript/module/scroll/store.d.ts +46 -0
- package/lib/typescript/module/scroll/store.d.ts.map +1 -0
- package/lib/typescript/module/scroll/types.d.ts +46 -0
- package/lib/typescript/module/scroll/types.d.ts.map +1 -0
- package/lib/typescript/module/theme/color-scope/index.web.d.ts.map +1 -1
- package/package.json +22 -1
- package/src/__tests__/BloomColorScope.test.tsx +67 -0
- package/src/__tests__/scroll-native.test.ts +25 -0
- package/src/__tests__/scroll-store.test.ts +85 -0
- package/src/scroll/index.ts +47 -0
- package/src/scroll/index.web.tsx +167 -0
- package/src/scroll/scrollable.web.ts +75 -0
- package/src/scroll/store.ts +84 -0
- package/src/scroll/types.ts +48 -0
- package/src/theme/color-scope/index.web.tsx +26 -2
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A normalized read/write interface over whatever the caller registered, so
|
|
5
|
+
* the hook does not branch on target shape. Both methods are no-ops when the
|
|
6
|
+
* underlying element is not yet (or no longer) attached.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
function isElement(value) {
|
|
10
|
+
return typeof HTMLElement !== 'undefined' && value instanceof HTMLElement;
|
|
11
|
+
}
|
|
12
|
+
function hasGetScrollableNode(value) {
|
|
13
|
+
return typeof value === 'object' && value !== null && typeof value.getScrollableNode === 'function';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the live DOM element a target currently points at, or `null`.
|
|
18
|
+
*
|
|
19
|
+
* RNW scroll components expose `getScrollableNode()`; plain refs may hold the
|
|
20
|
+
* DOM node directly. We never cache the node because RNW can swap it across
|
|
21
|
+
* renders — we re-resolve on every read/write.
|
|
22
|
+
*/
|
|
23
|
+
function resolveElement(target) {
|
|
24
|
+
if (target === 'window') return null;
|
|
25
|
+
const current = target.current;
|
|
26
|
+
if (current == null) return null;
|
|
27
|
+
if (isElement(current)) return current;
|
|
28
|
+
if (hasGetScrollableNode(current)) {
|
|
29
|
+
const node = current.getScrollableNode();
|
|
30
|
+
if (isElement(node)) return node;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Build a {@link ResolvedScroller} for a target. The window sentinel reads and
|
|
37
|
+
* writes the document scroller; everything else operates on the resolved
|
|
38
|
+
* element's `scrollTop`.
|
|
39
|
+
*/
|
|
40
|
+
export function createScroller(target) {
|
|
41
|
+
if (target === 'window') {
|
|
42
|
+
return {
|
|
43
|
+
getOffset: () => typeof window === 'undefined' ? 0 : window.scrollY,
|
|
44
|
+
setOffset: offset => {
|
|
45
|
+
if (typeof window !== 'undefined') window.scrollTo(0, offset);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
getOffset: () => {
|
|
51
|
+
const element = resolveElement(target);
|
|
52
|
+
return element ? element.scrollTop : 0;
|
|
53
|
+
},
|
|
54
|
+
setOffset: offset => {
|
|
55
|
+
const element = resolveElement(target);
|
|
56
|
+
if (element) element.scrollTop = offset;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=scrollable.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isElement","value","HTMLElement","hasGetScrollableNode","getScrollableNode","resolveElement","target","current","node","createScroller","getOffset","window","scrollY","setOffset","offset","scrollTo","element","scrollTop"],"sourceRoot":"../../../src","sources":["scroll/scrollable.web.ts"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;;AAMA,SAASA,SAASA,CAACC,KAAc,EAAwB;EACvD,OAAO,OAAOC,WAAW,KAAK,WAAW,IAAID,KAAK,YAAYC,WAAW;AAC3E;AAEA,SAASC,oBAAoBA,CAC3BF,KAAc,EACkD;EAChE,OACE,OAAOA,KAAK,KAAK,QAAQ,IACzBA,KAAK,KAAK,IAAI,IACd,OAAQA,KAAK,CAAsBG,iBAAiB,KAAK,UAAU;AAEvE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,cAAcA,CAACC,MAA+B,EAAsB;EAC3E,IAAIA,MAAM,KAAK,QAAQ,EAAE,OAAO,IAAI;EAEpC,MAAMC,OAAO,GAAID,MAAM,CAA0BC,OAAO;EACxD,IAAIA,OAAO,IAAI,IAAI,EAAE,OAAO,IAAI;EAEhC,IAAIP,SAAS,CAACO,OAAO,CAAC,EAAE,OAAOA,OAAO;EAEtC,IAAIJ,oBAAoB,CAACI,OAAO,CAAC,EAAE;IACjC,MAAMC,IAAI,GAAGD,OAAO,CAACH,iBAAiB,CAAC,CAAC;IACxC,IAAIJ,SAAS,CAACQ,IAAI,CAAC,EAAE,OAAOA,IAAI;EAClC;EAEA,OAAO,IAAI;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACH,MAA+B,EAAoB;EAChF,IAAIA,MAAM,KAAK,QAAQ,EAAE;IACvB,OAAO;MACLI,SAAS,EAAEA,CAAA,KAAO,OAAOC,MAAM,KAAK,WAAW,GAAG,CAAC,GAAGA,MAAM,CAACC,OAAQ;MACrEC,SAAS,EAAGC,MAAM,IAAK;QACrB,IAAI,OAAOH,MAAM,KAAK,WAAW,EAAEA,MAAM,CAACI,QAAQ,CAAC,CAAC,EAAED,MAAM,CAAC;MAC/D;IACF,CAAC;EACH;EAEA,OAAO;IACLJ,SAAS,EAAEA,CAAA,KAAM;MACf,MAAMM,OAAO,GAAGX,cAAc,CAACC,MAAM,CAAC;MACtC,OAAOU,OAAO,GAAGA,OAAO,CAACC,SAAS,GAAG,CAAC;IACxC,CAAC;IACDJ,SAAS,EAAGC,MAAM,IAAK;MACrB,MAAME,OAAO,GAAGX,cAAc,CAACC,MAAM,CAAC;MACtC,IAAIU,OAAO,EAAEA,OAAO,CAACC,SAAS,GAAGH,MAAM;IACzC;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pure, platform-agnostic core of the scroll-restoration primitive.
|
|
5
|
+
*
|
|
6
|
+
* This file deliberately contains NO React and NO DOM/native imports so the
|
|
7
|
+
* logic can be unit-tested in isolation and shared verbatim by the web and
|
|
8
|
+
* native barrels. The web barrel drives it with real scroll offsets; the
|
|
9
|
+
* native barrel never instantiates it (native-stack already restores scroll).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Separator between the navigation route key and an optional caller-supplied
|
|
14
|
+
* sub-key. A route may host more than one independently-scrolling list (e.g.
|
|
15
|
+
* a tabbed profile screen), so each list contributes its own sub-key.
|
|
16
|
+
*
|
|
17
|
+
* `\0` (NUL) can never appear in a React Navigation route key or in a
|
|
18
|
+
* developer-authored sub-key, so it is collision-free as a delimiter. It is
|
|
19
|
+
* written as an escape sequence (not a literal byte) so the source stays
|
|
20
|
+
* text-diffable.
|
|
21
|
+
*/
|
|
22
|
+
const COMPOSITE_KEY_SEPARATOR = '\0';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Derive the storage key for a scrollable from its owning route key and an
|
|
26
|
+
* optional caller sub-key.
|
|
27
|
+
*
|
|
28
|
+
* - `routeKey` is React Navigation's stable per-route `route.key`.
|
|
29
|
+
* - `subKey` distinguishes multiple scrollables that share a single route.
|
|
30
|
+
*
|
|
31
|
+
* Returns `null` when there is no route key to anchor against (the scrollable
|
|
32
|
+
* is not inside a navigator), which the caller treats as "do not persist".
|
|
33
|
+
*/
|
|
34
|
+
export function deriveScrollKey(routeKey, subKey) {
|
|
35
|
+
if (!routeKey) return null;
|
|
36
|
+
if (subKey === undefined || subKey === '') return routeKey;
|
|
37
|
+
return `${routeKey}${COMPOSITE_KEY_SEPARATOR}${subKey}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* In-memory map of `scrollKey -> last-known scroll offset`.
|
|
42
|
+
*
|
|
43
|
+
* Mirrors the semantics of Bluesky's `Map<screenKey, scrollY>`: offsets live
|
|
44
|
+
* only for the lifetime of the document/session. We never persist them — a
|
|
45
|
+
* full reload should start at the top — and we never auto-evict, because a
|
|
46
|
+
* route can be revisited via browser Forward/Back long after it blurred.
|
|
47
|
+
*/
|
|
48
|
+
export class ScrollOffsetStore {
|
|
49
|
+
offsets = new Map();
|
|
50
|
+
|
|
51
|
+
/** Persist the offset for a key. A negative offset is clamped to 0. */
|
|
52
|
+
save(key, offset) {
|
|
53
|
+
this.offsets.set(key, offset > 0 ? offset : 0);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Read the saved offset for a key. Returns `0` when nothing was saved, so
|
|
58
|
+
* callers can restore unconditionally (an unseen list restores to the top).
|
|
59
|
+
*/
|
|
60
|
+
read(key) {
|
|
61
|
+
return this.offsets.get(key) ?? 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Whether an offset was ever saved for this key. */
|
|
65
|
+
has(key) {
|
|
66
|
+
return this.offsets.has(key);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Drop a saved offset (e.g. when a route is permanently removed). */
|
|
70
|
+
forget(key) {
|
|
71
|
+
this.offsets.delete(key);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Clear every saved offset. Primarily for tests and full resets. */
|
|
75
|
+
clear() {
|
|
76
|
+
this.offsets.clear();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Number of distinct keys currently tracked. */
|
|
80
|
+
get size() {
|
|
81
|
+
return this.offsets.size;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["COMPOSITE_KEY_SEPARATOR","deriveScrollKey","routeKey","subKey","undefined","ScrollOffsetStore","offsets","Map","save","key","offset","set","read","get","has","forget","delete","clear","size"],"sourceRoot":"../../../src","sources":["scroll/store.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,uBAAuB,GAAG,IAAI;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,QAA4B,EAC5BC,MAAe,EACA;EACf,IAAI,CAACD,QAAQ,EAAE,OAAO,IAAI;EAC1B,IAAIC,MAAM,KAAKC,SAAS,IAAID,MAAM,KAAK,EAAE,EAAE,OAAOD,QAAQ;EAC1D,OAAO,GAAGA,QAAQ,GAAGF,uBAAuB,GAAGG,MAAM,EAAE;AACzD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,iBAAiB,CAAC;EACZC,OAAO,GAAG,IAAIC,GAAG,CAAiB,CAAC;;EAEpD;EACAC,IAAIA,CAACC,GAAW,EAAEC,MAAc,EAAQ;IACtC,IAAI,CAACJ,OAAO,CAACK,GAAG,CAACF,GAAG,EAAEC,MAAM,GAAG,CAAC,GAAGA,MAAM,GAAG,CAAC,CAAC;EAChD;;EAEA;AACF;AACA;AACA;EACEE,IAAIA,CAACH,GAAW,EAAU;IACxB,OAAO,IAAI,CAACH,OAAO,CAACO,GAAG,CAACJ,GAAG,CAAC,IAAI,CAAC;EACnC;;EAEA;EACAK,GAAGA,CAACL,GAAW,EAAW;IACxB,OAAO,IAAI,CAACH,OAAO,CAACQ,GAAG,CAACL,GAAG,CAAC;EAC9B;;EAEA;EACAM,MAAMA,CAACN,GAAW,EAAQ;IACxB,IAAI,CAACH,OAAO,CAACU,MAAM,CAACP,GAAG,CAAC;EAC1B;;EAEA;EACAQ,KAAKA,CAAA,EAAS;IACZ,IAAI,CAACX,OAAO,CAACW,KAAK,CAAC,CAAC;EACtB;;EAEA;EACA,IAAIC,IAAIA,CAAA,EAAW;IACjB,OAAO,IAAI,CAACZ,OAAO,CAACY,IAAI;EAC1B;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["scroll/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -4,6 +4,16 @@ import React, { Children, cloneElement, isValidElement, useContext, useMemo } fr
|
|
|
4
4
|
import { BloomThemeContext } from "../BloomThemeProvider.js";
|
|
5
5
|
import { buildTheme } from "../build-theme.js";
|
|
6
6
|
import { buildScopeVars } from "./style-builder.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* On web, the single `asChild` child is frequently a react-native-web
|
|
10
|
+
* component (e.g. RN `<View>`) whose `style` prop is a *style array* (or a
|
|
11
|
+
* numeric registered-style id), not a plain `React.CSSProperties` object.
|
|
12
|
+
* react-native-web flattens nested style arrays, so the cloned child must
|
|
13
|
+
* receive an array — spreading an array into an object literal would copy its
|
|
14
|
+
* numeric indices as keys and crash RNW when it commits them to the DOM
|
|
15
|
+
* (`Failed to set an indexed property [0] on 'CSSStyleDeclaration'`).
|
|
16
|
+
*/
|
|
7
17
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
8
18
|
export function BloomColorScope({
|
|
9
19
|
colorPreset,
|
|
@@ -34,16 +44,19 @@ export function BloomColorScope({
|
|
|
34
44
|
if (! /*#__PURE__*/isValidElement(child)) {
|
|
35
45
|
throw new Error('BloomColorScope with `asChild` requires a single React element child that accepts a `style` prop.');
|
|
36
46
|
}
|
|
47
|
+
// Merge as a style ARRAY (the RNW-safe form): scope vars first, then the
|
|
48
|
+
// caller's `style`, then the child's own `style` last so its explicit
|
|
49
|
+
// styles win. react-native-web flattens nested arrays correctly; spreading
|
|
50
|
+
// the child's style (which is often an RN style array or numeric id) into an
|
|
51
|
+
// object literal would copy numeric indices as keys and crash RNW.
|
|
37
52
|
const childStyle = child.props.style;
|
|
38
|
-
const mergedStyle =
|
|
39
|
-
...varsStyle,
|
|
40
|
-
...style,
|
|
41
|
-
...childStyle
|
|
42
|
-
};
|
|
53
|
+
const mergedStyle = [varsStyle, style, childStyle];
|
|
43
54
|
content = /*#__PURE__*/cloneElement(child, {
|
|
44
55
|
style: mergedStyle
|
|
45
56
|
});
|
|
46
57
|
} else {
|
|
58
|
+
// A plain DOM `<div>` does NOT accept style arrays — only the cloned child
|
|
59
|
+
// path can, so the wrapper keeps using an object spread.
|
|
47
60
|
const mergedStyle = {
|
|
48
61
|
...varsStyle,
|
|
49
62
|
...style
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Children","cloneElement","isValidElement","useContext","useMemo","BloomThemeContext","buildTheme","buildScopeVars","Fragment","_Fragment","jsx","_jsx","BloomColorScope","colorPreset","asChild","style","children","parent","Error","resolvedMode","theme","mode","contextValue","varsStyle","content","child","only","childStyle","props","mergedStyle","Provider","value","useColorScopeStyle"],"sourceRoot":"../../../../src","sources":["theme/color-scope/index.web.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,YAAY,EAAEC,cAAc,EAAEC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAE1F,SAASC,iBAAiB,QAAqC,0BAAuB;AACtF,SAASC,UAAU,QAAQ,mBAAgB;AAE3C,SAASC,cAAc,QAAQ,oBAAiB;
|
|
1
|
+
{"version":3,"names":["React","Children","cloneElement","isValidElement","useContext","useMemo","BloomThemeContext","buildTheme","buildScopeVars","Fragment","_Fragment","jsx","_jsx","BloomColorScope","colorPreset","asChild","style","children","parent","Error","resolvedMode","theme","mode","contextValue","varsStyle","content","child","only","childStyle","props","mergedStyle","Provider","value","useColorScopeStyle"],"sourceRoot":"../../../../src","sources":["theme/color-scope/index.web.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,YAAY,EAAEC,cAAc,EAAEC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAE1F,SAASC,iBAAiB,QAAqC,0BAAuB;AACtF,SAASC,UAAU,QAAQ,mBAAgB;AAE3C,SAASC,cAAc,QAAQ,oBAAiB;;AAkBhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AARA,SAAAC,QAAA,IAAAC,SAAA,EAAAC,GAAA,IAAAC,IAAA;AAqBA,OAAO,SAASC,eAAeA,CAAC;EAC9BC,WAAW;EACXC,OAAO,GAAG,KAAK;EACfC,KAAK;EACLC;AACoB,CAAC,EAAE;EACvB,MAAMC,MAAM,GAAGd,UAAU,CAACE,iBAAiB,CAAC;EAC5C,IAAI,CAACY,MAAM,EAAE;IACX,MAAM,IAAIC,KAAK,CAAC,4DAA4D,CAAC;EAC/E;EAEA,IAAI,CAACL,WAAW,EAAE,oBAAOF,IAAA,CAAAF,SAAA;IAAAO,QAAA,EAAGA;EAAQ,CAAG,CAAC;EAExC,MAAMG,YAAY,GAAGF,MAAM,CAACG,KAAK,CAACC,IAAI;EAEtC,MAAMC,YAAY,GAAGlB,OAAO,CAAyB,MAAM;IACzD,MAAMgB,KAAK,GAAGd,UAAU,CAACO,WAAW,EAAEM,YAAY,CAAC;IACnD,OAAO;MAAE,GAAGF,MAAM;MAAEG,KAAK;MAAEP;IAAY,CAAC;EAC1C,CAAC,EAAE,CAACA,WAAW,EAAEM,YAAY,EAAEF,MAAM,CAAC,CAAC;EAEvC,MAAMM,SAAS,GAAGnB,OAAO,CACvB,MAAMG,cAAc,CAACM,WAAW,EAAEM,YAAY,CAAwB,EACtE,CAACN,WAAW,EAAEM,YAAY,CAC5B,CAAC;EAED,IAAIK,OAAwB;EAC5B,IAAIV,OAAO,EAAE;IACX,MAAMW,KAAK,GAAGzB,QAAQ,CAAC0B,IAAI,CAACV,QAAQ,CAAC;IACrC,IAAI,eAACd,cAAc,CAAiBuB,KAAK,CAAC,EAAE;MAC1C,MAAM,IAAIP,KAAK,CACb,mGACF,CAAC;IACH;IACA;IACA;IACA;IACA;IACA;IACA,MAAMS,UAAU,GAAGF,KAAK,CAACG,KAAK,CAACb,KAAK;IACpC,MAAMc,WAAqB,GAAG,CAACN,SAAS,EAAER,KAAK,EAAEY,UAAU,CAAC;IAC5DH,OAAO,gBAAGvB,YAAY,CAACwB,KAAK,EAAE;MAAEV,KAAK,EAAEc;IAAY,CAAC,CAAC;EACvD,CAAC,MAAM;IACL;IACA;IACA,MAAMA,WAAgC,GAAG;MAAE,GAAGN,SAAS;MAAE,GAAGR;IAAM,CAAC;IACnES,OAAO,gBAAGb,IAAA;MAAKI,KAAK,EAAEc,WAAY;MAAAb,QAAA,EAAEA;IAAQ,CAAM,CAAC;EACrD;EAEA,oBAAOL,IAAA,CAACN,iBAAiB,CAACyB,QAAQ;IAACC,KAAK,EAAET,YAAa;IAAAN,QAAA,EAAEQ;EAAO,CAA6B,CAAC;AAChG;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASQ,kBAAkBA,CAACnB,WAAyB,EAAuB;EACjF,MAAMI,MAAM,GAAGd,UAAU,CAACE,iBAAiB,CAAC;EAC5C,IAAI,CAACY,MAAM,EAAE;IACX,MAAM,IAAIC,KAAK,CAAC,+DAA+D,CAAC;EAClF;EACA,MAAMC,YAAY,GAAGF,MAAM,CAACG,KAAK,CAACC,IAAI;EACtC,OAAOjB,OAAO,CACZ,MAAMG,cAAc,CAACM,WAAW,EAAEM,YAAY,CAAwB,EACtE,CAACN,WAAW,EAAEM,YAAY,CAC5B,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native variant of the scroll-restoration primitive — a deliberate no-op.
|
|
3
|
+
*
|
|
4
|
+
* React Navigation's native-stack keeps every screen mounted while it is in the
|
|
5
|
+
* stack, so a list's scroll position survives a push/pop for free. There is
|
|
6
|
+
* nothing to save or restore. We still ship the full API surface (provider +
|
|
7
|
+
* hook) so consumers write one set of call sites that compile and run on every
|
|
8
|
+
* platform; on native the provider just renders its children and the hook does
|
|
9
|
+
* nothing.
|
|
10
|
+
*
|
|
11
|
+
* Web bundlers select `./index.web` via the `"browser"` export condition in
|
|
12
|
+
* `package.json`; native bundlers fall through to this file.
|
|
13
|
+
*/
|
|
14
|
+
import type { ReactElement } from 'react';
|
|
15
|
+
import type { ScrollRestorationProviderProps, ScrollRestorationTarget, UseScrollRestorationOptions } from './types';
|
|
16
|
+
export type { ScrollableHandle, ScrollRestorationProviderProps, ScrollRestorationTarget, UseScrollRestorationOptions, } from './types';
|
|
17
|
+
/**
|
|
18
|
+
* No-op provider. Renders children unchanged — native scroll persistence is
|
|
19
|
+
* handled by the navigator, so no per-route state is kept.
|
|
20
|
+
*/
|
|
21
|
+
export declare function ScrollRestorationProvider({ children, }: ScrollRestorationProviderProps): ReactElement;
|
|
22
|
+
/**
|
|
23
|
+
* No-op hook. Accepts the same arguments as the web implementation so call
|
|
24
|
+
* sites are identical across platforms.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useScrollRestoration(_target: ScrollRestorationTarget, _options?: UseScrollRestorationOptions): void;
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scroll/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EACV,8BAA8B,EAC9B,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AAEjB,YAAY,EACV,gBAAgB,EAChB,8BAA8B,EAC9B,uBAAuB,EACvB,2BAA2B,GAC5B,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,QAAQ,GACT,EAAE,8BAA8B,GAAG,YAAY,CAE/C;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,uBAAuB,EAChC,QAAQ,CAAC,EAAE,2BAA2B,GACrC,IAAI,CAEN"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ScrollRestorationProviderProps, ScrollRestorationTarget, UseScrollRestorationOptions } from './types';
|
|
2
|
+
export type { ScrollableHandle, ScrollRestorationProviderProps, ScrollRestorationTarget, UseScrollRestorationOptions, } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Holds the per-route offset map for the subtree. One provider near the app
|
|
5
|
+
* root is enough; the store lives for the document's lifetime so offsets
|
|
6
|
+
* survive navigating away and back (including browser Back/Forward).
|
|
7
|
+
*/
|
|
8
|
+
export declare function ScrollRestorationProvider({ children, }: ScrollRestorationProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
/**
|
|
10
|
+
* Preserve and restore the scroll offset of `target` across navigation, keyed
|
|
11
|
+
* by the active route (plus an optional `options.key` for routes that host
|
|
12
|
+
* multiple scrollables).
|
|
13
|
+
*
|
|
14
|
+
* Behaviour (web):
|
|
15
|
+
* - On every scroll while the screen is focused, the current offset is saved.
|
|
16
|
+
* - On focus, the saved offset is applied in a single `requestAnimationFrame`,
|
|
17
|
+
* giving a remounted list one frame to lay out its content first (no retry
|
|
18
|
+
* loops, no hide/show tricks).
|
|
19
|
+
* - On blur, the latest offset is captured as a final safety net.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useScrollRestoration(target: ScrollRestorationTarget, options?: UseScrollRestorationOptions): void;
|
|
22
|
+
//# sourceMappingURL=index.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/scroll/index.web.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EACV,8BAA8B,EAC9B,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AAEjB,YAAY,EACV,gBAAgB,EAChB,8BAA8B,EAC9B,uBAAuB,EACvB,2BAA2B,GAC5B,MAAM,SAAS,CAAC;AAgBjB;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,QAAQ,GACT,EAAE,8BAA8B,2CAOhC;AAYD;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,uBAAuB,EAC/B,OAAO,CAAC,EAAE,2BAA2B,GACpC,IAAI,CAyDN"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ScrollRestorationTarget } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* A normalized read/write interface over whatever the caller registered, so
|
|
4
|
+
* the hook does not branch on target shape. Both methods are no-ops when the
|
|
5
|
+
* underlying element is not yet (or no longer) attached.
|
|
6
|
+
*/
|
|
7
|
+
export interface ResolvedScroller {
|
|
8
|
+
getOffset: () => number;
|
|
9
|
+
setOffset: (offset: number) => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Build a {@link ResolvedScroller} for a target. The window sentinel reads and
|
|
13
|
+
* writes the document scroller; everything else operates on the resolved
|
|
14
|
+
* element's `scrollTop`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createScroller(target: ScrollRestorationTarget): ResolvedScroller;
|
|
17
|
+
//# sourceMappingURL=scrollable.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrollable.web.d.ts","sourceRoot":"","sources":["../../../../src/scroll/scrollable.web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEzE;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,MAAM,CAAC;IACxB,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAuCD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,uBAAuB,GAAG,gBAAgB,CAoBhF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure, platform-agnostic core of the scroll-restoration primitive.
|
|
3
|
+
*
|
|
4
|
+
* This file deliberately contains NO React and NO DOM/native imports so the
|
|
5
|
+
* logic can be unit-tested in isolation and shared verbatim by the web and
|
|
6
|
+
* native barrels. The web barrel drives it with real scroll offsets; the
|
|
7
|
+
* native barrel never instantiates it (native-stack already restores scroll).
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Derive the storage key for a scrollable from its owning route key and an
|
|
11
|
+
* optional caller sub-key.
|
|
12
|
+
*
|
|
13
|
+
* - `routeKey` is React Navigation's stable per-route `route.key`.
|
|
14
|
+
* - `subKey` distinguishes multiple scrollables that share a single route.
|
|
15
|
+
*
|
|
16
|
+
* Returns `null` when there is no route key to anchor against (the scrollable
|
|
17
|
+
* is not inside a navigator), which the caller treats as "do not persist".
|
|
18
|
+
*/
|
|
19
|
+
export declare function deriveScrollKey(routeKey: string | undefined, subKey?: string): string | null;
|
|
20
|
+
/**
|
|
21
|
+
* In-memory map of `scrollKey -> last-known scroll offset`.
|
|
22
|
+
*
|
|
23
|
+
* Mirrors the semantics of Bluesky's `Map<screenKey, scrollY>`: offsets live
|
|
24
|
+
* only for the lifetime of the document/session. We never persist them — a
|
|
25
|
+
* full reload should start at the top — and we never auto-evict, because a
|
|
26
|
+
* route can be revisited via browser Forward/Back long after it blurred.
|
|
27
|
+
*/
|
|
28
|
+
export declare class ScrollOffsetStore {
|
|
29
|
+
private readonly offsets;
|
|
30
|
+
/** Persist the offset for a key. A negative offset is clamped to 0. */
|
|
31
|
+
save(key: string, offset: number): void;
|
|
32
|
+
/**
|
|
33
|
+
* Read the saved offset for a key. Returns `0` when nothing was saved, so
|
|
34
|
+
* callers can restore unconditionally (an unseen list restores to the top).
|
|
35
|
+
*/
|
|
36
|
+
read(key: string): number;
|
|
37
|
+
/** Whether an offset was ever saved for this key. */
|
|
38
|
+
has(key: string): boolean;
|
|
39
|
+
/** Drop a saved offset (e.g. when a route is permanently removed). */
|
|
40
|
+
forget(key: string): void;
|
|
41
|
+
/** Clear every saved offset. Primarily for tests and full resets. */
|
|
42
|
+
clear(): void;
|
|
43
|
+
/** Number of distinct keys currently tracked. */
|
|
44
|
+
get size(): number;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../src/scroll/store.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAcH;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,GAAG,IAAI,CAIf;AAED;;;;;;;GAOG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IAErD,uEAAuE;IACvE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAIvC;;;OAGG;IACH,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAIzB,qDAAqD;IACrD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB,sEAAsE;IACtE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIzB,qEAAqE;IACrE,KAAK,IAAI,IAAI;IAIb,iDAAiD;IACjD,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ReactNode, RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Anything `useScrollRestoration` knows how to read/write a vertical scroll
|
|
4
|
+
* offset from. The hook accepts a ref to one of these:
|
|
5
|
+
*
|
|
6
|
+
* - a React Native `ScrollView` / `FlatList` ref (which on web is backed by a
|
|
7
|
+
* DOM node and exposes `getScrollableNode()`),
|
|
8
|
+
* - a raw DOM element ref (when a component renders its own scroll container),
|
|
9
|
+
* - the literal `'window'` sentinel, for the rare layout where the list IS the
|
|
10
|
+
* window scroller (matches Bluesky's default).
|
|
11
|
+
*
|
|
12
|
+
* Native never reads any of these — the native hook is a no-op — so the type is
|
|
13
|
+
* intentionally permissive rather than coupled to a specific RN class.
|
|
14
|
+
*/
|
|
15
|
+
export interface ScrollableHandle {
|
|
16
|
+
/** Imperative scroll API exposed by RN scrollables. */
|
|
17
|
+
scrollTo?: (options: {
|
|
18
|
+
x?: number;
|
|
19
|
+
y?: number;
|
|
20
|
+
animated?: boolean;
|
|
21
|
+
}) => void;
|
|
22
|
+
/** Web/RNW path: returns the underlying DOM node. */
|
|
23
|
+
getScrollableNode?: () => unknown;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The accepted ref shapes. `'window'` is a sentinel for the document scroller.
|
|
27
|
+
*/
|
|
28
|
+
export type ScrollRestorationTarget = RefObject<ScrollableHandle | null> | RefObject<unknown> | 'window';
|
|
29
|
+
export interface UseScrollRestorationOptions {
|
|
30
|
+
/**
|
|
31
|
+
* Sub-key to disambiguate multiple scrollables that live on the same route
|
|
32
|
+
* (e.g. the tabs of a profile screen). Combined with the active route key to
|
|
33
|
+
* form the storage key. Omit when a route has a single scrollable.
|
|
34
|
+
*/
|
|
35
|
+
key?: string;
|
|
36
|
+
/**
|
|
37
|
+
* When `false`, the hook is inert (saves and restores are skipped). Useful to
|
|
38
|
+
* gate restoration behind a feature flag without changing call sites.
|
|
39
|
+
* Defaults to `true`.
|
|
40
|
+
*/
|
|
41
|
+
enabled?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface ScrollRestorationProviderProps {
|
|
44
|
+
children: ReactNode;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/scroll/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uDAAuD;IACvD,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7E,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAC/B,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAClC,SAAS,CAAC,OAAO,CAAC,GAClB,QAAQ,CAAC;AAEb,MAAM,WAAW,2BAA2B;IAC1C;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,EAAE,SAAS,CAAC;CACrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/index.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsE,MAAM,OAAO,CAAC;AAI3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGrD,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,WAAW,EAAE,YAAY,GAAG,SAAS,CAAC;IACtC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yGAAyG;IACzG,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;
|
|
1
|
+
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/index.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsE,MAAM,OAAO,CAAC;AAI3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGrD,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,WAAW,EAAE,YAAY,GAAG,SAAS,CAAC;IACtC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yGAAyG;IACzG,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAuBD,wBAAgB,eAAe,CAAC,EAC9B,WAAW,EACX,OAAe,EACf,KAAK,EACL,QAAQ,GACT,EAAE,oBAAoB,2CA4CtB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,YAAY,GAAG,KAAK,CAAC,aAAa,CAUjF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native variant of the scroll-restoration primitive — a deliberate no-op.
|
|
3
|
+
*
|
|
4
|
+
* React Navigation's native-stack keeps every screen mounted while it is in the
|
|
5
|
+
* stack, so a list's scroll position survives a push/pop for free. There is
|
|
6
|
+
* nothing to save or restore. We still ship the full API surface (provider +
|
|
7
|
+
* hook) so consumers write one set of call sites that compile and run on every
|
|
8
|
+
* platform; on native the provider just renders its children and the hook does
|
|
9
|
+
* nothing.
|
|
10
|
+
*
|
|
11
|
+
* Web bundlers select `./index.web` via the `"browser"` export condition in
|
|
12
|
+
* `package.json`; native bundlers fall through to this file.
|
|
13
|
+
*/
|
|
14
|
+
import type { ReactElement } from 'react';
|
|
15
|
+
import type { ScrollRestorationProviderProps, ScrollRestorationTarget, UseScrollRestorationOptions } from './types';
|
|
16
|
+
export type { ScrollableHandle, ScrollRestorationProviderProps, ScrollRestorationTarget, UseScrollRestorationOptions, } from './types';
|
|
17
|
+
/**
|
|
18
|
+
* No-op provider. Renders children unchanged — native scroll persistence is
|
|
19
|
+
* handled by the navigator, so no per-route state is kept.
|
|
20
|
+
*/
|
|
21
|
+
export declare function ScrollRestorationProvider({ children, }: ScrollRestorationProviderProps): ReactElement;
|
|
22
|
+
/**
|
|
23
|
+
* No-op hook. Accepts the same arguments as the web implementation so call
|
|
24
|
+
* sites are identical across platforms.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useScrollRestoration(_target: ScrollRestorationTarget, _options?: UseScrollRestorationOptions): void;
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scroll/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EACV,8BAA8B,EAC9B,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AAEjB,YAAY,EACV,gBAAgB,EAChB,8BAA8B,EAC9B,uBAAuB,EACvB,2BAA2B,GAC5B,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,QAAQ,GACT,EAAE,8BAA8B,GAAG,YAAY,CAE/C;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,uBAAuB,EAChC,QAAQ,CAAC,EAAE,2BAA2B,GACrC,IAAI,CAEN"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ScrollRestorationProviderProps, ScrollRestorationTarget, UseScrollRestorationOptions } from './types';
|
|
2
|
+
export type { ScrollableHandle, ScrollRestorationProviderProps, ScrollRestorationTarget, UseScrollRestorationOptions, } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Holds the per-route offset map for the subtree. One provider near the app
|
|
5
|
+
* root is enough; the store lives for the document's lifetime so offsets
|
|
6
|
+
* survive navigating away and back (including browser Back/Forward).
|
|
7
|
+
*/
|
|
8
|
+
export declare function ScrollRestorationProvider({ children, }: ScrollRestorationProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
/**
|
|
10
|
+
* Preserve and restore the scroll offset of `target` across navigation, keyed
|
|
11
|
+
* by the active route (plus an optional `options.key` for routes that host
|
|
12
|
+
* multiple scrollables).
|
|
13
|
+
*
|
|
14
|
+
* Behaviour (web):
|
|
15
|
+
* - On every scroll while the screen is focused, the current offset is saved.
|
|
16
|
+
* - On focus, the saved offset is applied in a single `requestAnimationFrame`,
|
|
17
|
+
* giving a remounted list one frame to lay out its content first (no retry
|
|
18
|
+
* loops, no hide/show tricks).
|
|
19
|
+
* - On blur, the latest offset is captured as a final safety net.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useScrollRestoration(target: ScrollRestorationTarget, options?: UseScrollRestorationOptions): void;
|
|
22
|
+
//# sourceMappingURL=index.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/scroll/index.web.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EACV,8BAA8B,EAC9B,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AAEjB,YAAY,EACV,gBAAgB,EAChB,8BAA8B,EAC9B,uBAAuB,EACvB,2BAA2B,GAC5B,MAAM,SAAS,CAAC;AAgBjB;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,QAAQ,GACT,EAAE,8BAA8B,2CAOhC;AAYD;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,uBAAuB,EAC/B,OAAO,CAAC,EAAE,2BAA2B,GACpC,IAAI,CAyDN"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ScrollRestorationTarget } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* A normalized read/write interface over whatever the caller registered, so
|
|
4
|
+
* the hook does not branch on target shape. Both methods are no-ops when the
|
|
5
|
+
* underlying element is not yet (or no longer) attached.
|
|
6
|
+
*/
|
|
7
|
+
export interface ResolvedScroller {
|
|
8
|
+
getOffset: () => number;
|
|
9
|
+
setOffset: (offset: number) => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Build a {@link ResolvedScroller} for a target. The window sentinel reads and
|
|
13
|
+
* writes the document scroller; everything else operates on the resolved
|
|
14
|
+
* element's `scrollTop`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createScroller(target: ScrollRestorationTarget): ResolvedScroller;
|
|
17
|
+
//# sourceMappingURL=scrollable.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrollable.web.d.ts","sourceRoot":"","sources":["../../../../src/scroll/scrollable.web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEzE;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,MAAM,CAAC;IACxB,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAuCD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,uBAAuB,GAAG,gBAAgB,CAoBhF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure, platform-agnostic core of the scroll-restoration primitive.
|
|
3
|
+
*
|
|
4
|
+
* This file deliberately contains NO React and NO DOM/native imports so the
|
|
5
|
+
* logic can be unit-tested in isolation and shared verbatim by the web and
|
|
6
|
+
* native barrels. The web barrel drives it with real scroll offsets; the
|
|
7
|
+
* native barrel never instantiates it (native-stack already restores scroll).
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Derive the storage key for a scrollable from its owning route key and an
|
|
11
|
+
* optional caller sub-key.
|
|
12
|
+
*
|
|
13
|
+
* - `routeKey` is React Navigation's stable per-route `route.key`.
|
|
14
|
+
* - `subKey` distinguishes multiple scrollables that share a single route.
|
|
15
|
+
*
|
|
16
|
+
* Returns `null` when there is no route key to anchor against (the scrollable
|
|
17
|
+
* is not inside a navigator), which the caller treats as "do not persist".
|
|
18
|
+
*/
|
|
19
|
+
export declare function deriveScrollKey(routeKey: string | undefined, subKey?: string): string | null;
|
|
20
|
+
/**
|
|
21
|
+
* In-memory map of `scrollKey -> last-known scroll offset`.
|
|
22
|
+
*
|
|
23
|
+
* Mirrors the semantics of Bluesky's `Map<screenKey, scrollY>`: offsets live
|
|
24
|
+
* only for the lifetime of the document/session. We never persist them — a
|
|
25
|
+
* full reload should start at the top — and we never auto-evict, because a
|
|
26
|
+
* route can be revisited via browser Forward/Back long after it blurred.
|
|
27
|
+
*/
|
|
28
|
+
export declare class ScrollOffsetStore {
|
|
29
|
+
private readonly offsets;
|
|
30
|
+
/** Persist the offset for a key. A negative offset is clamped to 0. */
|
|
31
|
+
save(key: string, offset: number): void;
|
|
32
|
+
/**
|
|
33
|
+
* Read the saved offset for a key. Returns `0` when nothing was saved, so
|
|
34
|
+
* callers can restore unconditionally (an unseen list restores to the top).
|
|
35
|
+
*/
|
|
36
|
+
read(key: string): number;
|
|
37
|
+
/** Whether an offset was ever saved for this key. */
|
|
38
|
+
has(key: string): boolean;
|
|
39
|
+
/** Drop a saved offset (e.g. when a route is permanently removed). */
|
|
40
|
+
forget(key: string): void;
|
|
41
|
+
/** Clear every saved offset. Primarily for tests and full resets. */
|
|
42
|
+
clear(): void;
|
|
43
|
+
/** Number of distinct keys currently tracked. */
|
|
44
|
+
get size(): number;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../src/scroll/store.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAcH;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,GAAG,IAAI,CAIf;AAED;;;;;;;GAOG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IAErD,uEAAuE;IACvE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAIvC;;;OAGG;IACH,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAIzB,qDAAqD;IACrD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB,sEAAsE;IACtE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIzB,qEAAqE;IACrE,KAAK,IAAI,IAAI;IAIb,iDAAiD;IACjD,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ReactNode, RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Anything `useScrollRestoration` knows how to read/write a vertical scroll
|
|
4
|
+
* offset from. The hook accepts a ref to one of these:
|
|
5
|
+
*
|
|
6
|
+
* - a React Native `ScrollView` / `FlatList` ref (which on web is backed by a
|
|
7
|
+
* DOM node and exposes `getScrollableNode()`),
|
|
8
|
+
* - a raw DOM element ref (when a component renders its own scroll container),
|
|
9
|
+
* - the literal `'window'` sentinel, for the rare layout where the list IS the
|
|
10
|
+
* window scroller (matches Bluesky's default).
|
|
11
|
+
*
|
|
12
|
+
* Native never reads any of these — the native hook is a no-op — so the type is
|
|
13
|
+
* intentionally permissive rather than coupled to a specific RN class.
|
|
14
|
+
*/
|
|
15
|
+
export interface ScrollableHandle {
|
|
16
|
+
/** Imperative scroll API exposed by RN scrollables. */
|
|
17
|
+
scrollTo?: (options: {
|
|
18
|
+
x?: number;
|
|
19
|
+
y?: number;
|
|
20
|
+
animated?: boolean;
|
|
21
|
+
}) => void;
|
|
22
|
+
/** Web/RNW path: returns the underlying DOM node. */
|
|
23
|
+
getScrollableNode?: () => unknown;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The accepted ref shapes. `'window'` is a sentinel for the document scroller.
|
|
27
|
+
*/
|
|
28
|
+
export type ScrollRestorationTarget = RefObject<ScrollableHandle | null> | RefObject<unknown> | 'window';
|
|
29
|
+
export interface UseScrollRestorationOptions {
|
|
30
|
+
/**
|
|
31
|
+
* Sub-key to disambiguate multiple scrollables that live on the same route
|
|
32
|
+
* (e.g. the tabs of a profile screen). Combined with the active route key to
|
|
33
|
+
* form the storage key. Omit when a route has a single scrollable.
|
|
34
|
+
*/
|
|
35
|
+
key?: string;
|
|
36
|
+
/**
|
|
37
|
+
* When `false`, the hook is inert (saves and restores are skipped). Useful to
|
|
38
|
+
* gate restoration behind a feature flag without changing call sites.
|
|
39
|
+
* Defaults to `true`.
|
|
40
|
+
*/
|
|
41
|
+
enabled?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface ScrollRestorationProviderProps {
|
|
44
|
+
children: ReactNode;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/scroll/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uDAAuD;IACvD,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7E,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAC/B,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAClC,SAAS,CAAC,OAAO,CAAC,GAClB,QAAQ,CAAC;AAEb,MAAM,WAAW,2BAA2B;IAC1C;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,EAAE,SAAS,CAAC;CACrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/index.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsE,MAAM,OAAO,CAAC;AAI3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGrD,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,WAAW,EAAE,YAAY,GAAG,SAAS,CAAC;IACtC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yGAAyG;IACzG,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;
|
|
1
|
+
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/index.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsE,MAAM,OAAO,CAAC;AAI3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGrD,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,WAAW,EAAE,YAAY,GAAG,SAAS,CAAC;IACtC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yGAAyG;IACzG,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAuBD,wBAAgB,eAAe,CAAC,EAC9B,WAAW,EACX,OAAe,EACf,KAAK,EACL,QAAQ,GACT,EAAE,oBAAoB,2CA4CtB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,YAAY,GAAG,KAAK,CAAC,aAAa,CAUjF"}
|