@apps-in-toss/web-bridge 0.0.34 → 0.0.36
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/build/bridge.d.ts +2 -1
- package/build/bridge.js +1 -1
- package/build/contactsViral.d.ts +110 -0
- package/package.json +5 -5
package/build/bridge.d.ts
CHANGED
|
@@ -27,4 +27,5 @@ export * from './openGameCenterLeaderboard.js';
|
|
|
27
27
|
export * from './submitGameCenterLeaderBoardScore.js';
|
|
28
28
|
export * from './getTossAppVersion.js';
|
|
29
29
|
export * from './getDeviceId.js';
|
|
30
|
-
export * from './startUpdateLocation.js';
|
|
30
|
+
export * from './startUpdateLocation.js';
|
|
31
|
+
export * from './contactsViral.js';
|
package/build/bridge.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createAsyncBridge,createConstantBridge,createEventBridge}from"@apps-in-toss/bridge-core";var createEvents=function(){return{emit:function emit(event,args){for(var callbacks=this.events[event]||[],i=0,length=callbacks.length;i<length;i++){callbacks[i](args)}},events:{},on:function on(event,cb){var _this=this;var _this_events,_event;((_this_events=this.events)[_event=event]||(_this_events[_event]=[])).push(cb);return function(){var _this_events_event;_this.events[event]=(_this_events_event=_this.events[event])===null||_this_events_event===void 0?void 0:_this_events_event.filter(function(i){return cb!==i})}}}};if(typeof window!=="undefined"){window.__BEDROCK_NATIVE_EMITTER=createEvents()}export var closeView=createAsyncBridge("closeView");export var generateHapticFeedback=createAsyncBridge("generateHapticFeedback");export var share=createAsyncBridge("share");export var setSecureScreen=createAsyncBridge("setSecureScreen");export var setScreenAwakeMode=createAsyncBridge("setScreenAwakeMode");export var getNetworkStatus=createAsyncBridge("getNetworkStatus");export var setIosSwipeGestureEnabled=createAsyncBridge("setIosSwipeGestureEnabled");export var openURL=createAsyncBridge("openURL");export var getLocale=createConstantBridge("getLocale");export var getSchemeUri=createConstantBridge("getSchemeUri");export var getPlatformOS=createConstantBridge("getPlatformOS");export var setClipboardText=createAsyncBridge("setClipboardText");export var getClipboardText=createAsyncBridge("getClipboardText");export var fetchContacts=createAsyncBridge("fetchContacts");export var fetchAlbumPhotos=createAsyncBridge("fetchAlbumPhotos");export var Accuracy=function(Accuracy){Accuracy[Accuracy["Lowest"]=1]="Lowest";Accuracy[Accuracy["Low"]=2]="Low";Accuracy[Accuracy["Balanced"]=3]="Balanced";Accuracy[Accuracy["High"]=4]="High";Accuracy[Accuracy["Highest"]=5]="Highest";Accuracy[Accuracy["BestForNavigation"]=6]="BestForNavigation";return Accuracy}({});export var getCurrentLocation=createAsyncBridge("getCurrentLocation");export var openCamera=createAsyncBridge("openCamera");export var appLogin=createAsyncBridge("appLogin");export var checkoutPayment=createAsyncBridge("checkoutPayment");export var eventLog=createAsyncBridge("eventLog");export var getTossShareLink=createAsyncBridge("getTossShareLink");export var setDeviceOrientation=createAsyncBridge("setDeviceOrientation");export var saveBase64Data=createAsyncBridge("saveBase64Data");export var getGameCenterGameProfile=createAsyncBridge("getGameCenterGameProfile");export var getOperationalEnvironment=createConstantBridge("getOperationalEnvironment");export var openGameCenterLeaderboard=createAsyncBridge("openGameCenterLeaderboard");export var submitGameCenterLeaderBoardScore=createAsyncBridge("submitGameCenterLeaderBoardScore");export var getTossAppVersion=createConstantBridge("getTossAppVersion");export var getDeviceId=createConstantBridge("getDeviceId");export var startUpdateLocation=createEventBridge("startUpdateLocation");
|
|
1
|
+
import{createAsyncBridge,createConstantBridge,createEventBridge}from"@apps-in-toss/bridge-core";var createEvents=function(){return{emit:function emit(event,args){for(var callbacks=this.events[event]||[],i=0,length=callbacks.length;i<length;i++){callbacks[i](args)}},events:{},on:function on(event,cb){var _this=this;var _this_events,_event;((_this_events=this.events)[_event=event]||(_this_events[_event]=[])).push(cb);return function(){var _this_events_event;_this.events[event]=(_this_events_event=_this.events[event])===null||_this_events_event===void 0?void 0:_this_events_event.filter(function(i){return cb!==i})}}}};if(typeof window!=="undefined"){window.__BEDROCK_NATIVE_EMITTER=createEvents()}export var closeView=createAsyncBridge("closeView");export var generateHapticFeedback=createAsyncBridge("generateHapticFeedback");export var share=createAsyncBridge("share");export var setSecureScreen=createAsyncBridge("setSecureScreen");export var setScreenAwakeMode=createAsyncBridge("setScreenAwakeMode");export var getNetworkStatus=createAsyncBridge("getNetworkStatus");export var setIosSwipeGestureEnabled=createAsyncBridge("setIosSwipeGestureEnabled");export var openURL=createAsyncBridge("openURL");export var getLocale=createConstantBridge("getLocale");export var getSchemeUri=createConstantBridge("getSchemeUri");export var getPlatformOS=createConstantBridge("getPlatformOS");export var setClipboardText=createAsyncBridge("setClipboardText");export var getClipboardText=createAsyncBridge("getClipboardText");export var fetchContacts=createAsyncBridge("fetchContacts");export var fetchAlbumPhotos=createAsyncBridge("fetchAlbumPhotos");export var Accuracy=function(Accuracy){Accuracy[Accuracy["Lowest"]=1]="Lowest";Accuracy[Accuracy["Low"]=2]="Low";Accuracy[Accuracy["Balanced"]=3]="Balanced";Accuracy[Accuracy["High"]=4]="High";Accuracy[Accuracy["Highest"]=5]="Highest";Accuracy[Accuracy["BestForNavigation"]=6]="BestForNavigation";return Accuracy}({});export var getCurrentLocation=createAsyncBridge("getCurrentLocation");export var openCamera=createAsyncBridge("openCamera");export var appLogin=createAsyncBridge("appLogin");export var checkoutPayment=createAsyncBridge("checkoutPayment");export var eventLog=createAsyncBridge("eventLog");export var getTossShareLink=createAsyncBridge("getTossShareLink");export var setDeviceOrientation=createAsyncBridge("setDeviceOrientation");export var saveBase64Data=createAsyncBridge("saveBase64Data");export var getGameCenterGameProfile=createAsyncBridge("getGameCenterGameProfile");export var getOperationalEnvironment=createConstantBridge("getOperationalEnvironment");export var openGameCenterLeaderboard=createAsyncBridge("openGameCenterLeaderboard");export var submitGameCenterLeaderBoardScore=createAsyncBridge("submitGameCenterLeaderBoardScore");export var getTossAppVersion=createConstantBridge("getTossAppVersion");export var getDeviceId=createConstantBridge("getDeviceId");export var startUpdateLocation=createEventBridge("startUpdateLocation");export var contactsViral=createEventBridge("contactsViral");
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
* @category 친구초대
|
|
4
|
+
* @name RewardFromContactsViralEvent
|
|
5
|
+
* @description 친구에게 공유하기를 완료했을 때 지급할 리워드 정보를 담는 타입이에요. 이 타입을 사용하면 공유가 완료됐을 때 지급할 리워드 정보를 확인할 수 있어요.
|
|
6
|
+
* @property {'sendViral'} type - 이벤트의 타입이에요. `'sendViral'`은 사용자가 친구에게 공유를 완료했을 때 돌아와요.
|
|
7
|
+
* @property {Object} data - 지급할 리워드 관련 정보를 담고 있어요.
|
|
8
|
+
* @property {number} data.rewardAmount - 지급할 리워드 수량이에요. 앱인토스 콘솔에서 설정한 수량 및 금액 값이에요.
|
|
9
|
+
* @property {string} data.rewardUnit - 리워드의 단위예요. 앱인토스 콘솔에 설정된 리워드 이름인 '하트', '보석' 등이 리워드 단위예요.
|
|
10
|
+
*/
|
|
11
|
+
export type RewardFromContactsViralEvent = {
|
|
12
|
+
type: "sendViral";
|
|
13
|
+
data: {
|
|
14
|
+
rewardAmount: number;
|
|
15
|
+
rewardUnit: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* @public
|
|
20
|
+
* @category 친구초대
|
|
21
|
+
* @name SuccessEvent
|
|
22
|
+
* @description 연락처 공유 모듈이 정상적으로 종료됐을 때 전달되는 이벤트 객체예요. 종료 이유와 함께 리워드 상태 및 남은 친구 수 등 관련 정보를 제공해요.
|
|
23
|
+
* @property {'close'} type - 이벤트의 타입이에요. `'close'`는 공유 모듈이 종료됐을 때 돌아와요.
|
|
24
|
+
* @property {Object} data - 모듈 종료와 관련된 세부 정보를 담고 있어요.
|
|
25
|
+
* @property {'clickBackButton' | 'noReward'} data.closeReason - 모듈이 종료된 이유예요. `'clickBackButton'`은 사용자가 뒤로 가기 버튼을 눌러 종료한 경우이고, `'noReward'`는 받을 수 있는 리워드가 없어서 종료된 경우예요.
|
|
26
|
+
* @property {number} data.sentRewardAmount - 사용자가 받은 전체 리워드 수량이에요.
|
|
27
|
+
* @property {number} data.sendableRewardsCount - 아직 공유할 수 있는 친구 수예요.
|
|
28
|
+
* @property {number} data.sentRewardsCount - 사용자가 공유를 완료한 친구 수예요.
|
|
29
|
+
* @property {string} data.rewardUnit - 리워드의 단위예요. 앱인토스 콘솔에 설정된 리워드 이름인 '하트', '보석' 등이 리워드 단위예요.
|
|
30
|
+
*/
|
|
31
|
+
export type ContactsViralSuccessEvent = {
|
|
32
|
+
type: "close";
|
|
33
|
+
data: {
|
|
34
|
+
closeReason: "clickBackButton" | "noReward";
|
|
35
|
+
sentRewardAmount?: number;
|
|
36
|
+
sendableRewardsCount?: number;
|
|
37
|
+
sentRewardsCount: number;
|
|
38
|
+
rewardUnit?: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export type ContactsViralEvent = RewardFromContactsViralEvent | ContactsViralSuccessEvent;
|
|
42
|
+
/**
|
|
43
|
+
* @public
|
|
44
|
+
* @category 친구초대
|
|
45
|
+
* @name ContactsViralOption
|
|
46
|
+
* @description [연락처 공유 기능](/bedrock/reference/framework/친구초대/contactsViral.html)을 사용할 때 필요한 옵션이에요.
|
|
47
|
+
* @property {string} moduleId - 공유 리워드를 구분하는 UUID 형식의 고유 ID예요. 앱인토스 콘솔의 미니앱 > 공유 리워드 메뉴에서 확인할 수 있어요.
|
|
48
|
+
*/
|
|
49
|
+
export type ContactsViralOption = {
|
|
50
|
+
moduleId: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* @public
|
|
54
|
+
* @category 친구초대
|
|
55
|
+
* @description `ContactsViralParams`는 연락처 공유 기능을 사용할 때 전달해야 하는 파라미터 타입이에요. 옵션을 설정하고, 이벤트 및 에러 처리 콜백을 지정할 수 있어요.
|
|
56
|
+
* @property {ContactsViralOption} options - 공유 기능에 사용할 옵션 객체예요.
|
|
57
|
+
* @property {(event: ContactsViralEvent) => void} onEvent - 공유 이벤트가 발생했을 때 실행되는 함수예요. [`RewardFromContactsViralEvent`](/bedrock/reference/framework/친구초대/RewardFromContactsViralEvent.html) 또는 [`ContactsViralSuccessEvent`](/bedrock/reference/framework/친구초대/ContactsViralSuccessEvent.html) 타입의 이벤트 객체가 전달돼요.
|
|
58
|
+
* @property {(error: unknown) => void} onError - 예기치 않은 에러가 발생했을 때 실행되는 함수예요.
|
|
59
|
+
*/
|
|
60
|
+
export interface ContactsViralParams {
|
|
61
|
+
options: ContactsViralOption;
|
|
62
|
+
onEvent: (event: ContactsViralEvent) => void;
|
|
63
|
+
onError: (error: unknown) => void;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @public
|
|
67
|
+
* @category 친구초대
|
|
68
|
+
* @name contactsViral
|
|
69
|
+
* @description 친구에게 공유하고 리워드를 받을 수 있는 기능을 제공해요. 사용자가 친구에게 공유를 완료하면 앱브릿지가 이벤트를 통해 리워드 정보를 전달해요.
|
|
70
|
+
* @param {ContactsViralParams} params - 연락처 공유 기능을 실행할 때 사용하는 파라미터예요. 옵션 설정과 이벤트 핸들러를 포함해요. 자세한 내용은 [ContactsViralParams](/bedrock/reference/framework/친구초대/ContactsViralParams.html) 문서를 참고하세요.
|
|
71
|
+
* @returns {() => void} 앱브릿지 cleanup 함수를 반환해요. 공유 기능이 끝나면 반드시 이 함수를 호출해서 리소스를 해제해야 해요.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ### 친구에게 공유하고 리워드 받기
|
|
75
|
+
*
|
|
76
|
+
* ```tsx
|
|
77
|
+
* import { useCallback } from 'react';
|
|
78
|
+
*
|
|
79
|
+
* import { contactsViral } from '@apps-in-toss/web-framework';
|
|
80
|
+
*
|
|
81
|
+
* function ContactsViralButton({ moduleId }: { moduleId: string }) {
|
|
82
|
+
* const handleContactsViral = useCallback(() => {
|
|
83
|
+
* try {
|
|
84
|
+
* const cleanup = contactsViral({
|
|
85
|
+
* options: { moduleId: moduleId.trim() },
|
|
86
|
+
* onEvent: (event) => {
|
|
87
|
+
* if (event.type === 'sendViral') {
|
|
88
|
+
* console.log('리워드 지급:', event.data.rewardAmount, event.data.rewardUnit);
|
|
89
|
+
* } else if (event.type === 'close') {
|
|
90
|
+
* console.log('모듈 종료:', event.data.closeReason);
|
|
91
|
+
* }
|
|
92
|
+
* },
|
|
93
|
+
* onError: (error) => {
|
|
94
|
+
* console.error('에러 발생:', error);
|
|
95
|
+
* },
|
|
96
|
+
* });
|
|
97
|
+
*
|
|
98
|
+
* return cleanup;
|
|
99
|
+
* } catch (error) {
|
|
100
|
+
* console.error('실행 중 에러:', error);
|
|
101
|
+
* }
|
|
102
|
+
* }, [moduleId]);
|
|
103
|
+
*
|
|
104
|
+
* return <input type="button" value="친구에게 공유하고 리워드 받기" onClick={handleContactsViral} />;
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export declare function contactsViral(params: ContactsViralParams): () => void;
|
|
109
|
+
|
|
110
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/web-bridge",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.36",
|
|
5
5
|
"description": "Web Bridge for Apps In Toss",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prepack": "yarn build",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"build"
|
|
24
24
|
],
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@apps-in-toss-internal/bridgepack": "0.0.
|
|
27
|
-
"@apps-in-toss/bridge-core": "0.0.
|
|
28
|
-
"@apps-in-toss/framework": "0.0.
|
|
26
|
+
"@apps-in-toss-internal/bridgepack": "0.0.36",
|
|
27
|
+
"@apps-in-toss/bridge-core": "0.0.36",
|
|
28
|
+
"@apps-in-toss/framework": "0.0.36",
|
|
29
29
|
"react-native-bedrock": "0.0.25",
|
|
30
30
|
"tsup": "^8.3.5",
|
|
31
31
|
"typescript": "4.9.5",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "b3b65b35bf9532480fcbd14f7d22b796644e2f2f"
|
|
41
41
|
}
|