@geastack/apple 0.2.31 → 0.2.33
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/index.js +8 -0
- package/generated/ActivityKit.d.ts +1 -0
- package/generated/AppKit.d.ts +1 -0
- package/generated/Foundation.d.ts +1 -0
- package/generated/Metal.d.ts +16 -0
- package/generated/MetalKit.d.ts +1 -0
- package/generated/SwiftData.d.ts +2 -0
- package/generated/UIKit.d.ts +1 -0
- package/package.json +6 -7
- package/targets/ios/Info.plist.in +1 -0
- package/targets/ios/build-ios.sh +14 -2
- package/targets/ios/generate-xcode-project.mjs +23 -3
- package/targets/ios/main/ios_http.mm +181 -0
- package/targets/ios/main/ios_main.mm +6 -1
- package/targets/ios/main/ios_microphone.mm +117 -0
- package/targets/ios/main/ios_websocket.mm +34 -0
- package/targets/macos/README.md +8 -3
- package/targets/macos/build-macos.sh +93 -200
- package/targets/macos/main/font_registry.mm +11 -16
- package/targets/macos/main/macos_app_platform.mm +77 -34
- package/targets/macos/main/macos_display.mm +16 -10
- package/targets/macos/main/macos_main.mm +35 -53
- package/targets/macos/main/macos_prerender.h +3 -1
- package/targets/macos/runtime-glyphs.mjs +1 -1
- package/targets/ios/main/ios_apps.c +0 -28
- package/targets/macos/generate-resident-entry.mjs +0 -80
- package/targets/macos/generate-resident-registry.mjs +0 -141
- package/targets/macos/main/macos_apps.c +0 -31
|
@@ -1,43 +1,79 @@
|
|
|
1
1
|
#import <AppKit/AppKit.h>
|
|
2
2
|
|
|
3
|
-
#include "
|
|
3
|
+
#include "geaos.h"
|
|
4
4
|
|
|
5
5
|
#include <string>
|
|
6
|
+
#include <vector>
|
|
6
7
|
|
|
7
|
-
// macOS
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
// window appears, launcher window goes away" — same UX as the watch, just
|
|
14
|
-
// realized via separate Mac processes.
|
|
8
|
+
// The macOS GeaOS host. Apps on macOS are bundled with the shell: the ones
|
|
9
|
+
// built next to this one (dist/<id>/<Name>.app) are its bundledApps(), and
|
|
10
|
+
// launching one opens that bundle and quits this process -- "click a tile,
|
|
11
|
+
// the app's window appears, Home's goes away", like the watch, realized as
|
|
12
|
+
// separate Mac processes. Apps are never downloaded and loaded at run time
|
|
13
|
+
// on Apple targets.
|
|
15
14
|
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
15
|
+
// An app that has not been built yet is not listed; build it with
|
|
16
|
+
// `gea build --target macos <id>`.
|
|
18
17
|
|
|
19
18
|
namespace {
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
// The bundle that plays Home.
|
|
21
|
+
constexpr const char *kHomeAppId = "app-launcher";
|
|
22
|
+
|
|
23
|
+
class MacosAppHost final : public gea::geaos::AppHost {
|
|
22
24
|
public:
|
|
23
|
-
explicit
|
|
25
|
+
explicit MacosAppHost(std::string currentId) : currentId_(std::move(currentId)) {}
|
|
26
|
+
|
|
27
|
+
const char *targetKey() const override { return "macos"; }
|
|
28
|
+
// Bundled apps are built with this shell; there is nothing to mismatch.
|
|
29
|
+
const char *abi() const override { return "macos-bundled"; }
|
|
30
|
+
const char *firmwareId() const override { return currentId_.c_str(); }
|
|
31
|
+
const char *runningAppId() const override { return currentId_ == kHomeAppId ? "" : currentId_.c_str(); }
|
|
24
32
|
|
|
25
|
-
|
|
26
|
-
bool runningAppIsLauncher(const char *launcherAppId) override
|
|
33
|
+
std::vector<gea::geaos::InstalledApp> bundledApps() const override
|
|
27
34
|
{
|
|
28
|
-
|
|
29
|
-
|
|
35
|
+
std::vector<gea::geaos::InstalledApp> apps;
|
|
36
|
+
NSString *dist = distDirectory();
|
|
37
|
+
NSArray<NSString *> *ids = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:dist error:nil];
|
|
38
|
+
for (NSString *candidate in ids) {
|
|
39
|
+
const char *id = candidate.UTF8String;
|
|
40
|
+
if (!gea::geaos::isValidAppId(id) || std::string(id) == kHomeAppId) continue;
|
|
41
|
+
NSString *bundle = findBundleForAppId(candidate);
|
|
42
|
+
if (!bundle) continue;
|
|
43
|
+
gea::geaos::InstalledApp app;
|
|
44
|
+
app.manifest.id = id;
|
|
45
|
+
NSString *name = [[bundle lastPathComponent] stringByDeletingPathExtension];
|
|
46
|
+
app.manifest.name = name.length ? name.UTF8String : id;
|
|
47
|
+
app.manifest.abi = abi();
|
|
48
|
+
app.volumeId = "bundle";
|
|
49
|
+
app.location = bundle.UTF8String;
|
|
50
|
+
apps.push_back(std::move(app));
|
|
51
|
+
}
|
|
52
|
+
return apps;
|
|
30
53
|
}
|
|
31
54
|
|
|
32
|
-
bool
|
|
55
|
+
bool launch(const gea::geaos::InstalledApp &app, std::string &error) override
|
|
56
|
+
{
|
|
57
|
+
return open(app.manifest.id.c_str(), error);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
bool home(std::string &error) override
|
|
61
|
+
{
|
|
62
|
+
if (currentId_ == kHomeAppId) {
|
|
63
|
+
error = "Home is already running";
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return open(kHomeAppId, error);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private:
|
|
70
|
+
bool open(const char *appId, std::string &error)
|
|
33
71
|
{
|
|
34
|
-
if (!appId || !appId[0]) return false;
|
|
35
72
|
NSString *target = [NSString stringWithUTF8String:appId];
|
|
36
73
|
NSString *bundle = findBundleForAppId(target);
|
|
37
74
|
if (!bundle) {
|
|
38
|
-
NSLog(@"[gea-launch] no built .app for '%@' under dist/. Run "
|
|
39
|
-
|
|
40
|
-
target, target);
|
|
75
|
+
NSLog(@"[gea-launch] no built .app for '%@' under dist/. Run gea build --target macos %@ first.", target, target);
|
|
76
|
+
error = std::string("no built app for ") + appId;
|
|
41
77
|
return false;
|
|
42
78
|
}
|
|
43
79
|
NSURL *url = [NSURL fileURLWithPath:bundle];
|
|
@@ -48,7 +84,11 @@ public:
|
|
|
48
84
|
configuration:cfg
|
|
49
85
|
completionHandler:^(NSRunningApplication *app, NSError *err) {
|
|
50
86
|
(void)app;
|
|
51
|
-
if (err)
|
|
87
|
+
if (err) {
|
|
88
|
+
NSLog(@"[gea-launch] open failed: %@", err);
|
|
89
|
+
gea::geaos::Launcher::setLastError(err.localizedDescription.UTF8String);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
52
92
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
53
93
|
[NSApp terminate:nil];
|
|
54
94
|
});
|
|
@@ -56,19 +96,22 @@ public:
|
|
|
56
96
|
return true;
|
|
57
97
|
}
|
|
58
98
|
|
|
99
|
+
// Default bundle: .../dist/<currentId>/<Name>.app. Tagged builds use
|
|
100
|
+
// .../dist/.namespaces/<tag>/<currentId>/<Name>.app. In both layouts two
|
|
101
|
+
// parent traversals land on the folder whose children are app ids, so a
|
|
102
|
+
// tagged Home opens apps built in the same output namespace.
|
|
103
|
+
static NSString *distDirectory()
|
|
104
|
+
{
|
|
105
|
+
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
|
|
106
|
+
return [[bundlePath stringByDeletingLastPathComponent] stringByDeletingLastPathComponent];
|
|
107
|
+
}
|
|
108
|
+
|
|
59
109
|
private:
|
|
60
110
|
std::string currentId_;
|
|
61
111
|
|
|
62
112
|
static NSString *findBundleForAppId(NSString *appId)
|
|
63
113
|
{
|
|
64
|
-
|
|
65
|
-
// .../dist/.namespaces/<tag>/<currentId>/<Name>.app. In both layouts,
|
|
66
|
-
// two parent traversals land on the root whose children are app ids, so a
|
|
67
|
-
// tagged launcher opens apps built in the same output namespace.
|
|
68
|
-
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
|
|
69
|
-
NSString *distDir = [[bundlePath stringByDeletingLastPathComponent]
|
|
70
|
-
stringByDeletingLastPathComponent];
|
|
71
|
-
NSString *appDir = [distDir stringByAppendingPathComponent:appId];
|
|
114
|
+
NSString *appDir = [distDirectory() stringByAppendingPathComponent:appId];
|
|
72
115
|
NSError *err = nil;
|
|
73
116
|
NSArray<NSString *> *entries =
|
|
74
117
|
[[NSFileManager defaultManager] contentsOfDirectoryAtPath:appDir error:&err];
|
|
@@ -86,10 +129,10 @@ namespace gea::macos {
|
|
|
86
129
|
|
|
87
130
|
void installAppLauncherPlatform(const char *currentAppId)
|
|
88
131
|
{
|
|
89
|
-
static
|
|
132
|
+
static MacosAppHost *instance = nullptr;
|
|
90
133
|
if (instance) return;
|
|
91
|
-
instance = new
|
|
92
|
-
gea::
|
|
134
|
+
instance = new MacosAppHost(currentAppId ? currentAppId : "");
|
|
135
|
+
gea::geaos::Launcher::setHost(instance);
|
|
93
136
|
}
|
|
94
137
|
|
|
95
138
|
} // namespace gea::macos
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
#include "canvas.h"
|
|
6
6
|
#include "host/display_orientation.h"
|
|
7
7
|
#include "pixel.h"
|
|
8
|
+
#include "platform/prerender_capture.h"
|
|
8
9
|
#include "thermalright_hid_display.h"
|
|
9
10
|
|
|
10
11
|
#include <algorithm>
|
|
@@ -91,22 +92,27 @@ bool gea_macos_prepare_prerender(int width, int height)
|
|
|
91
92
|
return true;
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
bool gea_macos_write_prerender_png(NSString *path)
|
|
95
|
+
bool gea_macos_write_prerender_png(NSString *path, const std::string &selector, bool transparent)
|
|
95
96
|
{
|
|
97
|
+
const auto region = gea::platform::prerender::prepareCaptureRegion(
|
|
98
|
+
g_canvas_w, g_canvas_h, selector, transparent);
|
|
99
|
+
const int channels = transparent ? 4 : 3;
|
|
96
100
|
NSBitmapImageRep *image = [[NSBitmapImageRep alloc]
|
|
97
|
-
initWithBitmapDataPlanes:nullptr pixelsWide:
|
|
98
|
-
bitsPerSample:8 samplesPerPixel:
|
|
99
|
-
colorSpaceName:NSDeviceRGBColorSpace
|
|
101
|
+
initWithBitmapDataPlanes:nullptr pixelsWide:region.width pixelsHigh:region.height
|
|
102
|
+
bitsPerSample:8 samplesPerPixel:channels hasAlpha:transparent isPlanar:NO
|
|
103
|
+
colorSpaceName:NSDeviceRGBColorSpace bitmapFormat:transparent ? NSBitmapFormatAlphaNonpremultiplied : 0
|
|
104
|
+
bytesPerRow:0 bitsPerPixel:0];
|
|
100
105
|
if (!image) return false;
|
|
101
|
-
for (int y = 0; y <
|
|
106
|
+
for (int y = 0; y < region.height; ++y) {
|
|
102
107
|
auto *row = image.bitmapData + y * image.bytesPerRow;
|
|
103
|
-
for (int x = 0; x <
|
|
108
|
+
for (int x = 0; x < region.width; ++x) {
|
|
104
109
|
int r, g, b, a;
|
|
105
110
|
gea::framework::graphics::pixel::unpackNative8(
|
|
106
|
-
g_framebuffer[static_cast<size_t>(y) * g_canvas_w + x], &r, &g, &b, &a);
|
|
107
|
-
row[x *
|
|
108
|
-
row[x *
|
|
109
|
-
row[x *
|
|
111
|
+
g_framebuffer[static_cast<size_t>(y + region.y) * g_canvas_w + x + region.x], &r, &g, &b, &a);
|
|
112
|
+
row[x * channels] = r;
|
|
113
|
+
row[x * channels + 1] = g;
|
|
114
|
+
row[x * channels + 2] = b;
|
|
115
|
+
if (transparent) row[x * channels + 3] = a;
|
|
110
116
|
}
|
|
111
117
|
}
|
|
112
118
|
NSData *png = [image representationUsingType:NSBitmapImageFileTypePNG properties:@{}];
|
|
@@ -19,7 +19,7 @@ extern void gea_macos_debugger_start();
|
|
|
19
19
|
#include "thermalright_hid_display.h"
|
|
20
20
|
|
|
21
21
|
// Optional app-owned process cleanup, before the native runtime/static teardown.
|
|
22
|
-
// No callback on a skin
|
|
22
|
+
// No callback on a skin replacement; this is actual process exit.
|
|
23
23
|
extern "C" __attribute__((weak)) void gea_native_application_terminate() {}
|
|
24
24
|
namespace {
|
|
25
25
|
void geaRetireNativeProcess() noexcept {
|
|
@@ -39,7 +39,10 @@ struct GeaNativeTerminationGuard {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
#if GEA_GEAOS
|
|
43
|
+
// GeaOS builds only (build-macos.sh with GEA_GEAOS=1): macos_app_platform.mm.
|
|
42
44
|
namespace gea::macos { void installAppLauncherPlatform(const char *currentAppId); }
|
|
45
|
+
#endif
|
|
43
46
|
namespace gea::macos { void installWifiDriver(); int nodeIdForView(NSView *view); }
|
|
44
47
|
|
|
45
48
|
#include "app.h"
|
|
@@ -51,12 +54,6 @@ namespace gea::macos { void installWifiDriver(); int nodeIdForView(NSView *view)
|
|
|
51
54
|
#define GEA_MACOS_PRERENDER_VIDEO 1
|
|
52
55
|
#endif
|
|
53
56
|
#include "platform/file_cache.h"
|
|
54
|
-
#if __has_include("resident_apps.h")
|
|
55
|
-
#include "resident_apps.h"
|
|
56
|
-
#define GEA_MACOS_HAS_RESIDENT_APPS 1
|
|
57
|
-
#else
|
|
58
|
-
#define GEA_MACOS_HAS_RESIDENT_APPS 0
|
|
59
|
-
#endif
|
|
60
57
|
#include "ui/document.h"
|
|
61
58
|
#include "ui/node.h"
|
|
62
59
|
#include "ui/node_model.h"
|
|
@@ -470,17 +467,26 @@ static __weak AppDelegate *gGeaAppDelegate = nil;
|
|
|
470
467
|
NSString *fontsDir = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Fonts"];
|
|
471
468
|
gea::macos::registerCustomTtfDirectory(fontsDir);
|
|
472
469
|
|
|
473
|
-
|
|
470
|
+
#if GEA_GEAOS
|
|
471
|
+
// GeaOS build: register the GeaOS host so JSX-level Apps.launch('foo') opens
|
|
474
472
|
// dist/foo/Foo.app and terminates this process. Derive the current app
|
|
475
473
|
// id from CFBundleIdentifier (set by Info.plist.in to com.gea.<id>).
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
474
|
+
{
|
|
475
|
+
NSString *bundleId = [[NSBundle mainBundle] bundleIdentifier] ?: @"";
|
|
476
|
+
NSString *currentId = [bundleId hasPrefix:@"com.gea."] ? [bundleId substringFromIndex:8] : @"";
|
|
477
|
+
gea::macos::installAppLauncherPlatform(currentId.UTF8String);
|
|
478
|
+
}
|
|
479
|
+
#endif
|
|
479
480
|
|
|
480
481
|
if (thermalrightTarget) {
|
|
481
482
|
NSLog(@"[gea-thermalright] headless display target %dx%d",
|
|
482
483
|
gea::platform::display::kWidth,
|
|
483
484
|
gea::platform::display::kHeight);
|
|
485
|
+
// Seed the timer clock with the frame clock before the program's top level
|
|
486
|
+
// runs: a setTimeout scheduled during init otherwise reads the host's
|
|
487
|
+
// steady clock (time since boot) while frames pass time since launch,
|
|
488
|
+
// and its deadline never arrives.
|
|
489
|
+
gea::host::runAnimationFrameCallbacks(gea_embedded_now_ms());
|
|
484
490
|
gea::framework::app::Application::init(gea::platform::display::kWidth,
|
|
485
491
|
gea::platform::display::kHeight);
|
|
486
492
|
[self tick];
|
|
@@ -564,6 +570,11 @@ static __weak AppDelegate *gGeaAppDelegate = nil;
|
|
|
564
570
|
gea_appkit_host_attach((__bridge void *)self.rootView, size.width, size.height,
|
|
565
571
|
self.window.backingScaleFactor > 0 ? self.window.backingScaleFactor : 1.0);
|
|
566
572
|
gea_macos_smoke_log("[gea-macos] before Application::init");
|
|
573
|
+
// Seed the timer clock with the frame clock before the program's top level
|
|
574
|
+
// runs: a setTimeout scheduled during init otherwise reads the host's
|
|
575
|
+
// steady clock (time since boot) while frames pass time since launch,
|
|
576
|
+
// and its deadline never arrives.
|
|
577
|
+
gea::host::runAnimationFrameCallbacks(gea_embedded_now_ms());
|
|
567
578
|
gea::framework::app::Application::init(static_cast<int>(size.width), static_cast<int>(size.height));
|
|
568
579
|
gea_macos_smoke_log("[gea-macos] after Application::init");
|
|
569
580
|
|
|
@@ -717,32 +728,6 @@ static __weak AppDelegate *gGeaAppDelegate = nil;
|
|
|
717
728
|
std::fprintf(stderr, "[gea-macos] tick %d now=%d\n", tickCount, gea_embedded_now_ms());
|
|
718
729
|
}
|
|
719
730
|
}
|
|
720
|
-
// Drain any pending resident-app launch from the previous frame BEFORE
|
|
721
|
-
// running app::frame for this tick. When the launcher's onPress called
|
|
722
|
-
// Apps.launch('foo'), the registry pushed 'foo' onto its pending queue;
|
|
723
|
-
// here we pop it, select it as the new active resident, and re-run
|
|
724
|
-
// Application::init so its __gea_top_level mounts the new UI. After this
|
|
725
|
-
// switch, Application::frame below targets the new resident.
|
|
726
|
-
#if GEA_MACOS_HAS_RESIDENT_APPS
|
|
727
|
-
{
|
|
728
|
-
char pendingId[64] = "";
|
|
729
|
-
if (gea::framework::apps::ResidentApps::consumeLaunch(pendingId, sizeof(pendingId))) {
|
|
730
|
-
if (gea::framework::apps::ResidentApps::select(pendingId)) {
|
|
731
|
-
NSSize sz = gea::macos::thermalright::enabled()
|
|
732
|
-
? NSMakeSize(gea::platform::display::kWidth, gea::platform::display::kHeight)
|
|
733
|
-
: self.rootView.bounds.size;
|
|
734
|
-
gea::macos::MacosRenderer::instance().teardown();
|
|
735
|
-
// Node ids are recycled by the next mount, so animations still
|
|
736
|
-
// running against the outgoing app's nodes must be dropped
|
|
737
|
-
// before it is torn down (runtime.cpp does this via
|
|
738
|
-
// LaunchSurface). The scan below restarts them for the new app.
|
|
739
|
-
gea::css::AnimationEngine::instance().clear();
|
|
740
|
-
gea::framework::app::Application::init(static_cast<int>(sz.width),
|
|
741
|
-
static_cast<int>(sz.height));
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
#endif
|
|
746
731
|
static const bool profile = std::getenv("GEA_NATIVE_FRAME_PROFILE") != nullptr;
|
|
747
732
|
using Clock = std::chrono::steady_clock;
|
|
748
733
|
const auto applicationBegin = profile ? Clock::now() : Clock::time_point{};
|
|
@@ -758,21 +743,11 @@ static __weak AppDelegate *gGeaAppDelegate = nil;
|
|
|
758
743
|
// loop and never compiled that file, so `data-anim` declarative animations
|
|
759
744
|
// and @keyframes rules were registered and then never started or advanced —
|
|
760
745
|
// every animated app rendered its first frame and froze. Mirrors
|
|
761
|
-
// runtime.cpp: scan once
|
|
762
|
-
// in a single-app build where activeId() is always null), then tick.
|
|
746
|
+
// runtime.cpp: scan once for the mounted app, then tick.
|
|
763
747
|
{
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
#endif
|
|
768
|
-
static char lastScannedAnim[64] = {0};
|
|
769
|
-
static bool singleAppAnimScanned = false;
|
|
770
|
-
const bool shouldScan = active ? std::strcmp(active, lastScannedAnim) != 0 : !singleAppAnimScanned;
|
|
771
|
-
if (shouldScan) {
|
|
772
|
-
if (active)
|
|
773
|
-
std::strncpy(lastScannedAnim, active, sizeof(lastScannedAnim) - 1);
|
|
774
|
-
else
|
|
775
|
-
singleAppAnimScanned = true;
|
|
748
|
+
static bool animScanned = false;
|
|
749
|
+
if (!animScanned) {
|
|
750
|
+
animScanned = true;
|
|
776
751
|
gea::css::DeclarativeAnimations::scanAndStart(gea_embedded_now_ms());
|
|
777
752
|
}
|
|
778
753
|
}
|
|
@@ -1389,12 +1364,16 @@ static int prerenderWorker()
|
|
|
1389
1364
|
NSNumber *heightNumber = request[@"height"] ?: @220;
|
|
1390
1365
|
NSNumber *dprNumber = request[@"dpr"] ?: @1;
|
|
1391
1366
|
NSNumber *reuse = request[@"reusePage"] ?: @NO;
|
|
1367
|
+
NSString *selector = request[@"selector"] ?: @"";
|
|
1368
|
+
NSNumber *transparent = request[@"transparent"] ?: @NO;
|
|
1392
1369
|
if (![input isKindOfClass:NSString.class] || input.length == 0 ||
|
|
1393
1370
|
![output isKindOfClass:NSString.class] || output.length == 0 ||
|
|
1394
1371
|
![widthNumber isKindOfClass:NSNumber.class] ||
|
|
1395
1372
|
![heightNumber isKindOfClass:NSNumber.class] ||
|
|
1396
1373
|
![dprNumber isKindOfClass:NSNumber.class] ||
|
|
1397
1374
|
![reuse isKindOfClass:NSNumber.class] ||
|
|
1375
|
+
![selector isKindOfClass:NSString.class] ||
|
|
1376
|
+
![transparent isKindOfClass:NSNumber.class] ||
|
|
1398
1377
|
widthNumber.doubleValue != widthNumber.intValue ||
|
|
1399
1378
|
heightNumber.doubleValue != heightNumber.intValue ||
|
|
1400
1379
|
!validPrerenderViewport(widthNumber.intValue, heightNumber.intValue, dprNumber.doubleValue)) {
|
|
@@ -1404,7 +1383,8 @@ static int prerenderWorker()
|
|
|
1404
1383
|
|
|
1405
1384
|
const int width = widthNumber.intValue, height = heightNumber.intValue;
|
|
1406
1385
|
const double dpr = dprNumber.doubleValue;
|
|
1407
|
-
const bool
|
|
1386
|
+
const bool isolated = selector.length != 0 || transparent.boolValue;
|
|
1387
|
+
const bool reusePage = reuse.boolValue && !isolated && mountedInput == input.UTF8String &&
|
|
1408
1388
|
mountedWidth == width && mountedHeight == height && mountedDpr == dpr;
|
|
1409
1389
|
const auto started = std::chrono::steady_clock::now();
|
|
1410
1390
|
try {
|
|
@@ -1421,10 +1401,12 @@ static int prerenderWorker()
|
|
|
1421
1401
|
mountedHeight = height;
|
|
1422
1402
|
mountedDpr = dpr;
|
|
1423
1403
|
}
|
|
1424
|
-
if (!gea_macos_write_prerender_png(output)) {
|
|
1404
|
+
if (!gea_macos_write_prerender_png(output, selector.UTF8String, transparent.boolValue)) {
|
|
1405
|
+
mountedInput.clear();
|
|
1425
1406
|
connected = writePrerenderReply(protocol, @{@"ok": @NO, @"error": @"Could not write the PNG"});
|
|
1426
1407
|
continue;
|
|
1427
1408
|
}
|
|
1409
|
+
if (isolated) mountedInput.clear();
|
|
1428
1410
|
const double ms = std::chrono::duration<double, std::milli>(
|
|
1429
1411
|
std::chrono::steady_clock::now() - started).count();
|
|
1430
1412
|
connected = writePrerenderReply(protocol, @{@"ok": @YES, @"ms": @(ms), @"reusedPage": @(reusePage)});
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
#pragma once
|
|
3
3
|
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
4
6
|
@class NSString;
|
|
5
7
|
|
|
6
8
|
bool gea_macos_prepare_prerender(int width, int height);
|
|
7
|
-
bool gea_macos_write_prerender_png(NSString *path);
|
|
9
|
+
bool gea_macos_write_prerender_png(NSString *path, const std::string &selector = {}, bool transparent = false);
|
|
8
10
|
void gea_macos_set_prerender_time(int timestampMs);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// The font generator puts that set -- its raster baseline plus every
|
|
6
6
|
// `--gea-font-charset` the app's CSS names -- into gea_embedded_font_generated.cpp,
|
|
7
7
|
// but a windowed macOS build does not link that TU (it carries baked atlases the
|
|
8
|
-
// window never uses)
|
|
8
|
+
// window never uses). Without this file
|
|
9
9
|
// the engine's weak default applies and `·`, `€`, `–` render as `?`.
|
|
10
10
|
//
|
|
11
11
|
// usage: runtime-glyphs.mjs --out <file.cpp> <gea_embedded_font_generated.cpp>...
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
#include <string.h>
|
|
2
|
-
|
|
3
|
-
int gea_embedded_apps_launch(const char *app_id);
|
|
4
|
-
int gea_embedded_apps_return_to_launcher_on_reset(void);
|
|
5
|
-
void gea_embedded_apps_start_launcher_button_task(void);
|
|
6
|
-
const char *gea_embedded_apps_get_current_id(void);
|
|
7
|
-
|
|
8
|
-
static char s_current_app_id[64] = "";
|
|
9
|
-
|
|
10
|
-
int gea_embedded_apps_launch(const char *app_id)
|
|
11
|
-
{
|
|
12
|
-
if (!app_id || !app_id[0]) return 0;
|
|
13
|
-
strncpy(s_current_app_id, app_id, sizeof(s_current_app_id) - 1);
|
|
14
|
-
s_current_app_id[sizeof(s_current_app_id) - 1] = '\0';
|
|
15
|
-
return 1;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
int gea_embedded_apps_return_to_launcher_on_reset(void)
|
|
19
|
-
{
|
|
20
|
-
return 0;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
void gea_embedded_apps_start_launcher_button_task(void) {}
|
|
24
|
-
|
|
25
|
-
const char *gea_embedded_apps_get_current_id(void)
|
|
26
|
-
{
|
|
27
|
-
return s_current_app_id;
|
|
28
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Per-resident-app entry.cpp generator (macOS-flavoured).
|
|
3
|
-
// Mirrors the template in targets/esp32-s3-touch-amoled-2.06/main/CMakeLists.txt
|
|
4
|
-
// but drops ESP-only host integration. Each entry.cpp exposes
|
|
5
|
-
// <prefix>_init/_frame/_settings_toggle/_mirror_*/_lookup_font*/_ble_* so the
|
|
6
|
-
// generated registry can populate a ResidentApp slot for this app.
|
|
7
|
-
|
|
8
|
-
import { writeFileSync } from 'node:fs'
|
|
9
|
-
|
|
10
|
-
const [, , prefix, outPath] = process.argv
|
|
11
|
-
if (!prefix || !outPath) {
|
|
12
|
-
console.error('Usage: generate-resident-entry.mjs <prefix> <out-cpp>')
|
|
13
|
-
process.exit(1)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const code = `// Auto-generated by targets/macos/generate-resident-entry.mjs. Do not edit.
|
|
17
|
-
#include "app.h"
|
|
18
|
-
#include "gea/embedded.h"
|
|
19
|
-
#include "graphics/font.h"
|
|
20
|
-
#include "host/timers.h"
|
|
21
|
-
#include "host/websocket.h"
|
|
22
|
-
#include "host/rtc.h"
|
|
23
|
-
#include "ui/document.h"
|
|
24
|
-
#include "ui/style.h"
|
|
25
|
-
|
|
26
|
-
extern void ${prefix}_top_level();
|
|
27
|
-
extern void ${prefix}_register_styles();
|
|
28
|
-
extern void gea_cpp_clear_microtasks();
|
|
29
|
-
|
|
30
|
-
namespace gea::framework::app::generated::${prefix} {
|
|
31
|
-
void drainMicrotasks();
|
|
32
|
-
} // namespace gea::framework::app::generated::${prefix}
|
|
33
|
-
|
|
34
|
-
void __attribute__((weak)) ${prefix}_register_styles() {}
|
|
35
|
-
|
|
36
|
-
void ${prefix}_init(int w, int h, double devicePixelRatio)
|
|
37
|
-
{
|
|
38
|
-
\tgea::embedded::ui::Document::setPreferredMountSize(w, h);
|
|
39
|
-
\tgea::embedded::ui::setViewportMetrics(w, h, devicePixelRatio);
|
|
40
|
-
\tgea::host::resetAnimationFrameCallbacks();
|
|
41
|
-
\tgea::host::resetScheduledTimers();
|
|
42
|
-
\tgea_cpp_clear_microtasks();
|
|
43
|
-
\tgea::embedded::ui::StyleSheet::instance().clear();
|
|
44
|
-
\t${prefix}_register_styles();
|
|
45
|
-
\tgea::embedded::ui::Document::instance().clear();
|
|
46
|
-
\t${prefix}_top_level();
|
|
47
|
-
\tgea::embedded::ui::Document::instance().refreshMountedIfDirty();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
void ${prefix}_frame(int timestamp_ms)
|
|
51
|
-
{
|
|
52
|
-
\t// Renderer callbacks create many short-lived native references. Keep the
|
|
53
|
-
\t// cycle collector out of those callbacks so their stack-owned references
|
|
54
|
-
\t// unwind before the collector traces the live graph.
|
|
55
|
-
\t{
|
|
56
|
-
\t\tgea::CycleCollectionDeferral deferCycleCollection;
|
|
57
|
-
\t\tgea::framework::app::generated::${prefix}::drainMicrotasks();
|
|
58
|
-
\t\tgea::host::runAnimationFrameCallbacks(timestamp_ms);
|
|
59
|
-
\t\tgea::host::websocket::runCallbacks();
|
|
60
|
-
\t\tgea::host::rtc::runCallbacks();
|
|
61
|
-
\t\tgea::embedded::ui::Document::instance().frame(timestamp_ms);
|
|
62
|
-
\t\tgea::embedded::ui::Document::instance().refreshMountedIfDirty();
|
|
63
|
-
\t}
|
|
64
|
-
\tgea::collectCyclesIfNeeded();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
void ${prefix}_settings_toggle() {}
|
|
68
|
-
int ${prefix}_mirror_begin_snapshot() { return 0; }
|
|
69
|
-
int ${prefix}_mirror_begin_diff() { return 0; }
|
|
70
|
-
int ${prefix}_mirror_next_record(unsigned char *, int) { return 0; }
|
|
71
|
-
void ${prefix}_mirror_clear_dirty() {}
|
|
72
|
-
void ${prefix}_ble_connected() {}
|
|
73
|
-
void ${prefix}_ble_disconnected() {}
|
|
74
|
-
void ${prefix}_ble_bound() {}
|
|
75
|
-
// Note: <prefix>_lookup_font, lookup_font_for_family, lookup_font_family
|
|
76
|
-
// come from each app's gea_embedded_font_generated.cpp — don't emit
|
|
77
|
-
// duplicates here or the link fails with multiple-definition errors.
|
|
78
|
-
`
|
|
79
|
-
|
|
80
|
-
writeFileSync(outPath, code)
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Generates the macOS resident-apps registry .cpp. Mirrors the ESP32
|
|
3
|
-
// generator (scripts/generate-resident-app-registry.mjs) but drops the
|
|
4
|
-
// FreeRTOS / ESP_LOG machinery — macOS uses std::mutex for pending-launch
|
|
5
|
-
// sync and just leaves the swap to be drained from the AppKit main tick.
|
|
6
|
-
//
|
|
7
|
-
// Usage: generate-resident-registry.mjs <out-cpp> <launcher-id> <app-id...>
|
|
8
|
-
// First app-id is treated as the boot/active app.
|
|
9
|
-
|
|
10
|
-
import { writeFileSync } from 'node:fs'
|
|
11
|
-
|
|
12
|
-
const [, , outPath, launcherId, ...appIds] = process.argv
|
|
13
|
-
if (!outPath || !launcherId || appIds.length === 0) {
|
|
14
|
-
console.error('Usage: generate-resident-registry.mjs <out-cpp> <launcher-id> <app-id...>')
|
|
15
|
-
process.exit(1)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const safe = (id) => id.replace(/[^A-Za-z0-9_]/g, '_')
|
|
19
|
-
const prefix = (id) => `gea_resident_${safe(id)}`
|
|
20
|
-
const quote = (s) => s.replace(/\\/g, '\\\\').replace(/"/g, '\\"')
|
|
21
|
-
|
|
22
|
-
const lines = []
|
|
23
|
-
lines.push('// Auto-generated by targets/macos/generate-resident-registry.mjs.')
|
|
24
|
-
lines.push('// Do not edit.')
|
|
25
|
-
lines.push('#include "app.h"')
|
|
26
|
-
lines.push('#include "apps.h"')
|
|
27
|
-
lines.push('#include "resident_apps.h"')
|
|
28
|
-
lines.push('#include "graphics/font.h"')
|
|
29
|
-
lines.push('')
|
|
30
|
-
lines.push('#include <cstdio>')
|
|
31
|
-
lines.push('#include <cstring>')
|
|
32
|
-
lines.push('#include <mutex>')
|
|
33
|
-
lines.push('')
|
|
34
|
-
|
|
35
|
-
for (const id of appIds) {
|
|
36
|
-
const p = prefix(id)
|
|
37
|
-
lines.push(`extern void ${p}_init(int w, int h, double devicePixelRatio);`)
|
|
38
|
-
lines.push(`extern void ${p}_frame(int timestamp_ms);`)
|
|
39
|
-
lines.push(`extern void ${p}_settings_toggle();`)
|
|
40
|
-
}
|
|
41
|
-
lines.push('')
|
|
42
|
-
|
|
43
|
-
lines.push('namespace gea::framework::apps {')
|
|
44
|
-
lines.push('namespace {')
|
|
45
|
-
lines.push(`constexpr const char *kLauncherAppId = "${quote(launcherId)}";`)
|
|
46
|
-
lines.push('std::mutex &pendingLock() { static std::mutex m; return m; }')
|
|
47
|
-
lines.push('char pendingLaunchAppId[64] = "";')
|
|
48
|
-
lines.push('bool pendingValid = false;')
|
|
49
|
-
lines.push('')
|
|
50
|
-
lines.push('const ResidentApp residentApps[] = {')
|
|
51
|
-
for (const id of appIds) {
|
|
52
|
-
const p = prefix(id)
|
|
53
|
-
lines.push('\t{')
|
|
54
|
-
lines.push(`\t\t.id = "${quote(id)}",`)
|
|
55
|
-
lines.push(`\t\t.displayFlushChunkRows = 0,`)
|
|
56
|
-
lines.push(`\t\t.displayFlushQueueDepth = 0,`)
|
|
57
|
-
lines.push(`\t\t.init = ${p}_init,`)
|
|
58
|
-
lines.push(`\t\t.frame = ${p}_frame,`)
|
|
59
|
-
lines.push(`\t\t.settingsToggle = ${p}_settings_toggle,`)
|
|
60
|
-
lines.push('\t},')
|
|
61
|
-
}
|
|
62
|
-
lines.push('};')
|
|
63
|
-
lines.push(`constexpr int kResidentAppCount = ${appIds.length};`)
|
|
64
|
-
lines.push('const ResidentApp *activeApp = &residentApps[0];')
|
|
65
|
-
lines.push('')
|
|
66
|
-
lines.push('const ResidentApp *findApp(const char *appId)')
|
|
67
|
-
lines.push('{')
|
|
68
|
-
lines.push("\tif (!appId || appId[0] == '\\0') return nullptr;")
|
|
69
|
-
lines.push('\tfor (int i = 0; i < kResidentAppCount; i++) {')
|
|
70
|
-
lines.push('\t\tif (std::strcmp(residentApps[i].id, appId) == 0) return &residentApps[i];')
|
|
71
|
-
lines.push('\t}')
|
|
72
|
-
lines.push('\treturn nullptr;')
|
|
73
|
-
lines.push('}')
|
|
74
|
-
lines.push('} // namespace')
|
|
75
|
-
lines.push('')
|
|
76
|
-
lines.push('namespace generated {')
|
|
77
|
-
lines.push('const ResidentApp *activeResidentApp() { return activeApp; }')
|
|
78
|
-
lines.push('} // namespace generated')
|
|
79
|
-
lines.push('')
|
|
80
|
-
lines.push('bool ResidentApps::isEnabled() { return kResidentAppCount > 0; }')
|
|
81
|
-
lines.push('const char *ResidentApps::activeId() { return activeApp ? activeApp->id : nullptr; }')
|
|
82
|
-
lines.push('')
|
|
83
|
-
lines.push('bool ResidentApps::select(const char *appId)')
|
|
84
|
-
lines.push('{')
|
|
85
|
-
lines.push('\tconst ResidentApp *next = findApp(appId);')
|
|
86
|
-
lines.push('\tif (!next) return false;')
|
|
87
|
-
lines.push('\tactiveApp = next;')
|
|
88
|
-
lines.push('\treturn true;')
|
|
89
|
-
lines.push('}')
|
|
90
|
-
lines.push('')
|
|
91
|
-
lines.push('bool ResidentApps::requestLaunch(const char *appId)')
|
|
92
|
-
lines.push('{')
|
|
93
|
-
lines.push('\tif (!findApp(appId)) return false;')
|
|
94
|
-
lines.push('\tstd::lock_guard guard(pendingLock());')
|
|
95
|
-
lines.push('\tstd::snprintf(pendingLaunchAppId, sizeof(pendingLaunchAppId), "%s", appId);')
|
|
96
|
-
lines.push('\tpendingValid = true;')
|
|
97
|
-
lines.push('\treturn true;')
|
|
98
|
-
lines.push('}')
|
|
99
|
-
lines.push('')
|
|
100
|
-
lines.push('bool ResidentApps::consumeLaunch(char *dst, std::size_t cap)')
|
|
101
|
-
lines.push('{')
|
|
102
|
-
lines.push('\tstd::lock_guard guard(pendingLock());')
|
|
103
|
-
lines.push('\tif (!pendingValid) return false;')
|
|
104
|
-
lines.push('\tif (dst && cap > 0) std::snprintf(dst, cap, "%s", pendingLaunchAppId);')
|
|
105
|
-
lines.push('\tpendingValid = false;')
|
|
106
|
-
lines.push("\tpendingLaunchAppId[0] = '\\0';")
|
|
107
|
-
lines.push('\treturn true;')
|
|
108
|
-
lines.push('}')
|
|
109
|
-
lines.push('')
|
|
110
|
-
lines.push('bool ResidentApps::returnToLauncher(const char *trigger)')
|
|
111
|
-
lines.push('{')
|
|
112
|
-
lines.push('\t(void)trigger;')
|
|
113
|
-
lines.push('\tif (!activeApp || std::strcmp(activeApp->id, kLauncherAppId) == 0) return false;')
|
|
114
|
-
lines.push('\treturn ResidentApps::requestLaunch(kLauncherAppId);')
|
|
115
|
-
lines.push('}')
|
|
116
|
-
lines.push('')
|
|
117
|
-
lines.push('} // namespace gea::framework::apps')
|
|
118
|
-
lines.push('')
|
|
119
|
-
// Application::init / frame / toggleSettings are normally provided by
|
|
120
|
-
// gea_app_entry.cpp (single-app mode). In multi-app mode the launcher's
|
|
121
|
-
// macOS build drops gea_app_entry.cpp and emits this version instead, so
|
|
122
|
-
// Application::init dispatches to whichever resident is currently active.
|
|
123
|
-
lines.push('namespace gea::framework::app {')
|
|
124
|
-
lines.push('void Application::init(int width, int height, double devicePixelRatio)')
|
|
125
|
-
lines.push('{')
|
|
126
|
-
lines.push('\tconst auto *active = gea::framework::apps::generated::activeResidentApp();')
|
|
127
|
-
lines.push('\tif (active && active->init) active->init(width, height, devicePixelRatio);')
|
|
128
|
-
lines.push('}')
|
|
129
|
-
lines.push('void Application::frame(int timestampMs)')
|
|
130
|
-
lines.push('{')
|
|
131
|
-
lines.push('\tconst auto *active = gea::framework::apps::generated::activeResidentApp();')
|
|
132
|
-
lines.push('\tif (active && active->frame) active->frame(timestampMs);')
|
|
133
|
-
lines.push('}')
|
|
134
|
-
lines.push('void Application::toggleSettings()')
|
|
135
|
-
lines.push('{')
|
|
136
|
-
lines.push('\tconst auto *active = gea::framework::apps::generated::activeResidentApp();')
|
|
137
|
-
lines.push('\tif (active && active->settingsToggle) active->settingsToggle();')
|
|
138
|
-
lines.push('}')
|
|
139
|
-
lines.push('} // namespace gea::framework::app')
|
|
140
|
-
|
|
141
|
-
writeFileSync(outPath, lines.join('\n') + '\n')
|