sa2kit 3.8.0 → 3.9.1

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.
@@ -0,0 +1,751 @@
1
+ 'use strict';
2
+
3
+ var chunkNSBPE2FW_js = require('./chunk-NSBPE2FW.js');
4
+
5
+ // src/common/appLauncher/adapters/rn.ts
6
+ function createRnAppLaunchAdapter(linking) {
7
+ const platform = "rn";
8
+ return {
9
+ platform,
10
+ async canOpen(url) {
11
+ try {
12
+ return await linking.canOpenURL(url);
13
+ } catch {
14
+ return false;
15
+ }
16
+ },
17
+ async launch(urls, options) {
18
+ const baseResult = {
19
+ provider: options.provider,
20
+ action: options.action,
21
+ platform
22
+ };
23
+ const tryOpen = async (url) => {
24
+ const canOpen = await linking.canOpenURL(url).catch(() => false);
25
+ if (!canOpen) {
26
+ return false;
27
+ }
28
+ await linking.openURL(url);
29
+ return true;
30
+ };
31
+ if (await tryOpen(urls.primary)) {
32
+ const result2 = {
33
+ ...baseResult,
34
+ status: "opened",
35
+ url: urls.primary
36
+ };
37
+ options.callbacks?.onOpened?.(result2);
38
+ return result2;
39
+ }
40
+ if (urls.fallback && await tryOpen(urls.fallback)) {
41
+ const result2 = {
42
+ ...baseResult,
43
+ status: "fallback",
44
+ url: urls.fallback
45
+ };
46
+ options.callbacks?.onFallback?.(result2);
47
+ return result2;
48
+ }
49
+ const result = {
50
+ ...baseResult,
51
+ status: "unavailable",
52
+ url: urls.primary
53
+ };
54
+ options.callbacks?.onUnavailable?.(result);
55
+ return result;
56
+ }
57
+ };
58
+ }
59
+ function createRnAppLaunchAdapterFromReactNative() {
60
+ let linking;
61
+ try {
62
+ linking = chunkNSBPE2FW_js.__require("react-native").Linking;
63
+ } catch {
64
+ throw new Error(
65
+ "[appLauncher/rn] \u672A\u627E\u5230 react-native\uFF0C\u8BF7\u4F7F\u7528 createRnAppLaunchAdapter(linking) \u624B\u52A8\u6CE8\u5165 Linking"
66
+ );
67
+ }
68
+ return createRnAppLaunchAdapter(linking);
69
+ }
70
+
71
+ // src/common/appLauncher/detect.ts
72
+ function isAndroid(userAgent = getUserAgent()) {
73
+ return /Android/i.test(userAgent);
74
+ }
75
+ function isIOS(userAgent = getUserAgent()) {
76
+ return /iPhone|iPad|iPod/i.test(userAgent);
77
+ }
78
+ function isMobileDevice(userAgent = getUserAgent()) {
79
+ return isAndroid(userAgent) || isIOS(userAgent);
80
+ }
81
+ function getUserAgent() {
82
+ if (typeof navigator === "undefined") {
83
+ return "";
84
+ }
85
+ return navigator.userAgent;
86
+ }
87
+
88
+ // src/common/appLauncher/adapters/web.ts
89
+ function dispatchCallbacks(options, result) {
90
+ const { callbacks } = options;
91
+ if (!callbacks) {
92
+ return;
93
+ }
94
+ switch (result.status) {
95
+ case "opened":
96
+ callbacks.onOpened?.(result);
97
+ break;
98
+ case "fallback":
99
+ callbacks.onFallback?.(result);
100
+ break;
101
+ case "unavailable":
102
+ case "timeout":
103
+ case "cancelled":
104
+ callbacks.onUnavailable?.(result);
105
+ break;
106
+ }
107
+ }
108
+ function openUrl(url, mobile) {
109
+ if (typeof window === "undefined") {
110
+ return;
111
+ }
112
+ if (mobile) {
113
+ window.location.assign(url);
114
+ return;
115
+ }
116
+ window.open(url, "_blank", "noopener,noreferrer");
117
+ }
118
+ function waitForAppOpen(timeoutMs) {
119
+ return new Promise((resolve) => {
120
+ if (typeof document === "undefined") {
121
+ resolve("opened");
122
+ return;
123
+ }
124
+ let settled = false;
125
+ const finish = (status) => {
126
+ if (settled) {
127
+ return;
128
+ }
129
+ settled = true;
130
+ document.removeEventListener("visibilitychange", onVisibilityChange);
131
+ window.clearTimeout(timer);
132
+ resolve(status);
133
+ };
134
+ const onVisibilityChange = () => {
135
+ if (document.hidden) {
136
+ finish("opened");
137
+ }
138
+ };
139
+ document.addEventListener("visibilitychange", onVisibilityChange);
140
+ const timer = window.setTimeout(() => finish("timeout"), timeoutMs);
141
+ });
142
+ }
143
+ function createWebAppLaunchAdapter() {
144
+ const platform = "web";
145
+ return {
146
+ platform,
147
+ async launch(urls, options) {
148
+ const mobile = isMobileDevice();
149
+ const baseResult = {
150
+ provider: options.provider,
151
+ action: options.action,
152
+ platform
153
+ };
154
+ openUrl(urls.primary, mobile);
155
+ if (mobile) {
156
+ const status = await waitForAppOpen(options.timeoutMs);
157
+ if (status === "opened") {
158
+ const result3 = {
159
+ ...baseResult,
160
+ status: "opened",
161
+ url: urls.primary
162
+ };
163
+ dispatchCallbacks(options, result3);
164
+ return result3;
165
+ }
166
+ if (urls.fallback) {
167
+ openUrl(urls.fallback, true);
168
+ const result3 = {
169
+ ...baseResult,
170
+ status: "fallback",
171
+ url: urls.fallback
172
+ };
173
+ dispatchCallbacks(options, result3);
174
+ return result3;
175
+ }
176
+ const result2 = {
177
+ ...baseResult,
178
+ status: "timeout",
179
+ url: urls.primary
180
+ };
181
+ dispatchCallbacks(options, result2);
182
+ return result2;
183
+ }
184
+ const result = {
185
+ ...baseResult,
186
+ status: "opened",
187
+ url: urls.primary
188
+ };
189
+ dispatchCallbacks(options, result);
190
+ return result;
191
+ }
192
+ };
193
+ }
194
+
195
+ // src/common/appLauncher/core/config.ts
196
+ var defaultConfig = {
197
+ sourceApplication: "sa2kit"
198
+ };
199
+ var runtimeConfig = { ...defaultConfig };
200
+ function configureAppLauncher(patch) {
201
+ runtimeConfig = {
202
+ ...runtimeConfig,
203
+ ...patch,
204
+ defaultOptions: {
205
+ ...runtimeConfig.defaultOptions,
206
+ ...patch.defaultOptions
207
+ },
208
+ defaultCallbacks: {
209
+ ...runtimeConfig.defaultCallbacks,
210
+ ...patch.defaultCallbacks
211
+ }
212
+ };
213
+ return getAppLauncherConfig();
214
+ }
215
+ function getAppLauncherConfig() {
216
+ return runtimeConfig;
217
+ }
218
+ function resetAppLauncherConfig() {
219
+ runtimeConfig = { ...defaultConfig };
220
+ }
221
+
222
+ // src/common/appLauncher/types.ts
223
+ var AppLaunchError = class extends Error {
224
+ constructor(code, message, details) {
225
+ super(message);
226
+ this.name = "AppLaunchError";
227
+ this.code = code;
228
+ this.details = details;
229
+ }
230
+ };
231
+
232
+ // src/common/appLauncher/utils/query.ts
233
+ function requireNonEmptyString(value, field) {
234
+ if (typeof value !== "string" || !value.trim()) {
235
+ throw new AppLaunchError("INVALID_PARAMS", `${field} \u4E0D\u80FD\u4E3A\u7A7A`);
236
+ }
237
+ return value.trim();
238
+ }
239
+ function encodeQuery(value) {
240
+ return encodeURIComponent(value);
241
+ }
242
+
243
+ // src/common/appLauncher/providers/amap.ts
244
+ function buildKeywordNavigationUrl(destination, sourceApplication) {
245
+ const keyword = encodeQuery(destination);
246
+ if (typeof navigator !== "undefined" && isAndroid()) {
247
+ return `androidamap://keywordNavi?sourceApplication=${encodeQuery(sourceApplication)}&keyword=${keyword}&style=2`;
248
+ }
249
+ return `https://uri.amap.com/navigation?to=,,${keyword}&mode=car&callnative=1`;
250
+ }
251
+ function buildCoordinateNavigationUrl(params, sourceApplication) {
252
+ const name = params.destination ? encodeQuery(params.destination) : "";
253
+ const mode = params.mode ?? "car";
254
+ const lon = params.longitude;
255
+ const lat = params.latitude;
256
+ const primary = typeof navigator !== "undefined" && isAndroid() ? `androidamap://route?sourceApplication=${encodeQuery(sourceApplication)}&dlat=${lat}&dlon=${lon}&dname=${name}&dev=0&t=0` : `iosamap://navi?sourceApplication=${encodeQuery(sourceApplication)}&lat=${lat}&lon=${lon}&dev=0&style=2`;
257
+ const fallback = `https://uri.amap.com/navigation?to=${lon},${lat},${name}&mode=${mode}&callnative=1`;
258
+ return { primary, fallback };
259
+ }
260
+ var amapProvider = {
261
+ id: "amap",
262
+ actions: ["navigate", "navigateByCoordinate"],
263
+ validateParams(action, params) {
264
+ if (action === "navigate") {
265
+ requireNonEmptyString(params.destination, "destination");
266
+ return;
267
+ }
268
+ if (action === "navigateByCoordinate") {
269
+ if (typeof params.latitude !== "number" || typeof params.longitude !== "number") {
270
+ throw new AppLaunchError(
271
+ "INVALID_PARAMS",
272
+ "navigateByCoordinate \u9700\u8981 latitude \u4E0E longitude"
273
+ );
274
+ }
275
+ }
276
+ },
277
+ buildUrls(action, params, context) {
278
+ const sourceApplication = context.sourceApplication;
279
+ if (action === "navigate") {
280
+ const destination = requireNonEmptyString(params.destination, "destination");
281
+ const url = buildKeywordNavigationUrl(destination, sourceApplication);
282
+ const fallback = context.options.fallbackUrl ?? `https://uri.amap.com/search?keyword=${encodeQuery(destination)}&callnative=1`;
283
+ return { primary: url, fallback };
284
+ }
285
+ if (action === "navigateByCoordinate") {
286
+ const coordinateParams = {
287
+ latitude: params.latitude,
288
+ longitude: params.longitude,
289
+ destination: params.destination,
290
+ mode: params.mode
291
+ };
292
+ const urls = buildCoordinateNavigationUrl(coordinateParams, sourceApplication);
293
+ if (context.options.fallbackUrl) {
294
+ urls.fallback = context.options.fallbackUrl;
295
+ }
296
+ return urls;
297
+ }
298
+ throw new Error(`[amapProvider] \u4E0D\u652F\u6301 action: ${action}`);
299
+ }
300
+ };
301
+ function buildAmapNavigationUrl(destination, sourceApplication = "sa2kit") {
302
+ return buildKeywordNavigationUrl(destination, sourceApplication);
303
+ }
304
+
305
+ // src/common/appLauncher/providers/baidu.ts
306
+ function buildSrcParam(sourceApplication) {
307
+ const normalized = sourceApplication.replace(/[^a-zA-Z0-9._-]/g, "");
308
+ return `andr.web.${normalized || "sa2kit"}`;
309
+ }
310
+ function buildKeywordNavigationUrl2(destination, sourceApplication) {
311
+ const encodedDestination = encodeQuery(destination);
312
+ const src = encodeQuery(buildSrcParam(sourceApplication));
313
+ return [
314
+ "baidumap://map/navi",
315
+ `?destination=${encodedDestination}`,
316
+ "&mode=driving",
317
+ "&coord_type=gcj02",
318
+ `&src=${src}`
319
+ ].join("");
320
+ }
321
+ var baiduProvider = {
322
+ id: "baidu",
323
+ actions: ["navigate", "navigateByCoordinate"],
324
+ validateParams(action, params) {
325
+ if (action === "navigate") {
326
+ requireNonEmptyString(params.destination, "destination");
327
+ return;
328
+ }
329
+ if (action === "navigateByCoordinate") {
330
+ if (typeof params.latitude !== "number" || typeof params.longitude !== "number") {
331
+ throw new AppLaunchError(
332
+ "INVALID_PARAMS",
333
+ "navigateByCoordinate \u9700\u8981 latitude \u4E0E longitude"
334
+ );
335
+ }
336
+ }
337
+ },
338
+ buildUrls(action, params, context) {
339
+ const sourceApplication = context.sourceApplication;
340
+ if (action === "navigate") {
341
+ const destination = requireNonEmptyString(params.destination, "destination");
342
+ const primary = buildKeywordNavigationUrl2(destination, sourceApplication);
343
+ const encodedDestination = encodeQuery(destination);
344
+ return {
345
+ primary,
346
+ fallback: context.options.fallbackUrl ?? `https://map.baidu.com/mobile/webapp/search/search/qt=na&wd=${encodedDestination}&mode=MAP_MODE&newmap=1`
347
+ };
348
+ }
349
+ if (action === "navigateByCoordinate") {
350
+ const latitude = String(params.latitude);
351
+ const longitude = String(params.longitude);
352
+ const name = params.destination ? encodeQuery(String(params.destination)) : "";
353
+ const src = encodeQuery(buildSrcParam(sourceApplication));
354
+ const destination = name ? `latlng:${latitude},${longitude}|name:${name}` : `latlng:${latitude},${longitude}`;
355
+ return {
356
+ primary: `baidumap://map/navi?destination=${encodeQuery(destination)}&mode=driving&coord_type=gcj02&src=${src}`,
357
+ fallback: context.options.fallbackUrl ?? `https://map.baidu.com/mobile/webapp/search/search/qt=na&wd=${encodeQuery(`${latitude},${longitude}`)}&mode=MAP_MODE&newmap=1`
358
+ };
359
+ }
360
+ throw new Error(`[baiduProvider] \u4E0D\u652F\u6301 action: ${action}`);
361
+ }
362
+ };
363
+ function buildBaiduNavigationUrl(destination, sourceApplication = "sa2kit") {
364
+ return buildKeywordNavigationUrl2(destination, sourceApplication);
365
+ }
366
+
367
+ // src/common/appLauncher/providers/generic.ts
368
+ var genericProvider = {
369
+ id: "generic",
370
+ actions: ["open"],
371
+ validateParams(_action, params) {
372
+ requireNonEmptyString(params.url, "url");
373
+ },
374
+ buildUrls(_action, params, context) {
375
+ const url = requireNonEmptyString(params.url, "url");
376
+ const fallback = context.options.fallbackUrl ?? (typeof params.fallback === "string" ? params.fallback : void 0);
377
+ return { primary: url, fallback };
378
+ }
379
+ };
380
+
381
+ // src/common/appLauncher/providers/google.ts
382
+ function buildKeywordNavigationUrl3(destination) {
383
+ const encoded = encodeQuery(destination);
384
+ const primary = typeof navigator !== "undefined" && isAndroid() ? `google.navigation:q=${encoded}` : `comgooglemaps://?daddr=${encoded}&directionsmode=driving`;
385
+ return {
386
+ primary,
387
+ fallback: `https://www.google.com/maps/dir/?api=1&destination=${encoded}&travelmode=driving`
388
+ };
389
+ }
390
+ function buildCoordinateNavigationUrl2(latitude, longitude, destination) {
391
+ const coordinateQuery = destination ? encodeQuery(destination) : `${latitude},${longitude}`;
392
+ const primary = typeof navigator !== "undefined" && isAndroid() ? `google.navigation:q=${latitude},${longitude}` : `comgooglemaps://?daddr=${coordinateQuery}&directionsmode=driving`;
393
+ const fallbackDestination = destination ? encodeQuery(destination) : `${latitude},${longitude}`;
394
+ return {
395
+ primary,
396
+ fallback: `https://www.google.com/maps/dir/?api=1&destination=${fallbackDestination}&travelmode=driving`
397
+ };
398
+ }
399
+ var googleProvider = {
400
+ id: "google",
401
+ actions: ["navigate", "navigateByCoordinate"],
402
+ validateParams(action, params) {
403
+ if (action === "navigate") {
404
+ requireNonEmptyString(params.destination, "destination");
405
+ return;
406
+ }
407
+ if (action === "navigateByCoordinate") {
408
+ if (typeof params.latitude !== "number" || typeof params.longitude !== "number") {
409
+ throw new AppLaunchError(
410
+ "INVALID_PARAMS",
411
+ "navigateByCoordinate \u9700\u8981 latitude \u4E0E longitude"
412
+ );
413
+ }
414
+ }
415
+ },
416
+ buildUrls(action, params, context) {
417
+ if (action === "navigate") {
418
+ const destination = requireNonEmptyString(params.destination, "destination");
419
+ const urls = buildKeywordNavigationUrl3(destination);
420
+ if (context.options.fallbackUrl) {
421
+ urls.fallback = context.options.fallbackUrl;
422
+ }
423
+ return urls;
424
+ }
425
+ if (action === "navigateByCoordinate") {
426
+ const urls = buildCoordinateNavigationUrl2(
427
+ params.latitude,
428
+ params.longitude,
429
+ params.destination
430
+ );
431
+ if (context.options.fallbackUrl) {
432
+ urls.fallback = context.options.fallbackUrl;
433
+ }
434
+ return urls;
435
+ }
436
+ throw new Error(`[googleProvider] \u4E0D\u652F\u6301 action: ${action}`);
437
+ }
438
+ };
439
+ function buildGoogleNavigationUrl(destination) {
440
+ return buildKeywordNavigationUrl3(destination).primary;
441
+ }
442
+
443
+ // src/common/appLauncher/providers/qq.ts
444
+ var qqProvider = {
445
+ id: "qq",
446
+ actions: ["share", "open"],
447
+ validateParams(action, params) {
448
+ if (action === "open") {
449
+ return;
450
+ }
451
+ requireNonEmptyString(params.title, "title");
452
+ requireNonEmptyString(params.url, "url");
453
+ },
454
+ buildUrls(action, params, context) {
455
+ if (action === "open") {
456
+ return {
457
+ primary: "mqqapi://",
458
+ fallback: context.options.fallbackUrl ?? "https://im.qq.com/"
459
+ };
460
+ }
461
+ const title = encodeQuery(requireNonEmptyString(params.title, "title"));
462
+ const summary = encodeQuery(
463
+ typeof params.summary === "string" ? params.summary : ""
464
+ );
465
+ const url = encodeQuery(requireNonEmptyString(params.url, "url"));
466
+ const imageUrl = params.imageUrl ? encodeQuery(String(params.imageUrl)) : "";
467
+ const primary = [
468
+ "mqqapi://share/to_fri",
469
+ "?src_type=web",
470
+ "&version=1",
471
+ "&file_type=news",
472
+ `&title=${title}`,
473
+ `&description=${summary}`,
474
+ `&url=${url}`,
475
+ imageUrl ? `&image_url=${imageUrl}` : ""
476
+ ].join("");
477
+ return {
478
+ primary,
479
+ fallback: context.options.fallbackUrl ?? `https://connect.qq.com/`
480
+ };
481
+ }
482
+ };
483
+
484
+ // src/common/appLauncher/providers/wechat.ts
485
+ var wechatProvider = {
486
+ id: "wechat",
487
+ actions: ["open", "share"],
488
+ validateParams(action, params) {
489
+ if (action === "open") {
490
+ return;
491
+ }
492
+ requireNonEmptyString(params.title, "title");
493
+ requireNonEmptyString(params.url, "url");
494
+ },
495
+ buildUrls(action, params, context) {
496
+ const sourceApplication = encodeQuery(context.sourceApplication);
497
+ if (action === "open") {
498
+ return {
499
+ primary: `weixin://`,
500
+ fallback: context.options.fallbackUrl ?? "https://weixin.qq.com/"
501
+ };
502
+ }
503
+ const title = encodeQuery(requireNonEmptyString(params.title, "title"));
504
+ const description = encodeQuery(
505
+ typeof params.description === "string" ? params.description : ""
506
+ );
507
+ const url = encodeQuery(requireNonEmptyString(params.url, "url"));
508
+ params.thumbUrl ? encodeQuery(String(params.thumbUrl)) : "";
509
+ const primary = `weixin://dl/businessWebview/link?appid=&url=${url}&title=${title}&description=${description}`;
510
+ return {
511
+ primary,
512
+ fallback: context.options.fallbackUrl ?? `https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=${url}&response_type=code&scope=snsapi_userinfo&state=${sourceApplication}#wechat_redirect`
513
+ };
514
+ }
515
+ };
516
+
517
+ // src/common/appLauncher/providers/registry.ts
518
+ var builtinProviders = {
519
+ amap: amapProvider,
520
+ baidu: baiduProvider,
521
+ google: googleProvider,
522
+ wechat: wechatProvider,
523
+ qq: qqProvider,
524
+ generic: genericProvider
525
+ };
526
+ var customProviders = /* @__PURE__ */ new Map();
527
+ function registerAppProvider(provider) {
528
+ customProviders.set(provider.id, provider);
529
+ }
530
+ function getAppProvider(id) {
531
+ return customProviders.get(id) ?? builtinProviders[id];
532
+ }
533
+ function listAppProviders() {
534
+ const ids = /* @__PURE__ */ new Set([
535
+ ...Object.keys(builtinProviders),
536
+ ...customProviders.keys()
537
+ ]);
538
+ return [...ids];
539
+ }
540
+
541
+ // src/common/appLauncher/core/launcher.ts
542
+ function resolveAdapter(request) {
543
+ const config = getAppLauncherConfig();
544
+ const adapter = request.adapter ?? config.adapter;
545
+ if (adapter) {
546
+ return adapter;
547
+ }
548
+ if (typeof window !== "undefined") {
549
+ return createWebAppLaunchAdapter();
550
+ }
551
+ throw new AppLaunchError(
552
+ "ADAPTER_MISSING",
553
+ "\u672A\u914D\u7F6E AppLaunchAdapter\uFF0C\u8BF7\u5728\u5BBF\u4E3B\u542F\u52A8\u65F6\u8C03\u7528 configureAppLauncher({ adapter })"
554
+ );
555
+ }
556
+ async function launchApp(request) {
557
+ const config = getAppLauncherConfig();
558
+ const provider = getAppProvider(request.provider);
559
+ if (!provider) {
560
+ throw new AppLaunchError("UNKNOWN_PROVIDER", `\u672A\u77E5 provider: ${request.provider}`);
561
+ }
562
+ if (!provider.actions.includes(request.action)) {
563
+ throw new AppLaunchError(
564
+ "UNKNOWN_ACTION",
565
+ `provider "${request.provider}" \u4E0D\u652F\u6301 action "${request.action}"`,
566
+ { supportedActions: [...provider.actions] }
567
+ );
568
+ }
569
+ const params = request.params ?? {};
570
+ provider.validateParams?.(request.action, params);
571
+ const mergedOptions = {
572
+ sourceApplication: config.sourceApplication,
573
+ timeoutMs: 1500,
574
+ ...config.defaultOptions,
575
+ ...request.options
576
+ };
577
+ const urls = provider.buildUrls(request.action, params, {
578
+ sourceApplication: mergedOptions.sourceApplication ?? config.sourceApplication,
579
+ options: mergedOptions
580
+ });
581
+ if (mergedOptions.fallbackUrl && !urls.fallback) {
582
+ urls.fallback = mergedOptions.fallbackUrl;
583
+ }
584
+ const adapter = resolveAdapter(request);
585
+ const callbacks = {
586
+ ...config.defaultCallbacks,
587
+ ...request.callbacks
588
+ };
589
+ try {
590
+ return await adapter.launch(urls, {
591
+ provider: request.provider,
592
+ action: request.action,
593
+ timeoutMs: mergedOptions.timeoutMs ?? 1500,
594
+ callbacks
595
+ });
596
+ } catch (error) {
597
+ const launchError = error instanceof AppLaunchError ? error : new AppLaunchError(
598
+ "OPEN_FAILED",
599
+ error instanceof Error ? error.message : "\u5524\u8D77\u7B2C\u4E09\u65B9 App \u5931\u8D25"
600
+ );
601
+ callbacks.onError?.(launchError);
602
+ throw launchError;
603
+ }
604
+ }
605
+
606
+ // src/common/appLauncher/core/return-handler.ts
607
+ function parseReturnUrl(url) {
608
+ let parsed;
609
+ try {
610
+ parsed = new URL(url);
611
+ } catch {
612
+ return { url, params: {} };
613
+ }
614
+ const params = {};
615
+ parsed.searchParams.forEach((value, key) => {
616
+ params[key] = value;
617
+ });
618
+ const provider = parsed.searchParams.get("provider");
619
+ return {
620
+ provider: provider ?? void 0,
621
+ action: parsed.searchParams.get("action") ?? void 0,
622
+ url,
623
+ params
624
+ };
625
+ }
626
+ var listeners = /* @__PURE__ */ new Set();
627
+ function notifyAppReturn(payload) {
628
+ listeners.forEach((listener) => listener(payload));
629
+ }
630
+ function subscribeAppReturn(listener) {
631
+ listeners.add(listener);
632
+ return () => listeners.delete(listener);
633
+ }
634
+ function matchesReturnUrl(incomingUrl, expectedReturnUrl) {
635
+ if (!expectedReturnUrl) {
636
+ return false;
637
+ }
638
+ if (incomingUrl === expectedReturnUrl) {
639
+ return true;
640
+ }
641
+ try {
642
+ const incoming = new URL(incomingUrl);
643
+ const expected = new URL(expectedReturnUrl);
644
+ return incoming.protocol === expected.protocol && incoming.hostname === expected.hostname && incoming.pathname === expected.pathname;
645
+ } catch {
646
+ return incomingUrl.startsWith(expectedReturnUrl);
647
+ }
648
+ }
649
+
650
+ // src/common/appLauncher/shortcuts/map-navigation.ts
651
+ var MAP_NAVIGATION_OPTIONS = [
652
+ { id: "amap", label: "\u9AD8\u5FB7\u5730\u56FE", description: "\u56FD\u5185\u5E38\u7528\uFF0C\u652F\u6301\u5173\u952E\u8BCD\u5BFC\u822A" },
653
+ { id: "baidu", label: "\u767E\u5EA6\u5730\u56FE", description: "\u56FD\u5185\u5E38\u7528\uFF0C\u652F\u6301\u5173\u952E\u8BCD\u5BFC\u822A" },
654
+ { id: "google", label: "\u8C37\u6B4C\u5730\u56FE", description: "\u6D77\u5916\u6216\u5DF2\u5B89\u88C5 Google Maps \u65F6\u9002\u7528" }
655
+ ];
656
+ async function launchMapNavigation(provider, destination, options) {
657
+ const { callbacks, ...launchOptions } = options ?? {};
658
+ return launchApp({
659
+ provider,
660
+ action: "navigate",
661
+ params: { destination },
662
+ options: launchOptions,
663
+ callbacks
664
+ });
665
+ }
666
+ function openMapNavigation(provider, destination, options) {
667
+ void launchMapNavigation(provider, destination, options);
668
+ }
669
+
670
+ // src/common/appLauncher/shortcuts/index.ts
671
+ async function launchAmapNavigation(destination, options) {
672
+ const { callbacks, ...launchOptions } = options ?? {};
673
+ return launchApp({
674
+ provider: "amap",
675
+ action: "navigate",
676
+ params: { destination },
677
+ options: launchOptions,
678
+ callbacks
679
+ });
680
+ }
681
+ function openAmapNavigation(destination, options) {
682
+ void launchAmapNavigation(destination, options);
683
+ }
684
+ async function launchWechatShare(options) {
685
+ const { callbacks, title, description, url, thumbUrl, ...launchOptions } = options;
686
+ return launchApp({
687
+ provider: "wechat",
688
+ action: "share",
689
+ params: { title, description, url, thumbUrl },
690
+ options: launchOptions,
691
+ callbacks
692
+ });
693
+ }
694
+ async function launchQqShare(options) {
695
+ const { callbacks, title, summary, url, imageUrl, ...launchOptions } = options;
696
+ return launchApp({
697
+ provider: "qq",
698
+ action: "share",
699
+ params: { title, summary, url, imageUrl },
700
+ options: launchOptions,
701
+ callbacks
702
+ });
703
+ }
704
+ async function launchGenericUrl(url, options) {
705
+ const { callbacks, fallback, ...launchOptions } = options ?? {};
706
+ return launchApp({
707
+ provider: "generic",
708
+ action: "open",
709
+ params: { url, fallback },
710
+ options: launchOptions,
711
+ callbacks
712
+ });
713
+ }
714
+
715
+ exports.AppLaunchError = AppLaunchError;
716
+ exports.MAP_NAVIGATION_OPTIONS = MAP_NAVIGATION_OPTIONS;
717
+ exports.amapProvider = amapProvider;
718
+ exports.baiduProvider = baiduProvider;
719
+ exports.buildAmapNavigationUrl = buildAmapNavigationUrl;
720
+ exports.buildBaiduNavigationUrl = buildBaiduNavigationUrl;
721
+ exports.buildGoogleNavigationUrl = buildGoogleNavigationUrl;
722
+ exports.configureAppLauncher = configureAppLauncher;
723
+ exports.createRnAppLaunchAdapter = createRnAppLaunchAdapter;
724
+ exports.createRnAppLaunchAdapterFromReactNative = createRnAppLaunchAdapterFromReactNative;
725
+ exports.createWebAppLaunchAdapter = createWebAppLaunchAdapter;
726
+ exports.genericProvider = genericProvider;
727
+ exports.getAppLauncherConfig = getAppLauncherConfig;
728
+ exports.getAppProvider = getAppProvider;
729
+ exports.googleProvider = googleProvider;
730
+ exports.isAndroid = isAndroid;
731
+ exports.isIOS = isIOS;
732
+ exports.isMobileDevice = isMobileDevice;
733
+ exports.launchAmapNavigation = launchAmapNavigation;
734
+ exports.launchApp = launchApp;
735
+ exports.launchGenericUrl = launchGenericUrl;
736
+ exports.launchMapNavigation = launchMapNavigation;
737
+ exports.launchQqShare = launchQqShare;
738
+ exports.launchWechatShare = launchWechatShare;
739
+ exports.listAppProviders = listAppProviders;
740
+ exports.matchesReturnUrl = matchesReturnUrl;
741
+ exports.notifyAppReturn = notifyAppReturn;
742
+ exports.openAmapNavigation = openAmapNavigation;
743
+ exports.openMapNavigation = openMapNavigation;
744
+ exports.parseReturnUrl = parseReturnUrl;
745
+ exports.qqProvider = qqProvider;
746
+ exports.registerAppProvider = registerAppProvider;
747
+ exports.resetAppLauncherConfig = resetAppLauncherConfig;
748
+ exports.subscribeAppReturn = subscribeAppReturn;
749
+ exports.wechatProvider = wechatProvider;
750
+ //# sourceMappingURL=chunk-FV7IHC23.js.map
751
+ //# sourceMappingURL=chunk-FV7IHC23.js.map