@swiftbrowser/react 0.26.2 → 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/dist/mount.d.ts CHANGED
@@ -3,9 +3,10 @@
3
3
  * (the root container, element id 0, inside the device frame or full screen)
4
4
  * drawing a SwiftUI root. The page keeps the device chrome (theme, text size)
5
5
  * and tells both sides through `setEnvironment`; the size class follows the
6
- * root's width and the scene phase the document's visibility and focus.
6
+ * root's width, the scene phase the document's visibility and focus, and the
7
+ * platform (docs/notes/macos.md) the browser, unless the page says.
7
8
  */
8
- import { type ColorScheme, type DynamicTypeSize } from '@swiftbrowser/web/src/protocol';
9
+ import { type ColorScheme, type DynamicTypeSize, type Platform } from '@swiftbrowser/web/src/protocol';
9
10
  import type { AssetCatalog } from '@swiftbrowser/web/src/assets';
10
11
  import { Renderer } from '@swiftbrowser/web/src/renderer';
11
12
  import type { ReactNode } from 'react';
@@ -13,6 +14,14 @@ import { type SwiftUIRoot } from './host/root';
13
14
  export interface MountOptions {
14
15
  colorScheme?: ColorScheme;
15
16
  dynamicTypeSize?: DynamicTypeSize;
17
+ /**
18
+ * The platform the app is drawn as (docs/notes/macos.md): `ios` or
19
+ * `macos`, or `auto` (the default), which is macOS in a browser with a
20
+ * fine pointer that can hover (a desktop) showing the root at 700 CSS px
21
+ * or more, and iOS otherwise. A preview page's device picker
22
+ * (`installDeviceFrame`) sets it afterwards from the device chosen.
23
+ */
24
+ platform?: Platform | 'auto';
16
25
  /** Device mode: the real safe-area insets (frame mode has the iPhone's). */
17
26
  safeArea?: {
18
27
  top: number;
@@ -56,11 +65,27 @@ export interface MountOptions {
56
65
  export interface Mounted {
57
66
  root: SwiftUIRoot;
58
67
  renderer: Renderer;
68
+ /** The device environment, for the renderer and the tree both (the page's theme toggle, a device picker's platform). */
59
69
  setEnvironment(environment: {
60
70
  colorScheme?: ColorScheme;
61
71
  dynamicTypeSize?: DynamicTypeSize;
72
+ platform?: Platform;
62
73
  }): void;
74
+ /** The renderer's (`installDeviceFrame` drives these). */
75
+ setSafeArea(insets: {
76
+ top: number;
77
+ leading: number;
78
+ bottom: number;
79
+ trailing: number;
80
+ } | null): void;
81
+ viewportChanged(): void;
63
82
  unmount(): void;
64
83
  }
84
+ /**
85
+ * The platform `auto` decides for a root `width` CSS px wide: macOS with a
86
+ * fine pointer that hovers (a desktop browser) at the regular width, iOS
87
+ * otherwise. Width alone is no signal: a narrow desktop window is not a phone.
88
+ */
89
+ export declare function decidePlatform(width: number, media?: (query: string) => boolean): Platform;
65
90
  export declare function mount(screen: HTMLElement, element: ReactNode, options?: MountOptions): Mounted;
66
91
  //# sourceMappingURL=mount.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAA0B,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAChH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAIjE,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAE1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAGlE,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,4EAA4E;IAC5E,QAAQ,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACrF,mFAAmF;IACnF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;;;OAGG;IAC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MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACrF,mFAAmF;IACnF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,QAAQ,CAAC;IACnB,wHAAwH;IACxH,cAAc,CAAC,WAAW,EAAE;QAAE,WAAW,CAAC,EAAE,WAAW,CAAC;QAAC,eAAe,CAAC,EAAE,eAAe,CAAC;QAAC,QAAQ,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,IAAI,CAAC;IACzH,0DAA0D;IAC1D,WAAW,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,GAAG,IAAI,CAAC;IACrG,eAAe,IAAI,IAAI,CAAC;IACxB,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAsB,GAAG,QAAQ,CAExG;AAMD,wBAAgB,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAwFlG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swiftbrowser/react",
3
- "version": "0.26.2",
3
+ "version": "0.26.3",
4
4
  "type": "module",
5
5
  "description": "SwiftUI's components for React: a react-reconciler host that emits SwiftBrowser render ops into the @swiftbrowser/web renderer, so a pure React/TypeScript web app gets the same iOS UI as a SwiftUI app in the browser.",
6
6
  "repository": {
@@ -29,7 +29,7 @@
29
29
  "test:unit": "vitest run"
30
30
  },
31
31
  "dependencies": {
32
- "@swiftbrowser/web": "0.26.2"
32
+ "@swiftbrowser/web": "0.26.3"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": "^19.0.0",