connectbase-client 4.0.0 → 4.2.0

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.mjs CHANGED
@@ -4996,6 +4996,101 @@ var NativeAPI = class {
4996
4996
  }
4997
4997
  );
4998
4998
  });
4999
+ },
5000
+ /**
5001
+ * 위치 추적 시작.
5002
+ *
5003
+ * 패키징 앱(모바일)에서는 네이티브가 `nativeLocationUpdate` 이벤트로 갱신을 보내고,
5004
+ * 웹/데스크톱에서는 Geolocation `watchPosition` 을 사용한다.
5005
+ *
5006
+ * @example
5007
+ * ```typescript
5008
+ * const watch = await cb.native.location.watchPosition((pos) => console.log(pos))
5009
+ * // 나중에
5010
+ * await watch.clear()
5011
+ * ```
5012
+ */
5013
+ watchPosition: async (onUpdate, options) => {
5014
+ const platform = this.getPlatform();
5015
+ const bridge = window.NativeBridge;
5016
+ if (platform === "mobile" && bridge?.location?.watchPosition) {
5017
+ const { watchId } = await bridge.location.watchPosition(options);
5018
+ const handler = (event) => {
5019
+ const detail = event.detail;
5020
+ if (!detail || detail.watchId && detail.watchId !== watchId) return;
5021
+ onUpdate({
5022
+ latitude: detail.latitude,
5023
+ longitude: detail.longitude,
5024
+ altitude: detail.altitude,
5025
+ accuracy: detail.accuracy,
5026
+ timestamp: detail.timestamp
5027
+ });
5028
+ };
5029
+ window.addEventListener("nativeLocationUpdate", handler);
5030
+ return {
5031
+ watchId,
5032
+ clear: async () => {
5033
+ window.removeEventListener("nativeLocationUpdate", handler);
5034
+ await bridge.location?.stopWatch(watchId);
5035
+ }
5036
+ };
5037
+ }
5038
+ const id = navigator.geolocation.watchPosition(
5039
+ (pos) => onUpdate({
5040
+ latitude: pos.coords.latitude,
5041
+ longitude: pos.coords.longitude,
5042
+ altitude: pos.coords.altitude,
5043
+ accuracy: pos.coords.accuracy,
5044
+ timestamp: pos.timestamp
5045
+ }),
5046
+ void 0,
5047
+ {
5048
+ enableHighAccuracy: options?.accuracy === "high",
5049
+ timeout: 1e4,
5050
+ maximumAge: 0
5051
+ }
5052
+ );
5053
+ return {
5054
+ watchId: String(id),
5055
+ clear: async () => navigator.geolocation.clearWatch(id)
5056
+ };
5057
+ }
5058
+ };
5059
+ /**
5060
+ * 모바일 전용 푸시 API
5061
+ *
5062
+ * 패키징 앱은 raw 디바이스 토큰(iOS=APNS, Android=FCM)을 발급받아
5063
+ * `cb.push.registerDevice()` 로 등록해야 서버 발송이 가능하다.
5064
+ */
5065
+ this.push = {
5066
+ /**
5067
+ * 네이티브 디바이스 푸시 토큰 조회.
5068
+ * 웹(패키징 앱이 아닌 경우)에서는 null 을 반환한다.
5069
+ */
5070
+ getToken: async () => {
5071
+ if (this.getPlatform() === "mobile" && window.NativeBridge?.push) {
5072
+ return window.NativeBridge.push.getToken();
5073
+ }
5074
+ return null;
5075
+ },
5076
+ /** 알림 권한 요청 (웹은 Web Notification 권한) */
5077
+ requestPermission: async () => {
5078
+ return this.notification.requestPermission();
5079
+ },
5080
+ /** 로컬 알림 예약 (패키징 앱 전용) */
5081
+ scheduleLocal: async (options) => {
5082
+ if (this.getPlatform() === "mobile" && window.NativeBridge?.push) {
5083
+ const result = await window.NativeBridge.push.scheduleLocal(options);
5084
+ return result.notificationId;
5085
+ }
5086
+ return null;
5087
+ },
5088
+ /** 앱 아이콘 배지 숫자 설정 (미지원 플랫폼에서는 무시) */
5089
+ setBadgeCount: async (count) => {
5090
+ const setter = window.NativeBridge?.push?.setBadgeCount;
5091
+ if (!setter) return false;
5092
+ const result = await setter(count);
5093
+ return result.success;
4999
5094
  }
5000
5095
  };
5001
5096
  /**
@@ -5011,6 +5106,16 @@ var NativeAPI = class {
5011
5106
  const result = await window.NativeBridge.notification.show(options);
5012
5107
  return result.success;
5013
5108
  }
5109
+ if (platform === "mobile" && window.NativeBridge?.push?.scheduleLocal) {
5110
+ const granted = await this.notification.requestPermission();
5111
+ if (!granted) return false;
5112
+ await window.NativeBridge.push.scheduleLocal({
5113
+ title: options.title,
5114
+ body: options.body,
5115
+ trigger: null
5116
+ });
5117
+ return true;
5118
+ }
5014
5119
  if (!("Notification" in window)) return false;
5015
5120
  if (Notification.permission !== "granted") {
5016
5121
  const permission = await Notification.requestPermission();
@@ -5050,6 +5155,10 @@ var NativeAPI = class {
5050
5155
  const result = await window.NativeBridge.shell.openExternal(url);
5051
5156
  return result.success;
5052
5157
  }
5158
+ if (platform === "mobile" && window.NativeBridge?.browser) {
5159
+ const result = await window.NativeBridge.browser.openExternal(url);
5160
+ return result.success;
5161
+ }
5053
5162
  window.open(url, "_blank");
5054
5163
  return true;
5055
5164
  }
@@ -5295,6 +5404,26 @@ var NativeAPI = class {
5295
5404
  if (bridge?.camera || window.ReactNativeWebView) return "mobile";
5296
5405
  return "web";
5297
5406
  }
5407
+ /**
5408
+ * 패키징 앱(네이티브 셸) 안에서 실행 중인지
5409
+ */
5410
+ isNativeApp() {
5411
+ return this.getPlatform() !== "web";
5412
+ }
5413
+ /**
5414
+ * 패키징 앱 정보 조회 (웹에서는 null)
5415
+ *
5416
+ * @example
5417
+ * ```typescript
5418
+ * const info = await cb.native.getAppInfo()
5419
+ * // { platform: 'react-native', os: 'ios', appVersion: '1.0.0', webUrl: '...' }
5420
+ * ```
5421
+ */
5422
+ async getAppInfo() {
5423
+ const getInfo = this.bridge?.app?.getInfo;
5424
+ if (!getInfo) return null;
5425
+ return getInfo();
5426
+ }
5298
5427
  /**
5299
5428
  * 특정 네이티브 기능 지원 여부 확인
5300
5429
  */
@@ -5967,6 +6096,7 @@ var PaymentAPI = class {
5967
6096
  }
5968
6097
  const params = new URLSearchParams();
5969
6098
  if (options?.status) params.set("status", options.status);
6099
+ if (options?.mode) params.set("mode", options.mode);
5970
6100
  if (options?.startDate) params.set("start_date", options.startDate);
5971
6101
  if (options?.endDate) params.set("end_date", options.endDate);
5972
6102
  if (options?.limit !== void 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "connectbase-client",
3
- "version": "4.0.0",
3
+ "version": "4.2.0",
4
4
  "description": "Connect Base JavaScript/TypeScript SDK for browser and Node.js",
5
5
  "repository": {
6
6
  "type": "git",