@heycar/heycars-map 0.7.10 → 0.7.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/dist/index.cjs CHANGED
@@ -9,7 +9,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
9
9
  const Vue = require("vue");
10
10
  const style = "";
11
11
  const name = "@heycar/heycars-map";
12
- const version = "0.7.10";
12
+ const version = "0.7.11";
13
13
  const type = "module";
14
14
  const scripts = {
15
15
  dev: "vite -c vite.config.dev.ts",
@@ -3373,6 +3373,19 @@ const BusinessQuotingMap = defineLagecySetup(function BusinessQuotingMap2(props)
3373
3373
  })]);
3374
3374
  };
3375
3375
  }).props(["fallback", "from", "loading", "mapRef", "registerOverlay", "renderDescription", "to", "fromDescription", "log"]);
3376
+ const MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT = "MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT";
3377
+ const MINI_PROGRAM_WEB_VIEW_CLOSE_TIMEOUT = 100 + 20;
3378
+ const MINI_PROGRAM_WEB_VIEW_CLOSE_DELAY = 100 + 70;
3379
+ const patchMiniprogramRedirectTo = (wx2) => {
3380
+ const patchedRedirectTo = (props) => {
3381
+ const webviewCloseEvent = new Event(MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT);
3382
+ dispatchEvent(webviewCloseEvent);
3383
+ setTimeout(() => {
3384
+ wx2.miniProgram.redirectTo(props);
3385
+ }, MINI_PROGRAM_WEB_VIEW_CLOSE_DELAY);
3386
+ };
3387
+ return patchedRedirectTo;
3388
+ };
3376
3389
  const DEVICE_ORIENTATION_INTERVAL = 1e3;
3377
3390
  const CSS_DEVICE_ORIENTATION_VAR_PREFIX = "--CSS_DEVICE_ORIENTATION_VAR_ROTATION_DEGREE_";
3378
3391
  const useDeviceOrientation = (props) => {
@@ -3416,8 +3429,12 @@ function compatibaleAddEventListenerDeviceOrientation(handler) {
3416
3429
  if (isIOSDeviceOrientationPermissionGranted) {
3417
3430
  return addEventListener("deviceorientation", handler);
3418
3431
  }
3419
- const handleTouchEnd = () => {
3432
+ const handleTouchEnd = async () => {
3420
3433
  removeEventListener("touchend", handleTouchEnd);
3434
+ if (detectBrowserPlatform() === BRWOSER_PLATFORM.WECHAT_MINIPROGRAM && await waitMiniProgramWebviewClose(MINI_PROGRAM_WEB_VIEW_CLOSE_TIMEOUT)) {
3435
+ addEventListener("touchend", handleTouchEnd);
3436
+ return;
3437
+ }
3421
3438
  DeviceOrientationEvent == null ? void 0 : DeviceOrientationEvent.requestPermission().then((permissionState) => {
3422
3439
  if (permissionState === "granted") {
3423
3440
  isIOSDeviceOrientationPermissionGranted = true;
@@ -3438,6 +3455,20 @@ function compatibleRemoveEventListenerDeviceOrientation(handler) {
3438
3455
  }
3439
3456
  return removeEventListener("deviceorientation", handler);
3440
3457
  }
3458
+ function waitMiniProgramWebviewClose(duration) {
3459
+ return new Promise((resolve) => {
3460
+ const handleMiniProgramWebviewClose = () => {
3461
+ removeEventListener(MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT, handleMiniProgramWebviewClose);
3462
+ clearTimeout(timer);
3463
+ resolve(true);
3464
+ };
3465
+ addEventListener(MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT, handleMiniProgramWebviewClose);
3466
+ const timer = setTimeout(() => {
3467
+ removeEventListener(MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT, handleMiniProgramWebviewClose);
3468
+ resolve(false);
3469
+ }, duration);
3470
+ });
3471
+ }
3441
3472
  const watchVisibilityState = () => {
3442
3473
  const visibilityStateRef = Vue.ref(document.visibilityState);
3443
3474
  const handleVisibilityChange = () => {
@@ -7586,6 +7617,8 @@ exports.BusinessTaxiServiceMap = BusinessTaxiServiceMap;
7586
7617
  exports.DrivingLine = DrivingLine;
7587
7618
  exports.DrivingRoute = DrivingRoute;
7588
7619
  exports.HeycarMap = HeycarMap;
7620
+ exports.MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT = MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT;
7621
+ exports.MINI_PROGRAM_WEB_VIEW_CLOSE_TIMEOUT = MINI_PROGRAM_WEB_VIEW_CLOSE_TIMEOUT;
7589
7622
  exports.MapProvider = MapProvider;
7590
7623
  exports.PassengerCircle = PassengerCircle;
7591
7624
  exports.PickupPoints = PickupPoints;
@@ -7595,6 +7628,7 @@ exports.TaxiCar = TaxiCar;
7595
7628
  exports.WalkingLine = WalkingLine;
7596
7629
  exports.WalkingRoute = WalkingRoute;
7597
7630
  exports.WaveCircle = WaveCircle;
7631
+ exports.patchMiniprogramRedirectTo = patchMiniprogramRedirectTo;
7598
7632
  exports.useBusinessAlarm = useBusinessAlarm;
7599
7633
  exports.useBusinessQuotingMap = useBusinessQuotingMap;
7600
7634
  exports.useBusinessRecomendPlaceMap = useBusinessRecomendPlaceMap;
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ var __publicField = (obj, key, value) => {
7
7
  import Vue, { defineComponent, h, computed, inject, provide, watch, onMounted, onUnmounted, watchPostEffect, shallowRef, ref, watchEffect, reactive, toRefs, toRef } from "vue";
8
8
  const style = "";
9
9
  const name = "@heycar/heycars-map";
10
- const version = "0.7.10";
10
+ const version = "0.7.11";
11
11
  const type = "module";
12
12
  const scripts = {
13
13
  dev: "vite -c vite.config.dev.ts",
@@ -3371,6 +3371,19 @@ const BusinessQuotingMap = defineLagecySetup(function BusinessQuotingMap2(props)
3371
3371
  })]);
3372
3372
  };
3373
3373
  }).props(["fallback", "from", "loading", "mapRef", "registerOverlay", "renderDescription", "to", "fromDescription", "log"]);
3374
+ const MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT = "MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT";
3375
+ const MINI_PROGRAM_WEB_VIEW_CLOSE_TIMEOUT = 100 + 20;
3376
+ const MINI_PROGRAM_WEB_VIEW_CLOSE_DELAY = 100 + 70;
3377
+ const patchMiniprogramRedirectTo = (wx2) => {
3378
+ const patchedRedirectTo = (props) => {
3379
+ const webviewCloseEvent = new Event(MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT);
3380
+ dispatchEvent(webviewCloseEvent);
3381
+ setTimeout(() => {
3382
+ wx2.miniProgram.redirectTo(props);
3383
+ }, MINI_PROGRAM_WEB_VIEW_CLOSE_DELAY);
3384
+ };
3385
+ return patchedRedirectTo;
3386
+ };
3374
3387
  const DEVICE_ORIENTATION_INTERVAL = 1e3;
3375
3388
  const CSS_DEVICE_ORIENTATION_VAR_PREFIX = "--CSS_DEVICE_ORIENTATION_VAR_ROTATION_DEGREE_";
3376
3389
  const useDeviceOrientation = (props) => {
@@ -3414,8 +3427,12 @@ function compatibaleAddEventListenerDeviceOrientation(handler) {
3414
3427
  if (isIOSDeviceOrientationPermissionGranted) {
3415
3428
  return addEventListener("deviceorientation", handler);
3416
3429
  }
3417
- const handleTouchEnd = () => {
3430
+ const handleTouchEnd = async () => {
3418
3431
  removeEventListener("touchend", handleTouchEnd);
3432
+ if (detectBrowserPlatform() === BRWOSER_PLATFORM.WECHAT_MINIPROGRAM && await waitMiniProgramWebviewClose(MINI_PROGRAM_WEB_VIEW_CLOSE_TIMEOUT)) {
3433
+ addEventListener("touchend", handleTouchEnd);
3434
+ return;
3435
+ }
3419
3436
  DeviceOrientationEvent == null ? void 0 : DeviceOrientationEvent.requestPermission().then((permissionState) => {
3420
3437
  if (permissionState === "granted") {
3421
3438
  isIOSDeviceOrientationPermissionGranted = true;
@@ -3436,6 +3453,20 @@ function compatibleRemoveEventListenerDeviceOrientation(handler) {
3436
3453
  }
3437
3454
  return removeEventListener("deviceorientation", handler);
3438
3455
  }
3456
+ function waitMiniProgramWebviewClose(duration) {
3457
+ return new Promise((resolve) => {
3458
+ const handleMiniProgramWebviewClose = () => {
3459
+ removeEventListener(MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT, handleMiniProgramWebviewClose);
3460
+ clearTimeout(timer);
3461
+ resolve(true);
3462
+ };
3463
+ addEventListener(MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT, handleMiniProgramWebviewClose);
3464
+ const timer = setTimeout(() => {
3465
+ removeEventListener(MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT, handleMiniProgramWebviewClose);
3466
+ resolve(false);
3467
+ }, duration);
3468
+ });
3469
+ }
3439
3470
  const watchVisibilityState = () => {
3440
3471
  const visibilityStateRef = ref(document.visibilityState);
3441
3472
  const handleVisibilityChange = () => {
@@ -7585,6 +7616,8 @@ export {
7585
7616
  DrivingLine,
7586
7617
  DrivingRoute,
7587
7618
  HeycarMap,
7619
+ MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT,
7620
+ MINI_PROGRAM_WEB_VIEW_CLOSE_TIMEOUT,
7588
7621
  MapProvider,
7589
7622
  PassengerCircle,
7590
7623
  PickupPoints,
@@ -7594,6 +7627,7 @@ export {
7594
7627
  WalkingLine,
7595
7628
  WalkingRoute,
7596
7629
  WaveCircle,
7630
+ patchMiniprogramRedirectTo,
7597
7631
  useBusinessAlarm,
7598
7632
  useBusinessQuotingMap,
7599
7633
  useBusinessRecomendPlaceMap,
@@ -31,3 +31,4 @@ export { useMapPlace } from "./hooks/useMapPlace";
31
31
  export { useMapRecomendPlace } from "./hooks/useMapRecomendPlace";
32
32
  export { useWalkingRoute } from "./hooks/useWalkingRoute";
33
33
  export * from "./types/interface";
34
+ export * from "./utils/patchMiniprogram";
@@ -7,6 +7,12 @@ export interface WxGetLocationSuccessResponse extends WxResponse {
7
7
  speed: string;
8
8
  accuracy: string;
9
9
  }
10
+ interface WxMiniProgramRedirectToProps {
11
+ url: string;
12
+ sucess?: () => void;
13
+ fail?: () => void;
14
+ complete?: () => void;
15
+ }
10
16
  interface WxGetLocationProps {
11
17
  type: "wgs84" | "gcj02";
12
18
  success: (response: WxGetLocationSuccessResponse) => void;
@@ -17,5 +23,8 @@ export interface Wx {
17
23
  ready: (callback: () => void) => void;
18
24
  error: (callback: (response: WxResponse) => void) => void;
19
25
  getLocation: (props: WxGetLocationProps) => void;
26
+ miniProgram: {
27
+ redirectTo: (props: WxMiniProgramRedirectToProps) => void;
28
+ };
20
29
  }
21
30
  export {};
@@ -0,0 +1,4 @@
1
+ import type { Wx } from "../types/wx";
2
+ export declare const MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT = "MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT";
3
+ export declare const MINI_PROGRAM_WEB_VIEW_CLOSE_TIMEOUT: number;
4
+ export declare const patchMiniprogramRedirectTo: (wx: Wx) => Wx["miniProgram"]["redirectTo"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.7.10",
3
+ "version": "0.7.11",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite -c vite.config.dev.ts",