@swiftbrowser/react 0.26.1 → 0.26.3
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 +25 -5
- 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/environment.d.ts +16 -1
- package/dist/environment.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 +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +136 -28
- package/dist/index.js.map +1 -1
- package/dist/modifiers.d.ts +5 -2
- package/dist/modifiers.d.ts.map +1 -1
- package/dist/mount.d.ts +27 -2
- package/dist/mount.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -42,10 +42,10 @@ One command lays out an app that runs the same code on iOS and the web:
|
|
|
42
42
|
npx @swiftbrowser/cli native init MyApp
|
|
43
43
|
cd MyApp && npm install
|
|
44
44
|
npm run dev:web # the app as a web page, at http://localhost:5175/
|
|
45
|
-
npm run build #
|
|
45
|
+
npm run build # apple/app.js, the bundle MyApp.xcodeproj runs natively (iOS and macOS)
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
The app is `src/App.tsx`, beside `
|
|
48
|
+
The app is `src/App.tsx`, beside `apple/` (the Xcode target's folder: the
|
|
49
49
|
App file, the asset catalog and the bundle), `web/` and `MyApp.xcodeproj`,
|
|
50
50
|
as React Native lays its shells out. `src/index.tsx` is the iOS entry (`run(<App />)`
|
|
51
51
|
in a [SwiftBrowser Native](https://github.com/noya-app/SwiftBrowser/blob/main/Native/README.md)
|
|
@@ -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`,
|
|
@@ -417,6 +419,17 @@ titles when regular and the first column when compact.
|
|
|
417
419
|
/>
|
|
418
420
|
```
|
|
419
421
|
|
|
422
|
+
### Platform
|
|
423
|
+
|
|
424
|
+
`usePlatform()` is `ios` or `macos`: the platform the app is drawn as. A
|
|
425
|
+
page decides it from the browser unless `mount`'s `platform` option says
|
|
426
|
+
(`auto`, the default, is `macos` for a fine pointer that can hover at the
|
|
427
|
+
regular width, iOS otherwise); a preview page's device picker sets it from
|
|
428
|
+
the device chosen (a Mac window is `macos`); the native app sends the OS it
|
|
429
|
+
runs on. The views adapt on their own as SwiftUI's do; read it for a layout
|
|
430
|
+
that differs between a phone and a Mac beyond what the size class says. The
|
|
431
|
+
Mac idiom the web renderer draws is being built (docs/notes/macos.md).
|
|
432
|
+
|
|
420
433
|
### Scene phase
|
|
421
434
|
|
|
422
435
|
`useScenePhase()` is `@Environment(\.scenePhase)`: `active` while the app is
|
|
@@ -1027,7 +1040,13 @@ the swipe, a tap on an earlier screen in the bar) pops the child's path to
|
|
|
1027
1040
|
the same place. The host's path holds the child's screens as pushed views,
|
|
1028
1041
|
so a bound `path` sees them; a screen the host pushes over them stays until
|
|
1029
1042
|
the child's stack moves. Outside a host stack the child's stack is drawn as
|
|
1030
|
-
its own.
|
|
1043
|
+
its own. A pushed value that is plain data (strings, numbers, booleans,
|
|
1044
|
+
arrays and plain objects) is the screen's `route`, on its host path value
|
|
1045
|
+
(`PushedScreen.route`), so the host can name the child's screens (in a
|
|
1046
|
+
URL), and `<RemoteTree initialPath={routes} />` opens them again: the
|
|
1047
|
+
child's stack is set to those values once it shows (a `setpath` event), and
|
|
1048
|
+
its destinations build the screens, as SwiftUI's `NavigationPath` of
|
|
1049
|
+
`Codable` values is restored. Only the child's first stack is mapped (one in a sheet presents in
|
|
1031
1050
|
the sheet), and not yet: `NavigationSplitView` in the child, `Host` elements
|
|
1032
1051
|
(their DOM lives in the child's page, which has none here), and the ops a
|
|
1033
1052
|
loader answers (`request`, `swiftdata`, `defaults`).
|
|
@@ -1037,7 +1056,8 @@ loader answers (`request`, `swiftdata`, `defaults`).
|
|
|
1037
1056
|
- `src/host/`: a [react-reconciler](https://www.npmjs.com/package/react-reconciler)
|
|
1038
1057
|
host whose instances are protocol elements. After each React commit,
|
|
1039
1058
|
`HostTree.flush` resolves two virtual kinds (a *preference* merges props
|
|
1040
|
-
into the enclosing `navscreen` or `sheet
|
|
1059
|
+
into the enclosing `navscreen` or `sheet`, in tree order, and a view's own
|
|
1060
|
+
preferences come before its content, so the innermost wins; a *hoist* moves children to the
|
|
1041
1061
|
enclosing screen or to the root, as `.toolbar`, `.sheet` and `.alert` do),
|
|
1042
1062
|
diffs the result against the last pass and emits one render pass: creates,
|
|
1043
1063
|
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,UAAU,CAAC;IAClB,8BAA8B;IAC9B,MAAM,C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Ae,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/environment.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* below it (`.buttonStyle`, `.controlSize`…), and the device environment the
|
|
4
4
|
* page sets (color scheme, Dynamic Type size, size class, scene phase).
|
|
5
5
|
*/
|
|
6
|
-
import type { ButtonStyle, ColorScheme, DynamicTypeSize, PickerStyle, ScenePhase, ToggleStyle } from '@swiftbrowser/web/src/protocol';
|
|
6
|
+
import type { ButtonStyle, ColorScheme, DynamicTypeSize, PickerStyle, Platform, ScenePhase, ToggleStyle } from '@swiftbrowser/web/src/protocol';
|
|
7
7
|
import { type ReactNode } from 'react';
|
|
8
8
|
export type ControlSize = 'mini' | 'small' | 'regular' | 'large' | 'extraLarge';
|
|
9
9
|
/** `.symbolRenderingMode(_:)`: `palette` draws a symbol's layers in the foreground styles' levels. */
|
|
@@ -47,6 +47,7 @@ export declare function useViewEnvironment(): ViewEnvironment;
|
|
|
47
47
|
/** Wrap `children` in an environment with `values` added. */
|
|
48
48
|
export declare function withEnvironment(values: ViewEnvironment, children: ReactNode): ReactNode;
|
|
49
49
|
export type HorizontalSizeClass = 'compact' | 'regular';
|
|
50
|
+
export type { Platform };
|
|
50
51
|
export interface Environment {
|
|
51
52
|
colorScheme: ColorScheme;
|
|
52
53
|
dynamicTypeSize: DynamicTypeSize;
|
|
@@ -59,6 +60,13 @@ export interface Environment {
|
|
|
59
60
|
* tab, an app the viewer left). `active` where nothing says otherwise.
|
|
60
61
|
*/
|
|
61
62
|
scenePhase: ScenePhase;
|
|
63
|
+
/**
|
|
64
|
+
* The platform the app is drawn as (docs/notes/macos.md): `ios` (the
|
|
65
|
+
* default) or `macos`. The renderer draws that platform's idiom; a page
|
|
66
|
+
* decides it from the browser (`mount`'s `platform`), a native app from
|
|
67
|
+
* the OS it runs on. Fixed for the app's life.
|
|
68
|
+
*/
|
|
69
|
+
platform: Platform;
|
|
62
70
|
}
|
|
63
71
|
export type { ScenePhase };
|
|
64
72
|
export declare const EnvironmentContext: import("react").Context<Environment>;
|
|
@@ -81,6 +89,13 @@ export declare function useHorizontalSizeClass(): HorizontalSizeClass;
|
|
|
81
89
|
* app follows its scene. Refresh what time moved on when it turns `active`.
|
|
82
90
|
*/
|
|
83
91
|
export declare function useScenePhase(): ScenePhase;
|
|
92
|
+
/**
|
|
93
|
+
* The platform the app is drawn as, `ios` or `macos` (docs/notes/macos.md):
|
|
94
|
+
* for a layout that differs between a phone and a Mac beyond what the size
|
|
95
|
+
* class says (a toolbar's placement, a window's columns). The views adapt
|
|
96
|
+
* on their own, as SwiftUI's do.
|
|
97
|
+
*/
|
|
98
|
+
export declare function usePlatform(): Platform;
|
|
84
99
|
/** `@Environment(\.redactionReasons)`: whether the views below are placeholders. */
|
|
85
100
|
export declare function useRedacted(): boolean;
|
|
86
101
|
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAChJ,OAAO,EAA4C,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;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mE;AACnE,eAAO,MAAM,cAAc,iCAAwB,IAAI,SAAe,CAAC;AAEvE,wBAAgB,UAAU,IAAI,MAAM,IAAI,CAGvC;AAED,4CAA4C;AAC5C,wBAAgB,sBAAsB,IAAI,mBAAmB,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAE1C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAEtC;AAED,oFAAoF;AACpF,wBAAgB,WAAW,IAAI,OAAO,CAErC"}
|
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,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AK,EAAE,SAAS,GAAG,QAAQ;IAgB1C,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,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,14 +5,14 @@
|
|
|
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';
|
|
12
12
|
export { useContextBridge } from './bridge';
|
|
13
13
|
export type { Binding, BindingValue } from './binding';
|
|
14
14
|
export { readBinding } from './binding';
|
|
15
|
-
export { useColorScheme, useDynamicTypeSize, useHorizontalSizeClass, useScenePhase, useRedacted, type HorizontalSizeClass, type ScenePhase, useDismiss, useViewEnvironment, type ControlSize, type SymbolRenderingMode, type KeyboardType, type TextContentType, type TextInputHints, type Environment, type ViewEnvironment, } from './environment';
|
|
15
|
+
export { useColorScheme, useDynamicTypeSize, useHorizontalSizeClass, useScenePhase, usePlatform, useRedacted, type HorizontalSizeClass, type ScenePhase, type Platform, useDismiss, useViewEnvironment, type ControlSize, type SymbolRenderingMode, type KeyboardType, type TextContentType, type TextInputHints, type Environment, type ViewEnvironment, } from './environment';
|
|
16
16
|
export { useNavigation } from './navigation-context';
|
|
17
17
|
export type { ViewModifiers, ForegroundLayers, BackgroundValue, SearchableModifier, ToolbarItemPlacementName, ToolbarRole, Visibility, CoordinateSpaceValue, DragGestureModifier, DragValue, GestureValue, TapGestureModifier, MagnifyGestureModifier, RotateGestureModifier, PinchValue, TouchPoint, TouchesPhase, TouchesHandler, SwipeActionsModifier, AlignmentGuideName, DropDestinationModifier, InspectorModifier, ContainerAxes, ContainerRelativeFrameValue, } from './modifiers';
|
|
18
18
|
export { VisualEffect, type ScrollTransitionClosure, type ScrollTransitionPhase, type ScrollTransitionSpec, type VisualEffectClosure, } from './visualEffect';
|
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,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;
|
|
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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AE,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -33,7 +33,8 @@ const EnvironmentContext = createContext({
|
|
|
33
33
|
colorScheme: "light",
|
|
34
34
|
dynamicTypeSize: "large",
|
|
35
35
|
horizontalSizeClass: "compact",
|
|
36
|
-
scenePhase: "active"
|
|
36
|
+
scenePhase: "active",
|
|
37
|
+
platform: "ios"
|
|
37
38
|
});
|
|
38
39
|
function EnvironmentProvider({ value, children }) {
|
|
39
40
|
return createElement(EnvironmentContext.Provider, { value }, children);
|
|
@@ -56,6 +57,9 @@ function useHorizontalSizeClass() {
|
|
|
56
57
|
function useScenePhase() {
|
|
57
58
|
return useContext(EnvironmentContext).scenePhase;
|
|
58
59
|
}
|
|
60
|
+
function usePlatform() {
|
|
61
|
+
return useContext(EnvironmentContext).platform;
|
|
62
|
+
}
|
|
59
63
|
function useRedacted() {
|
|
60
64
|
return useContext(ViewEnvironmentContext).redacted === true;
|
|
61
65
|
}
|
|
@@ -229,6 +233,10 @@ class HostTree {
|
|
|
229
233
|
committedColorScheme;
|
|
230
234
|
/** Remote: the root's props last sent. */
|
|
231
235
|
committedRootProps = {};
|
|
236
|
+
/** Whether another tree draws this one (`createSwiftUIRoot(sink, { remote: true })`, for a `RemoteTree`). */
|
|
237
|
+
get remote() {
|
|
238
|
+
return this.options.remote === true;
|
|
239
|
+
}
|
|
232
240
|
createInstance(props) {
|
|
233
241
|
return {
|
|
234
242
|
id: this.nextId++,
|
|
@@ -414,7 +422,7 @@ function deepEqual(a, b) {
|
|
|
414
422
|
if (keys.length !== Object.keys(right).length) return false;
|
|
415
423
|
return keys.every((key) => key in right && deepEqual(left[key], right[key]));
|
|
416
424
|
}
|
|
417
|
-
const DEFAULT_ENVIRONMENT = { colorScheme: "light", dynamicTypeSize: "large", horizontalSizeClass: "compact", scenePhase: "active" };
|
|
425
|
+
const DEFAULT_ENVIRONMENT = { colorScheme: "light", dynamicTypeSize: "large", horizontalSizeClass: "compact", scenePhase: "active", platform: "ios" };
|
|
418
426
|
const roots = /* @__PURE__ */ new Set();
|
|
419
427
|
const HostTreeContext = createContext(null);
|
|
420
428
|
function createSwiftUIRoot(sink, options = {}) {
|
|
@@ -701,7 +709,7 @@ function RemoteScreen({ root, id }) {
|
|
|
701
709
|
if (!screen?.parent) return null;
|
|
702
710
|
return renderScreen(root, screen, findStack(root.root));
|
|
703
711
|
}
|
|
704
|
-
function RemoteTree({ root }) {
|
|
712
|
+
function RemoteTree({ root, initialPath }) {
|
|
705
713
|
useSyncExternalStore(root.subscribe, root.getVersion, root.getVersion);
|
|
706
714
|
const environment = useContext(EnvironmentContext);
|
|
707
715
|
const tree = useContext(HostTreeContext);
|
|
@@ -719,25 +727,35 @@ function RemoteTree({ root }) {
|
|
|
719
727
|
const values = useRef(/* @__PURE__ */ new Map());
|
|
720
728
|
const ours = useRef(/* @__PURE__ */ new WeakSet());
|
|
721
729
|
const lastPushed = useRef([]);
|
|
722
|
-
const
|
|
723
|
-
|
|
730
|
+
const keyOf2 = (screen) => `${screen.id}:${JSON.stringify(screen.props["route"] ?? null)}`;
|
|
731
|
+
const valueFor = (screen) => {
|
|
732
|
+
const key = keyOf2(screen);
|
|
733
|
+
let value = values.current.get(key);
|
|
724
734
|
if (!value) {
|
|
725
|
-
value = { view: /* @__PURE__ */ jsx(RemoteScreen, { root, id }) };
|
|
726
|
-
values.current.set(
|
|
735
|
+
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 }) };
|
|
736
|
+
values.current.set(key, value);
|
|
727
737
|
ours.current.add(value);
|
|
728
738
|
}
|
|
729
739
|
return value;
|
|
730
740
|
};
|
|
741
|
+
const restored = useRef(false);
|
|
742
|
+
useLayoutEffect(() => {
|
|
743
|
+
if (restored.current) return;
|
|
744
|
+
const childStack = findStack(root.root);
|
|
745
|
+
if (!childStack) return;
|
|
746
|
+
restored.current = true;
|
|
747
|
+
if (initialPath?.length && screensOf(childStack).length === 1) root.dispatch({ type: "setpath", id: childStack.id, path: [...initialPath] });
|
|
748
|
+
});
|
|
731
749
|
useLayoutEffect(() => {
|
|
732
750
|
if (!navigation) return;
|
|
733
|
-
const
|
|
734
|
-
const wanted =
|
|
735
|
-
for (const
|
|
751
|
+
const keys = pushed.map(keyOf2);
|
|
752
|
+
const wanted = pushed.map(valueFor);
|
|
753
|
+
for (const key of values.current.keys()) if (!keys.includes(key)) values.current.delete(key);
|
|
736
754
|
const tail = navigation.path.slice(depth);
|
|
737
755
|
let shown = 0;
|
|
738
756
|
while (shown < tail.length && typeof tail[shown] === "object" && tail[shown] !== null && ours.current.has(tail[shown])) shown += 1;
|
|
739
|
-
const childMoved =
|
|
740
|
-
lastPushed.current =
|
|
757
|
+
const childMoved = keys.length !== lastPushed.current.length || keys.some((key, i) => key !== lastPushed.current[i]);
|
|
758
|
+
lastPushed.current = keys;
|
|
741
759
|
if (!childMoved && shown < wanted.length && tail.slice(0, shown).every((value, i) => value === wanted[i])) {
|
|
742
760
|
root.dispatch({ type: "tap", id: pushed[shown].id });
|
|
743
761
|
return;
|
|
@@ -918,25 +936,33 @@ function measureText(text, font$1 = "body", width) {
|
|
|
918
936
|
const constrained = typeof width === "number" && Number.isFinite(width) && width > 0 ? width : null;
|
|
919
937
|
return installed(text, font(font$1), constrained);
|
|
920
938
|
}
|
|
939
|
+
function decidePlatform(width, media = matchesMedia) {
|
|
940
|
+
return horizontalSizeClassFor(width) === "regular" && media("(hover: hover) and (pointer: fine)") ? "macos" : "ios";
|
|
941
|
+
}
|
|
942
|
+
function matchesMedia(query) {
|
|
943
|
+
return typeof matchMedia === "function" && matchMedia(query).matches;
|
|
944
|
+
}
|
|
921
945
|
function mount(screen, element, options = {}) {
|
|
922
946
|
let renderer = null;
|
|
923
947
|
const root = createSwiftUIRoot((ops) => renderer?.applyOps(ops));
|
|
924
948
|
renderer = new Renderer(screen, (event) => root.dispatch(event));
|
|
925
949
|
renderer.fileDrops = "reference";
|
|
926
|
-
const measurer = (text, font2,
|
|
950
|
+
const measurer = (text, font2, width2) => renderer.measureText(text, font2, width2);
|
|
927
951
|
installTextMeasurer(measurer);
|
|
928
952
|
let pageScheme = options.colorScheme ?? "light";
|
|
929
953
|
let preferred = null;
|
|
954
|
+
const width = screen.clientWidth || 393;
|
|
930
955
|
const environment = {
|
|
931
956
|
colorScheme: pageScheme,
|
|
932
957
|
dynamicTypeSize: options.dynamicTypeSize ?? "large",
|
|
933
|
-
horizontalSizeClass: horizontalSizeClassFor(
|
|
934
|
-
scenePhase: typeof document !== "undefined" ? currentScenePhase() : "active"
|
|
958
|
+
horizontalSizeClass: horizontalSizeClassFor(width),
|
|
959
|
+
scenePhase: typeof document !== "undefined" ? currentScenePhase() : "active",
|
|
960
|
+
platform: options.platform === void 0 || options.platform === "auto" ? decidePlatform(width) : options.platform
|
|
935
961
|
};
|
|
936
962
|
renderer.contentHeight = options.contentHeight ?? false;
|
|
937
963
|
if (options.assets) renderer.setAssetCatalog(options.assets);
|
|
938
964
|
if (options.app) browserEnvironment.files?.setApp?.(options.app);
|
|
939
|
-
renderer.setEnvironment({ colorScheme: environment.colorScheme, dynamicTypeSize: environment.dynamicTypeSize });
|
|
965
|
+
renderer.setEnvironment({ colorScheme: environment.colorScheme, dynamicTypeSize: environment.dynamicTypeSize, platform: environment.platform });
|
|
940
966
|
if (options.safeArea !== void 0) renderer.setSafeArea(options.safeArea);
|
|
941
967
|
root.setEnvironment(environment);
|
|
942
968
|
const browserHistory = (options.history ?? true) && typeof window !== "undefined" ? new BrowserHistory(renderer, screen) : null;
|
|
@@ -974,6 +1000,12 @@ function mount(screen, element, options = {}) {
|
|
|
974
1000
|
renderer?.setEnvironment({ ...next, colorScheme: scheme });
|
|
975
1001
|
root.setEnvironment({ ...next, colorScheme: scheme });
|
|
976
1002
|
},
|
|
1003
|
+
setSafeArea(insets2) {
|
|
1004
|
+
renderer?.setSafeArea(insets2);
|
|
1005
|
+
},
|
|
1006
|
+
viewportChanged() {
|
|
1007
|
+
renderer?.viewportChanged();
|
|
1008
|
+
},
|
|
977
1009
|
unmount() {
|
|
978
1010
|
observer?.disconnect();
|
|
979
1011
|
stopScenePhase?.();
|
|
@@ -1272,7 +1304,7 @@ function SwiftUIView({
|
|
|
1272
1304
|
mounted.current?.renderer.setSafeArea(insets2);
|
|
1273
1305
|
}, [insetsKey]);
|
|
1274
1306
|
useLayoutEffect(() => {
|
|
1275
|
-
if (device.current) applyTypeSizeVariables(device.current, dynamicTypeSize);
|
|
1307
|
+
if (device.current) applyTypeSizeVariables(device.current, dynamicTypeSize, mounted.current?.renderer.platform);
|
|
1276
1308
|
mounted.current?.setEnvironment({ colorScheme, dynamicTypeSize });
|
|
1277
1309
|
}, [colorScheme, dynamicTypeSize]);
|
|
1278
1310
|
const classes = ["device", "sb-island", className].filter(Boolean).join(" ");
|
|
@@ -2015,7 +2047,29 @@ function Link(props) {
|
|
|
2015
2047
|
const label = own.title !== void 0 ? /* @__PURE__ */ jsx(Text, { children: own.title }) : own.children;
|
|
2016
2048
|
return applyModifiers(sb("button", { role: null, style: "automatic" }, { tap: () => openURL(own.destination) }, label), modifiers);
|
|
2017
2049
|
}
|
|
2018
|
-
const isPushedView = (value) => typeof value === "object" && value !== null && "view" in value &&
|
|
2050
|
+
const isPushedView = (value) => typeof value === "object" && value !== null && "view" in value && isValidElement(value.view);
|
|
2051
|
+
function routeOf(value, depth = 0) {
|
|
2052
|
+
if (depth > 8) return void 0;
|
|
2053
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return value;
|
|
2054
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : void 0;
|
|
2055
|
+
if (Array.isArray(value)) {
|
|
2056
|
+
const items = value.map((item) => routeOf(item, depth + 1));
|
|
2057
|
+
return items.every((item) => item !== void 0) ? items : void 0;
|
|
2058
|
+
}
|
|
2059
|
+
if (typeof value === "object" && !isPushedView(value)) {
|
|
2060
|
+
const proto = Object.getPrototypeOf(value);
|
|
2061
|
+
if (proto !== Object.prototype && proto !== null) return void 0;
|
|
2062
|
+
const out = {};
|
|
2063
|
+
for (const [key, item] of Object.entries(value)) {
|
|
2064
|
+
if (item === void 0) continue;
|
|
2065
|
+
const plain2 = routeOf(item, depth + 1);
|
|
2066
|
+
if (plain2 === void 0) return void 0;
|
|
2067
|
+
out[key] = plain2;
|
|
2068
|
+
}
|
|
2069
|
+
return out;
|
|
2070
|
+
}
|
|
2071
|
+
return void 0;
|
|
2072
|
+
}
|
|
2019
2073
|
function NavigationStack(props) {
|
|
2020
2074
|
const enclosing = useNavigation();
|
|
2021
2075
|
if (enclosing) return /* @__PURE__ */ jsx(FlattenedStack, { ...props });
|
|
@@ -2033,6 +2087,7 @@ function FlattenedStack(props) {
|
|
|
2033
2087
|
}
|
|
2034
2088
|
function OwnStack(props) {
|
|
2035
2089
|
const { own, modifiers } = splitProps(props);
|
|
2090
|
+
const remote = useContext(HostTreeContext)?.remote ?? false;
|
|
2036
2091
|
const [internalPath, setInternalPath] = useState([]);
|
|
2037
2092
|
const [path, setPath] = own.path !== void 0 ? readBinding(own.path, own.onPathChange) : [internalPath, setInternalPath];
|
|
2038
2093
|
const destination = useRef(null);
|
|
@@ -2051,17 +2106,18 @@ function OwnStack(props) {
|
|
|
2051
2106
|
];
|
|
2052
2107
|
path.forEach((value, index) => {
|
|
2053
2108
|
const pop = () => setPath(path.slice(0, index));
|
|
2109
|
+
const route = remote ? routeOf(value) : void 0;
|
|
2054
2110
|
screens.push(
|
|
2055
2111
|
/* @__PURE__ */ jsx(Fragment, { children: sb(
|
|
2056
2112
|
"navscreen",
|
|
2057
|
-
{ title: "", displayMode: "automatic", depth: index + 1 },
|
|
2113
|
+
{ title: "", displayMode: "automatic", depth: index + 1, ...route === void 0 ? {} : { route } },
|
|
2058
2114
|
{ tap: pop },
|
|
2059
2115
|
/* @__PURE__ */ jsx(DismissContext.Provider, { value: pop, children: /* @__PURE__ */ jsx(ScreenDepthContext.Provider, { value: index + 1, children: /* @__PURE__ */ jsx(PathScreen, { value, destination }) }) })
|
|
2060
2116
|
) }, index + 1)
|
|
2061
2117
|
);
|
|
2062
2118
|
});
|
|
2063
2119
|
return applyModifiers(
|
|
2064
|
-
sb("navstack", {},
|
|
2120
|
+
sb("navstack", {}, { setpath: (event) => setPath(Array.isArray(event.path) ? event.path : []) }, /* @__PURE__ */ jsx(NavigationContext.Provider, { value: context, children: screens })),
|
|
2065
2121
|
modifiers
|
|
2066
2122
|
);
|
|
2067
2123
|
}
|
|
@@ -2672,8 +2728,11 @@ function Searchable({ text, onChange, prompt }) {
|
|
|
2672
2728
|
function applyModifiers(element, modifiers) {
|
|
2673
2729
|
const sides = [];
|
|
2674
2730
|
const node = wrap(element, modifiers, sides);
|
|
2675
|
-
|
|
2731
|
+
const prefs = sides.filter(isPreference);
|
|
2732
|
+
const rest = sides.filter((side) => !isPreference(side));
|
|
2733
|
+
return createElement(Fragment, null, createElement(Fragment, null, ...prefs), node, ...rest);
|
|
2676
2734
|
}
|
|
2735
|
+
const isPreference = (side) => isValidElement(side) && side.props.kind === PREF_KIND;
|
|
2677
2736
|
function wrap(element, modifiers, sides) {
|
|
2678
2737
|
let node = element;
|
|
2679
2738
|
for (const [key, value] of modifiers) {
|
|
@@ -5092,26 +5151,72 @@ ContainerRelativeShape.shape = { kind: "containerRelative", cornerRadius: null }
|
|
|
5092
5151
|
function Shape(props) {
|
|
5093
5152
|
const { own, modifiers } = splitProps(props);
|
|
5094
5153
|
const [size, setSize] = useState(null);
|
|
5154
|
+
const affine = affinePath(own.path);
|
|
5095
5155
|
const shapeProps = {
|
|
5096
5156
|
shape: "path",
|
|
5097
5157
|
cornerRadius: 0,
|
|
5098
5158
|
fill: own.fill !== void 0 ? shapeStyle(own.fill) : null,
|
|
5099
5159
|
// A custom shape's border is its path stroked as is (the shim insets an InsettableShape first).
|
|
5100
5160
|
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
|
|
5161
|
+
reportsSize: affine === null,
|
|
5162
|
+
path: affine === null && size ? own.path({ x: 0, y: 0, width: size.width, height: size.height }).svg() : "",
|
|
5163
|
+
size: affine === null && size || { width: 0, height: 0 }
|
|
5104
5164
|
};
|
|
5165
|
+
if (affine) shapeProps["affinePath"] = affine;
|
|
5105
5166
|
if (own.evenOdd) shapeProps["fillRule"] = "evenodd";
|
|
5106
5167
|
return applyModifiers(
|
|
5107
|
-
sb(
|
|
5108
|
-
|
|
5109
|
-
|
|
5168
|
+
sb(
|
|
5169
|
+
"shape",
|
|
5170
|
+
shapeProps,
|
|
5171
|
+
affine ? void 0 : {
|
|
5172
|
+
geometry: (event) => {
|
|
5173
|
+
if (!size || size.width !== event.width || size.height !== event.height) setSize({ width: event.width, height: event.height });
|
|
5174
|
+
}
|
|
5110
5175
|
}
|
|
5111
|
-
|
|
5176
|
+
),
|
|
5112
5177
|
modifiers
|
|
5113
5178
|
);
|
|
5114
5179
|
}
|
|
5180
|
+
const NUMBER = /(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/;
|
|
5181
|
+
const BASE = 1e3;
|
|
5182
|
+
const CHECKS = [
|
|
5183
|
+
[613, 389],
|
|
5184
|
+
[257, 911],
|
|
5185
|
+
[3, 2]
|
|
5186
|
+
];
|
|
5187
|
+
function affinePath(path) {
|
|
5188
|
+
try {
|
|
5189
|
+
const at = (width2, height2) => path({ x: 0, y: 0, width: width2, height: height2 }).svg().split(NUMBER);
|
|
5190
|
+
const base = at(BASE, BASE);
|
|
5191
|
+
const wider = at(2 * BASE, BASE);
|
|
5192
|
+
const taller = at(BASE, 2 * BASE);
|
|
5193
|
+
const same = (parts) => parts.length === base.length && parts.every((part, i) => i % 2 === 1 || part === base[i]);
|
|
5194
|
+
if (!same(wider) || !same(taller)) return null;
|
|
5195
|
+
const round2 = (n, places) => Math.round(n * 10 ** places) / 10 ** places || 0;
|
|
5196
|
+
const count = (base.length - 1) / 2;
|
|
5197
|
+
const width = [];
|
|
5198
|
+
const height = [];
|
|
5199
|
+
const constant = [];
|
|
5200
|
+
for (let i = 0; i < count; i += 1) {
|
|
5201
|
+
const n = Number(base[2 * i + 1]);
|
|
5202
|
+
width.push(round2((Number(wider[2 * i + 1]) - n) / BASE, 6));
|
|
5203
|
+
height.push(round2((Number(taller[2 * i + 1]) - n) / BASE, 6));
|
|
5204
|
+
constant.push(round2(n - BASE * width[i] - BASE * height[i], 4));
|
|
5205
|
+
}
|
|
5206
|
+
for (const [w, h] of CHECKS) {
|
|
5207
|
+
const parts = at(w, h);
|
|
5208
|
+
if (!same(parts)) return null;
|
|
5209
|
+
for (let i = 0; i < count; i += 1) {
|
|
5210
|
+
if (Math.abs(constant[i] + w * width[i] + h * height[i] - Number(parts[2 * i + 1])) > 0.02) return null;
|
|
5211
|
+
}
|
|
5212
|
+
}
|
|
5213
|
+
const text = base.map((part, i) => i % 2 === 1 ? String(constant[(i - 1) / 2]) : part).join("");
|
|
5214
|
+
if (constant.some((n) => !Number.isFinite(n))) return null;
|
|
5215
|
+
return { path: text, width, height };
|
|
5216
|
+
} catch {
|
|
5217
|
+
return null;
|
|
5218
|
+
}
|
|
5219
|
+
}
|
|
5115
5220
|
function UnevenRoundedRectangle(props) {
|
|
5116
5221
|
const { topLeadingRadius = 0, bottomLeadingRadius = 0, bottomTrailingRadius = 0, topTrailingRadius = 0, trim: _trim, ...rest } = props;
|
|
5117
5222
|
const path = (rect) => {
|
|
@@ -7246,6 +7351,7 @@ export {
|
|
|
7246
7351
|
ViewThatFits,
|
|
7247
7352
|
VisualEffect,
|
|
7248
7353
|
ZStack,
|
|
7354
|
+
affinePath,
|
|
7249
7355
|
answerLayout,
|
|
7250
7356
|
appStorage,
|
|
7251
7357
|
appleCredentialState,
|
|
@@ -7283,6 +7389,7 @@ export {
|
|
|
7283
7389
|
providingScrollSettings,
|
|
7284
7390
|
readBinding,
|
|
7285
7391
|
rgb,
|
|
7392
|
+
routeOf,
|
|
7286
7393
|
samplerZones,
|
|
7287
7394
|
scrollGeometryOf,
|
|
7288
7395
|
shapeStyle,
|
|
@@ -7306,6 +7413,7 @@ export {
|
|
|
7306
7413
|
useHorizontalSizeClass,
|
|
7307
7414
|
useNamespace,
|
|
7308
7415
|
useNavigation,
|
|
7416
|
+
usePlatform,
|
|
7309
7417
|
useRedacted,
|
|
7310
7418
|
useRefreshable,
|
|
7311
7419
|
useReportSplitSelection,
|