@geastack/apple 0.2.23 → 0.2.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/apple",
3
- "version": "0.2.23",
3
+ "version": "0.2.24",
4
4
  "description": "Generated Apple SDK bindings plus the macOS, iOS and tvOS native build targets for Gea apps.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -2115,12 +2115,12 @@ done
2115
2115
 
2116
2116
  # Per-app window config — the macOS main reads window.json out of Resources/
2117
2117
  # at launch to pick up size, transparent title bar, dark appearance, etc.
2118
- # Source path is apps/<id>/macos.json so the file lives next to the JSX
2119
- # it configures; we copy it as window.json so the runtime path is stable
2118
+ # Source is apps/<id>/macos.json overlaid with gea.targets.macos.window from
2119
+ # the app's package.json (window-config.mjs), written as window.json so the runtime path is stable
2120
2120
  # regardless of which app id produced it.
2121
2121
  APP_DIR_FOR_CONFIG="$(resolve_app_dir "$APP_ID")"
2122
- if [[ -n "$APP_DIR_FOR_CONFIG" && -f "$APP_DIR_FOR_CONFIG/macos.json" ]]; then
2123
- cp "$APP_DIR_FOR_CONFIG/macos.json" "$RES_DIR/window.json"
2122
+ if [[ -n "$APP_DIR_FOR_CONFIG" ]]; then
2123
+ node "$ROOT_DIR/targets/macos/window-config.mjs" "$APP_DIR_FOR_CONFIG" "$RES_DIR/window.json"
2124
2124
  fi
2125
2125
  else
2126
2126
  APP_DIRS_FOR_FONTS=()
@@ -348,6 +348,8 @@ static bool geaOwnsContourPress(int x, int y) {
348
348
  @property(nonatomic, strong) NSWindow *window;
349
349
  @property(nonatomic, strong) GeaContentView *rootView;
350
350
  @property(nonatomic, strong) NSTimer *frameTimer;
351
+ // window.json `vsync: false`: frames run uncapped instead of at the display's cadence.
352
+ @property(nonatomic) BOOL vsyncDisabled;
351
353
  @property(nonatomic, strong) CADisplayLink *frameDisplayLink API_AVAILABLE(macos(14.0));
352
354
  @property(nonatomic, strong) GeaSplitShell *splitShell;
353
355
  @property(nonatomic, strong) id geaToolbarDelegate; // NSToolbar.delegate is weak; retain it here
@@ -473,6 +475,7 @@ static __weak AppDelegate *gGeaAppDelegate = nil;
473
475
  BOOL fullSizeContentView = NO;
474
476
  BOOL transparentTitleBar = NO;
475
477
  BOOL titleHidden = NO;
478
+ BOOL startFullscreen = NO;
476
479
  NSString *appearanceName = nil;
477
480
 
478
481
  NSString *cfgPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"window.json"];
@@ -494,6 +497,8 @@ static __weak AppDelegate *gGeaAppDelegate = nil;
494
497
  if ([tv isKindOfClass:[NSString class]] && [(NSString *)tv isEqualToString:@"hidden"]) titleHidden = YES;
495
498
  id ap = win[@"appearance"];
496
499
  if ([ap isKindOfClass:[NSString class]]) appearanceName = ap;
500
+ id vs = win[@"vsync"]; if ([vs respondsToSelector:@selector(boolValue)]) self.vsyncDisabled = ![vs boolValue];
501
+ id fs = win[@"fullscreen"]; if ([fs respondsToSelector:@selector(boolValue)]) startFullscreen = [fs boolValue];
497
502
  }
498
503
  }
499
504
 
@@ -546,10 +551,10 @@ static __weak AppDelegate *gGeaAppDelegate = nil;
546
551
 
547
552
  [self tick];
548
553
  [self startFrameTimer];
549
- // GEA_MACOS_FULLSCREEN=1 starts fullscreen. With GEA_MACOS_VSYNC=0 this is
554
+ // window.json `fullscreen: true` starts fullscreen. With `vsync: false` it is
550
555
  // the uncapped arm: a windowed CAMetalLayer gets drawables back only as the
551
556
  // compositor runs, a fullscreen one presents directly.
552
- if (const char *fullscreen = std::getenv("GEA_MACOS_FULLSCREEN"); fullscreen && std::strcmp(fullscreen, "1") == 0) {
557
+ if (startFullscreen) {
553
558
  self.window.collectionBehavior |= NSWindowCollectionBehaviorFullScreenPrimary;
554
559
  NSWindow *window = self.window;
555
560
  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC / 2), dispatch_get_main_queue(), ^{
@@ -565,10 +570,9 @@ static __weak AppDelegate *gGeaAppDelegate = nil;
565
570
  #endif
566
571
  if (self.frameTimer) return;
567
572
  const BOOL thermalrightTarget = gea::macos::thermalright::enabled();
568
- // GEA_MACOS_VSYNC=0 drops the display-link cadence for the fast timer, so a
569
- // renderer presenting with swap interval 0 runs uncapped (benchmarking).
570
- const char *vsync = std::getenv("GEA_MACOS_VSYNC");
571
- const BOOL uncapped = vsync && std::strcmp(vsync, "0") == 0;
573
+ // window.json `vsync: false` drops the display-link cadence for the fast
574
+ // timer, so a renderer presenting with swap interval 0 runs uncapped.
575
+ const BOOL uncapped = self.vsyncDisabled;
572
576
  if (!thermalrightTarget && !uncapped) {
573
577
  if (@available(macOS 14.0, *)) {
574
578
  if (self.frameDisplayLink) return;
@@ -2,6 +2,7 @@
2
2
 
3
3
  import fs from 'node:fs'
4
4
  import path from 'node:path'
5
+ import { windowConfigText } from './window-config.mjs'
5
6
 
6
7
  const args = process.argv.slice(2)
7
8
 
@@ -160,9 +161,15 @@ const windowConfig = path.join(resourcesDir, 'window.json')
160
161
  for (const entry of fs.readdirSync(resourcesDir, { withFileTypes: true })) {
161
162
  if (entry.isFile() && /^window\.json\.tmp\.\d+$/.test(entry.name)) removeFile(path.join(resourcesDir, entry.name))
162
163
  }
163
- const configSource = configDir ? path.join(configDir, 'macos.json') : ''
164
- if (configSource && fs.existsSync(configSource)) syncFile(configSource, windowConfig)
165
- else removeFile(windowConfig)
164
+ const windowText = windowConfigText(configDir)
165
+ if (windowText) {
166
+ if (!fs.existsSync(windowConfig) || fs.readFileSync(windowConfig, 'utf8') !== windowText) {
167
+ const temporary = `${windowConfig}.tmp.${process.pid}`
168
+ fs.writeFileSync(temporary, windowText)
169
+ fs.renameSync(temporary, windowConfig)
170
+ changed = true
171
+ }
172
+ } else removeFile(windowConfig)
166
173
 
167
174
  const manifest = `${JSON.stringify({ fonts: [...desiredFonts.keys()].sort(), fontLicenses: [...desiredFontLicenses.keys()].sort() }, null, 2)}\n`
168
175
  fs.mkdirSync(path.dirname(manifestPath), { recursive: true })
@@ -0,0 +1,35 @@
1
+ // The window settings the macOS main reads from Resources/window.json: an app's
2
+ // macos.json, overlaid with `gea.targets.macos.window` from its package.json
3
+ // (size, title bar, appearance, `vsync`, `fullscreen`). Returns the JSON text,
4
+ // or '' when the app configures nothing.
5
+ //
6
+ // Run directly, it writes that file: node window-config.mjs <appDir> <out>
7
+ import fs from 'node:fs'
8
+ import path from 'node:path'
9
+ import { fileURLToPath } from 'node:url'
10
+
11
+ function readJson(file) {
12
+ try {
13
+ return JSON.parse(fs.readFileSync(file, 'utf8'))
14
+ } catch {
15
+ return null
16
+ }
17
+ }
18
+
19
+ export function windowConfigText(appDir) {
20
+ if (!appDir) return ''
21
+ const file = readJson(path.join(appDir, 'macos.json'))
22
+ const fromPackage = readJson(path.join(appDir, 'package.json'))?.gea?.targets?.macos?.window
23
+ if (!file && !fromPackage) return ''
24
+ const base = file && typeof file === 'object' ? file : {}
25
+ // The main reads `window` when present, else the whole file (flat macos.json).
26
+ const window = { ...(base.window ?? base), ...(fromPackage && typeof fromPackage === 'object' ? fromPackage : {}) }
27
+ return `${JSON.stringify({ ...base, window }, null, 2)}\n`
28
+ }
29
+
30
+ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
31
+ const [appDir, out] = process.argv.slice(2)
32
+ const text = windowConfigText(appDir)
33
+ if (text) fs.writeFileSync(out, text)
34
+ else fs.rmSync(out, { force: true })
35
+ }