-
Notifications
You must be signed in to change notification settings - Fork 41
feat: categorize constants and expose layout SDK via SuperIsland.constants #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -140,6 +140,7 @@ final class ExtensionJSRuntime { | |
| injectSystem(into: superIsland) | ||
| injectFeedback(into: superIsland) | ||
| injectMascot(into: superIsland) | ||
| injectConstants(into: superIsland) | ||
| injectConsole(into: superIsland) | ||
| injectTimers() | ||
| injectViewHelpers() | ||
|
|
@@ -517,6 +518,30 @@ final class ExtensionJSRuntime { | |
| superIsland.setObject(mascot, forKeyedSubscript: "mascot" as NSString) | ||
| } | ||
|
|
||
| /// Exposes read-only layout and sizing constants to extensions so that | ||
| /// content can be sized precisely for each island state without hard-coding | ||
| /// magic numbers. Available as `SuperIsland.constants` in JavaScript. | ||
| private func injectConstants(into superIsland: JSValue) { | ||
| let constants = JSValue(newObjectIn: context)! | ||
|
|
||
| // Layout dimensions (all values in SwiftUI points) | ||
| let layout = JSValue(newObjectIn: context)! | ||
| layout.setObject(Double(Constants.compactSize.width), forKeyedSubscript: "compactWidth" as NSString) | ||
| layout.setObject(Double(Constants.compactSize.height), forKeyedSubscript: "compactHeight" as NSString) | ||
| layout.setObject(Double(Constants.nonNotchCompactSize.width), forKeyedSubscript: "nonNotchCompactWidth" as NSString) | ||
| layout.setObject(Double(Constants.nonNotchCompactSize.height), forKeyedSubscript: "nonNotchCompactHeight" as NSString) | ||
| layout.setObject(Double(Constants.expandedSize.width), forKeyedSubscript: "expandedWidth" as NSString) | ||
| layout.setObject(Double(Constants.expandedSize.height), forKeyedSubscript: "expandedHeight" as NSString) | ||
| layout.setObject(Double(Constants.fullExpandedSize.width), forKeyedSubscript: "fullExpandedWidth" as NSString) | ||
| layout.setObject(Double(Constants.fullExpandedSize.height), forKeyedSubscript: "fullExpandedHeight" as NSString) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||
| layout.setObject(Double(Constants.compactCornerRadius), forKeyedSubscript: "compactCornerRadius" as NSString) | ||
| layout.setObject(Double(Constants.expandedCornerRadius), forKeyedSubscript: "expandedCornerRadius" as NSString) | ||
| layout.setObject(Double(Constants.fullExpandedCornerRadius), forKeyedSubscript: "fullExpandedCornerRadius" as NSString) | ||
| constants.setObject(layout, forKeyedSubscript: "layout" as NSString) | ||
|
|
||
| superIsland.setObject(constants, forKeyedSubscript: "constants" as NSString) | ||
| } | ||
|
|
||
| private func injectConsole(into superIsland: JSValue) { | ||
| let logInfo: @convention(block) (String) -> Void = { [weak self] message in | ||
| guard let self else { return } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SDK exports
compactWidth/compactHeightfromConstants.compactSize, but compact geometry is runtime-dependent on notched Macs (compactIslandMetricsandcontentSize(for: .compact)inSuperIsland/App/AppState.swiftaround lines 856–866 and 1057–1069). Because the exported values are static defaults, modules that rely onSuperIsland.constants.layout.compact*can be sized incorrectly (e.g., clipped when actual compact height is reduced).Useful? React with 👍 / 👎.