@crossbind/extension-page-location 0.0.0-bootstrap.0 → 2.0.0-beta.69
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/LICENSE +21 -0
- package/README.md +21 -3
- package/crossbind.extension.js +13 -0
- package/native/darwin.mm +303 -0
- package/package.json +28 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Buğra Sarı and crossbind contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
# @crossbind/extension-page-location
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
package that exists, so it reserves the name for the crossbind release workflow.
|
|
3
|
+
navigator.geolocation on macOS, which WKWebView leaves out.
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
An app has it by having `@crossbind/core-app-host`, which lists it as a dependency: there is nothing to install or list.
|
|
6
|
+
|
|
7
|
+
## What it does
|
|
8
|
+
|
|
9
|
+
A macOS page gets `navigator.geolocation`, which WKWebView gives a macOS page none of, where `app.permissions` lists the
|
|
10
|
+
location. The system asks its user first.
|
|
11
|
+
|
|
12
|
+
## Options
|
|
13
|
+
|
|
14
|
+
`app.permissions.location` turns it on, with the reason the system shows, as `{ location: 'To show where you are' }`.
|
|
15
|
+
|
|
16
|
+
## Platforms
|
|
17
|
+
|
|
18
|
+
macOS alone.
|
|
19
|
+
|
|
20
|
+
## Replace or leave out
|
|
21
|
+
|
|
22
|
+
It holds the role `page-location`. An extension that gives `replaces: 'page-location'` takes it; `app: { without: ['page-location'] }` in `crossbind.config.js` leaves it out. Leaving it out while `app.permissions.location` is set stops the build. [The guide](https://crossbind.dev/guide/extensions/#replace) shows how, and [extensions.md](https://github.com/crossbind/crossbind/blob/main/docs/api/extensions.md#the-hosts-own-extensions) what a replacement answers.
|
|
23
|
+
|
|
24
|
+
[extensions.md](https://github.com/crossbind/crossbind/blob/main/docs/api/extensions.md#the-pages-requests) has the hooks a replacement answers.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default function pageLocation() {
|
|
2
|
+
return {
|
|
3
|
+
name: 'page-location',
|
|
4
|
+
contract: 1,
|
|
5
|
+
root: import.meta.dirname,
|
|
6
|
+
reads: ['permissions.location'],
|
|
7
|
+
// WKWebView gives a macOS page no location of its own.
|
|
8
|
+
fromApp: (api) => (api.platform === 'macos' && api.config.app.permissions?.location !== undefined ? {} : null),
|
|
9
|
+
app: {
|
|
10
|
+
macos: { sources: ['native/darwin.mm'], frameworks: ['CoreLocation'] },
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
}
|
package/native/darwin.mm
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
// The host's page-location: a macOS page's navigator.geolocation, to which WKWebView gives no position there, answered
|
|
2
|
+
// from CoreLocation as page-permissions lets the page have it. The build gives it to an app whose app.permissions lists
|
|
3
|
+
// the location, with the reason CoreLocation asks the app's user with.
|
|
4
|
+
#import <CoreLocation/CoreLocation.h>
|
|
5
|
+
#import <WebKit/WebKit.h>
|
|
6
|
+
|
|
7
|
+
#include "crossbind/extension.h"
|
|
8
|
+
|
|
9
|
+
#include <cmath>
|
|
10
|
+
#include <functional>
|
|
11
|
+
#include <map>
|
|
12
|
+
#include <optional>
|
|
13
|
+
#include <string>
|
|
14
|
+
#include <utility>
|
|
15
|
+
#include <vector>
|
|
16
|
+
|
|
17
|
+
namespace {
|
|
18
|
+
|
|
19
|
+
using Reply = std::function<void(const std::string &)>;
|
|
20
|
+
|
|
21
|
+
// How long the host holds an ask before it answers that it has no position yet, and the page asks again: an ask of a
|
|
22
|
+
// page that went away is answered too, as WebKit wants every reply given.
|
|
23
|
+
constexpr NSTimeInterval ASK_HELD = 5;
|
|
24
|
+
|
|
25
|
+
// navigator.geolocation in the top frame, which asks the host until it has a position or an error the API's codes name.
|
|
26
|
+
// The host answers a first ask at once and holds the next, and a timeout counts from once the system's question has
|
|
27
|
+
// been answered; a watch asks again after each position, and a second after an error, until denied.
|
|
28
|
+
NSString *const LOCATION_SCRIPT = @"(() => {"
|
|
29
|
+
"const ask = (message) => window.webkit.messageHandlers.crossbind_location.postMessage(JSON.stringify(message)).then(JSON.parse);"
|
|
30
|
+
"const failure = (code, message) => ({ code, message, PERMISSION_DENIED: 1, POSITION_UNAVAILABLE: 2, TIMEOUT: 3 });"
|
|
31
|
+
"const ageOf = (options) => Math.max(0, Math.min(Number(options?.maximumAge) || 0, Number.MAX_SAFE_INTEGER));"
|
|
32
|
+
"const timeoutOf = (options) => (Number.isFinite(options?.timeout) ? Math.max(0, options.timeout) : undefined);"
|
|
33
|
+
"const watches = new Set();"
|
|
34
|
+
"let nextWatch = 1;"
|
|
35
|
+
"const geolocation = {"
|
|
36
|
+
" getCurrentPosition(success, error, options) {"
|
|
37
|
+
" let isDone = false;"
|
|
38
|
+
" let timer;"
|
|
39
|
+
" const done = (callback, value) => { if (!isDone) { isDone = true; clearTimeout(timer); callback?.(value); } };"
|
|
40
|
+
" const next = (wait) => ask({ wait, highAccuracy: Boolean(options?.enableHighAccuracy), maximumAge: ageOf(options) }).then((reply) => {"
|
|
41
|
+
" if (isDone) return;"
|
|
42
|
+
" if (reply.coords) return done(success, reply);"
|
|
43
|
+
" if (reply.error) return done(error, failure(reply.error, reply.message));"
|
|
44
|
+
" if (!reply.asking && timer === undefined && timeoutOf(options) !== undefined) {"
|
|
45
|
+
" timer = setTimeout(() => done(error, failure(3, 'Timeout expired')), timeoutOf(options));"
|
|
46
|
+
" }"
|
|
47
|
+
" next(true);"
|
|
48
|
+
" });"
|
|
49
|
+
" next(false);"
|
|
50
|
+
" },"
|
|
51
|
+
" watchPosition(success, error, options) {"
|
|
52
|
+
" const id = nextWatch++;"
|
|
53
|
+
" let maximumAge = ageOf(options);"
|
|
54
|
+
" let timer;"
|
|
55
|
+
" const countDown = () => {"
|
|
56
|
+
" clearTimeout(timer);"
|
|
57
|
+
" if (timeoutOf(options) !== undefined) timer = setTimeout(() => watches.has(id) && error?.(failure(3, 'Timeout expired')), timeoutOf(options));"
|
|
58
|
+
" };"
|
|
59
|
+
" const next = (wait) => ask({ wait, highAccuracy: Boolean(options?.enableHighAccuracy), maximumAge }).then((reply) => {"
|
|
60
|
+
" if (!watches.has(id)) return clearTimeout(timer);"
|
|
61
|
+
" try {"
|
|
62
|
+
" if (reply.coords) {"
|
|
63
|
+
" maximumAge = 0;"
|
|
64
|
+
" countDown();"
|
|
65
|
+
" success(reply);"
|
|
66
|
+
" } else if (reply.error) {"
|
|
67
|
+
" error?.(failure(reply.error, reply.message));"
|
|
68
|
+
" } else if (!reply.asking && timer === undefined) {"
|
|
69
|
+
" countDown();"
|
|
70
|
+
" }"
|
|
71
|
+
" } finally {"
|
|
72
|
+
" if (reply.error === 1) {"
|
|
73
|
+
" watches.delete(id);"
|
|
74
|
+
" clearTimeout(timer);"
|
|
75
|
+
" } else if (watches.has(id)) {"
|
|
76
|
+
" setTimeout(() => watches.has(id) && next(true), reply.error ? 1000 : 0);"
|
|
77
|
+
" }"
|
|
78
|
+
" }"
|
|
79
|
+
" });"
|
|
80
|
+
" watches.add(id);"
|
|
81
|
+
" next(false);"
|
|
82
|
+
" return id;"
|
|
83
|
+
" },"
|
|
84
|
+
" clearWatch(id) {"
|
|
85
|
+
" watches.delete(id);"
|
|
86
|
+
" },"
|
|
87
|
+
"};"
|
|
88
|
+
"Object.defineProperty(Navigator.prototype, 'geolocation', { configurable: true, enumerable: true, get: () => geolocation });"
|
|
89
|
+
"})();";
|
|
90
|
+
|
|
91
|
+
std::string jsonOf(NSDictionary *object) {
|
|
92
|
+
NSData *data = [NSJSONSerialization dataWithJSONObject:object options:0 error:nil];
|
|
93
|
+
return data ? std::string(static_cast<const char *>(data.bytes), data.length) : "{\"error\":2}";
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
std::string failureOf(int code, NSString *message) { return jsonOf(@{@"error" : @(code), @"message" : message ? message : @""}); }
|
|
97
|
+
|
|
98
|
+
// The answer while the host has no position, which says whether the system still asks the app's user.
|
|
99
|
+
std::string noPosition(CLAuthorizationStatus status) { return status == kCLAuthorizationStatusNotDetermined ? "{\"asking\":true}" : "{}"; }
|
|
100
|
+
|
|
101
|
+
// A number the page sent, or 0 for anything else.
|
|
102
|
+
double numberIn(NSDictionary *ask, NSString *key) {
|
|
103
|
+
id value = ask[key];
|
|
104
|
+
return [value isKindOfClass:NSNumber.class] ? [value doubleValue] : 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
id known(double value, bool isKnown) { return isKnown ? @(value) : NSNull.null; }
|
|
108
|
+
|
|
109
|
+
// An origin as the page's scripts name it, as "crossbind://app" or "http://localhost:5173".
|
|
110
|
+
std::string originOf(WKSecurityOrigin *origin) {
|
|
111
|
+
std::string text = std::string(origin.protocol.UTF8String ?: "") + "://" + std::string(origin.host.UTF8String ?: "");
|
|
112
|
+
if (origin.port != 0) text += ":" + std::to_string(origin.port);
|
|
113
|
+
return text;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
std::string positionOf(CLLocation *location) {
|
|
117
|
+
return jsonOf(@{
|
|
118
|
+
@"coords" : @{
|
|
119
|
+
@"latitude" : @(location.coordinate.latitude),
|
|
120
|
+
@"longitude" : @(location.coordinate.longitude),
|
|
121
|
+
@"accuracy" : @(location.horizontalAccuracy),
|
|
122
|
+
@"altitude" : known(location.altitude, location.verticalAccuracy >= 0),
|
|
123
|
+
@"altitudeAccuracy" : known(location.verticalAccuracy, location.verticalAccuracy >= 0),
|
|
124
|
+
@"heading" : known(location.course, location.course >= 0),
|
|
125
|
+
@"speed" : known(location.speed, location.speed >= 0),
|
|
126
|
+
},
|
|
127
|
+
@"timestamp" : @(std::floor(location.timestamp.timeIntervalSince1970 * 1000)),
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// An ask for a position no older than maximumAge milliseconds before the ask came.
|
|
132
|
+
struct Ask {
|
|
133
|
+
double maximumAge;
|
|
134
|
+
NSDate *since;
|
|
135
|
+
Reply reply;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// Gives the asks isDue picks the answer, and keeps the others.
|
|
139
|
+
template <typename IsDue>
|
|
140
|
+
void answer(std::vector<Ask> &asks, const std::string &text, IsDue isDue) {
|
|
141
|
+
std::erase_if(asks, [&](const Ask &ask) {
|
|
142
|
+
if (!isDue(ask)) return false;
|
|
143
|
+
ask.reply(text);
|
|
144
|
+
return true;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
bool always(const Ask &) { return true; }
|
|
149
|
+
|
|
150
|
+
} // namespace
|
|
151
|
+
|
|
152
|
+
// The positions CoreLocation gives the app, which asks its user first, with app.permissions.location's reason.
|
|
153
|
+
@interface CBLocation : NSObject <CLLocationManagerDelegate, WKScriptMessageHandlerWithReply>
|
|
154
|
+
@end
|
|
155
|
+
|
|
156
|
+
@implementation CBLocation {
|
|
157
|
+
CLLocationManager *_manager;
|
|
158
|
+
std::vector<Ask> _asks;
|
|
159
|
+
// Ticks while the page asks, answering the asks held too long, and stops CoreLocation once none came for a while.
|
|
160
|
+
NSTimer *_clock;
|
|
161
|
+
NSDate *_lastAsk;
|
|
162
|
+
// Whether page-permissions lets the page of an origin have the location, which the host asks it once in the app's
|
|
163
|
+
// run for each, and the asks that wait for its answer.
|
|
164
|
+
std::map<std::string, bool> _allowed;
|
|
165
|
+
std::map<std::string, std::vector<std::pair<NSDictionary *, Reply>>> _undecided;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
- (instancetype)init {
|
|
169
|
+
if ((self = [super init])) {
|
|
170
|
+
_manager = [CLLocationManager new];
|
|
171
|
+
_manager.delegate = self;
|
|
172
|
+
_manager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
|
|
173
|
+
}
|
|
174
|
+
return self;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Only the top frame learns where the app's user is, once page-permissions allows its origin, which the host refuses
|
|
178
|
+
// for another origin than the app's own.
|
|
179
|
+
- (void)userContentController:(WKUserContentController *)controller
|
|
180
|
+
didReceiveScriptMessage:(WKScriptMessage *)message
|
|
181
|
+
replyHandler:(void (^)(id, NSString *))replyHandler {
|
|
182
|
+
void (^respond)(id, NSString *) = [replyHandler copy];
|
|
183
|
+
Reply reply = [respond](const std::string &text) { respond([NSString stringWithUTF8String:text.c_str()], nil); };
|
|
184
|
+
if (!message.frameInfo.isMainFrame) {
|
|
185
|
+
reply(failureOf(1, @"crossbind: a frame inside the page has no location"));
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
NSString *body = [message.body isKindOfClass:NSString.class] ? message.body : @"";
|
|
189
|
+
id ask = [NSJSONSerialization JSONObjectWithData:[body dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES] options:0 error:nil];
|
|
190
|
+
[self decide:[ask isKindOfClass:NSDictionary.class] ? ask : @{} origin:originOf(message.frameInfo.securityOrigin) reply:std::move(reply)];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// The page has a position once page-permissions allows it, which a watch would otherwise ask after each position;
|
|
194
|
+
// without that extension the page has none, as WebKit gives a macOS page none of its own.
|
|
195
|
+
- (void)decide:(NSDictionary *)ask origin:(std::string)origin reply:(Reply)reply {
|
|
196
|
+
if (const auto decided = _allowed.find(origin); decided != _allowed.end()) {
|
|
197
|
+
if (decided->second) [self ask:ask reply:std::move(reply)];
|
|
198
|
+
else reply(failureOf(1, @"User denied Geolocation"));
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
auto &waiting = _undecided[origin];
|
|
202
|
+
waiting.emplace_back(ask, std::move(reply));
|
|
203
|
+
if (waiting.size() > 1) return;
|
|
204
|
+
crossbind::askPagePermission({"location"}, origin, [self, origin](bool isAllowed) { [self decided:isAllowed origin:origin]; });
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
- (void)decided:(bool)isAllowed origin:(const std::string &)origin {
|
|
208
|
+
_allowed[origin] = isAllowed;
|
|
209
|
+
auto waiting = std::move(_undecided[origin]);
|
|
210
|
+
_undecided.erase(origin);
|
|
211
|
+
for (auto &[ask, reply] : waiting) {
|
|
212
|
+
if (isAllowed) [self ask:ask reply:std::move(reply)];
|
|
213
|
+
else reply(failureOf(1, @"User denied Geolocation"));
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
- (void)ask:(NSDictionary *)ask reply:(Reply)reply {
|
|
218
|
+
const CLAuthorizationStatus status = _manager.authorizationStatus;
|
|
219
|
+
if (status == kCLAuthorizationStatusDenied || status == kCLAuthorizationStatusRestricted) {
|
|
220
|
+
reply(failureOf(1, @"User denied Geolocation"));
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const double maximumAge = numberIn(ask, @"maximumAge");
|
|
224
|
+
if (status == kCLAuthorizationStatusNotDetermined) {
|
|
225
|
+
[_manager requestWhenInUseAuthorization];
|
|
226
|
+
} else {
|
|
227
|
+
CLLocation *last = _manager.location;
|
|
228
|
+
if (last && -last.timestamp.timeIntervalSinceNow * 1000 <= maximumAge) {
|
|
229
|
+
reply(positionOf(last));
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (numberIn(ask, @"highAccuracy")) _manager.desiredAccuracy = kCLLocationAccuracyBest;
|
|
233
|
+
[_manager startUpdatingLocation];
|
|
234
|
+
}
|
|
235
|
+
_lastAsk = [NSDate date];
|
|
236
|
+
if (!_clock) _clock = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(tick) userInfo:nil repeats:YES];
|
|
237
|
+
if (numberIn(ask, @"wait")) {
|
|
238
|
+
_asks.push_back({maximumAge, _lastAsk, std::move(reply)});
|
|
239
|
+
} else {
|
|
240
|
+
reply(noPosition(status));
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
- (void)tick {
|
|
245
|
+
NSDate *now = [NSDate date];
|
|
246
|
+
// A page whose ask this tick answers asks again at once, so CoreLocation stops only after a tick that held none.
|
|
247
|
+
const bool isIdle = _asks.empty();
|
|
248
|
+
answer(_asks, noPosition(_manager.authorizationStatus), [now](const Ask &ask) { return [now timeIntervalSinceDate:ask.since] >= ASK_HELD; });
|
|
249
|
+
if (isIdle && [now timeIntervalSinceDate:_lastAsk] >= ASK_HELD) [self rest];
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Nothing asks: CoreLocation stops looking.
|
|
253
|
+
- (void)rest {
|
|
254
|
+
[_clock invalidate];
|
|
255
|
+
_clock = nil;
|
|
256
|
+
[_manager stopUpdatingLocation];
|
|
257
|
+
_manager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
- (void)locationManagerDidChangeAuthorization:(CLLocationManager *)manager {
|
|
261
|
+
switch (manager.authorizationStatus) {
|
|
262
|
+
case kCLAuthorizationStatusNotDetermined:
|
|
263
|
+
return;
|
|
264
|
+
case kCLAuthorizationStatusDenied:
|
|
265
|
+
case kCLAuthorizationStatusRestricted:
|
|
266
|
+
answer(_asks, failureOf(1, @"User denied Geolocation"), always);
|
|
267
|
+
[self rest];
|
|
268
|
+
return;
|
|
269
|
+
default:
|
|
270
|
+
// The page's timeout starts now, and its next ask starts CoreLocation.
|
|
271
|
+
answer(_asks, "{}", always);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations {
|
|
276
|
+
CLLocation *location = locations.lastObject;
|
|
277
|
+
// CoreLocation may hand over an old position first.
|
|
278
|
+
answer(_asks, positionOf(location), [location](const Ask &ask) {
|
|
279
|
+
return [location.timestamp timeIntervalSinceDate:ask.since] * 1000 >= -ask.maximumAge;
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
|
|
284
|
+
// CoreLocation has no position yet and goes on looking; the page's timeout says how long to wait.
|
|
285
|
+
if (error.code == kCLErrorLocationUnknown) return;
|
|
286
|
+
answer(_asks, failureOf(error.code == kCLErrorDenied ? 1 : 2, error.localizedDescription), always);
|
|
287
|
+
[self rest];
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
@end
|
|
291
|
+
|
|
292
|
+
// The page's navigator.geolocation and the handler of its asks join the webview as the window opens, before its page
|
|
293
|
+
// loads.
|
|
294
|
+
void crossbind_extension_page_location(crossbind::Registry ®istry) {
|
|
295
|
+
registry.onWindow([](const crossbind::Window &window) {
|
|
296
|
+
static CBLocation *location = [CBLocation new];
|
|
297
|
+
WKUserContentController *contents = ((__bridge WKWebView *)window.webView()).configuration.userContentController;
|
|
298
|
+
[contents addUserScript:[[WKUserScript alloc] initWithSource:LOCATION_SCRIPT
|
|
299
|
+
injectionTime:WKUserScriptInjectionTimeAtDocumentStart
|
|
300
|
+
forMainFrameOnly:YES]];
|
|
301
|
+
[contents addScriptMessageHandlerWithReply:location contentWorld:WKContentWorld.pageWorld name:@"crossbind_location"];
|
|
302
|
+
});
|
|
303
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,29 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
"name": "@crossbind/extension-page-location",
|
|
3
|
+
"version": "2.0.0-beta.69",
|
|
4
|
+
"description": "crossbind app extension: navigator.geolocation on macOS, which WKWebView leaves out.",
|
|
5
|
+
"homepage": "https://github.com/crossbind/crossbind/tree/main/extensions/page-location#readme",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/crossbind/crossbind.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
"./crossbind.extension.js": "./crossbind.extension.js"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"crossbind.extension.js",
|
|
17
|
+
"native"
|
|
18
|
+
],
|
|
19
|
+
"crossbind": {
|
|
20
|
+
"extension": "./crossbind.extension.js"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"crossbind-extension",
|
|
24
|
+
"crossbind",
|
|
25
|
+
"page",
|
|
26
|
+
"location",
|
|
27
|
+
"app"
|
|
28
|
+
]
|
|
29
|
+
}
|