@swiftbrowser/native 0.26.4 → 0.26.5
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/run.d.ts.map +1 -1
- package/dist/run.js +3 -0
- package/dist/run.js.map +1 -1
- package/package.json +3 -3
- package/src/run.ts +4 -0
- package/swift/Sources/SwiftBrowserNative/Views/Conversions.swift +35 -0
- package/swift/Sources/SwiftBrowserNative/Views/Kinds/Lists.swift +4 -1
- package/swift/Sources/SwiftBrowserNative/Views/Kinds/Navigation.swift +10 -0
- package/swift/Sources/SwiftBrowserProtocol/Props.swift +3 -0
- package/wasm/SwiftBrowserNative.wasm +2 -2
package/dist/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAA4D,KAAK,WAAW,EAA6B,MAAM,qBAAqB,CAAC;AAC5I,OAAO,KAAK,EAAM,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAI3D,MAAM,WAAW,UAAU;IACzB,wEAAwE;IACxE,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,sFAAsF;IACtF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,WAAW,CAAC;IAClB,wDAAwD;IACxD,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAAC;IAC9C,OAAO,IAAI,IAAI,CAAC;CACjB;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAA4D,KAAK,WAAW,EAA6B,MAAM,qBAAqB,CAAC;AAC5I,OAAO,KAAK,EAAM,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAI3D,MAAM,WAAW,UAAU;IACzB,wEAAwE;IACxE,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,sFAAsF;IACtF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,WAAW,CAAC;IAClB,wDAAwD;IACxD,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAAC;IAC9C,OAAO,IAAI,IAAI,CAAC;CACjB;AAeD,wBAAgB,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,GAAE,UAAe,GAAG,OAAO,CA6EzE"}
|
package/dist/run.js
CHANGED
|
@@ -69,6 +69,9 @@ export function run(element, options = {}) {
|
|
|
69
69
|
next.horizontalSizeClass = fields.horizontalSizeClass;
|
|
70
70
|
if (fields.scenePhase)
|
|
71
71
|
next.scenePhase = fields.scenePhase;
|
|
72
|
+
// Without this the tree's `usePlatform` said `ios` on a Mac.
|
|
73
|
+
if (fields.platform === 'ios' || fields.platform === 'macos')
|
|
74
|
+
next.platform = fields.platform;
|
|
72
75
|
if (Object.keys(next).length > 0)
|
|
73
76
|
root.setEnvironment(next);
|
|
74
77
|
return;
|
package/dist/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAiE,MAAM,qBAAqB,CAAC;AAG5I,OAAO,EAAE,kBAAkB,EAAE,MAAM,oC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J,QAAQ;QACR,OAAO;YACL,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,QAAQ;gBAAE,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YAClD,IAAI,CAAC,CAAC,cAAc,CAAC;gBAAE,OAAO,CAAC,CAAC,cAAc,CAAC,CAAC;YAChD,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;KACF,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swiftbrowser/native",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Run a @swiftbrowser/react app natively: the runtime a JavaScriptCore-hosted app needs (timers, console, fetch and the other web globals over the SwiftBrowser Native bridge), the `run` entry that renders into the native SwiftUI renderer, and the bundler that builds app.js for the Xcode target.",
|
|
6
6
|
"repository": {
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@babel/core": "^7.29.7",
|
|
66
|
-
"@swiftbrowser/react": "0.26.
|
|
67
|
-
"@swiftbrowser/web": "0.26.
|
|
66
|
+
"@swiftbrowser/react": "0.26.5",
|
|
67
|
+
"@swiftbrowser/web": "0.26.5",
|
|
68
68
|
"esbuild": "^0.28.2",
|
|
69
69
|
"react-refresh": "^0.17.0"
|
|
70
70
|
},
|
package/src/run.ts
CHANGED
|
@@ -36,6 +36,8 @@ interface EnvironmentFields {
|
|
|
36
36
|
dynamicTypeSize?: string;
|
|
37
37
|
horizontalSizeClass?: 'compact' | 'regular';
|
|
38
38
|
scenePhase?: 'active' | 'inactive' | 'background';
|
|
39
|
+
/** The platform the app is drawn on (docs/notes/macos.md): `ios` or `macos`, from the native root view. */
|
|
40
|
+
platform?: 'ios' | 'macos';
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
/** The running app, when `run` was called (the dev loop calls it again on every save). */
|
|
@@ -91,6 +93,8 @@ export function run(element: ReactNode, options: RunOptions = {}): Running {
|
|
|
91
93
|
if (fields.dynamicTypeSize) next.dynamicTypeSize = fields.dynamicTypeSize as Environment['dynamicTypeSize'];
|
|
92
94
|
if (fields.horizontalSizeClass) next.horizontalSizeClass = fields.horizontalSizeClass;
|
|
93
95
|
if (fields.scenePhase) next.scenePhase = fields.scenePhase;
|
|
96
|
+
// Without this the tree's `usePlatform` said `ios` on a Mac.
|
|
97
|
+
if (fields.platform === 'ios' || fields.platform === 'macos') next.platform = fields.platform;
|
|
94
98
|
if (Object.keys(next).length > 0) root.setEnvironment(next);
|
|
95
99
|
return;
|
|
96
100
|
}
|
|
@@ -4,6 +4,8 @@ import SwiftBrowserProtocol
|
|
|
4
4
|
import SwiftUI
|
|
5
5
|
#if canImport(UIKit)
|
|
6
6
|
import UIKit
|
|
7
|
+
#elseif canImport(AppKit)
|
|
8
|
+
import AppKit
|
|
7
9
|
#endif
|
|
8
10
|
|
|
9
11
|
// The protocol's value types as SwiftUI's. Names are SwiftUI's own (the shim
|
|
@@ -70,6 +72,39 @@ extension Color {
|
|
|
70
72
|
case "systemGray6": return Color(uiColor: .systemGray6)
|
|
71
73
|
default: break
|
|
72
74
|
}
|
|
75
|
+
#elseif canImport(AppKit)
|
|
76
|
+
// AppKit has no UIKit system colors: each is its light and dark value,
|
|
77
|
+
// as the web renderer's Mac idiom draws it (the window, grouped and
|
|
78
|
+
// grouped cell backgrounds white and #1e1e1e there; the rest iOS's).
|
|
79
|
+
func dynamic(_ light: UInt32, _ dark: UInt32, _ lightAlpha: Double = 1, _ darkAlpha: Double = 1) -> Color {
|
|
80
|
+
func rgb(_ hex: UInt32, _ alpha: Double) -> NSColor {
|
|
81
|
+
NSColor(srgbRed: CGFloat((hex >> 16) & 0xff) / 255, green: CGFloat((hex >> 8) & 0xff) / 255, blue: CGFloat(hex & 0xff) / 255, alpha: alpha)
|
|
82
|
+
}
|
|
83
|
+
return Color(nsColor: NSColor(name: nil) { appearance in
|
|
84
|
+
appearance.bestMatch(from: [.aqua, .darkAqua]) == .darkAqua ? rgb(dark, darkAlpha) : rgb(light, lightAlpha)
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
switch name {
|
|
88
|
+
case "systemBackground", "systemGroupedBackground", "secondarySystemGroupedBackground": return dynamic(0xffffff, 0x1e1e1e)
|
|
89
|
+
case "secondarySystemBackground": return dynamic(0xf2f2f7, 0x1c1c1e)
|
|
90
|
+
case "tertiarySystemGroupedBackground": return dynamic(0xf2f2f7, 0x2c2c2e)
|
|
91
|
+
case "tertiarySystemBackground": return dynamic(0xffffff, 0x2c2c2e)
|
|
92
|
+
case "tertiaryLabel": return dynamic(0x3c3c43, 0xebebf5, 0.3, 0.3)
|
|
93
|
+
case "quaternaryLabel": return dynamic(0x3c3c43, 0xebebf5, 0.18, 0.16)
|
|
94
|
+
case "placeholderText": return dynamic(0x3c3c43, 0xebebf5, 0.3, 0.3)
|
|
95
|
+
case "separator": return dynamic(0x3c3c43, 0x545458, 0.29, 0.6)
|
|
96
|
+
case "opaqueSeparator": return dynamic(0xc6c6c8, 0x38383a)
|
|
97
|
+
case "systemFill": return dynamic(0x787880, 0x787880, 0.2, 0.36)
|
|
98
|
+
case "secondarySystemFill": return dynamic(0x787880, 0x787880, 0.16, 0.32)
|
|
99
|
+
case "tertiarySystemFill": return dynamic(0x767680, 0x767680, 0.12, 0.24)
|
|
100
|
+
case "quaternarySystemFill": return dynamic(0x747480, 0x767680, 0.08, 0.18)
|
|
101
|
+
case "systemGray2": return dynamic(0xaeaeb2, 0x636366)
|
|
102
|
+
case "systemGray3": return dynamic(0xc7c7cc, 0x48484a)
|
|
103
|
+
case "systemGray4": return dynamic(0xd1d1d6, 0x3a3a3c)
|
|
104
|
+
case "systemGray5": return dynamic(0xe5e5ea, 0x2c2c2e)
|
|
105
|
+
case "systemGray6": return dynamic(0xf2f2f7, 0x1c1c1e)
|
|
106
|
+
default: break
|
|
107
|
+
}
|
|
73
108
|
#else
|
|
74
109
|
switch name {
|
|
75
110
|
case "systemBackground", "secondarySystemGroupedBackground", "tertiarySystemBackground": return Color(white: 1)
|
|
@@ -31,7 +31,10 @@ struct ListElement: View {
|
|
|
31
31
|
#endif
|
|
32
32
|
}
|
|
33
33
|
}()
|
|
34
|
-
|
|
34
|
+
// `.environment(\.defaultMinListRowHeight, _)` (the list's `minRowHeight`):
|
|
35
|
+
// a Mac app spaces a content list's rows like a sidebar's, 32.
|
|
36
|
+
let sized = props.minRowHeight.map { AnyView(styled.environment(\.defaultMinListRowHeight, CGFloat($0))) } ?? styled
|
|
37
|
+
let refreshable = props.refreshable ? AnyView(sized.refreshable { app?.dispatch(.refresh(node.id)) }) : sized
|
|
35
38
|
#if os(iOS) || canImport(FoundationBridge)
|
|
36
39
|
if let editing = props.editing {
|
|
37
40
|
refreshable.environment(\.editMode, .constant(editing ? .active : .inactive))
|
|
@@ -338,6 +338,15 @@ struct NavigationLinkElement: View {
|
|
|
338
338
|
let inList = Self.isListRow(node)
|
|
339
339
|
let label = Group {
|
|
340
340
|
if inList {
|
|
341
|
+
#if os(macOS)
|
|
342
|
+
// A Mac's link row has no chevron (macOS 26, as the web
|
|
343
|
+
// renderer's Mac idiom draws it).
|
|
344
|
+
HStack(spacing: 0) {
|
|
345
|
+
ChildrenView(node: node)
|
|
346
|
+
Spacer(minLength: 0)
|
|
347
|
+
}
|
|
348
|
+
.contentShape(Rectangle())
|
|
349
|
+
#else
|
|
341
350
|
// The disclosure chevron in the trailing 22 points, as measured
|
|
342
351
|
// against iOS's row: 13 pt semibold, 2 in from the content's edge
|
|
343
352
|
// (the web renderer's LIST_CHEVRON_WIDTH reserves 20).
|
|
@@ -351,6 +360,7 @@ struct NavigationLinkElement: View {
|
|
|
351
360
|
.padding(.trailing, 2)
|
|
352
361
|
}
|
|
353
362
|
.contentShape(Rectangle())
|
|
363
|
+
#endif
|
|
354
364
|
} else {
|
|
355
365
|
ChildrenView(node: node)
|
|
356
366
|
}
|
|
@@ -177,12 +177,15 @@ public struct ListProps: Equatable, Sendable {
|
|
|
177
177
|
public var multiSelect: Bool
|
|
178
178
|
/// A `Form`: drawn as one (on a Mac, the columns style).
|
|
179
179
|
public var form: Bool
|
|
180
|
+
/// `.environment(\.defaultMinListRowHeight, _)`: the rows at least this tall (a Mac app's content list, 32).
|
|
181
|
+
public var minRowHeight: Double?
|
|
180
182
|
public init(props: JSONObject) {
|
|
181
183
|
style = props.string("style") ?? "insetGrouped"
|
|
182
184
|
refreshable = props.bool("refreshable") ?? false
|
|
183
185
|
editing = props.bool("editing")
|
|
184
186
|
multiSelect = props.bool("multiSelect") ?? false
|
|
185
187
|
form = props.bool("form") ?? false
|
|
188
|
+
minRowHeight = props.double("minRowHeight")
|
|
186
189
|
}
|
|
187
190
|
}
|
|
188
191
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/wasm/SwiftBrowserNative.wasm
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 50289339 bytes
|
|
4
|
+
sha256: 5249606957c30e9c98f3a1f3d51c42b6ae48bfb960b166de7cf8e42a6cfa9cb2
|