@swiftbrowser/react 0.25.0 → 0.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -9
- package/dist/components/navigation.d.ts.map +1 -1
- package/dist/components/remoteTree.d.ts +10 -0
- package/dist/components/remoteTree.d.ts.map +1 -1
- package/dist/host/remote.d.ts +2 -0
- package/dist/host/remote.d.ts.map +1 -1
- package/dist/index.js +95 -20
- package/dist/index.js.map +1 -1
- package/dist/navigation-context.d.ts +6 -0
- package/dist/navigation-context.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1010,15 +1010,27 @@ root.render(<Counter />);
|
|
|
1010
1010
|
receive((event) => root.dispatch(event));
|
|
1011
1011
|
```
|
|
1012
1012
|
|
|
1013
|
-
The child
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
the
|
|
1013
|
+
The child's top-level views are drawn in place; what it would put on a
|
|
1014
|
+
screen of its own joins the screen `RemoteTree` sits in (`navigationTitle`,
|
|
1015
|
+
`toolbar`, `searchable`, `toolbarVisibility`), and its `sheet`s and `alert`s
|
|
1016
|
+
are presented over the host's root. A pass the child made in `withAnimation`
|
|
1017
|
+
animates here too, and the child's completion runs when the host's animation
|
|
1018
|
+
ends.
|
|
1019
|
+
|
|
1020
|
+
A `NavigationStack` in the child becomes the host's, when `RemoteTree` sits
|
|
1021
|
+
in one: the child's root screen is drawn in place, and every screen the
|
|
1022
|
+
child pushes (`NavigationLink`, its `path`) is pushed on the host's stack,
|
|
1023
|
+
with the child's title, display mode, toolbar and search field on it. The
|
|
1024
|
+
child's path stays the truth: a push or pop there (`dismiss` included)
|
|
1025
|
+
pushes or pops the host's screens, and a pop in the host (the back button,
|
|
1026
|
+
the swipe, a tap on an earlier screen in the bar) pops the child's path to
|
|
1027
|
+
the same place. The host's path holds the child's screens as pushed views,
|
|
1028
|
+
so a bound `path` sees them; a screen the host pushes over them stays until
|
|
1029
|
+
the child's stack moves. Outside a host stack the child's stack is drawn as
|
|
1030
|
+
its own. Only the child's first stack is mapped (one in a sheet presents in
|
|
1031
|
+
the sheet), and not yet: `NavigationSplitView` in the child, `Host` elements
|
|
1032
|
+
(their DOM lives in the child's page, which has none here), and the ops a
|
|
1033
|
+
loader answers (`request`, `swiftdata`, `defaults`).
|
|
1022
1034
|
|
|
1023
1035
|
## How it works
|
|
1024
1036
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/components/navigation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAG5D,OAAO,EAA4C,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAM5F,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,mDAAmD;IACnD,IAAI,CAAC,EAAE,YAAY,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;IACxC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,KAAK,IAAI,CAAC;IAClD,8DAA8D;IAC9D,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC;IAC1C,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAUD,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,SAAS,CAMtE;
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/components/navigation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAG5D,OAAO,EAA4C,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAM5F,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,mDAAmD;IACnD,IAAI,CAAC,EAAE,YAAY,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;IACxC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,KAAK,IAAI,CAAC;IAClD,8DAA8D;IAC9D,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC;IAC1C,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAUD,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,SAAS,CAMtE;AA8DD,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,0BAA0B;IAC1B,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,SAAS,CA4BpE"}
|
|
@@ -6,6 +6,16 @@
|
|
|
6
6
|
* screen and its renderer, web or native alike. What a child hoists to its
|
|
7
7
|
* root for lack of a screen of its own joins this tree's enclosing screen
|
|
8
8
|
* (a title, a toolbar, a search field) or root (a sheet, an alert).
|
|
9
|
+
*
|
|
10
|
+
* A child's `NavigationStack` becomes this tree's: inside a host stack, the
|
|
11
|
+
* child's root screen is drawn in place (its title and toolbar on the host's
|
|
12
|
+
* screen) and each screen the child pushes is pushed onto the host's stack,
|
|
13
|
+
* so the child's screens slide in, get the host's back button and swipe,
|
|
14
|
+
* and show in its bar like the host's own. The child's path stays the
|
|
15
|
+
* truth: a push or pop in the child pushes or pops the host's screens, and
|
|
16
|
+
* a pop in the host (back, swipe, a tap on an earlier screen) is sent to the
|
|
17
|
+
* child as the renderer would send it (a `tap` on the popped screen), which
|
|
18
|
+
* pops the child's path.
|
|
9
19
|
*/
|
|
10
20
|
import { type ReactNode } from 'react';
|
|
11
21
|
import type { RemoteRoot } from '../host/remote';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteTree.d.ts","sourceRoot":"","sources":["../../src/components/remoteTree.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"remoteTree.d.ts","sourceRoot":"","sources":["../../src/components/remoteTree.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAsF,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG3H,OAAO,KAAK,EAAc,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAK7D,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,UAAU,CAAC;CAClB;AA+DD,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,EAAE,eAAe,GAAG,SAAS,CA6D/D"}
|
package/dist/host/remote.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ export interface RemoteRoot {
|
|
|
35
35
|
getVersion(): number;
|
|
36
36
|
/** The mirror: element 0, whose children are the child's top-level elements (hoisted sheets and alerts last). */
|
|
37
37
|
readonly root: MirrorNode;
|
|
38
|
+
/** The mirrored element with that id (the child's own id), if it is there. */
|
|
39
|
+
node(id: number): MirrorNode | undefined;
|
|
38
40
|
/** What the child's root carries (a title with no screen of its own, a color scheme); `update` of element 0. */
|
|
39
41
|
readonly rootProps: Record<string, unknown>;
|
|
40
42
|
/** The handlers a mirrored element gets: every event forwarded to the child under the child's id. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../src/host/remote.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAa,EAAE,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAkB,aAAa,E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AAI,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IACzC,gHAAgH;IAChH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,qGAAqG;IACrG,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,CAAC;IACvC,kGAAkG;IAClG,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI,CAAC;IACpC,qFAAqF;IACrF,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,wBAAgB,gBAAgB,IAAI,UAAU,CAkJ7C"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { createContext, useContext, createElement, useSyncExternalStore, useLayoutEffect,
|
|
1
|
+
import { createContext, useContext, createElement, useSyncExternalStore, useLayoutEffect, useRef, Fragment, useState, Children, useEffect, isValidElement, useId, cloneElement, useCallback } from "react";
|
|
2
2
|
import { DefaultEventPriority, ConcurrentRoot } from "react-reconciler/constants";
|
|
3
3
|
import Reconciler from "react-reconciler";
|
|
4
|
+
import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
4
5
|
import { horizontalSizeClassFor } from "@swiftbrowser/web/src/protocol";
|
|
5
6
|
import { BrowserHistory } from "@swiftbrowser/web/src/browserHistory";
|
|
6
7
|
import { watchKeyboard } from "@swiftbrowser/web/src/deviceMode";
|
|
7
8
|
import { browserEnvironment, exportFiles, loadableURL, performHostRequest } from "@swiftbrowser/web/src/hostRequests";
|
|
8
9
|
import { Renderer } from "@swiftbrowser/web/src/renderer";
|
|
9
10
|
import { currentScenePhase, watchScenePhase } from "@swiftbrowser/web/src/scenePhase";
|
|
10
|
-
import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
11
11
|
import { applyTypeSizeVariables } from "@swiftbrowser/web/src/typography";
|
|
12
12
|
import { configureSignInWithApple } from "@swiftbrowser/web/src/appleSignIn";
|
|
13
13
|
import { fileURL } from "@swiftbrowser/web/src/files";
|
|
@@ -583,6 +583,9 @@ function createRemoteRoot() {
|
|
|
583
583
|
notify2();
|
|
584
584
|
answer?.();
|
|
585
585
|
},
|
|
586
|
+
node(id) {
|
|
587
|
+
return nodes.get(id);
|
|
588
|
+
},
|
|
586
589
|
onEvent(handler) {
|
|
587
590
|
eventHandler = handler;
|
|
588
591
|
},
|
|
@@ -643,16 +646,67 @@ function sb(kind, props, on, children, target) {
|
|
|
643
646
|
if (target) hostProps.target = target;
|
|
644
647
|
return children === void 0 ? createElement("sb", hostProps) : createElement("sb", hostProps, children);
|
|
645
648
|
}
|
|
649
|
+
const NavigationContext = createContext(null);
|
|
650
|
+
const ScreenDepthContext = createContext(0);
|
|
651
|
+
function useScreenDepth() {
|
|
652
|
+
return useContext(ScreenDepthContext);
|
|
653
|
+
}
|
|
654
|
+
function useNavigation() {
|
|
655
|
+
return useContext(NavigationContext);
|
|
656
|
+
}
|
|
657
|
+
function RegisterDestination({ destination }) {
|
|
658
|
+
const navigation = useContext(NavigationContext);
|
|
659
|
+
navigation?.registerDestination(destination);
|
|
660
|
+
return null;
|
|
661
|
+
}
|
|
646
662
|
const SCREEN_PROPS = ["title", "displayMode", "toolbarRole", "navigationBarHidden", "bottomBarHidden", "statusBarHidden"];
|
|
647
|
-
function
|
|
663
|
+
function screenPrefs(props, key) {
|
|
664
|
+
const picked = {};
|
|
665
|
+
for (const name of SCREEN_PROPS) if (name in props) picked[name] = props[name];
|
|
666
|
+
if (picked["title"] === "") delete picked["title"];
|
|
667
|
+
if (picked["displayMode"] === "automatic") delete picked["displayMode"];
|
|
668
|
+
return Object.keys(picked).length ? createElement(Fragment, { key }, sb(PREF_KIND, picked, void 0, void 0, "navscreen")) : null;
|
|
669
|
+
}
|
|
670
|
+
function findStack(node) {
|
|
671
|
+
for (const child of node.children) {
|
|
672
|
+
if (child.kind === "sheet" || child.kind === "alert") continue;
|
|
673
|
+
if (child.kind === "navstack") return child;
|
|
674
|
+
const found = findStack(child);
|
|
675
|
+
if (found) return found;
|
|
676
|
+
}
|
|
677
|
+
return null;
|
|
678
|
+
}
|
|
679
|
+
const screensOf = (stack) => stack ? stack.children.filter((child) => child.kind === "navscreen") : [];
|
|
680
|
+
function renderNode(root, node, stack) {
|
|
648
681
|
if (node.kind === "host") return null;
|
|
649
|
-
|
|
682
|
+
if (node === stack) {
|
|
683
|
+
const first = screensOf(stack)[0];
|
|
684
|
+
return createElement(Fragment, { key: node.id }, first ? renderScreen(root, first, stack) : null);
|
|
685
|
+
}
|
|
686
|
+
const children = node.children.length ? node.children.map((child) => renderNode(root, child, stack)) : void 0;
|
|
650
687
|
return createElement(Fragment, { key: node.id }, sb(node.kind, node.props, root.handlersFor(node.id), children));
|
|
651
688
|
}
|
|
689
|
+
function renderScreen(root, screen, stack) {
|
|
690
|
+
const out = [screenPrefs(screen.props, "$screen")];
|
|
691
|
+
for (const child of screen.children) {
|
|
692
|
+
const drawn = renderNode(root, child, stack);
|
|
693
|
+
if (child.kind === "toolbar" || child.kind === "searchfield") out.push(createElement(Fragment, { key: child.id }, sb(HOIST_KIND, void 0, void 0, drawn, "navscreen")));
|
|
694
|
+
else out.push(drawn);
|
|
695
|
+
}
|
|
696
|
+
return createElement(Fragment, null, ...out);
|
|
697
|
+
}
|
|
698
|
+
function RemoteScreen({ root, id }) {
|
|
699
|
+
useSyncExternalStore(root.subscribe, root.getVersion, root.getVersion);
|
|
700
|
+
const screen = root.node(id);
|
|
701
|
+
if (!screen?.parent) return null;
|
|
702
|
+
return renderScreen(root, screen, findStack(root.root));
|
|
703
|
+
}
|
|
652
704
|
function RemoteTree({ root }) {
|
|
653
705
|
useSyncExternalStore(root.subscribe, root.getVersion, root.getVersion);
|
|
654
706
|
const environment = useContext(EnvironmentContext);
|
|
655
707
|
const tree = useContext(HostTreeContext);
|
|
708
|
+
const navigation = useNavigation();
|
|
709
|
+
const depth = useScreenDepth();
|
|
656
710
|
useLayoutEffect(() => {
|
|
657
711
|
root.attach(tree);
|
|
658
712
|
return () => root.attach(null);
|
|
@@ -660,14 +714,42 @@ function RemoteTree({ root }) {
|
|
|
660
714
|
useLayoutEffect(() => {
|
|
661
715
|
root.setEnvironment(environment);
|
|
662
716
|
}, [root, environment]);
|
|
663
|
-
const
|
|
664
|
-
const
|
|
665
|
-
|
|
666
|
-
|
|
717
|
+
const stack = navigation ? findStack(root.root) : null;
|
|
718
|
+
const pushed = screensOf(stack).slice(1);
|
|
719
|
+
const values = useRef(/* @__PURE__ */ new Map());
|
|
720
|
+
const ours = useRef(/* @__PURE__ */ new WeakSet());
|
|
721
|
+
const lastPushed = useRef([]);
|
|
722
|
+
const valueFor = (id) => {
|
|
723
|
+
let value = values.current.get(id);
|
|
724
|
+
if (!value) {
|
|
725
|
+
value = { view: /* @__PURE__ */ jsx(RemoteScreen, { root, id }) };
|
|
726
|
+
values.current.set(id, value);
|
|
727
|
+
ours.current.add(value);
|
|
728
|
+
}
|
|
729
|
+
return value;
|
|
730
|
+
};
|
|
731
|
+
useLayoutEffect(() => {
|
|
732
|
+
if (!navigation) return;
|
|
733
|
+
const ids = pushed.map((screen) => screen.id);
|
|
734
|
+
const wanted = ids.map(valueFor);
|
|
735
|
+
for (const id of values.current.keys()) if (!ids.includes(id)) values.current.delete(id);
|
|
736
|
+
const tail = navigation.path.slice(depth);
|
|
737
|
+
let shown = 0;
|
|
738
|
+
while (shown < tail.length && typeof tail[shown] === "object" && tail[shown] !== null && ours.current.has(tail[shown])) shown += 1;
|
|
739
|
+
const childMoved = ids.length !== lastPushed.current.length || ids.some((id, i) => id !== lastPushed.current[i]);
|
|
740
|
+
lastPushed.current = ids;
|
|
741
|
+
if (!childMoved && shown < wanted.length && tail.slice(0, shown).every((value, i) => value === wanted[i])) {
|
|
742
|
+
root.dispatch({ type: "tap", id: pushed[shown].id });
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
if (shown === wanted.length && wanted.every((value, i) => tail[i] === value)) return;
|
|
746
|
+
navigation.setPath([...navigation.path.slice(0, depth), ...wanted]);
|
|
747
|
+
});
|
|
748
|
+
const out = [screenPrefs(root.rootProps, "$root")];
|
|
667
749
|
if ("colorScheme" in root.rootProps)
|
|
668
750
|
out.push(createElement(Fragment, { key: "$scheme" }, sb(PREF_KIND, { colorScheme: root.rootProps["colorScheme"] }, void 0, void 0, "root")));
|
|
669
751
|
for (const child of root.root.children) {
|
|
670
|
-
const drawn = renderNode(root, child);
|
|
752
|
+
const drawn = renderNode(root, child, stack);
|
|
671
753
|
if (child.kind === "sheet" || child.kind === "alert") out.push(createElement(Fragment, { key: child.id }, sb(HOIST_KIND, void 0, void 0, drawn, "root")));
|
|
672
754
|
else if (child.kind === "toolbar" || child.kind === "searchfield") out.push(createElement(Fragment, { key: child.id }, sb(HOIST_KIND, void 0, void 0, drawn, "navscreen")));
|
|
673
755
|
else out.push(drawn);
|
|
@@ -905,15 +987,6 @@ function mount(screen, element, options = {}) {
|
|
|
905
987
|
};
|
|
906
988
|
return mounted;
|
|
907
989
|
}
|
|
908
|
-
const NavigationContext = createContext(null);
|
|
909
|
-
function useNavigation() {
|
|
910
|
-
return useContext(NavigationContext);
|
|
911
|
-
}
|
|
912
|
-
function RegisterDestination({ destination }) {
|
|
913
|
-
const navigation = useContext(NavigationContext);
|
|
914
|
-
navigation?.registerDestination(destination);
|
|
915
|
-
return null;
|
|
916
|
-
}
|
|
917
990
|
const EMPTY = { canUndo: false, canRedo: false, undoActionName: "", redoActionName: "" };
|
|
918
991
|
const defaultSchedule = (close) => {
|
|
919
992
|
if (typeof queueMicrotask === "function") queueMicrotask(close);
|
|
@@ -1967,12 +2040,14 @@ function OwnStack(props) {
|
|
|
1967
2040
|
const context = {
|
|
1968
2041
|
push: (value) => setPath([...path, value]),
|
|
1969
2042
|
pop: () => setPath(path.slice(0, -1)),
|
|
2043
|
+
path,
|
|
2044
|
+
setPath: (next) => setPath(next),
|
|
1970
2045
|
registerDestination: (builder) => {
|
|
1971
2046
|
destination.current = builder;
|
|
1972
2047
|
}
|
|
1973
2048
|
};
|
|
1974
2049
|
const screens = [
|
|
1975
|
-
/* @__PURE__ */ jsx(Fragment, { children: sb("navscreen", { title: "", displayMode: "automatic", depth: 0 }, { tap: context.pop }, own.children) }, "root")
|
|
2050
|
+
/* @__PURE__ */ jsx(Fragment, { children: sb("navscreen", { title: "", displayMode: "automatic", depth: 0 }, { tap: context.pop }, /* @__PURE__ */ jsx(ScreenDepthContext.Provider, { value: 0, children: own.children })) }, "root")
|
|
1976
2051
|
];
|
|
1977
2052
|
path.forEach((value, index) => {
|
|
1978
2053
|
const pop = () => setPath(path.slice(0, index));
|
|
@@ -1981,7 +2056,7 @@ function OwnStack(props) {
|
|
|
1981
2056
|
"navscreen",
|
|
1982
2057
|
{ title: "", displayMode: "automatic", depth: index + 1 },
|
|
1983
2058
|
{ tap: pop },
|
|
1984
|
-
/* @__PURE__ */ jsx(DismissContext.Provider, { value: pop, children: /* @__PURE__ */ jsx(PathScreen, { value, destination }) })
|
|
2059
|
+
/* @__PURE__ */ jsx(DismissContext.Provider, { value: pop, children: /* @__PURE__ */ jsx(ScreenDepthContext.Provider, { value: index + 1, children: /* @__PURE__ */ jsx(PathScreen, { value, destination }) }) })
|
|
1985
2060
|
) }, index + 1)
|
|
1986
2061
|
);
|
|
1987
2062
|
});
|