@swiftbrowser/web 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/src/typography.ts CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  textStyleSize,
17
17
  type TextStyle,
18
18
  } from './layout/typography';
19
- import type { DynamicTypeSize } from './protocol';
19
+ import type { DynamicTypeSize, Platform } from './protocol';
20
20
 
21
21
  export {
22
22
  DYNAMIC_TYPE_SIZES,
@@ -27,6 +27,7 @@ export {
27
27
  leadingFor,
28
28
  textHeight,
29
29
  TEXT_STYLE_SIZES,
30
+ MAC_TEXT_STYLE_SIZES,
30
31
  defaultFont,
31
32
  lineHeightFor,
32
33
  makeFont,
@@ -49,15 +50,15 @@ export interface ResolvedTextStyle {
49
50
  lineHeight: number;
50
51
  }
51
52
 
52
- /** Point size and line height of `style` at `size`. */
53
- export function resolveTextStyle(style: TextStyle, size: DynamicTypeSize): ResolvedTextStyle {
54
- const fontSize = textStyleSize(style, size);
53
+ /** Point size and line height of `style` at `size` (on the Mac, its one size). */
54
+ export function resolveTextStyle(style: TextStyle, size: DynamicTypeSize, platform: Platform = 'ios'): ResolvedTextStyle {
55
+ const fontSize = textStyleSize(style, size, platform);
55
56
  return { fontSize, lineHeight: lineHeightFor(fontSize) };
56
57
  }
57
58
 
58
- /** Scale factor of `style` at `size` relative to Large (`Font.system(size:relativeTo:)`). */
59
- export function relativeScale(style: TextStyle, size: DynamicTypeSize): number {
60
- return textStyleSize(style, size) / textStyleSize(style, DEFAULT_TYPE_SIZE);
59
+ /** Scale factor of `style` at `size` relative to Large (`Font.system(size:relativeTo:)`); 1 on the Mac. */
60
+ export function relativeScale(style: TextStyle, size: DynamicTypeSize, platform: Platform = 'ios'): number {
61
+ return textStyleSize(style, size, platform) / textStyleSize(style, DEFAULT_TYPE_SIZE, platform);
61
62
  }
62
63
 
63
64
  /** CSS custom property names the renderer reads for a text style. */
@@ -69,11 +70,11 @@ export function textStyleVar(style: TextStyle, metric: 'size' | 'lh'): string {
69
70
  * Write every text style's size and line height for `size` as CSS custom
70
71
  * properties on `target` (the device frame).
71
72
  */
72
- export function applyTypeSizeVariables(target: HTMLElement, size: DynamicTypeSize): void {
73
+ export function applyTypeSizeVariables(target: HTMLElement, size: DynamicTypeSize, platform: Platform = 'ios'): void {
73
74
  for (const style of TEXT_STYLES) {
74
- const { fontSize, lineHeight } = resolveTextStyle(style, size);
75
+ const { fontSize, lineHeight } = resolveTextStyle(style, size, platform);
75
76
  target.style.setProperty(textStyleVar(style, 'size'), `${fontSize}px`);
76
77
  target.style.setProperty(textStyleVar(style, 'lh'), `${Math.round(lineHeight * 100) / 100}px`);
77
- target.style.setProperty(`--sb-ts-${style}-scale`, String(relativeScale(style, size)));
78
+ target.style.setProperty(`--sb-ts-${style}-scale`, String(relativeScale(style, size, platform)));
78
79
  }
79
80
  }
package/src/vite-env.d.ts CHANGED
@@ -22,6 +22,8 @@ interface SBLandingApp {
22
22
  webPushKey?: string;
23
23
  /** Hosts the app's requests may not reach (src/blockedHosts.ts). */
24
24
  blockedHosts?: string[];
25
+ /** The platform the app was built for (`--platform`, docs/notes/macos.md); iOS when absent. */
26
+ platform?: 'ios' | 'macos';
25
27
  }
26
28
 
27
29
  /** The registered apps, in registry order. */