@geastack/apple 0.2.10 → 0.2.11
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 +46 -0
- package/dist/desktop-api.d.ts +3 -0
- package/dist/desktop-api.js +187 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +47 -1
- package/generated/AppKit.d.ts +32 -1
- package/generated/Foundation.d.ts +8 -0
- package/generated/Security.d.ts +3 -0
- package/generated/UserNotifications.d.ts +3 -0
- package/package.json +12 -3
- package/runtime/AVFoundation.js +1 -1
- package/runtime/ActivityKit.js +1 -1
- package/runtime/AppKit.js +38 -5
- package/runtime/CoreGraphics.js +1 -1
- package/runtime/CoreLocation.js +1 -1
- package/runtime/CoreMedia.js +1 -1
- package/runtime/Dispatch.js +1 -1
- package/runtime/Foundation.js +29 -1
- package/runtime/MapKit.js +1 -1
- package/runtime/Metal.js +1 -1
- package/runtime/MetalKit.js +1 -1
- package/runtime/Photos.js +1 -1
- package/runtime/QuartzCore.js +1 -1
- package/runtime/Security.js +15 -0
- package/runtime/SwiftData.js +1 -1
- package/runtime/UIKit.js +1 -1
- package/runtime/UserNotifications.js +15 -0
- package/targets/ios/generate-xcode-project.mjs +2 -0
- package/targets/macos/build-macos.sh +1 -1
package/README.md
CHANGED
|
@@ -43,6 +43,52 @@ Calls into these bindings are compiled to native Objective-C++ by `geatsc`
|
|
|
43
43
|
through `@geastack/geatsc-plugin-apple-native`, which reads binding metadata
|
|
44
44
|
the build generates from this package's declarations.
|
|
45
45
|
|
|
46
|
+
## Desktop services
|
|
47
|
+
|
|
48
|
+
`@geastack/apple/AppKit` exports `NSStatusBar`, `NSStatusItem`, `NSStatusBarButton`,
|
|
49
|
+
`NSMenu`, and `NSMenuItem`. Obtain the shared bar with
|
|
50
|
+
`NSStatusBar.systemStatusBar()`, create an item with `statusItemWithLength(-1)`
|
|
51
|
+
(variable width), set its button title or menu, and retain the item while it is
|
|
52
|
+
in use. Menu items use the existing `ObjCTarget`/selector action bridge.
|
|
53
|
+
Remove the item with `removeStatusItem(item)` when finished.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { randomUUID, localTimeZone, readTextFile, writeTextFile,
|
|
57
|
+
watchPath, stopWatchingPath, sharedContainerPath } from '@geastack/apple/Foundation'
|
|
58
|
+
|
|
59
|
+
const id = randomUUID()
|
|
60
|
+
const timeZone = localTimeZone() // IANA time-zone name
|
|
61
|
+
const folder = sharedContainerPath('group.example.app')
|
|
62
|
+
writeTextFile(folder + '/snapshot.json', JSON.stringify({ id, timeZone }))
|
|
63
|
+
const watch = watchPath(folder, () => {
|
|
64
|
+
const snapshot = readTextFile(folder + '/snapshot.json')
|
|
65
|
+
// Reload application state from the snapshot.
|
|
66
|
+
})
|
|
67
|
+
// Call when the owner is disposed:
|
|
68
|
+
stopWatchingPath(watch)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
File reads and atomic UTF-8 writes are synchronous. Errors throw. Path observation delivers callbacks on the main queue. Observe a file for
|
|
72
|
+
in-place writes, or its directory for entry changes and atomic file replacements.
|
|
73
|
+
Observation is not recursive; after replacing a file, recreate its file observer
|
|
74
|
+
or keep observing its directory. Stop observing before releasing callback-owned state. Sandbox file access
|
|
75
|
+
still requires the application's usual entitlements or granted access.
|
|
76
|
+
`sharedContainerPath` requires matching App Group entitlements on the app and its
|
|
77
|
+
WidgetKit extension. It exposes shared storage; the extension remains a separate
|
|
78
|
+
Xcode target.
|
|
79
|
+
|
|
80
|
+
`@geastack/apple/Security` exports `writePassword(service, account, password)`,
|
|
81
|
+
`readPassword(service, account)`, and `deletePassword(service, account)`. Write
|
|
82
|
+
and delete return the native `OSStatus` (zero means success); read throws on a
|
|
83
|
+
failed lookup. They use generic-password Keychain items.
|
|
84
|
+
|
|
85
|
+
`@geastack/apple/UserNotifications` exports `requestAuthorization(callback)`,
|
|
86
|
+
`scheduleNotification(id, title, body, delaySeconds, callback)`, and
|
|
87
|
+
`cancelNotification(id)`. Authorization returns `(granted, error)`; scheduling
|
|
88
|
+
returns an error string (empty on success). Delays must be positive and finite.
|
|
89
|
+
Completion callbacks run on the main queue. Request authorization from the
|
|
90
|
+
signed application before scheduling; the operating system controls delivery.
|
|
91
|
+
|
|
46
92
|
## App Store
|
|
47
93
|
|
|
48
94
|
The package is Apache-2.0, so App Store distribution has no license obstacle
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
const string = { kind: 'primitive', name: 'string' };
|
|
2
|
+
const number = { kind: 'primitive', name: 'number' };
|
|
3
|
+
const boolean = { kind: 'primitive', name: 'boolean' };
|
|
4
|
+
const nothing = { kind: 'primitive', name: 'void' };
|
|
5
|
+
const callback = { kind: 'function', returns: nothing };
|
|
6
|
+
const completion = {
|
|
7
|
+
kind: 'function',
|
|
8
|
+
returns: nothing,
|
|
9
|
+
parameters: [{ name: 'error', type: string }]
|
|
10
|
+
};
|
|
11
|
+
export const foundationServices = [
|
|
12
|
+
{
|
|
13
|
+
name: 'randomUUID',
|
|
14
|
+
returns: string,
|
|
15
|
+
bridgeBody: 'return gea::apple::Foundation::fromNSString([[NSUUID UUID] UUIDString]);'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'localTimeZone',
|
|
19
|
+
returns: string,
|
|
20
|
+
bridgeBody: 'return gea::apple::Foundation::fromNSString([[NSTimeZone localTimeZone] name]);'
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'sharedContainerPath',
|
|
24
|
+
returns: string,
|
|
25
|
+
parameters: [{ name: 'groupIdentifier', type: string }],
|
|
26
|
+
bridgeBody: `::NSURL *url = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:gea::apple::Foundation::toNSString(groupIdentifier)];
|
|
27
|
+
if (!url) throw std::runtime_error("App Group container is unavailable; check the application's entitlements");
|
|
28
|
+
return gea::apple::Foundation::fromNSString(url.path);`
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'readTextFile',
|
|
32
|
+
returns: string,
|
|
33
|
+
parameters: [{ name: 'path', type: string }],
|
|
34
|
+
bridgeBody: `NSError *error = nil;
|
|
35
|
+
NSString *text = [NSString stringWithContentsOfFile:gea::apple::Foundation::toNSString(path) encoding:NSUTF8StringEncoding error:&error];
|
|
36
|
+
if (!text) throw std::runtime_error(gea::apple::Foundation::fromNSString(error.localizedDescription));
|
|
37
|
+
return gea::apple::Foundation::fromNSString(text);`
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'writeTextFile',
|
|
41
|
+
returns: nothing,
|
|
42
|
+
parameters: [
|
|
43
|
+
{ name: 'path', type: string },
|
|
44
|
+
{ name: 'text', type: string }
|
|
45
|
+
],
|
|
46
|
+
bridgeBody: `NSError *error = nil;
|
|
47
|
+
if (![gea::apple::Foundation::toNSString(text) writeToFile:gea::apple::Foundation::toNSString(path) atomically:YES encoding:NSUTF8StringEncoding error:&error])
|
|
48
|
+
throw std::runtime_error(gea::apple::Foundation::fromNSString(error.localizedDescription));`
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'watchPath',
|
|
52
|
+
returns: number,
|
|
53
|
+
parameters: [
|
|
54
|
+
{ name: 'path', type: string },
|
|
55
|
+
{ name: 'changed', type: callback }
|
|
56
|
+
],
|
|
57
|
+
bridgeBody: `const int descriptor = open(path.c_str(), O_EVTONLY);
|
|
58
|
+
if (descriptor < 0) throw std::runtime_error("Cannot open path for observation");
|
|
59
|
+
dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, descriptor,
|
|
60
|
+
DISPATCH_VNODE_WRITE | DISPATCH_VNODE_DELETE | DISPATCH_VNODE_RENAME | DISPATCH_VNODE_EXTEND | DISPATCH_VNODE_ATTRIB,
|
|
61
|
+
dispatch_get_main_queue());
|
|
62
|
+
if (!source) { close(descriptor); throw std::runtime_error("Cannot observe path"); }
|
|
63
|
+
dispatch_source_set_event_handler(source, ^{ if (changed) changed(); });
|
|
64
|
+
dispatch_source_set_cancel_handler(source, ^{ close(descriptor); });
|
|
65
|
+
const double handle = gea::apple::objc::retain((__bridge void *)source);
|
|
66
|
+
dispatch_resume(source);
|
|
67
|
+
return handle;`
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'stopWatchingPath',
|
|
71
|
+
returns: nothing,
|
|
72
|
+
parameters: [{ name: 'handle', type: number }],
|
|
73
|
+
bridgeBody: `dispatch_source_t source = (__bridge dispatch_source_t)gea::apple::objc::object(handle);
|
|
74
|
+
if (source) { dispatch_source_cancel(source); gea::apple::objc::release(handle); }`
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
export const desktopFrameworks = [
|
|
78
|
+
{
|
|
79
|
+
name: 'Security',
|
|
80
|
+
bridgeHeaders: ['Security/Security.h', 'stdexcept'],
|
|
81
|
+
functions: [
|
|
82
|
+
{
|
|
83
|
+
name: 'writePassword',
|
|
84
|
+
returns: number,
|
|
85
|
+
parameters: [
|
|
86
|
+
{ name: 'service', type: string },
|
|
87
|
+
{ name: 'account', type: string },
|
|
88
|
+
{ name: 'password', type: string }
|
|
89
|
+
],
|
|
90
|
+
bridgeBody: `NSDictionary *query = @{(__bridge id)kSecClass: (__bridge id)kSecClassGenericPassword,
|
|
91
|
+
(__bridge id)kSecAttrService: gea::apple::Foundation::toNSString(service),
|
|
92
|
+
(__bridge id)kSecAttrAccount: gea::apple::Foundation::toNSString(account)};
|
|
93
|
+
NSData *data = [NSData dataWithBytes:password.data() length:password.size()];
|
|
94
|
+
OSStatus status = SecItemUpdate((__bridge CFDictionaryRef)query, (__bridge CFDictionaryRef)@{(__bridge id)kSecValueData: data});
|
|
95
|
+
if (status == errSecItemNotFound) {
|
|
96
|
+
NSMutableDictionary *item = [query mutableCopy];
|
|
97
|
+
item[(__bridge id)kSecValueData] = data;
|
|
98
|
+
status = SecItemAdd((__bridge CFDictionaryRef)item, nullptr);
|
|
99
|
+
}
|
|
100
|
+
return status;`
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'readPassword',
|
|
104
|
+
returns: string,
|
|
105
|
+
parameters: [
|
|
106
|
+
{ name: 'service', type: string },
|
|
107
|
+
{ name: 'account', type: string }
|
|
108
|
+
],
|
|
109
|
+
bridgeBody: `NSDictionary *query = @{(__bridge id)kSecClass: (__bridge id)kSecClassGenericPassword,
|
|
110
|
+
(__bridge id)kSecAttrService: gea::apple::Foundation::toNSString(service),
|
|
111
|
+
(__bridge id)kSecAttrAccount: gea::apple::Foundation::toNSString(account),
|
|
112
|
+
(__bridge id)kSecReturnData: @YES, (__bridge id)kSecMatchLimit: (__bridge id)kSecMatchLimitOne};
|
|
113
|
+
CFTypeRef result = nullptr;
|
|
114
|
+
const OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &result);
|
|
115
|
+
if (status != errSecSuccess) throw std::runtime_error("Keychain read failed: " + std::to_string(status));
|
|
116
|
+
NSData *data = CFBridgingRelease(result);
|
|
117
|
+
return std::string(static_cast<const char *>(data.bytes), data.length);`
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: 'deletePassword',
|
|
121
|
+
returns: number,
|
|
122
|
+
parameters: [
|
|
123
|
+
{ name: 'service', type: string },
|
|
124
|
+
{ name: 'account', type: string }
|
|
125
|
+
],
|
|
126
|
+
bridgeBody: `return SecItemDelete((__bridge CFDictionaryRef)@{(__bridge id)kSecClass: (__bridge id)kSecClassGenericPassword,
|
|
127
|
+
(__bridge id)kSecAttrService: gea::apple::Foundation::toNSString(service),
|
|
128
|
+
(__bridge id)kSecAttrAccount: gea::apple::Foundation::toNSString(account)});`
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: 'UserNotifications',
|
|
134
|
+
bridgeHeaders: ['UserNotifications/UserNotifications.h'],
|
|
135
|
+
functions: [
|
|
136
|
+
{
|
|
137
|
+
name: 'requestAuthorization',
|
|
138
|
+
returns: nothing,
|
|
139
|
+
parameters: [
|
|
140
|
+
{
|
|
141
|
+
name: 'completed',
|
|
142
|
+
type: {
|
|
143
|
+
kind: 'function',
|
|
144
|
+
returns: nothing,
|
|
145
|
+
parameters: [
|
|
146
|
+
{ name: 'granted', type: boolean },
|
|
147
|
+
{ name: 'error', type: string }
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
],
|
|
152
|
+
bridgeBody: `[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge)
|
|
153
|
+
completionHandler:^(BOOL granted, NSError *error) {
|
|
154
|
+
const std::string message = gea::apple::Foundation::fromNSString(error.localizedDescription);
|
|
155
|
+
dispatch_async(dispatch_get_main_queue(), ^{ if (completed) completed(granted, message); });
|
|
156
|
+
}];`
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: 'scheduleNotification',
|
|
160
|
+
returns: nothing,
|
|
161
|
+
parameters: [
|
|
162
|
+
{ name: 'identifier', type: string },
|
|
163
|
+
{ name: 'title', type: string },
|
|
164
|
+
{ name: 'body', type: string },
|
|
165
|
+
{ name: 'delaySeconds', type: number },
|
|
166
|
+
{ name: 'completed', type: completion }
|
|
167
|
+
],
|
|
168
|
+
bridgeBody: `if (!std::isfinite(delaySeconds) || delaySeconds <= 0) { if (completed) completed("delaySeconds must be positive and finite"); return; }
|
|
169
|
+
UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
|
|
170
|
+
content.title = gea::apple::Foundation::toNSString(title);
|
|
171
|
+
content.body = gea::apple::Foundation::toNSString(body);
|
|
172
|
+
UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:delaySeconds repeats:NO];
|
|
173
|
+
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:gea::apple::Foundation::toNSString(identifier) content:content trigger:trigger];
|
|
174
|
+
[[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError *error) {
|
|
175
|
+
const std::string message = gea::apple::Foundation::fromNSString(error.localizedDescription);
|
|
176
|
+
dispatch_async(dispatch_get_main_queue(), ^{ if (completed) completed(message); });
|
|
177
|
+
}];`
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: 'cancelNotification',
|
|
181
|
+
returns: nothing,
|
|
182
|
+
parameters: [{ name: 'identifier', type: string }],
|
|
183
|
+
bridgeBody: '[[UNUserNotificationCenter currentNotificationCenter] removePendingNotificationRequestsWithIdentifiers:@[gea::apple::Foundation::toNSString(identifier)]];'
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
];
|
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export interface ApplePropertyDefinition {
|
|
|
30
30
|
readonly?: boolean;
|
|
31
31
|
}
|
|
32
32
|
export interface AppleFunctionDefinition {
|
|
33
|
+
bridgeBody?: string;
|
|
33
34
|
name: string;
|
|
34
35
|
returns: AppleTypeReference;
|
|
35
36
|
parameters?: AppleParameterDefinition[];
|
|
@@ -79,6 +80,7 @@ export interface AppleBridgeConstantMetadata {
|
|
|
79
80
|
value: string | number | boolean;
|
|
80
81
|
}
|
|
81
82
|
export interface AppleBridgeFunctionMetadata {
|
|
83
|
+
bridgeBody?: string;
|
|
82
84
|
framework: string;
|
|
83
85
|
name: string;
|
|
84
86
|
thunk: string;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { foundationServices, desktopFrameworks } from './desktop-api.js';
|
|
1
2
|
const objcFrameworkImports = {
|
|
2
3
|
AVFoundation: 'AVFoundation/AVFoundation.h',
|
|
3
4
|
CoreMedia: 'CoreMedia/CoreMedia.h',
|
|
@@ -90,6 +91,8 @@ export const appleSdkFixture = {
|
|
|
90
91
|
frameworks: [
|
|
91
92
|
{
|
|
92
93
|
name: 'Foundation',
|
|
94
|
+
bridgeHeaders: ['dispatch/dispatch.h', 'fcntl.h', 'unistd.h', 'stdexcept', 'cmath'],
|
|
95
|
+
functions: foundationServices,
|
|
93
96
|
classes: [
|
|
94
97
|
{ name: 'NSObject' },
|
|
95
98
|
{ name: 'NSData', extends: 'Foundation.NSObject' },
|
|
@@ -1941,6 +1944,40 @@ export const appleSdkFixture = {
|
|
|
1941
1944
|
{ name: 'contentTintColor', type: { kind: 'class', name: 'AppKit.NSColor', nullable: true } },
|
|
1942
1945
|
],
|
|
1943
1946
|
},
|
|
1947
|
+
{
|
|
1948
|
+
name: 'NSMenuItem', extends: 'Foundation.NSObject',
|
|
1949
|
+
constructors: [{ name: 'init', selector: 'init', returns: { kind: 'class', name: 'AppKit.NSMenuItem' } }],
|
|
1950
|
+
properties: [
|
|
1951
|
+
{ name: 'title', type: stringType },
|
|
1952
|
+
{ name: 'keyEquivalent', type: stringType },
|
|
1953
|
+
{ name: 'target', type: { kind: 'class', name: 'Foundation.NSObject', nullable: true } },
|
|
1954
|
+
{ name: 'action', type: selectorType },
|
|
1955
|
+
{ name: 'enabled', type: { kind: 'primitive', name: 'boolean' } },
|
|
1956
|
+
],
|
|
1957
|
+
},
|
|
1958
|
+
{
|
|
1959
|
+
name: 'NSMenu', extends: 'Foundation.NSObject',
|
|
1960
|
+
constructors: [{ name: 'init', selector: 'init', returns: { kind: 'class', name: 'AppKit.NSMenu' } }],
|
|
1961
|
+
properties: [{ name: 'autoenablesItems', type: { kind: 'primitive', name: 'boolean' } }],
|
|
1962
|
+
methods: [{ name: 'addItem', selector: 'addItem:', returns: voidType, parameters: [{ name: 'item', type: { kind: 'class', name: 'AppKit.NSMenuItem' } }] }],
|
|
1963
|
+
},
|
|
1964
|
+
{
|
|
1965
|
+
name: 'NSStatusBar', extends: 'Foundation.NSObject',
|
|
1966
|
+
methods: [
|
|
1967
|
+
{ name: 'systemStatusBar', selector: 'systemStatusBar', static: true, returns: { kind: 'class', name: 'AppKit.NSStatusBar' } },
|
|
1968
|
+
{ name: 'statusItemWithLength', selector: 'statusItemWithLength:', returns: { kind: 'class', name: 'AppKit.NSStatusItem' }, parameters: [{ name: 'length', type: numberType }] },
|
|
1969
|
+
{ name: 'removeStatusItem', selector: 'removeStatusItem:', returns: voidType, parameters: [{ name: 'item', type: { kind: 'class', name: 'AppKit.NSStatusItem' } }] },
|
|
1970
|
+
],
|
|
1971
|
+
},
|
|
1972
|
+
{
|
|
1973
|
+
name: 'NSStatusItem', extends: 'Foundation.NSObject',
|
|
1974
|
+
properties: [
|
|
1975
|
+
{ name: 'menu', type: { kind: 'class', name: 'AppKit.NSMenu', nullable: true } },
|
|
1976
|
+
{ name: 'button', readonly: true, type: { kind: 'class', name: 'AppKit.NSStatusBarButton', nullable: true } },
|
|
1977
|
+
{ name: 'visible', type: { kind: 'primitive', name: 'boolean' } },
|
|
1978
|
+
{ name: 'length', type: numberType },
|
|
1979
|
+
],
|
|
1980
|
+
},
|
|
1944
1981
|
{
|
|
1945
1982
|
name: 'NSButton',
|
|
1946
1983
|
extends: 'AppKit.NSControl',
|
|
@@ -1950,6 +1987,7 @@ export const appleSdkFixture = {
|
|
|
1950
1987
|
{ name: 'bordered', type: { kind: 'primitive', name: 'boolean' } },
|
|
1951
1988
|
],
|
|
1952
1989
|
},
|
|
1990
|
+
{ name: 'NSStatusBarButton', extends: 'AppKit.NSButton' },
|
|
1953
1991
|
{
|
|
1954
1992
|
name: 'NSViewController',
|
|
1955
1993
|
extends: 'Foundation.NSObject',
|
|
@@ -2126,6 +2164,7 @@ export const appleSdkFixture = {
|
|
|
2126
2164
|
},
|
|
2127
2165
|
],
|
|
2128
2166
|
},
|
|
2167
|
+
...desktopFrameworks,
|
|
2129
2168
|
],
|
|
2130
2169
|
};
|
|
2131
2170
|
export function generateAppleDeclarations(sdk) {
|
|
@@ -2274,7 +2313,7 @@ function sourceBackedBridgeDeclarations(metadata) {
|
|
|
2274
2313
|
declarations.push(bridgeDeclaration(name, returnType, params));
|
|
2275
2314
|
};
|
|
2276
2315
|
for (const fn of Object.values(metadata.functions)) {
|
|
2277
|
-
if (fn.framework === 'Dispatch' || fn.framework === 'Metal') {
|
|
2316
|
+
if (fn.bridgeBody !== undefined || fn.framework === 'Dispatch' || fn.framework === 'Metal') {
|
|
2278
2317
|
append(fn.thunk, cppValueType(fn.returns, fn.framework), fn.parameters.map((parameter) => bridgeParameter(parameter, fn.framework)).join(', '));
|
|
2279
2318
|
}
|
|
2280
2319
|
}
|
|
@@ -2352,6 +2391,12 @@ export function generateAppleNativeBridgeObjCxxSource(metadata) {
|
|
|
2352
2391
|
}
|
|
2353
2392
|
lines.push('', '#include <cstdint>', '#include <functional>', '#include <mutex>', '#include <unordered_map>', '#include <utility>', '#include <vector>', '', 'namespace {', 'std::mutex geaAppleObjectMutex;', 'std::unordered_map<std::uint64_t, void *> geaAppleObjects;', 'std::uint64_t geaAppleNextObjectHandle = 1;', '}', '', 'namespace gea::apple::objc {', 'void *object(double handle) {', ' if (handle <= 0) return nullptr;', ' const auto key = static_cast<std::uint64_t>(handle);', ' std::lock_guard<std::mutex> lock(geaAppleObjectMutex);', ' const auto found = geaAppleObjects.find(key);', ' return found == geaAppleObjects.end() ? nullptr : found->second;', '}', '', 'double retain(void *object) {', ' if (!object) return 0;', ' void *retained = const_cast<void *>(CFRetain(object));', ' std::lock_guard<std::mutex> lock(geaAppleObjectMutex);', ' const auto handle = geaAppleNextObjectHandle++;', ' geaAppleObjects.emplace(handle, retained);', ' return static_cast<double>(handle);', '}', '', 'void release(double handle) {', ' if (handle <= 0) return;', ' void *object = nullptr;', ' {', ' std::lock_guard<std::mutex> lock(geaAppleObjectMutex);', ' const auto key = static_cast<std::uint64_t>(handle);', ' const auto found = geaAppleObjects.find(key);', ' if (found == geaAppleObjects.end()) return;', ' object = found->second;', ' geaAppleObjects.erase(found);', ' }', ' CFRelease(object);', '}', '}', '');
|
|
2354
2393
|
appendFoundationStringConversions(lines, metadata);
|
|
2394
|
+
for (const fn of Object.values(metadata.functions)) {
|
|
2395
|
+
if (fn.bridgeBody === undefined)
|
|
2396
|
+
continue;
|
|
2397
|
+
const parameters = fn.parameters.map((parameter) => bridgeParameter(parameter, fn.framework)).join(', ');
|
|
2398
|
+
lines.push(`${cppValueType(fn.returns, fn.framework)} ${fn.thunk}(${parameters}) {`, fn.bridgeBody, '}', '');
|
|
2399
|
+
}
|
|
2355
2400
|
appendDispatchBridges(lines, metadata);
|
|
2356
2401
|
appendAVFoundationBridges(lines, metadata);
|
|
2357
2402
|
appendPhotosBridges(lines, metadata);
|
|
@@ -2928,6 +2973,7 @@ function functionMetadata(framework, fn) {
|
|
|
2928
2973
|
thunk: frameworkFunctionThunk(framework, fn.name),
|
|
2929
2974
|
returns: fn.returns,
|
|
2930
2975
|
parameters: fn.parameters ?? [],
|
|
2976
|
+
...(fn.bridgeBody !== undefined ? { bridgeBody: fn.bridgeBody } : {}),
|
|
2931
2977
|
};
|
|
2932
2978
|
}
|
|
2933
2979
|
function methodMetadata(framework, cls, method) {
|
package/generated/AppKit.d.ts
CHANGED
|
@@ -57,8 +57,8 @@ export declare const ObjCTargetAction: Selector
|
|
|
57
57
|
export declare function installRootView(view: NSView): void
|
|
58
58
|
export declare function installRootViewController(viewController: NSViewController): void
|
|
59
59
|
export declare function installToolbar(spec: string, newNoteTarget: NSObject | null): void
|
|
60
|
-
export declare function setScrollDocumentTopAligned(scrollView: NSScrollView, content: NSView): void
|
|
61
60
|
export declare function runDeviceCommand(command: string): string
|
|
61
|
+
export declare function setScrollDocumentTopAligned(scrollView: NSScrollView, content: NSView): void
|
|
62
62
|
|
|
63
63
|
export declare class NSColor extends NSObject {
|
|
64
64
|
static whiteColor(): NSColor
|
|
@@ -240,12 +240,43 @@ export declare class NSImageView extends NSView {
|
|
|
240
240
|
contentTintColor: NSColor | null
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
+
export declare class NSMenuItem extends NSObject {
|
|
244
|
+
constructor()
|
|
245
|
+
title: string
|
|
246
|
+
keyEquivalent: string
|
|
247
|
+
target: NSObject | null
|
|
248
|
+
action: Selector
|
|
249
|
+
enabled: boolean
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export declare class NSMenu extends NSObject {
|
|
253
|
+
constructor()
|
|
254
|
+
autoenablesItems: boolean
|
|
255
|
+
addItem(item: NSMenuItem): void
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export declare class NSStatusBar extends NSObject {
|
|
259
|
+
static systemStatusBar(): NSStatusBar
|
|
260
|
+
statusItemWithLength(length: number): NSStatusItem
|
|
261
|
+
removeStatusItem(item: NSStatusItem): void
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export declare class NSStatusItem extends NSObject {
|
|
265
|
+
menu: NSMenu | null
|
|
266
|
+
readonly button: NSStatusBarButton | null
|
|
267
|
+
visible: boolean
|
|
268
|
+
length: number
|
|
269
|
+
}
|
|
270
|
+
|
|
243
271
|
export declare class NSButton extends NSControl {
|
|
244
272
|
constructor()
|
|
245
273
|
title: string
|
|
246
274
|
bordered: boolean
|
|
247
275
|
}
|
|
248
276
|
|
|
277
|
+
export declare class NSStatusBarButton extends NSButton {
|
|
278
|
+
}
|
|
279
|
+
|
|
249
280
|
export declare class NSViewController extends NSObject {
|
|
250
281
|
constructor()
|
|
251
282
|
view: NSView
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
export declare function randomUUID(): string
|
|
2
|
+
export declare function localTimeZone(): string
|
|
3
|
+
export declare function sharedContainerPath(groupIdentifier: string): string
|
|
4
|
+
export declare function readTextFile(path: string): string
|
|
5
|
+
export declare function writeTextFile(path: string, text: string): void
|
|
6
|
+
export declare function watchPath(path: string, changed: () => void): number
|
|
7
|
+
export declare function stopWatchingPath(handle: number): void
|
|
8
|
+
|
|
1
9
|
export declare class NSObject {
|
|
2
10
|
}
|
|
3
11
|
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function requestAuthorization(completed: (granted: boolean, error: string) => void): void
|
|
2
|
+
export declare function scheduleNotification(identifier: string, title: string, body: string, delaySeconds: number, completed: (error: string) => void): void
|
|
3
|
+
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.
|
|
3
|
+
"version": "0.2.11",
|
|
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": {
|
|
@@ -24,6 +24,14 @@
|
|
|
24
24
|
"types": "./generated/Foundation.d.ts",
|
|
25
25
|
"import": "./runtime/Foundation.js"
|
|
26
26
|
},
|
|
27
|
+
"./Security": {
|
|
28
|
+
"types": "./generated/Security.d.ts",
|
|
29
|
+
"import": "./runtime/Security.js"
|
|
30
|
+
},
|
|
31
|
+
"./UserNotifications": {
|
|
32
|
+
"types": "./generated/UserNotifications.d.ts",
|
|
33
|
+
"import": "./runtime/UserNotifications.js"
|
|
34
|
+
},
|
|
27
35
|
"./Dispatch": {
|
|
28
36
|
"types": "./generated/Dispatch.d.ts",
|
|
29
37
|
"import": "./runtime/Dispatch.js"
|
|
@@ -84,7 +92,8 @@
|
|
|
84
92
|
"./targets/*": "./targets/*"
|
|
85
93
|
},
|
|
86
94
|
"files": [
|
|
87
|
-
"dist",
|
|
95
|
+
"dist/*.js",
|
|
96
|
+
"dist/*.d.ts",
|
|
88
97
|
"generated",
|
|
89
98
|
"runtime",
|
|
90
99
|
"targets",
|
|
@@ -107,7 +116,7 @@
|
|
|
107
116
|
"@geastack/elements": "^0.1.2",
|
|
108
117
|
"@geastack/engine": "^0.1.5",
|
|
109
118
|
"@geastack/geaos": "^0.1.3",
|
|
110
|
-
"@geastack/geatsc-plugin-apple-native": "^0.1.
|
|
119
|
+
"@geastack/geatsc-plugin-apple-native": "^0.1.4",
|
|
111
120
|
"@geastack/geatsc-plugin-gea": "^0.1.6",
|
|
112
121
|
"@geastack/host": "^0.1.8"
|
|
113
122
|
},
|
package/runtime/AVFoundation.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function geaAppleAVFoundationNativeOnly(name) {
|
|
2
|
-
throw new Error(`@
|
|
2
|
+
throw new Error(`@geastack/apple/AVFoundation ${name} is native-only and must be lowered by @geastack/geatsc-plugin-apple-native.`)
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export const AVMediaTypeVideo = "vide"
|
package/runtime/ActivityKit.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function geaAppleActivityKitNativeOnly(name) {
|
|
2
|
-
throw new Error(`@
|
|
2
|
+
throw new Error(`@geastack/apple/ActivityKit ${name} is native-only and must be lowered by @geastack/geatsc-plugin-apple-native.`)
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export function requestLiveActivity() {
|
package/runtime/AppKit.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function geaAppleAppKitNativeOnly(name) {
|
|
2
|
-
throw new Error(`@
|
|
2
|
+
throw new Error(`@geastack/apple/AppKit ${name} is native-only and must be lowered by @geastack/geatsc-plugin-apple-native.`)
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export const NSViewNotSizable = 0
|
|
@@ -64,14 +64,14 @@ export function installToolbar() {
|
|
|
64
64
|
return geaAppleAppKitNativeOnly("installToolbar")
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
export function setScrollDocumentTopAligned() {
|
|
68
|
-
return geaAppleAppKitNativeOnly("setScrollDocumentTopAligned")
|
|
69
|
-
}
|
|
70
|
-
|
|
71
67
|
export function runDeviceCommand() {
|
|
72
68
|
return geaAppleAppKitNativeOnly("runDeviceCommand")
|
|
73
69
|
}
|
|
74
70
|
|
|
71
|
+
export function setScrollDocumentTopAligned() {
|
|
72
|
+
return geaAppleAppKitNativeOnly("setScrollDocumentTopAligned")
|
|
73
|
+
}
|
|
74
|
+
|
|
75
75
|
export class NSColor {
|
|
76
76
|
static whiteColor() {
|
|
77
77
|
return geaAppleAppKitNativeOnly("NSColor.whiteColor")
|
|
@@ -279,12 +279,45 @@ export class NSImageView {
|
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
+
export class NSMenuItem {
|
|
283
|
+
constructor() {
|
|
284
|
+
geaAppleAppKitNativeOnly("new NSMenuItem")
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export class NSMenu {
|
|
289
|
+
constructor() {
|
|
290
|
+
geaAppleAppKitNativeOnly("new NSMenu")
|
|
291
|
+
}
|
|
292
|
+
addItem() {
|
|
293
|
+
return geaAppleAppKitNativeOnly("NSMenu.addItem")
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export class NSStatusBar {
|
|
298
|
+
static systemStatusBar() {
|
|
299
|
+
return geaAppleAppKitNativeOnly("NSStatusBar.systemStatusBar")
|
|
300
|
+
}
|
|
301
|
+
statusItemWithLength() {
|
|
302
|
+
return geaAppleAppKitNativeOnly("NSStatusBar.statusItemWithLength")
|
|
303
|
+
}
|
|
304
|
+
removeStatusItem() {
|
|
305
|
+
return geaAppleAppKitNativeOnly("NSStatusBar.removeStatusItem")
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export class NSStatusItem {
|
|
310
|
+
}
|
|
311
|
+
|
|
282
312
|
export class NSButton {
|
|
283
313
|
constructor() {
|
|
284
314
|
geaAppleAppKitNativeOnly("new NSButton")
|
|
285
315
|
}
|
|
286
316
|
}
|
|
287
317
|
|
|
318
|
+
export class NSStatusBarButton {
|
|
319
|
+
}
|
|
320
|
+
|
|
288
321
|
export class NSViewController {
|
|
289
322
|
constructor() {
|
|
290
323
|
geaAppleAppKitNativeOnly("new NSViewController")
|
package/runtime/CoreGraphics.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function geaAppleCoreGraphicsNativeOnly(name) {
|
|
2
|
-
throw new Error(`@
|
|
2
|
+
throw new Error(`@geastack/apple/CoreGraphics ${name} is native-only and must be lowered by @geastack/geatsc-plugin-apple-native.`)
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export function CGRectMake() {
|
package/runtime/CoreLocation.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function geaAppleCoreLocationNativeOnly(name) {
|
|
2
|
-
throw new Error(`@
|
|
2
|
+
throw new Error(`@geastack/apple/CoreLocation ${name} is native-only and must be lowered by @geastack/geatsc-plugin-apple-native.`)
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export const kCLLocationAccuracyBest = -1
|
package/runtime/CoreMedia.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function geaAppleCoreMediaNativeOnly(name) {
|
|
2
|
-
throw new Error(`@
|
|
2
|
+
throw new Error(`@geastack/apple/CoreMedia ${name} is native-only and must be lowered by @geastack/geatsc-plugin-apple-native.`)
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export function CMTimeMakeWithSeconds() {
|
package/runtime/Dispatch.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function geaAppleDispatchNativeOnly(name) {
|
|
2
|
-
throw new Error(`@
|
|
2
|
+
throw new Error(`@geastack/apple/Dispatch ${name} is native-only and must be lowered by @geastack/geatsc-plugin-apple-native.`)
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export function dispatchAsyncGlobal() {
|
package/runtime/Foundation.js
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
function geaAppleFoundationNativeOnly(name) {
|
|
2
|
-
throw new Error(`@
|
|
2
|
+
throw new Error(`@geastack/apple/Foundation ${name} is native-only and must be lowered by @geastack/geatsc-plugin-apple-native.`)
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function randomUUID() {
|
|
6
|
+
return geaAppleFoundationNativeOnly("randomUUID")
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function localTimeZone() {
|
|
10
|
+
return geaAppleFoundationNativeOnly("localTimeZone")
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function sharedContainerPath() {
|
|
14
|
+
return geaAppleFoundationNativeOnly("sharedContainerPath")
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function readTextFile() {
|
|
18
|
+
return geaAppleFoundationNativeOnly("readTextFile")
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function writeTextFile() {
|
|
22
|
+
return geaAppleFoundationNativeOnly("writeTextFile")
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function watchPath() {
|
|
26
|
+
return geaAppleFoundationNativeOnly("watchPath")
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function stopWatchingPath() {
|
|
30
|
+
return geaAppleFoundationNativeOnly("stopWatchingPath")
|
|
3
31
|
}
|
|
4
32
|
|
|
5
33
|
export class NSObject {
|
package/runtime/MapKit.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function geaAppleMapKitNativeOnly(name) {
|
|
2
|
-
throw new Error(`@
|
|
2
|
+
throw new Error(`@geastack/apple/MapKit ${name} is native-only and must be lowered by @geastack/geatsc-plugin-apple-native.`)
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export const MKMapTypeStandard = 0
|
package/runtime/Metal.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function geaAppleMetalNativeOnly(name) {
|
|
2
|
-
throw new Error(`@
|
|
2
|
+
throw new Error(`@geastack/apple/Metal ${name} is native-only and must be lowered by @geastack/geatsc-plugin-apple-native.`)
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export const MTLPixelFormatInvalid = 0
|
package/runtime/MetalKit.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function geaAppleMetalKitNativeOnly(name) {
|
|
2
|
-
throw new Error(`@
|
|
2
|
+
throw new Error(`@geastack/apple/MetalKit ${name} is native-only and must be lowered by @geastack/geatsc-plugin-apple-native.`)
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export class MTKView {
|
package/runtime/Photos.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function geaApplePhotosNativeOnly(name) {
|
|
2
|
-
throw new Error(`@
|
|
2
|
+
throw new Error(`@geastack/apple/Photos ${name} is native-only and must be lowered by @geastack/geatsc-plugin-apple-native.`)
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export class PHPhotoLibrary {
|
package/runtime/QuartzCore.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function geaAppleQuartzCoreNativeOnly(name) {
|
|
2
|
-
throw new Error(`@
|
|
2
|
+
throw new Error(`@geastack/apple/QuartzCore ${name} is native-only and must be lowered by @geastack/geatsc-plugin-apple-native.`)
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export class CALayer {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function geaAppleSecurityNativeOnly(name) {
|
|
2
|
+
throw new Error(`@geastack/apple/Security ${name} is native-only and must be lowered by @geastack/geatsc-plugin-apple-native.`)
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function writePassword() {
|
|
6
|
+
return geaAppleSecurityNativeOnly("writePassword")
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function readPassword() {
|
|
10
|
+
return geaAppleSecurityNativeOnly("readPassword")
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function deletePassword() {
|
|
14
|
+
return geaAppleSecurityNativeOnly("deletePassword")
|
|
15
|
+
}
|
package/runtime/SwiftData.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function geaAppleSwiftDataNativeOnly(name) {
|
|
2
|
-
throw new Error(`@
|
|
2
|
+
throw new Error(`@geastack/apple/SwiftData ${name} is native-only and must be lowered by @geastack/geatsc-plugin-apple-native.`)
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export function openModelContainer() {
|
package/runtime/UIKit.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function geaAppleUIKitNativeOnly(name) {
|
|
2
|
-
throw new Error(`@
|
|
2
|
+
throw new Error(`@geastack/apple/UIKit ${name} is native-only and must be lowered by @geastack/geatsc-plugin-apple-native.`)
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export const UIAlertActionStyleDefault = 0
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function geaAppleUserNotificationsNativeOnly(name) {
|
|
2
|
+
throw new Error(`@geastack/apple/UserNotifications ${name} is native-only and must be lowered by @geastack/geatsc-plugin-apple-native.`)
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function requestAuthorization() {
|
|
6
|
+
return geaAppleUserNotificationsNativeOnly("requestAuthorization")
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function scheduleNotification() {
|
|
10
|
+
return geaAppleUserNotificationsNativeOnly("scheduleNotification")
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function cancelNotification() {
|
|
14
|
+
return geaAppleUserNotificationsNativeOnly("cancelNotification")
|
|
15
|
+
}
|
|
@@ -1893,7 +1893,7 @@ if [[ "$APPLE_NATIVE" == "1" ]]; then
|
|
|
1893
1893
|
LINK_FRAMEWORKS+=(
|
|
1894
1894
|
-framework Metal -framework MetalKit -framework MapKit
|
|
1895
1895
|
-framework CoreLocation -framework AVFoundation -framework CoreMedia
|
|
1896
|
-
-framework Photos
|
|
1896
|
+
-framework Photos -framework Security -framework UserNotifications
|
|
1897
1897
|
)
|
|
1898
1898
|
fi
|
|
1899
1899
|
|