@swiftbrowser/react 0.26.1 → 0.26.2
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 +12 -3
- package/dist/components/navigation.d.ts +9 -0
- package/dist/components/navigation.d.ts.map +1 -1
- package/dist/components/remoteTree.d.ts +17 -1
- package/dist/components/remoteTree.d.ts.map +1 -1
- package/dist/components/shapes.d.ts +23 -2
- package/dist/components/shapes.d.ts.map +1 -1
- package/dist/host/tree.d.ts +2 -0
- package/dist/host/tree.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +110 -21
- package/dist/index.js.map +1 -1
- package/dist/modifiers.d.ts +5 -2
- package/dist/modifiers.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -193,7 +193,9 @@ modifiers (`buttonStyle`, `controlSize`, `pickerStyle`, `toggleStyle`, `labelsHi
|
|
|
193
193
|
navigation bar or the bottom bar hidden, as `.toolbar(.hidden, for:)`),
|
|
194
194
|
`statusBarHidden`, `searchable`, `sheet`, `alert`,
|
|
195
195
|
`presentationDetents` and `preferredColorScheme` attach to the enclosing
|
|
196
|
-
screen, sheet or page, as the SwiftUI preferences do
|
|
196
|
+
screen, sheet or page, as the SwiftUI preferences do; where views nested
|
|
197
|
+
in each other set the same one, the innermost wins (a `List`'s
|
|
198
|
+
`navigationTitle` over the one on the `VStack` around it). Effects (`blur`,
|
|
197
199
|
`grayscale`, `saturation`, `brightness`, `contrast`, `hueRotation`,
|
|
198
200
|
`colorInvert`, `colorMultiply`, `blendMode`, `mask`, `rotation3DEffect`),
|
|
199
201
|
layout hints (`aspectRatio`, `scaledToFit`, `position`, `zIndex`,
|
|
@@ -1027,7 +1029,13 @@ the swipe, a tap on an earlier screen in the bar) pops the child's path to
|
|
|
1027
1029
|
the same place. The host's path holds the child's screens as pushed views,
|
|
1028
1030
|
so a bound `path` sees them; a screen the host pushes over them stays until
|
|
1029
1031
|
the child's stack moves. Outside a host stack the child's stack is drawn as
|
|
1030
|
-
its own.
|
|
1032
|
+
its own. A pushed value that is plain data (strings, numbers, booleans,
|
|
1033
|
+
arrays and plain objects) is the screen's `route`, on its host path value
|
|
1034
|
+
(`PushedScreen.route`), so the host can name the child's screens (in a
|
|
1035
|
+
URL), and `<RemoteTree initialPath={routes} />` opens them again: the
|
|
1036
|
+
child's stack is set to those values once it shows (a `setpath` event), and
|
|
1037
|
+
its destinations build the screens, as SwiftUI's `NavigationPath` of
|
|
1038
|
+
`Codable` values is restored. Only the child's first stack is mapped (one in a sheet presents in
|
|
1031
1039
|
the sheet), and not yet: `NavigationSplitView` in the child, `Host` elements
|
|
1032
1040
|
(their DOM lives in the child's page, which has none here), and the ops a
|
|
1033
1041
|
loader answers (`request`, `swiftdata`, `defaults`).
|
|
@@ -1037,7 +1045,8 @@ loader answers (`request`, `swiftdata`, `defaults`).
|
|
|
1037
1045
|
- `src/host/`: a [react-reconciler](https://www.npmjs.com/package/react-reconciler)
|
|
1038
1046
|
host whose instances are protocol elements. After each React commit,
|
|
1039
1047
|
`HostTree.flush` resolves two virtual kinds (a *preference* merges props
|
|
1040
|
-
into the enclosing `navscreen` or `sheet
|
|
1048
|
+
into the enclosing `navscreen` or `sheet`, in tree order, and a view's own
|
|
1049
|
+
preferences come before its content, so the innermost wins; a *hoist* moves children to the
|
|
1041
1050
|
enclosing screen or to the root, as `.toolbar`, `.sheet` and `.alert` do),
|
|
1042
1051
|
diffs the result against the last pass and emits one render pass: creates,
|
|
1043
1052
|
updates, inserts (parents before children), removes, `commit`. Events from
|
|
@@ -9,6 +9,15 @@ export interface NavigationStackProps extends ViewModifiers {
|
|
|
9
9
|
destination?: (value: never) => ReactNode;
|
|
10
10
|
children?: ReactNode;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* A pushed value as plain data (strings, finite numbers, booleans, null, and
|
|
14
|
+
* arrays and plain objects of them), or undefined for anything else (a view,
|
|
15
|
+
* a function, a class instance). In a tree another draws (a remote root), a
|
|
16
|
+
* pushed screen carries it as `route`, so the tree that hosts it (`RemoteTree`) can name the screen, in a URL
|
|
17
|
+
* say, and set the path back from it (`setpath`), as SwiftUI's
|
|
18
|
+
* `NavigationPath` of `Codable` values can be saved and restored.
|
|
19
|
+
*/
|
|
20
|
+
export declare function routeOf(value: unknown, depth?: number): unknown;
|
|
12
21
|
export declare function NavigationStack(props: NavigationStackProps): ReactNode;
|
|
13
22
|
export interface NavigationLinkProps extends ViewModifiers {
|
|
14
23
|
title?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/components/navigation.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/components/navigation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0D,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/F,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAI5D,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;AASD;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAAI,GAAG,OAAO,CAqB1D;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,SAAS,CAMtE;AAiED,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"}
|
|
@@ -21,6 +21,22 @@ import { type ReactNode } from 'react';
|
|
|
21
21
|
import type { RemoteRoot } from '../host/remote';
|
|
22
22
|
export interface RemoteTreeProps {
|
|
23
23
|
root: RemoteRoot;
|
|
24
|
+
/**
|
|
25
|
+
* The child's stack's path to open with, as its screens' `route`s name it
|
|
26
|
+
* (a link to one of the child's screens): set once, when the child's stack
|
|
27
|
+
* first shows, so the child's destinations build the screens.
|
|
28
|
+
*/
|
|
29
|
+
initialPath?: readonly unknown[];
|
|
24
30
|
}
|
|
25
|
-
|
|
31
|
+
/**
|
|
32
|
+
* A value on the host's path standing for one of the child's screens (a
|
|
33
|
+
* pushed view, as `NavigationLink(destination:)` pushes), with the child's
|
|
34
|
+
* value for it as plain data when it has one (`route`): what the host's
|
|
35
|
+
* URL can name it by, and `initialPath` takes back.
|
|
36
|
+
*/
|
|
37
|
+
export interface PushedScreen {
|
|
38
|
+
view: ReactNode;
|
|
39
|
+
route?: unknown;
|
|
40
|
+
}
|
|
41
|
+
export declare function RemoteTree({ root, initialPath }: RemoteTreeProps): ReactNode;
|
|
26
42
|
//# sourceMappingURL=remoteTree.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;IACjB;;;;OAIG;IACH,WAAW,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;CAClC;AA0DD;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,eAAe,GAAG,SAAS,CA2E5E"}
|
|
@@ -81,10 +81,31 @@ export interface CustomShapeProps extends Omit<ShapeProps, 'trim'> {
|
|
|
81
81
|
evenOdd?: boolean;
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
|
-
* A custom `Shape
|
|
85
|
-
*
|
|
84
|
+
* A custom `Shape`. A path whose every number is affine in the rectangle's
|
|
85
|
+
* size (a point a fraction of the way across, a margin in from an edge) is
|
|
86
|
+
* sent once as that (`affinePath`), and the page draws it at whatever size the
|
|
87
|
+
* shape is laid out at, from its first frame. Any other path waits for the
|
|
88
|
+
* element to report its laid-out size, and is drawn for that size, as the
|
|
89
|
+
* Swift shim does.
|
|
86
90
|
*/
|
|
87
91
|
export declare function Shape(props: CustomShapeProps): ReactNode;
|
|
92
|
+
/**
|
|
93
|
+
* A path as its numbers' parts: SVG path data with each number its value for
|
|
94
|
+
* an empty rectangle, and how much each grows a point of the rectangle's width
|
|
95
|
+
* and of its height.
|
|
96
|
+
*/
|
|
97
|
+
export interface AffinePath {
|
|
98
|
+
path: string;
|
|
99
|
+
width: number[];
|
|
100
|
+
height: number[];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* `path` as an `AffinePath`, or null where it is not one: where its commands
|
|
104
|
+
* change with the size, or a number is not the same straight function of the
|
|
105
|
+
* width and height at every size it is checked at (to the hundredth a point
|
|
106
|
+
* the data is rounded to).
|
|
107
|
+
*/
|
|
108
|
+
export declare function affinePath(path: (rect: CGRect) => Path): AffinePath | null;
|
|
88
109
|
export interface UnevenRoundedRectangleProps extends ShapeProps {
|
|
89
110
|
topLeadingRadius?: number;
|
|
90
111
|
bottomLeadingRadius?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shapes.d.ts","sourceRoot":"","sources":["../../src/components/shapes.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,EAA8C,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAC9F,OAAO,EAAE,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAqB,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAE7F,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IACtC,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,UAAU,CAAC;AAElD,MAAM,WAAW,UAAW,SAAQ,aAAa;IAC/C,qFAAqF;IACrF,IAAI,CAAC,EAAE,UA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AG,SAAS,CAoBpF;AAMD,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,KAAK,EAAE,UAAU,CAAC;CACnB;AAED,yEAAyE;AACzE,iBAAS,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,CAGnD;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK,EAAE,OAAO,SAAS,GAAG,OAAO,WAAmD,CAAC"}
|
package/dist/host/tree.d.ts
CHANGED
|
@@ -43,6 +43,8 @@ export declare class HostTree {
|
|
|
43
43
|
/** Remote: the root's props last sent. */
|
|
44
44
|
private committedRootProps;
|
|
45
45
|
constructor(sink: OpsSink, options?: HostTreeOptions);
|
|
46
|
+
/** Whether another tree draws this one (`createSwiftUIRoot(sink, { remote: true })`, for a `RemoteTree`). */
|
|
47
|
+
get remote(): boolean;
|
|
46
48
|
createInstance(props: HostProps): Instance;
|
|
47
49
|
updateInstance(instance: Instance, next: HostProps): void;
|
|
48
50
|
/** Emit the ops for everything that changed since the last commit. */
|
package/dist/host/tree.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/host/tree.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAY,EAAE,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC7F,OAAO,EAAyB,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAiB,MAAM,YAAY,CAAC;AAEhH,MAAM,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,KAAK,IAAI,CAAC;AAE1C,MAAM,WAAW,eAAe;IAC9B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAqCD,qBAAa,QAAQ;IAmBjB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAnB1B,QAAQ,CAAC,IAAI,EA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E,IAAI,EAAE,SAAS,GAAG,IAAI;IAoBzD,sEAAsE;IACtE,MAAM,IAAI,IAAI;IAKd,KAAK,IAAI,EAAE,EAAE;IAoIb,qEAAqE;IACrE,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAIzC,mEAAmE;IACnE,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;CAgBrC;AAED,+CAA+C;AAC/C,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAazD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { createSwiftUIRoot, injectIntoDevTools, withAnimation, type AnimationCompletionCriteria, type SwiftUIRoot, type SwiftUIRootOptions, type WithAnimationOptions } from './host/root';
|
|
7
7
|
export { createRemoteRoot, type MirrorNode, type RemoteRoot } from './host/remote';
|
|
8
|
-
export { RemoteTree, type RemoteTreeProps } from './components/remoteTree';
|
|
8
|
+
export { RemoteTree, type PushedScreen, type RemoteTreeProps } from './components/remoteTree';
|
|
9
9
|
export type { Op, RendererEvent } from '@swiftbrowser/web/src/protocol';
|
|
10
10
|
export { mount, type MountOptions, type Mounted } from './mount';
|
|
11
11
|
export { SwiftUIView, type SwiftUIViewProps } from './island';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,aAAa,EAAE,KAAK,2BAA2B,EAAE,KAAK,WAAW,EAAE,KAAK,kBAAkB,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC3L,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE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AkB,CAAC;AACtD,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -229,6 +229,10 @@ class HostTree {
|
|
|
229
229
|
committedColorScheme;
|
|
230
230
|
/** Remote: the root's props last sent. */
|
|
231
231
|
committedRootProps = {};
|
|
232
|
+
/** Whether another tree draws this one (`createSwiftUIRoot(sink, { remote: true })`, for a `RemoteTree`). */
|
|
233
|
+
get remote() {
|
|
234
|
+
return this.options.remote === true;
|
|
235
|
+
}
|
|
232
236
|
createInstance(props) {
|
|
233
237
|
return {
|
|
234
238
|
id: this.nextId++,
|
|
@@ -701,7 +705,7 @@ function RemoteScreen({ root, id }) {
|
|
|
701
705
|
if (!screen?.parent) return null;
|
|
702
706
|
return renderScreen(root, screen, findStack(root.root));
|
|
703
707
|
}
|
|
704
|
-
function RemoteTree({ root }) {
|
|
708
|
+
function RemoteTree({ root, initialPath }) {
|
|
705
709
|
useSyncExternalStore(root.subscribe, root.getVersion, root.getVersion);
|
|
706
710
|
const environment = useContext(EnvironmentContext);
|
|
707
711
|
const tree = useContext(HostTreeContext);
|
|
@@ -719,25 +723,35 @@ function RemoteTree({ root }) {
|
|
|
719
723
|
const values = useRef(/* @__PURE__ */ new Map());
|
|
720
724
|
const ours = useRef(/* @__PURE__ */ new WeakSet());
|
|
721
725
|
const lastPushed = useRef([]);
|
|
722
|
-
const
|
|
723
|
-
|
|
726
|
+
const keyOf2 = (screen) => `${screen.id}:${JSON.stringify(screen.props["route"] ?? null)}`;
|
|
727
|
+
const valueFor = (screen) => {
|
|
728
|
+
const key = keyOf2(screen);
|
|
729
|
+
let value = values.current.get(key);
|
|
724
730
|
if (!value) {
|
|
725
|
-
value = { view: /* @__PURE__ */ jsx(RemoteScreen, { root, id }) };
|
|
726
|
-
values.current.set(
|
|
731
|
+
value = "route" in screen.props ? { view: /* @__PURE__ */ jsx(RemoteScreen, { root, id: screen.id }), route: screen.props["route"] } : { view: /* @__PURE__ */ jsx(RemoteScreen, { root, id: screen.id }) };
|
|
732
|
+
values.current.set(key, value);
|
|
727
733
|
ours.current.add(value);
|
|
728
734
|
}
|
|
729
735
|
return value;
|
|
730
736
|
};
|
|
737
|
+
const restored = useRef(false);
|
|
738
|
+
useLayoutEffect(() => {
|
|
739
|
+
if (restored.current) return;
|
|
740
|
+
const childStack = findStack(root.root);
|
|
741
|
+
if (!childStack) return;
|
|
742
|
+
restored.current = true;
|
|
743
|
+
if (initialPath?.length && screensOf(childStack).length === 1) root.dispatch({ type: "setpath", id: childStack.id, path: [...initialPath] });
|
|
744
|
+
});
|
|
731
745
|
useLayoutEffect(() => {
|
|
732
746
|
if (!navigation) return;
|
|
733
|
-
const
|
|
734
|
-
const wanted =
|
|
735
|
-
for (const
|
|
747
|
+
const keys = pushed.map(keyOf2);
|
|
748
|
+
const wanted = pushed.map(valueFor);
|
|
749
|
+
for (const key of values.current.keys()) if (!keys.includes(key)) values.current.delete(key);
|
|
736
750
|
const tail = navigation.path.slice(depth);
|
|
737
751
|
let shown = 0;
|
|
738
752
|
while (shown < tail.length && typeof tail[shown] === "object" && tail[shown] !== null && ours.current.has(tail[shown])) shown += 1;
|
|
739
|
-
const childMoved =
|
|
740
|
-
lastPushed.current =
|
|
753
|
+
const childMoved = keys.length !== lastPushed.current.length || keys.some((key, i) => key !== lastPushed.current[i]);
|
|
754
|
+
lastPushed.current = keys;
|
|
741
755
|
if (!childMoved && shown < wanted.length && tail.slice(0, shown).every((value, i) => value === wanted[i])) {
|
|
742
756
|
root.dispatch({ type: "tap", id: pushed[shown].id });
|
|
743
757
|
return;
|
|
@@ -2015,7 +2029,29 @@ function Link(props) {
|
|
|
2015
2029
|
const label = own.title !== void 0 ? /* @__PURE__ */ jsx(Text, { children: own.title }) : own.children;
|
|
2016
2030
|
return applyModifiers(sb("button", { role: null, style: "automatic" }, { tap: () => openURL(own.destination) }, label), modifiers);
|
|
2017
2031
|
}
|
|
2018
|
-
const isPushedView = (value) => typeof value === "object" && value !== null && "view" in value &&
|
|
2032
|
+
const isPushedView = (value) => typeof value === "object" && value !== null && "view" in value && isValidElement(value.view);
|
|
2033
|
+
function routeOf(value, depth = 0) {
|
|
2034
|
+
if (depth > 8) return void 0;
|
|
2035
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return value;
|
|
2036
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : void 0;
|
|
2037
|
+
if (Array.isArray(value)) {
|
|
2038
|
+
const items = value.map((item) => routeOf(item, depth + 1));
|
|
2039
|
+
return items.every((item) => item !== void 0) ? items : void 0;
|
|
2040
|
+
}
|
|
2041
|
+
if (typeof value === "object" && !isPushedView(value)) {
|
|
2042
|
+
const proto = Object.getPrototypeOf(value);
|
|
2043
|
+
if (proto !== Object.prototype && proto !== null) return void 0;
|
|
2044
|
+
const out = {};
|
|
2045
|
+
for (const [key, item] of Object.entries(value)) {
|
|
2046
|
+
if (item === void 0) continue;
|
|
2047
|
+
const plain2 = routeOf(item, depth + 1);
|
|
2048
|
+
if (plain2 === void 0) return void 0;
|
|
2049
|
+
out[key] = plain2;
|
|
2050
|
+
}
|
|
2051
|
+
return out;
|
|
2052
|
+
}
|
|
2053
|
+
return void 0;
|
|
2054
|
+
}
|
|
2019
2055
|
function NavigationStack(props) {
|
|
2020
2056
|
const enclosing = useNavigation();
|
|
2021
2057
|
if (enclosing) return /* @__PURE__ */ jsx(FlattenedStack, { ...props });
|
|
@@ -2033,6 +2069,7 @@ function FlattenedStack(props) {
|
|
|
2033
2069
|
}
|
|
2034
2070
|
function OwnStack(props) {
|
|
2035
2071
|
const { own, modifiers } = splitProps(props);
|
|
2072
|
+
const remote = useContext(HostTreeContext)?.remote ?? false;
|
|
2036
2073
|
const [internalPath, setInternalPath] = useState([]);
|
|
2037
2074
|
const [path, setPath] = own.path !== void 0 ? readBinding(own.path, own.onPathChange) : [internalPath, setInternalPath];
|
|
2038
2075
|
const destination = useRef(null);
|
|
@@ -2051,17 +2088,18 @@ function OwnStack(props) {
|
|
|
2051
2088
|
];
|
|
2052
2089
|
path.forEach((value, index) => {
|
|
2053
2090
|
const pop = () => setPath(path.slice(0, index));
|
|
2091
|
+
const route = remote ? routeOf(value) : void 0;
|
|
2054
2092
|
screens.push(
|
|
2055
2093
|
/* @__PURE__ */ jsx(Fragment, { children: sb(
|
|
2056
2094
|
"navscreen",
|
|
2057
|
-
{ title: "", displayMode: "automatic", depth: index + 1 },
|
|
2095
|
+
{ title: "", displayMode: "automatic", depth: index + 1, ...route === void 0 ? {} : { route } },
|
|
2058
2096
|
{ tap: pop },
|
|
2059
2097
|
/* @__PURE__ */ jsx(DismissContext.Provider, { value: pop, children: /* @__PURE__ */ jsx(ScreenDepthContext.Provider, { value: index + 1, children: /* @__PURE__ */ jsx(PathScreen, { value, destination }) }) })
|
|
2060
2098
|
) }, index + 1)
|
|
2061
2099
|
);
|
|
2062
2100
|
});
|
|
2063
2101
|
return applyModifiers(
|
|
2064
|
-
sb("navstack", {},
|
|
2102
|
+
sb("navstack", {}, { setpath: (event) => setPath(Array.isArray(event.path) ? event.path : []) }, /* @__PURE__ */ jsx(NavigationContext.Provider, { value: context, children: screens })),
|
|
2065
2103
|
modifiers
|
|
2066
2104
|
);
|
|
2067
2105
|
}
|
|
@@ -2672,8 +2710,11 @@ function Searchable({ text, onChange, prompt }) {
|
|
|
2672
2710
|
function applyModifiers(element, modifiers) {
|
|
2673
2711
|
const sides = [];
|
|
2674
2712
|
const node = wrap(element, modifiers, sides);
|
|
2675
|
-
|
|
2713
|
+
const prefs = sides.filter(isPreference);
|
|
2714
|
+
const rest = sides.filter((side) => !isPreference(side));
|
|
2715
|
+
return createElement(Fragment, null, createElement(Fragment, null, ...prefs), node, ...rest);
|
|
2676
2716
|
}
|
|
2717
|
+
const isPreference = (side) => isValidElement(side) && side.props.kind === PREF_KIND;
|
|
2677
2718
|
function wrap(element, modifiers, sides) {
|
|
2678
2719
|
let node = element;
|
|
2679
2720
|
for (const [key, value] of modifiers) {
|
|
@@ -5092,26 +5133,72 @@ ContainerRelativeShape.shape = { kind: "containerRelative", cornerRadius: null }
|
|
|
5092
5133
|
function Shape(props) {
|
|
5093
5134
|
const { own, modifiers } = splitProps(props);
|
|
5094
5135
|
const [size, setSize] = useState(null);
|
|
5136
|
+
const affine = affinePath(own.path);
|
|
5095
5137
|
const shapeProps = {
|
|
5096
5138
|
shape: "path",
|
|
5097
5139
|
cornerRadius: 0,
|
|
5098
5140
|
fill: own.fill !== void 0 ? shapeStyle(own.fill) : null,
|
|
5099
5141
|
// A custom shape's border is its path stroked as is (the shim insets an InsettableShape first).
|
|
5100
5142
|
stroke: strokeOf(own.strokeBorder ?? own.stroke, false),
|
|
5101
|
-
reportsSize:
|
|
5102
|
-
path: size ? own.path({ x: 0, y: 0, width: size.width, height: size.height }).svg() : "",
|
|
5103
|
-
size: size
|
|
5143
|
+
reportsSize: affine === null,
|
|
5144
|
+
path: affine === null && size ? own.path({ x: 0, y: 0, width: size.width, height: size.height }).svg() : "",
|
|
5145
|
+
size: affine === null && size || { width: 0, height: 0 }
|
|
5104
5146
|
};
|
|
5147
|
+
if (affine) shapeProps["affinePath"] = affine;
|
|
5105
5148
|
if (own.evenOdd) shapeProps["fillRule"] = "evenodd";
|
|
5106
5149
|
return applyModifiers(
|
|
5107
|
-
sb(
|
|
5108
|
-
|
|
5109
|
-
|
|
5150
|
+
sb(
|
|
5151
|
+
"shape",
|
|
5152
|
+
shapeProps,
|
|
5153
|
+
affine ? void 0 : {
|
|
5154
|
+
geometry: (event) => {
|
|
5155
|
+
if (!size || size.width !== event.width || size.height !== event.height) setSize({ width: event.width, height: event.height });
|
|
5156
|
+
}
|
|
5110
5157
|
}
|
|
5111
|
-
|
|
5158
|
+
),
|
|
5112
5159
|
modifiers
|
|
5113
5160
|
);
|
|
5114
5161
|
}
|
|
5162
|
+
const NUMBER = /(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/;
|
|
5163
|
+
const BASE = 1e3;
|
|
5164
|
+
const CHECKS = [
|
|
5165
|
+
[613, 389],
|
|
5166
|
+
[257, 911],
|
|
5167
|
+
[3, 2]
|
|
5168
|
+
];
|
|
5169
|
+
function affinePath(path) {
|
|
5170
|
+
try {
|
|
5171
|
+
const at = (width2, height2) => path({ x: 0, y: 0, width: width2, height: height2 }).svg().split(NUMBER);
|
|
5172
|
+
const base = at(BASE, BASE);
|
|
5173
|
+
const wider = at(2 * BASE, BASE);
|
|
5174
|
+
const taller = at(BASE, 2 * BASE);
|
|
5175
|
+
const same = (parts) => parts.length === base.length && parts.every((part, i) => i % 2 === 1 || part === base[i]);
|
|
5176
|
+
if (!same(wider) || !same(taller)) return null;
|
|
5177
|
+
const round2 = (n, places) => Math.round(n * 10 ** places) / 10 ** places || 0;
|
|
5178
|
+
const count = (base.length - 1) / 2;
|
|
5179
|
+
const width = [];
|
|
5180
|
+
const height = [];
|
|
5181
|
+
const constant = [];
|
|
5182
|
+
for (let i = 0; i < count; i += 1) {
|
|
5183
|
+
const n = Number(base[2 * i + 1]);
|
|
5184
|
+
width.push(round2((Number(wider[2 * i + 1]) - n) / BASE, 6));
|
|
5185
|
+
height.push(round2((Number(taller[2 * i + 1]) - n) / BASE, 6));
|
|
5186
|
+
constant.push(round2(n - BASE * width[i] - BASE * height[i], 4));
|
|
5187
|
+
}
|
|
5188
|
+
for (const [w, h] of CHECKS) {
|
|
5189
|
+
const parts = at(w, h);
|
|
5190
|
+
if (!same(parts)) return null;
|
|
5191
|
+
for (let i = 0; i < count; i += 1) {
|
|
5192
|
+
if (Math.abs(constant[i] + w * width[i] + h * height[i] - Number(parts[2 * i + 1])) > 0.02) return null;
|
|
5193
|
+
}
|
|
5194
|
+
}
|
|
5195
|
+
const text = base.map((part, i) => i % 2 === 1 ? String(constant[(i - 1) / 2]) : part).join("");
|
|
5196
|
+
if (constant.some((n) => !Number.isFinite(n))) return null;
|
|
5197
|
+
return { path: text, width, height };
|
|
5198
|
+
} catch {
|
|
5199
|
+
return null;
|
|
5200
|
+
}
|
|
5201
|
+
}
|
|
5115
5202
|
function UnevenRoundedRectangle(props) {
|
|
5116
5203
|
const { topLeadingRadius = 0, bottomLeadingRadius = 0, bottomTrailingRadius = 0, topTrailingRadius = 0, trim: _trim, ...rest } = props;
|
|
5117
5204
|
const path = (rect) => {
|
|
@@ -7246,6 +7333,7 @@ export {
|
|
|
7246
7333
|
ViewThatFits,
|
|
7247
7334
|
VisualEffect,
|
|
7248
7335
|
ZStack,
|
|
7336
|
+
affinePath,
|
|
7249
7337
|
answerLayout,
|
|
7250
7338
|
appStorage,
|
|
7251
7339
|
appleCredentialState,
|
|
@@ -7283,6 +7371,7 @@ export {
|
|
|
7283
7371
|
providingScrollSettings,
|
|
7284
7372
|
readBinding,
|
|
7285
7373
|
rgb,
|
|
7374
|
+
routeOf,
|
|
7286
7375
|
samplerZones,
|
|
7287
7376
|
scrollGeometryOf,
|
|
7288
7377
|
shapeStyle,
|