@geastack/apple 0.2.18 → 0.2.20
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/README.md +85 -2
- package/dist/desktop-api.js +295 -0
- package/generated/EventKit.d.ts +16 -0
- package/package.json +10 -6
- package/runtime/EventKit.js +35 -0
- package/targets/ios/Info-tvOS.plist.in +39 -0
- package/targets/ios/Info.plist.in +14 -0
- package/targets/ios/README.md +35 -0
- package/targets/ios/build-ios.sh +122 -52
- package/targets/ios/generate-xcode-project.mjs +57 -12
- package/targets/ios/main/canvas_view.h +2 -0
- package/targets/ios/main/canvas_view.mm +268 -17
- package/targets/ios/main/font_registry.h +4 -0
- package/targets/ios/main/font_registry.mm +32 -0
- package/targets/ios/main/gea_uikit_host.h +55 -0
- package/targets/ios/main/ios_camera.mm +10 -0
- package/targets/ios/main/ios_display.mm +25 -6
- package/targets/ios/main/ios_main.mm +289 -6
- package/targets/ios/main/ios_sensors.mm +22 -0
- package/targets/ios/main/renderer/native_scroll_container.mm +3 -0
- package/targets/ios/main/renderer/view_reconciler.mm +1 -1
- package/targets/ios/main/uikit_host.mm +71 -0
- package/targets/macos/build-macos.sh +17 -10
- package/targets/macos/merge-info-plist.mjs +35 -0
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
#import <UIKit/UIKit.h>
|
|
2
2
|
#import <QuartzCore/QuartzCore.h>
|
|
3
3
|
|
|
4
|
+
#include <TargetConditionals.h>
|
|
5
|
+
|
|
6
|
+
#if TARGET_OS_TV
|
|
7
|
+
#import <GameController/GameController.h>
|
|
8
|
+
#endif
|
|
9
|
+
|
|
4
10
|
#include "app.h"
|
|
5
11
|
#include "apps.h"
|
|
6
12
|
#include "canvas.h"
|
|
13
|
+
#include "css/animation.h"
|
|
14
|
+
#include "css/declarative.h"
|
|
7
15
|
#include "display.h"
|
|
16
|
+
#include "display_underlay.h"
|
|
8
17
|
#include "event.h"
|
|
9
18
|
#include "events.h"
|
|
10
19
|
#include "font_registry.h"
|
|
20
|
+
#include "gea_uikit_host.h"
|
|
11
21
|
#include "image.h"
|
|
12
22
|
#include "ios_renderer.h"
|
|
13
23
|
#include "ios_root_background.h"
|
|
@@ -198,6 +208,113 @@ bool attributedStringHasTextDecoration(NSAttributedString *value)
|
|
|
198
208
|
|
|
199
209
|
@end
|
|
200
210
|
|
|
211
|
+
#if TARGET_OS_TV
|
|
212
|
+
static void dispatchRemoteKey(int keyCode)
|
|
213
|
+
{
|
|
214
|
+
auto &tree = gea::embedded::ui::Tree::instance();
|
|
215
|
+
const int root = tree.mountedRoot();
|
|
216
|
+
if (root < 0) return;
|
|
217
|
+
|
|
218
|
+
gea::framework::events::PointerEvent event;
|
|
219
|
+
event.targetId = tree.firstChildOf(root);
|
|
220
|
+
if (event.targetId < 0) event.targetId = root;
|
|
221
|
+
event.type = gea::framework::events::PointerEventType::KeyDown;
|
|
222
|
+
event.keyCode = keyCode;
|
|
223
|
+
const bool delivered = gea::embedded::ui::dispatchRootKeyEvent(event, true);
|
|
224
|
+
if (std::getenv("GEA_TV_INPUT_DIAGNOSTICS"))
|
|
225
|
+
NSLog(@"[Gea TV] key=%d root=%d target=%d delivered=%d", keyCode, root, event.targetId, delivered);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
@interface GeaTVController : GCEventViewController
|
|
229
|
+
@property(nonatomic, weak) GCMotion *remoteMotion;
|
|
230
|
+
@property(nonatomic, assign) BOOL tiltReady;
|
|
231
|
+
@property(nonatomic, strong) NSHashTable<GCController *> *configuredControllers;
|
|
232
|
+
- (void)pollRemoteMotion;
|
|
233
|
+
@end
|
|
234
|
+
|
|
235
|
+
@implementation GeaTVController
|
|
236
|
+
- (BOOL)canBecomeFirstResponder { return YES; }
|
|
237
|
+
|
|
238
|
+
- (void)viewDidAppear:(BOOL)animated
|
|
239
|
+
{
|
|
240
|
+
[super viewDidAppear:animated];
|
|
241
|
+
[self becomeFirstResponder];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
- (void)pollRemoteMotion
|
|
245
|
+
{
|
|
246
|
+
if (!self.configuredControllers) self.configuredControllers = [NSHashTable weakObjectsHashTable];
|
|
247
|
+
for (GCController *controller in GCController.controllers) {
|
|
248
|
+
if ([self.configuredControllers containsObject:controller]) continue;
|
|
249
|
+
[self.configuredControllers addObject:controller];
|
|
250
|
+
controller.handlerQueue = dispatch_get_main_queue();
|
|
251
|
+
GCMicroGamepad *remote = controller.microGamepad;
|
|
252
|
+
if (remote) remote.reportsAbsoluteDpadValues = YES;
|
|
253
|
+
GCExtendedGamepad *pad = controller.extendedGamepad;
|
|
254
|
+
const bool directionalRemote = [remote isKindOfClass:GCDirectionalGamepad.class];
|
|
255
|
+
// The silver remote's generic dpad is its touch surface and buttonA
|
|
256
|
+
// means a click anywhere, including the direction ring. Use the
|
|
257
|
+
// dedicated physical ring and center elements to keep actions separate.
|
|
258
|
+
GCControllerDirectionPad *directions = directionalRemote
|
|
259
|
+
? remote.dpads[GCInputDirectionalCardinalDpad]
|
|
260
|
+
: (remote ? remote.dpad : pad.dpad);
|
|
261
|
+
directions.left.pressedChangedHandler = ^(GCControllerButtonInput *, float, BOOL pressed) {
|
|
262
|
+
if (pressed) dispatchRemoteKey(37);
|
|
263
|
+
};
|
|
264
|
+
directions.right.pressedChangedHandler = ^(GCControllerButtonInput *, float, BOOL pressed) {
|
|
265
|
+
if (pressed) dispatchRemoteKey(39);
|
|
266
|
+
};
|
|
267
|
+
directions.up.pressedChangedHandler = ^(GCControllerButtonInput *, float, BOOL pressed) {
|
|
268
|
+
if (pressed) dispatchRemoteKey(38);
|
|
269
|
+
};
|
|
270
|
+
directions.down.pressedChangedHandler = ^(GCControllerButtonInput *, float, BOOL pressed) {
|
|
271
|
+
if (pressed) dispatchRemoteKey(40);
|
|
272
|
+
};
|
|
273
|
+
GCControllerButtonInput *select = directionalRemote
|
|
274
|
+
? remote.buttons[GCInputDirectionalCenterButton]
|
|
275
|
+
: (remote ? remote.buttonA : pad.buttonA);
|
|
276
|
+
select.pressedChangedHandler = ^(GCControllerButtonInput *, float, BOOL pressed) {
|
|
277
|
+
if (pressed) dispatchRemoteKey(13);
|
|
278
|
+
};
|
|
279
|
+
GCControllerButtonInput *back = remote ? remote.buttonMenu : pad.buttonMenu;
|
|
280
|
+
back.pressedChangedHandler = ^(GCControllerButtonInput *, float, BOOL pressed) {
|
|
281
|
+
if (pressed) dispatchRemoteKey(27);
|
|
282
|
+
};
|
|
283
|
+
GCControllerButtonInput *dive = remote ? remote.buttonX : pad.buttonX;
|
|
284
|
+
dive.pressedChangedHandler = ^(GCControllerButtonInput *, float, BOOL pressed) {
|
|
285
|
+
if (pressed) dispatchRemoteKey(40);
|
|
286
|
+
};
|
|
287
|
+
if (std::getenv("GEA_TV_INPUT_DIAGNOSTICS"))
|
|
288
|
+
NSLog(@"[Gea TV] controller=%@ profile=%@ motion=%d", controller.vendorName,
|
|
289
|
+
NSStringFromClass(remote ? remote.class : pad.class), controller.motion != nil);
|
|
290
|
+
}
|
|
291
|
+
GCMotion *motion = nil;
|
|
292
|
+
for (GCController *controller in GCController.controllers) {
|
|
293
|
+
if (!controller.motion) continue;
|
|
294
|
+
motion = controller.motion;
|
|
295
|
+
if (controller.microGamepad) break;
|
|
296
|
+
}
|
|
297
|
+
if (motion != self.remoteMotion) {
|
|
298
|
+
GCMotion *previous = self.remoteMotion;
|
|
299
|
+
if (previous.sensorsRequireManualActivation) previous.sensorsActive = NO;
|
|
300
|
+
self.remoteMotion = motion;
|
|
301
|
+
self.tiltReady = NO;
|
|
302
|
+
if (motion.sensorsRequireManualActivation) motion.sensorsActive = YES;
|
|
303
|
+
}
|
|
304
|
+
if (!motion) return;
|
|
305
|
+
if (motion.sensorsRequireManualActivation && !motion.sensorsActive) motion.sensorsActive = YES;
|
|
306
|
+
|
|
307
|
+
// Hold the remote upright with its buttons facing you. Re-center before
|
|
308
|
+
// the next lane change so a held tilt only generates one input.
|
|
309
|
+
const double sideways = motion.hasGravityAndUserAcceleration ? motion.gravity.x : motion.acceleration.x;
|
|
310
|
+
if (std::abs(sideways) < 0.16) self.tiltReady = YES;
|
|
311
|
+
if (!self.tiltReady || std::abs(sideways) < 0.34) return;
|
|
312
|
+
self.tiltReady = NO;
|
|
313
|
+
dispatchRemoteKey(sideways < 0 ? 37 : 39);
|
|
314
|
+
}
|
|
315
|
+
@end
|
|
316
|
+
#endif
|
|
317
|
+
|
|
201
318
|
@interface GeaDisplayView : UIView
|
|
202
319
|
@property(nonatomic, strong) NSMapTable<UITouch *, NSNumber *> *touchPointerIds;
|
|
203
320
|
- (void)syncNativeTextInputs;
|
|
@@ -216,7 +333,9 @@ bool attributedStringHasTextDecoration(NSAttributedString *value)
|
|
|
216
333
|
// Track multiple simultaneous fingers so one button can be held while
|
|
217
334
|
// another is tapped (e.g. move + jump). Keyed by touch identity; the
|
|
218
335
|
// value is the pointer index (0 = primary).
|
|
336
|
+
#if !TARGET_OS_TV
|
|
219
337
|
self.multipleTouchEnabled = YES;
|
|
338
|
+
#endif
|
|
220
339
|
self.touchPointerIds = [NSMapTable mapTableWithKeyOptions:NSMapTableWeakMemory | NSMapTableObjectPointerPersonality
|
|
221
340
|
valueOptions:NSMapTableStrongMemory];
|
|
222
341
|
}
|
|
@@ -452,6 +571,12 @@ bool attributedStringHasTextDecoration(NSAttributedString *value)
|
|
|
452
571
|
touching:(bool)touching
|
|
453
572
|
{
|
|
454
573
|
if (!touch) return;
|
|
574
|
+
#if TARGET_OS_TV
|
|
575
|
+
// Remote touch coordinates describe the clickpad, not positions on the TV.
|
|
576
|
+
// GameController owns that input; forwarding it as pointer gestures sends
|
|
577
|
+
// a second, unrelated action whenever a thumb touches or moves on the pad.
|
|
578
|
+
if (touch.type == UITouchTypeIndirect) return;
|
|
579
|
+
#endif
|
|
455
580
|
const BOOL isDown = phase == gea::framework::events::TouchPhase::Down;
|
|
456
581
|
const int pointerId = [self pointerIdForTouch:touch assignIfAbsent:isDown];
|
|
457
582
|
if (pointerId < 0) return;
|
|
@@ -554,6 +679,9 @@ bool attributedStringHasTextDecoration(NSAttributedString *value)
|
|
|
554
679
|
@property(nonatomic, strong) GeaDisplayView *displayView;
|
|
555
680
|
@property(nonatomic, strong) UIView *nativeRootView;
|
|
556
681
|
@property(nonatomic, strong) CADisplayLink *displayLink;
|
|
682
|
+
// The root view's size (height times scale, so a scale change shows) last
|
|
683
|
+
// reported to the host extensions.
|
|
684
|
+
@property(nonatomic, assign) CGSize extensionLayout;
|
|
557
685
|
- (void)installNativeRootView:(UIView *)view;
|
|
558
686
|
@end
|
|
559
687
|
|
|
@@ -562,11 +690,15 @@ bool attributedStringHasTextDecoration(NSAttributedString *value)
|
|
|
562
690
|
- (void)layoutDisplayViewInSafeArea
|
|
563
691
|
{
|
|
564
692
|
if (!self.rootView || !self.displayView) return;
|
|
693
|
+
#if TARGET_OS_TV
|
|
694
|
+
CGRect frame = self.rootView.bounds;
|
|
695
|
+
#else
|
|
565
696
|
CGRect frame = self.rootView.safeAreaLayoutGuide.layoutFrame;
|
|
566
697
|
if (frame.size.width <= 0 || frame.size.height <= 0) {
|
|
567
698
|
frame = UIEdgeInsetsInsetRect(self.rootView.bounds, self.rootView.safeAreaInsets);
|
|
568
699
|
}
|
|
569
700
|
if (frame.size.width <= 0 || frame.size.height <= 0) frame = self.rootView.bounds;
|
|
701
|
+
#endif
|
|
570
702
|
self.displayView.frame = frame;
|
|
571
703
|
if (self.nativeRootView) self.nativeRootView.frame = self.rootView.bounds;
|
|
572
704
|
}
|
|
@@ -590,6 +722,9 @@ bool attributedStringHasTextDecoration(NSAttributedString *value)
|
|
|
590
722
|
|
|
591
723
|
- (CGSize)viewportSize
|
|
592
724
|
{
|
|
725
|
+
#if defined(GEA_UIKIT_VIEWPORT_WIDTH) && defined(GEA_UIKIT_VIEWPORT_HEIGHT)
|
|
726
|
+
return CGSizeMake(GEA_UIKIT_VIEWPORT_WIDTH, GEA_UIKIT_VIEWPORT_HEIGHT);
|
|
727
|
+
#endif
|
|
593
728
|
CGSize size = self.displayView.bounds.size;
|
|
594
729
|
if (size.width <= 0 || size.height <= 0) size = self.rootView.safeAreaLayoutGuide.layoutFrame.size;
|
|
595
730
|
if (size.width <= 0 || size.height <= 0) size = self.rootView.bounds.size;
|
|
@@ -616,12 +751,42 @@ bool attributedStringHasTextDecoration(NSAttributedString *value)
|
|
|
616
751
|
self.displayView.backgroundColor = color;
|
|
617
752
|
}
|
|
618
753
|
|
|
754
|
+
// Apps linked against the iOS/tvOS 27 SDKs must adopt the scene lifecycle:
|
|
755
|
+
// UIKit traps at launch otherwise. The window and everything that hangs off it
|
|
756
|
+
// is built when the scene connects (GeaSceneDelegate), not at launch.
|
|
619
757
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
|
620
758
|
{
|
|
621
759
|
(void)application;
|
|
622
760
|
(void)launchOptions;
|
|
623
|
-
|
|
761
|
+
gGeaAppDelegate = self;
|
|
762
|
+
return YES;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
- (UISceneConfiguration *)application:(UIApplication *)application
|
|
766
|
+
configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession
|
|
767
|
+
options:(UISceneConnectionOptions *)options
|
|
768
|
+
{
|
|
769
|
+
(void)application;
|
|
770
|
+
(void)options;
|
|
771
|
+
UISceneConfiguration *configuration = [[UISceneConfiguration alloc] initWithName:@"Default"
|
|
772
|
+
sessionRole:connectingSceneSession.role];
|
|
773
|
+
configuration.delegateClass = NSClassFromString(@"GeaSceneDelegate");
|
|
774
|
+
return configuration;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
- (void)startInWindowScene:(UIWindowScene *)scene
|
|
778
|
+
{
|
|
779
|
+
if (self.window) return;
|
|
780
|
+
UIApplication *application = UIApplication.sharedApplication;
|
|
781
|
+
self.window = [[UIWindow alloc] initWithWindowScene:scene];
|
|
782
|
+
#if TARGET_OS_TV
|
|
783
|
+
GeaTVController *controller = [[GeaTVController alloc] init];
|
|
784
|
+
controller.controllerUserInteractionEnabled = NO;
|
|
785
|
+
application.idleTimerDisabled = YES;
|
|
786
|
+
#else
|
|
787
|
+
(void)application;
|
|
624
788
|
UIViewController *controller = [[UIViewController alloc] init];
|
|
789
|
+
#endif
|
|
625
790
|
self.rootView = [[UIView alloc] initWithFrame:self.window.bounds];
|
|
626
791
|
self.rootView.opaque = YES;
|
|
627
792
|
self.rootView.backgroundColor = UIColor.blackColor;
|
|
@@ -632,6 +797,9 @@ bool attributedStringHasTextDecoration(NSAttributedString *value)
|
|
|
632
797
|
controller.view = self.rootView;
|
|
633
798
|
self.window.rootViewController = controller;
|
|
634
799
|
[self.window makeKeyAndVisible];
|
|
800
|
+
#if TARGET_OS_TV
|
|
801
|
+
[controller becomeFirstResponder];
|
|
802
|
+
#endif
|
|
635
803
|
[self.rootView layoutIfNeeded];
|
|
636
804
|
[self layoutDisplayViewInSafeArea];
|
|
637
805
|
gGeaAppDelegate = self;
|
|
@@ -656,7 +824,15 @@ bool attributedStringHasTextDecoration(NSAttributedString *value)
|
|
|
656
824
|
// On iOS the build sets GEA_EMBEDDED_PIXEL_FORMAT=GEA_PIXEL_RGBA8888, so the
|
|
657
825
|
// ImageStore decodes straight to full-colour RGBA8888 native pixels (no 565
|
|
658
826
|
// quantization, no separate retained buffer) for native UIImageView.
|
|
827
|
+
// Host extensions (a package's GL or GPU surface) take their part of the
|
|
828
|
+
// window before the program's top level runs: the program creates its
|
|
829
|
+
// context while it initializes, inside the extensions' frame bracket.
|
|
830
|
+
const CGSize rootSize = self.rootView.bounds.size;
|
|
831
|
+
self.extensionLayout = CGSizeMake(rootSize.width, rootSize.height * viewportScale);
|
|
832
|
+
gea_uikit_host_attach((__bridge void *)self.rootView, rootSize.width, rootSize.height, viewportScale);
|
|
833
|
+
const bool extensionsBegun = gea_uikit_host_begin_frame() != 0;
|
|
659
834
|
gea::framework::app::Application::init(viewportWidth, viewportHeight, devicePixelRatio);
|
|
835
|
+
if (extensionsBegun) gea_uikit_host_end_frame();
|
|
660
836
|
[self syncAppBackgroundColor];
|
|
661
837
|
[self tick:nil];
|
|
662
838
|
|
|
@@ -667,25 +843,132 @@ bool attributedStringHasTextDecoration(NSAttributedString *value)
|
|
|
667
843
|
self.displayLink.preferredFramesPerSecond = 60;
|
|
668
844
|
}
|
|
669
845
|
[self.displayLink addToRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
|
|
670
|
-
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
- (void)applicationWillResignActive:(UIApplication *)application
|
|
849
|
+
{
|
|
850
|
+
(void)application;
|
|
851
|
+
self.displayLink.paused = YES;
|
|
852
|
+
#if TARGET_OS_TV
|
|
853
|
+
GCMotion *motion = ((GeaTVController *)self.window.rootViewController).remoteMotion;
|
|
854
|
+
if (motion.sensorsRequireManualActivation) motion.sensorsActive = NO;
|
|
855
|
+
#endif
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
- (void)applicationDidEnterBackground:(UIApplication *)application
|
|
859
|
+
{
|
|
860
|
+
#if TARGET_OS_TV
|
|
861
|
+
application.idleTimerDisabled = NO;
|
|
862
|
+
#else
|
|
863
|
+
(void)application;
|
|
864
|
+
#endif
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
- (void)applicationDidBecomeActive:(UIApplication *)application
|
|
868
|
+
{
|
|
869
|
+
#if TARGET_OS_TV
|
|
870
|
+
application.idleTimerDisabled = YES;
|
|
871
|
+
[self.window.rootViewController becomeFirstResponder];
|
|
872
|
+
#else
|
|
873
|
+
(void)application;
|
|
874
|
+
#endif
|
|
875
|
+
self.displayLink.paused = NO;
|
|
671
876
|
}
|
|
672
877
|
|
|
673
878
|
- (void)tick:(CADisplayLink *)link
|
|
674
879
|
{
|
|
880
|
+
#if TARGET_OS_TV
|
|
881
|
+
[(GeaTVController *)self.window.rootViewController pollRemoteMotion];
|
|
882
|
+
#endif
|
|
675
883
|
(void)link;
|
|
676
|
-
|
|
884
|
+
const int nowMs = gea_embedded_now_ms();
|
|
885
|
+
// This host replaces runtime.cpp's frame loop, including its animation
|
|
886
|
+
// clock. Prime newly mounted CSS tracks and advance them before rendering.
|
|
887
|
+
static bool declarativeAnimationsScanned = false;
|
|
888
|
+
if (!declarativeAnimationsScanned) {
|
|
889
|
+
declarativeAnimationsScanned = true;
|
|
890
|
+
gea::css::DeclarativeAnimations::scanAndStart(nowMs);
|
|
891
|
+
}
|
|
892
|
+
gea::embedded::ui::StyleSheet::instance().startCssAnimations(static_cast<std::uint32_t>(nowMs));
|
|
893
|
+
gea::css::AnimationEngine::instance().tick(static_cast<std::uint32_t>(nowMs));
|
|
894
|
+
// Native views present the tree, so the software framebuffer is never
|
|
895
|
+
// shown: skip rasterizing it (a 4K canvas costs two full-frame copies).
|
|
896
|
+
gea::embedded::ui::Tree::instance().setSoftwareRasterSuppressed(
|
|
897
|
+
!self.nativeRootView && gea::ios::IosRenderer::instance().hasNativeTree() &&
|
|
898
|
+
!gea::framework::display::Underlay::active());
|
|
899
|
+
if (gea_uikit_host_has_extensions()) {
|
|
900
|
+
const CGSize rootSize = self.rootView.bounds.size;
|
|
901
|
+
const CGFloat scale = [self viewportScale];
|
|
902
|
+
const CGSize layout = CGSizeMake(rootSize.width, rootSize.height * scale);
|
|
903
|
+
if (!CGSizeEqualToSize(layout, self.extensionLayout)) {
|
|
904
|
+
self.extensionLayout = layout;
|
|
905
|
+
gea_uikit_host_layout(rootSize.width, rootSize.height, scale);
|
|
906
|
+
}
|
|
907
|
+
if (!gea_uikit_host_begin_frame()) return;
|
|
908
|
+
gea::framework::app::Application::frame(nowMs);
|
|
909
|
+
gea_uikit_host_end_frame();
|
|
910
|
+
} else {
|
|
911
|
+
gea::framework::app::Application::frame(nowMs);
|
|
912
|
+
}
|
|
677
913
|
[self syncAppBackgroundColor];
|
|
678
914
|
auto &tree = gea::embedded::ui::Tree::instance();
|
|
679
915
|
const int root = tree.mountedRoot();
|
|
680
|
-
if (!self.nativeRootView
|
|
681
|
-
gea::ios::IosRenderer::instance()
|
|
682
|
-
|
|
916
|
+
if (!self.nativeRootView) {
|
|
917
|
+
auto &renderer = gea::ios::IosRenderer::instance();
|
|
918
|
+
if (root < 0 || gea::framework::display::Underlay::active()) {
|
|
919
|
+
// Direct-canvas apps and composited underlays present the framework
|
|
920
|
+
// framebuffer. Remove native views that would cover that image.
|
|
921
|
+
if (renderer.hasNativeTree()) renderer.teardown();
|
|
922
|
+
} else {
|
|
923
|
+
renderer.sync(self.displayView, root);
|
|
924
|
+
[self.displayView syncNativeTextInputs];
|
|
925
|
+
}
|
|
683
926
|
[self.displayView setNeedsDisplay];
|
|
684
927
|
}
|
|
685
928
|
}
|
|
686
929
|
|
|
687
930
|
@end
|
|
688
931
|
|
|
932
|
+
// The one window scene: builds the host on connect and forwards the scene's
|
|
933
|
+
// activity to the app delegate, which keeps the per-app state (display link,
|
|
934
|
+
// idle timer, remote motion). UIKit no longer sends the application-level
|
|
935
|
+
// active/background callbacks once a scene manifest is declared.
|
|
936
|
+
@interface GeaSceneDelegate : UIResponder <UIWindowSceneDelegate>
|
|
937
|
+
@property(nonatomic, strong) UIWindow *window;
|
|
938
|
+
@end
|
|
939
|
+
|
|
940
|
+
@implementation GeaSceneDelegate
|
|
941
|
+
|
|
942
|
+
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)options
|
|
943
|
+
{
|
|
944
|
+
(void)session;
|
|
945
|
+
(void)options;
|
|
946
|
+
if (![scene isKindOfClass:UIWindowScene.class]) return;
|
|
947
|
+
GeaAppDelegate *app = gGeaAppDelegate ?: (GeaAppDelegate *)UIApplication.sharedApplication.delegate;
|
|
948
|
+
[app startInWindowScene:(UIWindowScene *)scene];
|
|
949
|
+
self.window = app.window;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
- (void)sceneWillResignActive:(UIScene *)scene
|
|
953
|
+
{
|
|
954
|
+
(void)scene;
|
|
955
|
+
[gGeaAppDelegate applicationWillResignActive:UIApplication.sharedApplication];
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
- (void)sceneDidEnterBackground:(UIScene *)scene
|
|
959
|
+
{
|
|
960
|
+
(void)scene;
|
|
961
|
+
[gGeaAppDelegate applicationDidEnterBackground:UIApplication.sharedApplication];
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
- (void)sceneDidBecomeActive:(UIScene *)scene
|
|
965
|
+
{
|
|
966
|
+
(void)scene;
|
|
967
|
+
[gGeaAppDelegate applicationDidBecomeActive:UIApplication.sharedApplication];
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
@end
|
|
971
|
+
|
|
689
972
|
#if GEA_IOS_HAS_APPLE_NATIVE_BRIDGE
|
|
690
973
|
void gea::apple::UIKit::installRootView(gea::apple::UIKit::UIView view)
|
|
691
974
|
{
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#include "imu.h"
|
|
2
2
|
#include "touch.h"
|
|
3
3
|
|
|
4
|
+
#include <TargetConditionals.h>
|
|
5
|
+
|
|
6
|
+
#if !TARGET_OS_TV
|
|
4
7
|
#import <CoreMotion/CoreMotion.h>
|
|
5
8
|
#import <Foundation/Foundation.h>
|
|
6
9
|
|
|
@@ -204,6 +207,25 @@ void Accelerometer::setWebTilt(int, int) {}
|
|
|
204
207
|
|
|
205
208
|
} // namespace gea::platform::sensors
|
|
206
209
|
|
|
210
|
+
#else
|
|
211
|
+
namespace gea::platform::sensors {
|
|
212
|
+
|
|
213
|
+
void Accelerometer::init() {}
|
|
214
|
+
void Accelerometer::close() {}
|
|
215
|
+
void Accelerometer::calibrateBias() {}
|
|
216
|
+
int Accelerometer::tiltX() { return 0; }
|
|
217
|
+
int Accelerometer::tiltY() { return 0; }
|
|
218
|
+
double Accelerometer::accelerationX() { return 0.0; }
|
|
219
|
+
double Accelerometer::accelerationY() { return 0.0; }
|
|
220
|
+
double Accelerometer::accelerationZ() { return 9.80665; } // gravity, plate flat
|
|
221
|
+
double Accelerometer::gyroscopeX() { return 0.0; }
|
|
222
|
+
double Accelerometer::gyroscopeY() { return 0.0; }
|
|
223
|
+
double Accelerometer::gyroscopeZ() { return 0.0; }
|
|
224
|
+
void Accelerometer::setWebTilt(int, int) {}
|
|
225
|
+
|
|
226
|
+
} // namespace gea::platform::sensors
|
|
227
|
+
#endif
|
|
228
|
+
|
|
207
229
|
namespace gea::platform::touch {
|
|
208
230
|
|
|
209
231
|
namespace {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
#include "ui/tree_internal.h"
|
|
4
4
|
|
|
5
|
+
#include <TargetConditionals.h>
|
|
5
6
|
#include <algorithm>
|
|
6
7
|
#include <cmath>
|
|
7
8
|
#include <cstdlib>
|
|
@@ -84,7 +85,9 @@ bool rectNearlyEqual(CGRect a, CGRect b)
|
|
|
84
85
|
self.showsHorizontalScrollIndicator = NO;
|
|
85
86
|
self.delaysContentTouches = NO;
|
|
86
87
|
self.canCancelContentTouches = YES;
|
|
88
|
+
#if !TARGET_OS_TV
|
|
87
89
|
self.scrollsToTop = NO;
|
|
90
|
+
#endif
|
|
88
91
|
if (@available(iOS 11.0, *)) self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
|
89
92
|
_contentView = [[UIView alloc] initWithFrame:CGRectZero];
|
|
90
93
|
_contentView.userInteractionEnabled = NO;
|
|
@@ -167,7 +167,7 @@ void applyImageProps(UIImageView *imageView, const gea::embedded::ui::Node &node
|
|
|
167
167
|
void applyCanvasProps(GeaCanvasView *canvasView, int nodeId)
|
|
168
168
|
{
|
|
169
169
|
canvasView.nodeId = nodeId;
|
|
170
|
-
[canvasView
|
|
170
|
+
[canvasView present];
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
void applyTypeSpecificProps(UIView *view, const gea::embedded::ui::Node &node, int nodeId, CGFloat scale)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// The registry and life-cycle calls of iOS/tvOS host extensions (gea_uikit_host.h).
|
|
3
|
+
#include "gea_uikit_host.h"
|
|
4
|
+
|
|
5
|
+
#include <cstdio>
|
|
6
|
+
|
|
7
|
+
namespace {
|
|
8
|
+
|
|
9
|
+
constexpr int kMaxExtensions = 8;
|
|
10
|
+
const gea_uikit_host_extension *gExtensions[kMaxExtensions];
|
|
11
|
+
int gExtensionCount = 0;
|
|
12
|
+
// Extensions whose begin_frame ran this frame, so only they get end_frame.
|
|
13
|
+
bool gBegun[kMaxExtensions];
|
|
14
|
+
|
|
15
|
+
} // namespace
|
|
16
|
+
|
|
17
|
+
extern "C" void gea_uikit_register_host_extension(const gea_uikit_host_extension *extension)
|
|
18
|
+
{
|
|
19
|
+
if (!extension || extension->version != GEA_UIKIT_HOST_EXTENSION_VERSION) {
|
|
20
|
+
std::fprintf(stderr, "[gea] host extension %s has an unsupported version\n", extension && extension->name ? extension->name : "?");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (gExtensionCount >= kMaxExtensions) {
|
|
24
|
+
std::fprintf(stderr, "[gea] too many host extensions; %s ignored\n", extension->name ? extension->name : "?");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
gExtensions[gExtensionCount++] = extension;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
extern "C" int gea_uikit_host_has_extensions(void) { return gExtensionCount > 0; }
|
|
31
|
+
|
|
32
|
+
extern "C" void gea_uikit_host_attach(void *rootView, double width, double height, double scale)
|
|
33
|
+
{
|
|
34
|
+
for (int i = 0; i < gExtensionCount; ++i) {
|
|
35
|
+
const auto *extension = gExtensions[i];
|
|
36
|
+
if (extension->attach && !extension->attach(rootView, width, height, scale)) {
|
|
37
|
+
std::fprintf(stderr, "[gea] host extension %s failed to attach\n", extension->name ? extension->name : "?");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
extern "C" void gea_uikit_host_layout(double width, double height, double scale)
|
|
43
|
+
{
|
|
44
|
+
for (int i = 0; i < gExtensionCount; ++i) {
|
|
45
|
+
if (gExtensions[i]->layout) gExtensions[i]->layout(width, height, scale);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
extern "C" int gea_uikit_host_begin_frame(void)
|
|
50
|
+
{
|
|
51
|
+
bool run = true;
|
|
52
|
+
for (int i = 0; i < gExtensionCount; ++i) {
|
|
53
|
+
gBegun[i] = false;
|
|
54
|
+
if (!run) continue;
|
|
55
|
+
if (gExtensions[i]->begin_frame && !gExtensions[i]->begin_frame()) {
|
|
56
|
+
run = false;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
gBegun[i] = true;
|
|
60
|
+
}
|
|
61
|
+
if (!run) gea_uikit_host_end_frame();
|
|
62
|
+
return run ? 1 : 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
extern "C" void gea_uikit_host_end_frame(void)
|
|
66
|
+
{
|
|
67
|
+
for (int i = gExtensionCount - 1; i >= 0; --i) {
|
|
68
|
+
if (gBegun[i] && gExtensions[i]->end_frame) gExtensions[i]->end_frame();
|
|
69
|
+
gBegun[i] = false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -365,16 +365,6 @@ if [[ "$MACOS_PIPELINE_CACHE" == "0" ]]; then rm -rf "$RES_DIR"; fi
|
|
|
365
365
|
mkdir -p "$MACOS_DIR" "$RES_DIR" "$BUILD_DIR"
|
|
366
366
|
BUNDLE_CONTENT_CHANGED=0
|
|
367
367
|
|
|
368
|
-
INFO_PLIST_TMP="$BUILD_DIR/Info.plist.tmp.$$"
|
|
369
|
-
sed -e "s/@APP_EXEC@/$APP_EXEC/g" \
|
|
370
|
-
-e "s/@APP_ID@/$APP_ID/g" \
|
|
371
|
-
-e "s/@APP_NAME@/$APP_NAME/g" \
|
|
372
|
-
"$ROOT_DIR/targets/macos/Info.plist.in" > "$INFO_PLIST_TMP"
|
|
373
|
-
if replace_content_stable "$APP_BUNDLE/Contents/Info.plist" "$INFO_PLIST_TMP"; then
|
|
374
|
-
BUNDLE_CONTENT_CHANGED=1
|
|
375
|
-
fi
|
|
376
|
-
timing_mark bootstrap
|
|
377
|
-
|
|
378
368
|
# Resolve package metadata once per app. Bash 3.2 has no associative arrays, so
|
|
379
369
|
# keep parallel indexed arrays and publish the result through a global instead
|
|
380
370
|
# of command substitution (which would update the cache in a subshell).
|
|
@@ -405,6 +395,22 @@ resolve_app_dir() {
|
|
|
405
395
|
echo "$root"
|
|
406
396
|
}
|
|
407
397
|
|
|
398
|
+
# Info.plist comes from the shared template plus the optional `infoPlist`
|
|
399
|
+
# object of apps/<id>/macos.json (usage descriptions and other per-app keys).
|
|
400
|
+
INFO_PLIST_TMP="$BUILD_DIR/Info.plist.tmp.$$"
|
|
401
|
+
sed -e "s/@APP_EXEC@/$APP_EXEC/g" \
|
|
402
|
+
-e "s/@APP_ID@/$APP_ID/g" \
|
|
403
|
+
-e "s/@APP_NAME@/$APP_NAME/g" \
|
|
404
|
+
"$ROOT_DIR/targets/macos/Info.plist.in" > "$INFO_PLIST_TMP"
|
|
405
|
+
INFO_PLIST_APP_DIR="$(resolve_app_dir "$APP_ID")"
|
|
406
|
+
if [[ -n "$INFO_PLIST_APP_DIR" && -f "$INFO_PLIST_APP_DIR/macos.json" ]]; then
|
|
407
|
+
node "$ROOT_DIR/targets/macos/merge-info-plist.mjs" "$INFO_PLIST_TMP" "$INFO_PLIST_APP_DIR/macos.json"
|
|
408
|
+
fi
|
|
409
|
+
if replace_content_stable "$APP_BUNDLE/Contents/Info.plist" "$INFO_PLIST_TMP"; then
|
|
410
|
+
BUNDLE_CONTENT_CHANGED=1
|
|
411
|
+
fi
|
|
412
|
+
timing_mark bootstrap
|
|
413
|
+
|
|
408
414
|
# Cheap read-only equivalent of the post-generation finalizer for no-op cache
|
|
409
415
|
# validation. Avoiding a Node process per resident saves meaningful traversal
|
|
410
416
|
# time while preserving the same ownership invariants.
|
|
@@ -1962,6 +1968,7 @@ if [[ "$APPLE_NATIVE" == "1" ]]; then
|
|
|
1962
1968
|
-framework Metal -framework MetalKit -framework MapKit
|
|
1963
1969
|
-framework CoreLocation -framework AVFoundation -framework CoreMedia
|
|
1964
1970
|
-framework Photos -framework Security -framework UserNotifications
|
|
1971
|
+
-framework EventKit
|
|
1965
1972
|
)
|
|
1966
1973
|
fi
|
|
1967
1974
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Merge the optional `infoPlist` object of an app's macos.json into the
|
|
3
|
+
// generated Info.plist, so an app can declare its own keys (for example
|
|
4
|
+
// NSCalendarsFullAccessUsageDescription) without a per-app template. Each key
|
|
5
|
+
// is written with `plutil -replace`, so values may be any JSON plutil accepts:
|
|
6
|
+
// strings, numbers, booleans, arrays and objects.
|
|
7
|
+
//
|
|
8
|
+
// node merge-info-plist.mjs <Info.plist> <macos.json>
|
|
9
|
+
import { execFileSync } from 'node:child_process'
|
|
10
|
+
import { readFileSync } from 'node:fs'
|
|
11
|
+
|
|
12
|
+
const [plist, config] = process.argv.slice(2)
|
|
13
|
+
if (!plist || !config) {
|
|
14
|
+
console.error('usage: merge-info-plist.mjs <Info.plist> <macos.json>')
|
|
15
|
+
process.exit(2)
|
|
16
|
+
}
|
|
17
|
+
const fail = (message) => {
|
|
18
|
+
console.error(`${config}: ${message}`)
|
|
19
|
+
process.exit(1)
|
|
20
|
+
}
|
|
21
|
+
let parsed
|
|
22
|
+
try {
|
|
23
|
+
parsed = JSON.parse(readFileSync(config, 'utf8'))
|
|
24
|
+
} catch (error) {
|
|
25
|
+
fail(`cannot read JSON (${error.message})`)
|
|
26
|
+
}
|
|
27
|
+
const entries = parsed?.infoPlist
|
|
28
|
+
if (entries === undefined) process.exit(0)
|
|
29
|
+
if (entries === null || typeof entries !== 'object' || Array.isArray(entries)) fail('infoPlist must be an object')
|
|
30
|
+
for (const [key, value] of Object.entries(entries)) {
|
|
31
|
+
// plutil reads a dot as a key-path separator.
|
|
32
|
+
if (!key || key.includes('.')) fail(`infoPlist key ${JSON.stringify(key)} must be a non-empty name without dots`)
|
|
33
|
+
if (value === null) fail(`infoPlist.${key} must not be null`)
|
|
34
|
+
execFileSync('plutil', ['-replace', key, '-json', JSON.stringify(value), plist], { stdio: ['ignore', 'ignore', 'inherit'] })
|
|
35
|
+
}
|