@geastack/apple 0.2.14 → 0.2.16

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.
Files changed (36) hide show
  1. package/dist/index.js +7 -0
  2. package/generated/ActivityKit.d.ts +3 -0
  3. package/generated/AppKit.d.ts +5 -0
  4. package/generated/CoreGraphics.d.ts +3 -0
  5. package/generated/CoreLocation.d.ts +1 -0
  6. package/generated/CoreMedia.d.ts +1 -0
  7. package/generated/Dispatch.d.ts +2 -0
  8. package/generated/Foundation.d.ts +7 -0
  9. package/generated/MapKit.d.ts +1 -0
  10. package/generated/Metal.d.ts +2 -0
  11. package/generated/Security.d.ts +3 -0
  12. package/generated/SwiftData.d.ts +5 -0
  13. package/generated/UIKit.d.ts +1 -0
  14. package/generated/UserNotifications.d.ts +3 -0
  15. package/package.json +7 -7
  16. package/targets/ios/generate-xcode-project.mjs +5 -0
  17. package/targets/macos/app-compiler-plugins.mjs +22 -0
  18. package/targets/macos/build-macos.sh +108 -6
  19. package/targets/macos/generate-resident-entry.mjs +1 -1
  20. package/targets/macos/main/canvas_view.mm +8 -8
  21. package/targets/macos/main/color_convert.h +3 -3
  22. package/targets/macos/main/color_convert.mm +12 -12
  23. package/targets/macos/main/font_registry.h +2 -0
  24. package/targets/macos/main/font_registry.mm +72 -51
  25. package/targets/macos/main/image_bridge.h +5 -2
  26. package/targets/macos/main/image_bridge.mm +47 -9
  27. package/targets/macos/main/macos_background_test.h +54 -0
  28. package/targets/macos/main/macos_control_admission.h +13 -0
  29. package/targets/macos/main/macos_display.mm +29 -27
  30. package/targets/macos/main/macos_key_event.h +73 -0
  31. package/targets/macos/main/macos_main.mm +410 -14
  32. package/targets/macos/main/macos_renderer.h +5 -0
  33. package/targets/macos/main/macos_renderer.mm +717 -80
  34. package/targets/macos/main/press_bridge.h +21 -3
  35. package/targets/macos/main/press_bridge.mm +126 -26
  36. package/targets/macos/sync-resources.mjs +24 -2
package/dist/index.js CHANGED
@@ -2421,6 +2421,13 @@ function declarationForFramework(framework) {
2421
2421
  if ((framework.constants ?? []).length > 0)
2422
2422
  lines.push('');
2423
2423
  for (const fn of framework.functions ?? []) {
2424
+ // Every framework function is a native bridge: its arguments cross as
2425
+ // native carriers, so it cannot write, define or delete a property on any
2426
+ // script object. Without the contract, geatsc's global mutation census
2427
+ // reads each call as able to rewrite every intrinsic its arguments reach
2428
+ // (an `NSView` reaches `Object` through `.constructor`), which revokes the
2429
+ // stock `Object.assign` for the whole program.
2430
+ lines.push('/** @gea-host-no-property-writes */');
2424
2431
  lines.push(`export declare function ${fn.name}(${parametersSignature(fn.parameters ?? [], framework.name)}): ${typeScriptType(fn.returns, framework.name)}`);
2425
2432
  }
2426
2433
  if ((framework.functions ?? []).length > 0)
@@ -1,5 +1,8 @@
1
+ /** @gea-host-no-property-writes */
1
2
  export declare function requestLiveActivity(attributesJSON: string, contentStateJSON: string): LiveActivityHandle
3
+ /** @gea-host-no-property-writes */
2
4
  export declare function updateLiveActivity(activity: LiveActivityHandle, contentStateJSON: string): void
5
+ /** @gea-host-no-property-writes */
3
6
  export declare function endLiveActivity(activity: LiveActivityHandle): void
4
7
 
5
8
  export declare class LiveActivityHandle {
@@ -54,10 +54,15 @@ export declare const NSLayoutPriorityDefaultLow: number
54
54
  export declare const NSBoxCustom: number
55
55
  export declare const ObjCTargetAction: Selector
56
56
 
57
+ /** @gea-host-no-property-writes */
57
58
  export declare function installRootView(view: NSView): void
59
+ /** @gea-host-no-property-writes */
58
60
  export declare function installRootViewController(viewController: NSViewController): void
61
+ /** @gea-host-no-property-writes */
59
62
  export declare function installToolbar(spec: string, newNoteTarget: NSObject | null): void
63
+ /** @gea-host-no-property-writes */
60
64
  export declare function runDeviceCommand(command: string): string
65
+ /** @gea-host-no-property-writes */
61
66
  export declare function setScrollDocumentTopAligned(scrollView: NSScrollView, content: NSView): void
62
67
 
63
68
  export declare class NSColor extends NSObject {
@@ -1,5 +1,8 @@
1
+ /** @gea-host-no-property-writes */
1
2
  export declare function CGRectMake(x: number, y: number, width: number, height: number): CGRect
3
+ /** @gea-host-no-property-writes */
2
4
  export declare function CGPointMake(x: number, y: number): CGPoint
5
+ /** @gea-host-no-property-writes */
3
6
  export declare function CGSizeMake(width: number, height: number): CGSize
4
7
 
5
8
  export interface CGPoint {
@@ -5,6 +5,7 @@ export declare const CLDistanceFilterNone: number
5
5
  export declare const CLAuthorizationStatusNotDetermined: number
6
6
  export declare const CLAuthorizationStatusAuthorizedWhenInUse: number
7
7
 
8
+ /** @gea-host-no-property-writes */
8
9
  export declare function CLLocationCoordinate2DMake(latitude: number, longitude: number): CLLocationCoordinate2D
9
10
 
10
11
  export interface CLLocationCoordinate2D {
@@ -1,3 +1,4 @@
1
+ /** @gea-host-no-property-writes */
1
2
  export declare function CMTimeMakeWithSeconds(seconds: number, preferredTimescale: number): CMTime
2
3
 
3
4
  export interface CMTime {
@@ -1,2 +1,4 @@
1
+ /** @gea-host-no-property-writes */
1
2
  export declare function dispatchAsyncGlobal(execute: () => void): void
3
+ /** @gea-host-no-property-writes */
2
4
  export declare function dispatchAsyncMain(execute: () => void): void
@@ -1,9 +1,16 @@
1
+ /** @gea-host-no-property-writes */
1
2
  export declare function randomUUID(): string
3
+ /** @gea-host-no-property-writes */
2
4
  export declare function localTimeZone(): string
5
+ /** @gea-host-no-property-writes */
3
6
  export declare function sharedContainerPath(groupIdentifier: string): string
7
+ /** @gea-host-no-property-writes */
4
8
  export declare function readTextFile(path: string): string
9
+ /** @gea-host-no-property-writes */
5
10
  export declare function writeTextFile(path: string, text: string): void
11
+ /** @gea-host-no-property-writes */
6
12
  export declare function watchPath(path: string, changed: () => void): number
13
+ /** @gea-host-no-property-writes */
7
14
  export declare function stopWatchingPath(handle: number): void
8
15
 
9
16
  export declare class NSObject {
@@ -7,6 +7,7 @@ export declare const MKMapTypeSatellite: number
7
7
  export declare const MKUserTrackingModeNone: number
8
8
  export declare const MKUserTrackingModeFollow: number
9
9
 
10
+ /** @gea-host-no-property-writes */
10
11
  export declare function MKCoordinateRegionMakeWithDistance(centerCoordinate: CLLocationCoordinate2D, latitudinalMeters: number, longitudinalMeters: number): MKCoordinateRegion
11
12
 
12
13
  export interface MKCoordinateSpan {
@@ -5,7 +5,9 @@ export declare const MTLPrimitiveTypeTriangle: number
5
5
  export declare const MTLResourceStorageModeShared: number
6
6
  export declare const MTLCompareFunctionLess: number
7
7
 
8
+ /** @gea-host-no-property-writes */
8
9
  export declare function MTLCreateSystemDefaultDevice(): MTLDevice | null
10
+ /** @gea-host-no-property-writes */
9
11
  export declare function MTLClearColorMake(red: number, green: number, blue: number, alpha: number): MTLClearColor
10
12
 
11
13
  export interface MTLClearColor {
@@ -1,3 +1,6 @@
1
+ /** @gea-host-no-property-writes */
1
2
  export declare function writePassword(service: string, account: string, password: string): number
3
+ /** @gea-host-no-property-writes */
2
4
  export declare function readPassword(service: string, account: string): string
5
+ /** @gea-host-no-property-writes */
3
6
  export declare function deletePassword(service: string, account: string): number
@@ -1,7 +1,12 @@
1
+ /** @gea-host-no-property-writes */
1
2
  export declare function openModelContainer(schemaJSON: string): ModelContainer
3
+ /** @gea-host-no-property-writes */
2
4
  export declare function mainModelContext(container: ModelContainer): ModelContext
5
+ /** @gea-host-no-property-writes */
3
6
  export declare function insertModelJSON(context: ModelContext, modelJSON: string): void
7
+ /** @gea-host-no-property-writes */
4
8
  export declare function saveModelContext(context: ModelContext): void
9
+ /** @gea-host-no-property-writes */
5
10
  export declare function fetchModelsJSON(context: ModelContext, descriptorJSON: string): string
6
11
 
7
12
  export declare class ModelContainer {
@@ -17,6 +17,7 @@ export declare const UIControlEventTouchCancel: number
17
17
  export declare const UIControlEventValueChanged: number
18
18
  export declare const ObjCTargetAction: Selector
19
19
 
20
+ /** @gea-host-no-property-writes */
20
21
  export declare function installRootView(view: UIView): void
21
22
 
22
23
  export declare class UIColor extends NSObject {
@@ -1,3 +1,6 @@
1
+ /** @gea-host-no-property-writes */
1
2
  export declare function requestAuthorization(completed: (granted: boolean, error: string) => void): void
3
+ /** @gea-host-no-property-writes */
2
4
  export declare function scheduleNotification(identifier: string, title: string, body: string, delaySeconds: number, completed: (error: string) => void): void
5
+ /** @gea-host-no-property-writes */
3
6
  export declare function cancelNotification(identifier: string): void
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/apple",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
4
4
  "description": "Generated Apple SDK bindings plus the macOS and iOS native build targets for Gea apps.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -111,14 +111,14 @@
111
111
  "access": "public"
112
112
  },
113
113
  "dependencies": {
114
- "@geastack/compiler": "^1.0.22",
115
- "@geastack/core": "^0.1.37",
116
- "@geastack/elements": "^0.1.5",
117
- "@geastack/engine": "^0.1.13",
114
+ "@geastack/compiler": "^1.0.34",
115
+ "@geastack/core": "^0.1.44",
116
+ "@geastack/elements": "^0.1.6",
117
+ "@geastack/engine": "^0.1.18",
118
118
  "@geastack/geaos": "^0.1.3",
119
119
  "@geastack/geatsc-plugin-apple-native": "^0.1.4",
120
- "@geastack/geatsc-plugin-gea": "^0.1.19",
121
- "@geastack/host": "^0.1.14"
120
+ "@geastack/geatsc-plugin-gea": "^0.1.24",
121
+ "@geastack/host": "^0.1.18"
122
122
  },
123
123
  "scripts": {
124
124
  "prepublishOnly": "npm run build",
@@ -299,6 +299,10 @@ const includePaths = [
299
299
  ...(process.env.GEA_FW_INCLUDE_DIRS || '').split('\n').filter(Boolean),
300
300
  ]
301
301
 
302
+ // OTHER_LDFLAGS -no_deduplicate: ld64 folds functions with identical code by
303
+ // default, address-taken ones included, and the runtime tells callables apart
304
+ // by entry address (CallableObject::callWithReceiver finds a method's receiver
305
+ // check by it), so a folded method template ran its twin's check.
302
306
  function buildSettings(configuration) {
303
307
  const preprocessorDefinitions = [
304
308
  'GEA_EMBEDDED_GIF_C_API=1',
@@ -331,6 +335,7 @@ function buildSettings(configuration) {
331
335
  IPHONEOS_DEPLOYMENT_TARGET = 16.0;
332
336
  LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
333
337
  ONLY_ACTIVE_ARCH = ${configuration === 'Debug' ? 'YES' : 'NO'};
338
+ OTHER_LDFLAGS = ("$(inherited)", "-Wl,-no_deduplicate");
334
339
  PRODUCT_BUNDLE_IDENTIFIER = ${q(bundleId)};
335
340
  PRODUCT_NAME = ${q(appName)};
336
341
  SDKROOT = iphoneos;
@@ -0,0 +1,22 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+ import {createHash} from 'node:crypto'
4
+ import {fileURLToPath} from 'node:url'
5
+
6
+ // Consume the actual CLI apps-inspect record, not a second app registry.
7
+ export function appCompilerPlugins(app) {
8
+ if(!app||typeof app.root!=='string'||!path.isAbsolute(app.root))throw Error('Missing absolute app root for compiler plugins')
9
+ const entries=app.compilerPlugins??[]
10
+ if(!Array.isArray(entries))throw Error('Invalid app compilerPlugins')
11
+ const paths=[]
12
+ for(const entry of entries){
13
+ if(typeof entry!=='string'||!entry||/[\x00-\x1f\x7f]/.test(entry)||path.isAbsolute(entry)||entry.split(/[\\/]/).includes('..'))throw Error('Invalid declared app compiler plugin')
14
+ const file=fs.realpathSync(path.resolve(app.root,entry))
15
+ if(!fs.statSync(file).isFile())throw Error('Declared app compiler plugin is not a file: '+file)
16
+ if(!paths.includes(file))paths.push(file)
17
+ }
18
+ const hash=createHash('sha256').update('gea-app-compiler-plugins-v1\0')
19
+ for(const file of paths)hash.update(file).update('\0').update(fs.readFileSync(file)).update('\0')
20
+ return {paths,fingerprint:hash.digest('hex')}
21
+ }
22
+ if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url))process.stdout.write(JSON.stringify(appCompilerPlugins(JSON.parse(process.argv[2]))))
@@ -153,7 +153,7 @@ resolve_gea_package() {
153
153
  fi
154
154
  done
155
155
  }
156
- GEA_CORE="$(resolve_gea_package @geastack/core)"
156
+ GEA_CORE="${GEA_CORE:-$(resolve_gea_package @geastack/core)}"
157
157
  GEA_APPLE_NATIVE_PLUGIN="$(resolve_gea_package @geastack/geatsc-plugin-apple-native)"
158
158
  # An app that installs @geastack/apple gets the plugin from node_modules; inside
159
159
  # this repository it is a sibling package that nothing links, so name it there.
@@ -161,8 +161,8 @@ if [[ -z "$GEA_APPLE_NATIVE_PLUGIN" && -d "$ROOT_DIR/../geatsc-plugin-apple-nati
161
161
  GEA_APPLE_NATIVE_PLUGIN="$(cd "$ROOT_DIR/../geatsc-plugin-apple-native" && pwd)"
162
162
  fi
163
163
  [ -n "$GEA_APPLE_NATIVE_PLUGIN" ] && [ -f "$GEA_APPLE_NATIVE_PLUGIN/dist/index.js" ] || { echo "Cannot resolve @geastack/geatsc-plugin-apple-native" >&2; exit 1; }
164
- GEA_COMPILER="$(resolve_gea_package @geastack/compiler)"
165
- GEA_PLUGIN="$(resolve_gea_package @geastack/geatsc-plugin-gea)"
164
+ GEA_COMPILER="${GEA_COMPILER:-$(resolve_gea_package @geastack/compiler)}"
165
+ GEA_PLUGIN="${GEA_PLUGIN:-$(resolve_gea_package @geastack/geatsc-plugin-gea)}"
166
166
  [ -n "$GEA_CORE" ] && [ -f "$GEA_CORE/package.json" ] || { echo "Cannot resolve @geastack/core via node_modules — run 'npm install' in $ROOT_DIR" >&2; exit 1; }
167
167
  GEA_HOST_DIR="${GEA_HOST_DIR:-$GEA_CORE/../host}"
168
168
  GEA_ENGINE_DIR="${GEA_ENGINE_DIR:-$GEA_CORE/../engine}"
@@ -551,7 +551,12 @@ generate_app() {
551
551
  fi
552
552
  local buildConfig="$outDir/gea-build-config.json"
553
553
  mkdir -p "$outDir"
554
- node "${GEA_CLI_BIN:?Use gea build --target macos}" config --project "$appDir" --target macos > "$buildConfig"
554
+ local debugConfigArgs=()
555
+ [[ "${GEA_NATIVE_DEBUGGER:-0}" != "1" ]] || debugConfigArgs+=(--debug)
556
+ if ! node "${GEA_CLI_BIN:?Use gea build --target macos}" config --project "$appDir" --target macos "${debugConfigArgs[@]+"${debugConfigArgs[@]}"}" > "$buildConfig"; then
557
+ echo "Cannot resolve macOS build configuration for '$id'" >&2
558
+ return 1
559
+ fi
555
560
  extraArgs+=(--build-config "$buildConfig")
556
561
  local moduleGraphOnly
557
562
  moduleGraphOnly="$(node -e 'console.log(require(process.argv[1]).settings.compiler?.moduleGraph === "only" ? "1" : "0")' "$buildConfig")"
@@ -566,6 +571,19 @@ generate_app() {
566
571
  elif [[ -f "$appDir/geatsc-plugin.mjs" ]]; then
567
572
  extraArgs+=(--extra-geatsc-plugin "$appDir/geatsc-plugin.mjs")
568
573
  fi
574
+ # Explicit app-owned host mappings are separate from dependency plugins.
575
+ # Resolve the same validated CLI record used by nativeSources below.
576
+ local declaredAppMetadata declaredAppPlugins declaredPluginPath
577
+ declaredAppMetadata="$(node "$GEA_CLI" apps inspect "$id" --json)" || return 1
578
+ declaredAppPlugins="$(node "$ROOT_DIR/targets/macos/app-compiler-plugins.mjs" "$declaredAppMetadata")" || return 1
579
+ while IFS= read -r declaredPluginPath; do
580
+ [[ -n "$declaredPluginPath" ]] || continue
581
+ local alreadySelected=0 selectedArgument
582
+ for selectedArgument in ${extraArgs[@]+"${extraArgs[@]}"}; do
583
+ if [[ "$selectedArgument" == "$declaredPluginPath" ]] || { [[ -f "$selectedArgument" ]] && [[ "$selectedArgument" -ef "$declaredPluginPath" ]]; }; then alreadySelected=1; fi
584
+ done
585
+ (( alreadySelected != 0 )) || extraArgs+=(--extra-geatsc-plugin "$declaredPluginPath")
586
+ done < <(node -e 'for(const p of JSON.parse(process.argv[1]).paths)console.log(p)' "$declaredAppPlugins")
569
587
  if [[ "$appRuntime" == "apple-native" ]]; then
570
588
  extraArgs+=(--apple-native)
571
589
  fi
@@ -575,7 +593,8 @@ generate_app() {
575
593
  local envSignature="GEA_BUILD_CONFIG=$(cat "$buildConfig")
576
594
  GEA_WEBGL_AUTO_INSTANCE=${GEA_WEBGL_AUTO_INSTANCE:-}
577
595
  GEA_WEBGL_AUTO_INSTANCE_TEST=${GEA_WEBGL_AUTO_INSTANCE_TEST:-}
578
- GEA_COMPILER_FINGERPRINT=${compilerFingerprint}"
596
+ GEA_COMPILER_FINGERPRINT=${compilerFingerprint}
597
+ GEA_APP_PLUGIN_FINGERPRINT=$(node -e 'process.stdout.write(JSON.parse(process.argv[1]).fingerprint)' "$declaredAppPlugins")"
579
598
 
580
599
  # Only when an alternate compiler was named, so the default signature -- and
581
600
  # therefore every existing generated directory's freshness -- is unchanged.
@@ -589,6 +608,17 @@ GEA_GEATSC_FINGERPRINT=$(tree_fingerprint "$(dirname "$GEA_GEATSC_BIN")")"
589
608
  local generationSentinel="$outDir/.gea-generation.stamp"
590
609
  local appleStateFile="$outDir/.gea-current-apple-native"
591
610
  local moduleGraphFile="$outDir/module-graph/gea-module-graph.json"
611
+ # Explicit native-only iteration uses the last generated snapshot. Do not
612
+ # update freshness stamps: a normal build must still regenerate changed TS.
613
+ if [[ "${GEA_MACOS_REUSE_GENERATED:-0}" == "1" ]]; then
614
+ [[ -s "$sourceList" ]] || { echo "No generated C++ snapshot for '$id'" >&2; return 1; }
615
+ local snapshotSource
616
+ while IFS= read -r snapshotSource; do
617
+ [[ -s "$snapshotSource" ]] || { echo "Missing generated source: $snapshotSource" >&2; return 1; }
618
+ done < <(read_geatsc_sources "$outDir")
619
+ echo "Reusing generated C++ snapshot for '$id' (native-only rebuild)"
620
+ return 0
621
+ fi
592
622
  if [[ -f "$sourceList" && -f "$generationSentinel" ]]; then
593
623
  local generationInputDirs=()
594
624
  # Every plugin that feeds generation is a generation input: an edit to one
@@ -848,6 +878,10 @@ fi
848
878
 
849
879
  CXX_DEFINES=(
850
880
  -DGEA_EMBEDDED_ENABLE_VIRTUAL_KEYBOARD=0
881
+ # Desktop screens exceed the embedded default of 512 nodes. Apply the
882
+ # capacity consistently to generated app code and every framework TU.
883
+ -DGEA_EMBEDDED_MAX_NODES=8192
884
+ -DGEA_EMBEDDED_MAX_IMAGES=8192
851
885
  # Canvas ctx.fillText glyphs: rasterize at runtime from the bundle's
852
886
  # Resources/Fonts TTFs (font_registry.mm's lookupRuntimeTtfFontForFamily).
853
887
  # Windowed builds link no baked font atlas, so without this canvas text
@@ -856,6 +890,40 @@ CXX_DEFINES=(
856
890
  # registered TTF bytes there, and falls through.
857
891
  -DGEA_EMBEDDED_TTF_RUNTIME_FONTS=1
858
892
  )
893
+ if [[ "${GEA_NATIVE_DEBUGGER:-0}" == "1" ]]; then
894
+ [[ -f "${GEA_DEBUGGER_NATIVE_SOURCE:-}" ]] || { echo "GEA_DEBUGGER_NATIVE_SOURCE must name debugger/native/macos.mm" >&2; exit 2; }
895
+ # Run the same declaration model in the host adapter and native inspector JSC.
896
+ node --input-type=module - "$GEA_DEBUGGER_NATIVE_SOURCE" "$GENERATED_DIR/gea_debugger_css.h" <<'NODE'
897
+ import { readFileSync, writeFileSync, existsSync } from 'node:fs'
898
+ import path from 'node:path'
899
+ const [nativeSource, output] = process.argv.slice(2)
900
+ const source = readFileSync(path.resolve(path.dirname(nativeSource), '../src/css.mjs'), 'utf8')
901
+ const names = [...source.matchAll(/export function (\w+)/g)].map(m => m[1])
902
+ const script = source.replace(/export function /g, 'function ') +
903
+ '\nglobalThis.__geaCSS = {' + names.join(',') + '};\n'
904
+ const header = 'static const char geaDebuggerCss[] = {' +
905
+ [...Buffer.from(script)].join(',') + ',0};\n'
906
+ if (!existsSync(output) || readFileSync(output, 'utf8') !== header) writeFileSync(output, header)
907
+ NODE
908
+ # JSX handlers are delegated to the body; the runtime's listener hook tells
909
+ # the inspector which element registered each one. Its callers are runtime
910
+ # helpers of varying depth, so record several frames; the inspector picks
911
+ # the first one that maps to the app's original source.
912
+ debuggerHooks="$GENERATED_DIR/gea_debugger_hooks.h"
913
+ hooksText='#pragma once
914
+ #ifdef __cplusplus
915
+ extern "C" void gea_debugger_note_listener(int node, const char *type, void *const *sites, int count);
916
+ #define GEA_JSX_NODE_LISTENER_HOOK(node, type) do { \
917
+ _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wframe-address\"") \
918
+ void *const geaDebuggerSites[] = {__builtin_return_address(1), __builtin_return_address(2), \
919
+ __builtin_return_address(3), __builtin_return_address(4)}; \
920
+ _Pragma("clang diagnostic pop") \
921
+ gea_debugger_note_listener((node), (type), geaDebuggerSites, 4); \
922
+ } while (0)
923
+ #endif'
924
+ [[ -f "$debuggerHooks" && "$(cat "$debuggerHooks")" == "$hooksText" ]] || printf '%s\n' "$hooksText" > "$debuggerHooks"
925
+ CXX_DEFINES+=(-DGEA_NATIVE_DEBUGGER=1 -include "$debuggerHooks")
926
+ fi
859
927
  MACOS_SHARED_RUNTIME_BUILTINS="${GEA_MACOS_SHARED_RUNTIME_BUILTINS:-0}"
860
928
  case "$MACOS_SHARED_RUNTIME_BUILTINS" in
861
929
  0) ;;
@@ -906,6 +974,9 @@ case "${GEA_MACOS_THERMALRIGHT_PRODUCT_ID:-}" in
906
974
  THERMALRIGHT_DEFAULT_PRODUCT_ID="${GEA_MACOS_THERMALRIGHT_PRODUCT_ID}"
907
975
  ;;
908
976
  esac
977
+ if [[ "$THERMALRIGHT_DISPLAY_TARGET" == "0" ]]; then
978
+ CXX_DEFINES+=(-DGEA_EMBEDDED_PIXEL_FORMAT=1 -DGEA_CSS_FONT_STRETCH=1) # RGBA8888 and native variable-font style for AppKit
979
+ fi
909
980
  if [[ "$THERMALRIGHT_DISPLAY_TARGET" == "1" ]]; then
910
981
  THERMALRIGHT_WIDTH="${GEA_MACOS_THERMALRIGHT_WIDTH:-$THERMALRIGHT_DEFAULT_WIDTH}"
911
982
  THERMALRIGHT_HEIGHT="${GEA_MACOS_THERMALRIGHT_HEIGHT:-$THERMALRIGHT_DEFAULT_HEIGHT}"
@@ -1012,6 +1083,16 @@ MM_SOURCES=(
1012
1083
  "$ROOT_DIR/targets/macos/main/macos_host_device_control.mm"
1013
1084
  "$ROOT_DIR/targets/macos/main/macos_network.mm"
1014
1085
  )
1086
+ # Fail rather than silently linking weak transport fallbacks from an older core.
1087
+ FRAMEWORK_OBJCXX_SOURCES="$(gea_fw_objcxx_sources)" || exit 1
1088
+ [[ -n "$FRAMEWORK_OBJCXX_SOURCES" ]] || { echo "Missing framework Apple transport sources" >&2; exit 1; }
1089
+ while IFS= read -r framework_mm; do
1090
+ [[ -n "$framework_mm" ]] && MM_SOURCES+=("$framework_mm")
1091
+ done <<< "$FRAMEWORK_OBJCXX_SOURCES"
1092
+
1093
+ if [[ "${GEA_NATIVE_DEBUGGER:-0}" == "1" ]]; then
1094
+ MM_SOURCES+=("$GEA_DEBUGGER_NATIVE_SOURCE")
1095
+ fi
1015
1096
 
1016
1097
  if [[ -n "$SINGLE_APP_DIR" ]]; then
1017
1098
  while IFS= read -r native_src; do
@@ -1868,7 +1949,10 @@ timing_mark compile
1868
1949
  # AVFoundation is unconditional: targets/shared/apple_audio.mm (the real audio
1869
1950
  # backend, oscillators + file/PCM playback) is built into every macOS app, not
1870
1951
  # just apple-native ones.
1871
- LINK_FRAMEWORKS=(-framework Cocoa -framework QuartzCore -framework CoreText -framework IOKit -framework ImageIO -framework CoreGraphics -framework SystemConfiguration -framework AVFoundation)
1952
+ LINK_FRAMEWORKS=(-framework GameController -framework Cocoa -framework QuartzCore -framework CoreText -framework IOKit -framework ImageIO -framework CoreGraphics -framework SystemConfiguration -framework AVFoundation)
1953
+ if [[ "${GEA_NATIVE_DEBUGGER:-0}" == "1" ]]; then
1954
+ LINK_FRAMEWORKS+=(-framework JavaScriptCore)
1955
+ fi
1872
1956
  if [[ "$APPLE_NATIVE" == "1" ]]; then
1873
1957
  # The apple-native bridge emits Objective-C++ for every framework in the
1874
1958
  # metadata (UIKit + the iOS-only AVFoundation camera shims are compiled out
@@ -1881,6 +1965,16 @@ if [[ "$APPLE_NATIVE" == "1" ]]; then
1881
1965
  )
1882
1966
  fi
1883
1967
 
1968
+ # App-owned archive/framework inputs come only from the validated CLI record.
1969
+ APP_LINK_JSON="$(node "$GEA_CLI" apps inspect "$APP_ID" --json)"
1970
+ APP_LINK_RECORD="$(node -e 'const a=JSON.parse(process.argv[1]);const c=a.nativeLink?.macos;if(!c)throw Error("CLI lacks validated macos nativeLink");process.stdout.write(JSON.stringify(c))' "$APP_LINK_JSON")"
1971
+ APP_NATIVE_LIBRARIES=()
1972
+ while IFS= read -r library; do [[ -z "$library" ]] || APP_NATIVE_LIBRARIES+=("$library"); done < <(node -e 'for(const p of JSON.parse(process.argv[1]).nativeLibraries)console.log(p)' "$APP_LINK_RECORD")
1973
+ while IFS= read -r framework; do [[ -z "$framework" ]] || LINK_FRAMEWORKS+=(-framework "$framework"); done < <(node -e 'for(const p of JSON.parse(process.argv[1]).frameworks)console.log(p)' "$APP_LINK_RECORD")
1974
+
1975
+ node "$GEA_CLI" apps sync-native-resources "$APP_ID" --target macos --output "$RES_DIR" > "$BUILD_DIR/native-resources.json"
1976
+ if [[ "$(node -e 'process.stdout.write(String(JSON.parse(require("fs").readFileSync(process.argv[1],"utf8")).changed))' "$BUILD_DIR/native-resources.json")" == "true" ]]; then BUNDLE_CONTENT_CHANGED=1; fi
1977
+
1884
1978
  LINK_OUTPUT="$MACOS_DIR/$APP_EXEC"
1885
1979
  LINK_OUTPUT_TMP="$LINK_OUTPUT.tmp.$$"
1886
1980
  LINK_SIGNATURE_FILE="$BUILD_DIR/link.sig"
@@ -1889,8 +1983,10 @@ LINK_SIGNATURE_TMP="$LINK_SIGNATURE_FILE.tmp.$$"
1889
1983
  printf 'compiler=%s\n' "$MACOS_COMPILER_VERSION"
1890
1984
  printf 'opt=%s\n' "$GEA_MACOS_OPT_LEVEL"
1891
1985
  printf 'debug=%s\n' "${GEA_MACOS_DEBUG_INFO:-}"
1986
+ printf 'link=%s\n' -Wl,-no_deduplicate
1892
1987
  printf 'framework=%s\n' "${LINK_FRAMEWORKS[@]}"
1893
1988
  printf 'object=%s\n' "${OBJ_FILES[@]}"
1989
+ for library in ${APP_NATIVE_LIBRARIES[@]+"${APP_NATIVE_LIBRARIES[@]}"}; do shasum -a 256 "$library"; done
1894
1990
  } > "$LINK_SIGNATURE_TMP"
1895
1991
 
1896
1992
  LINK_NEEDED=0
@@ -1909,9 +2005,15 @@ if (( LINK_NEEDED != 0 )); then
1909
2005
  # Preserve the last complete executable until the linker succeeds. Clear both
1910
2006
  # completion markers first so a killed link is retried and re-signed.
1911
2007
  rm -f "$LINK_SIGNATURE_FILE" "$BUILD_DIR/codesign.complete" "$LINK_OUTPUT_TMP"
2008
+ # -no_deduplicate: ld64 folds functions with identical code by default,
2009
+ # address-taken ones included, and the runtime tells callables apart by
2010
+ # entry address (CallableObject::callWithReceiver finds a method's receiver
2011
+ # check by it), so a folded method template ran its twin's check.
1912
2012
  macos_run_tracked_child clang++ -std=c++20 -ObjC++ -fobjc-arc "$GEA_MACOS_OPT_LEVEL" ${GEA_MACOS_DEBUG_INFO} \
2013
+ -Wl,-no_deduplicate \
1913
2014
  "${LINK_FRAMEWORKS[@]}" \
1914
2015
  "${OBJ_FILES[@]}" \
2016
+ ${APP_NATIVE_LIBRARIES[@]+"${APP_NATIVE_LIBRARIES[@]}"} \
1915
2017
  -o "$LINK_OUTPUT_TMP"
1916
2018
  mv "$LINK_OUTPUT_TMP" "$LINK_OUTPUT"
1917
2019
  mv "$LINK_SIGNATURE_TMP" "$LINK_SIGNATURE_FILE"
@@ -55,7 +55,7 @@ void ${prefix}_frame(int timestamp_ms)
55
55
  \t{
56
56
  \t\tgea::CycleCollectionDeferral deferCycleCollection;
57
57
  \t\tgea::framework::app::generated::${prefix}::drainMicrotasks();
58
- \t\tgea::host::runAnimationFrameCallbacks(static_cast<double>(timestamp_ms));
58
+ \t\tgea::host::runAnimationFrameCallbacks(timestamp_ms);
59
59
  \t\tgea::host::websocket::runCallbacks();
60
60
  \t\tgea::host::rtc::runCallbacks();
61
61
  \t\tgea::embedded::ui::Document::instance().frame(timestamp_ms);
@@ -141,7 +141,7 @@ std::uint8_t *ensureScratch(size_t bytes)
141
141
  if (self.nodeId >= tree.nodeCount()) return;
142
142
  const auto *canvas = tree.canvas(self.nodeId);
143
143
  if (!canvas) return;
144
- const std::uint16_t *src = canvas->pixels();
144
+ const gea::framework::graphics::pixel::native_t *src = canvas->pixels();
145
145
  const int w = canvas->width();
146
146
  const int h = canvas->height();
147
147
  if (!src || w <= 0 || h <= 0) return;
@@ -150,17 +150,17 @@ std::uint8_t *ensureScratch(size_t bytes)
150
150
  std::uint8_t *dst = ensureScratch(bytes);
151
151
  if (!dst) return;
152
152
  for (int i = 0; i < w * h; i++) {
153
- int r, g, b;
154
- gea::framework::graphics::pixel::unpackRgb565(src[i], &r, &g, &b);
155
- dst[i * 4 + 0] = static_cast<std::uint8_t>((r * 255 + 15) / 31);
156
- dst[i * 4 + 1] = static_cast<std::uint8_t>((g * 255 + 31) / 63);
157
- dst[i * 4 + 2] = static_cast<std::uint8_t>((b * 255 + 15) / 31);
158
- dst[i * 4 + 3] = 0xFF;
153
+ int r, g, b, a;
154
+ gea::framework::graphics::pixel::unpackNative8(src[i], &r, &g, &b, &a);
155
+ dst[i * 4 + 0] = static_cast<std::uint8_t>(r);
156
+ dst[i * 4 + 1] = static_cast<std::uint8_t>(g);
157
+ dst[i * 4 + 2] = static_cast<std::uint8_t>(b);
158
+ dst[i * 4 + 3] = static_cast<std::uint8_t>(a);
159
159
  }
160
160
 
161
161
  CGColorSpaceRef cs = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
162
162
  CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, dst, bytes, NULL);
163
- const uint32_t bitmapInfo = (uint32_t)kCGImageAlphaNoneSkipLast | (uint32_t)kCGBitmapByteOrder32Big;
163
+ const uint32_t bitmapInfo = (uint32_t)kCGImageAlphaLast | (uint32_t)kCGBitmapByteOrder32Big;
164
164
  CGImageRef img = CGImageCreate((size_t)w, (size_t)h, 8, 32, (size_t)w * 4,
165
165
  cs, bitmapInfo,
166
166
  provider, NULL, false, kCGRenderingIntentDefault);
@@ -1,6 +1,6 @@
1
1
  #pragma once
2
2
 
3
- #include <cstdint>
3
+ #include "pixel.h"
4
4
 
5
5
  #ifdef __OBJC__
6
6
  @class NSColor;
@@ -9,10 +9,10 @@
9
9
  namespace gea::macos {
10
10
 
11
11
  #ifdef __OBJC__
12
- NSColor *rgb565ToNSColor(std::uint16_t rgb565);
12
+ NSColor *nativeToNSColor(gea::framework::graphics::pixel::native_t color);
13
13
  #endif
14
14
 
15
15
  // Caller-owns the returned CGColorRef; release with CGColorRelease.
16
- struct CGColor *rgb565ToCGColor(std::uint16_t rgb565);
16
+ struct CGColor *nativeToCGColor(gea::framework::graphics::pixel::native_t color);
17
17
 
18
18
  } // namespace gea::macos
@@ -7,33 +7,33 @@ namespace gea::macos {
7
7
 
8
8
  namespace {
9
9
 
10
- void unpack(std::uint16_t rgb565, CGFloat *r, CGFloat *g, CGFloat *b)
10
+ void unpack(gea::framework::graphics::pixel::native_t color, CGFloat *r, CGFloat *g, CGFloat *b)
11
11
  {
12
- int ri, gi, bi;
13
- gea::framework::graphics::pixel::unpackRgb565(rgb565, &ri, &gi, &bi);
14
- *r = static_cast<CGFloat>(ri) / 31.0;
15
- *g = static_cast<CGFloat>(gi) / 63.0;
16
- *b = static_cast<CGFloat>(bi) / 31.0;
12
+ int ri, gi, bi, ai;
13
+ gea::framework::graphics::pixel::unpackNative8(color, &ri, &gi, &bi, &ai);
14
+ *r = static_cast<CGFloat>(ri) / 255.0;
15
+ *g = static_cast<CGFloat>(gi) / 255.0;
16
+ *b = static_cast<CGFloat>(bi) / 255.0;
17
17
  }
18
18
 
19
19
  } // namespace
20
20
 
21
- NSColor *rgb565ToNSColor(std::uint16_t rgb565)
21
+ NSColor *nativeToNSColor(gea::framework::graphics::pixel::native_t color)
22
22
  {
23
23
  CGFloat r, g, b;
24
- unpack(rgb565, &r, &g, &b);
24
+ unpack(color, &r, &g, &b);
25
25
  return [NSColor colorWithSRGBRed:r green:g blue:b alpha:1.0];
26
26
  }
27
27
 
28
- CGColor *rgb565ToCGColor(std::uint16_t rgb565)
28
+ CGColor *nativeToCGColor(gea::framework::graphics::pixel::native_t color)
29
29
  {
30
30
  CGFloat r, g, b;
31
- unpack(rgb565, &r, &g, &b);
31
+ unpack(color, &r, &g, &b);
32
32
  CGFloat comps[4] = {r, g, b, 1.0};
33
33
  CGColorSpaceRef cs = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
34
- CGColorRef color = CGColorCreate(cs, comps);
34
+ CGColorRef result = CGColorCreate(cs, comps);
35
35
  CGColorSpaceRelease(cs);
36
- return color;
36
+ return result;
37
37
  }
38
38
 
39
39
  } // namespace gea::macos
@@ -16,6 +16,8 @@ namespace gea::macos {
16
16
  // to assign stable ids the first time each family is seen. Unknown ids fall
17
17
  // back to the system font.
18
18
  NSFont *fontForId(int fontId, int sizePx);
19
+ // Stretch uses percentage tenths (1000 = 100%). The tuple is part of font identity.
20
+ NSFont *fontForId(int fontId, int sizePx, int weight, int stretch);
19
21
 
20
22
  // Walks `directoryPath` for .ttf / .otf files and registers each with
21
23
  // CTFontManager in the process scope. Returns the count of newly registered