|
| 1 | +export {}; |
| 2 | + |
| 3 | +declare global { |
| 4 | + namespace Kakao { |
| 5 | + const VERSION: string; |
| 6 | + |
| 7 | + /** |
| 8 | + * @see https://developers.kakao.com/sdk/reference/js/release/Kakao.html#init |
| 9 | + */ |
| 10 | + function init(appKey: string): void; |
| 11 | + |
| 12 | + /** |
| 13 | + * @see https://developers.kakao.com/sdk/reference/js/release/Kakao.html#isInitialized |
| 14 | + */ |
| 15 | + function isInitialized(): boolean; |
| 16 | + |
| 17 | + /** |
| 18 | + * @see https://developers.kakao.com/sdk/reference/js/release/Kakao.html#cleanup |
| 19 | + */ |
| 20 | + function cleanup(): void; |
| 21 | + |
| 22 | + namespace Auth { |
| 23 | + interface AuthorizeSettings { |
| 24 | + redirectUri?: string; |
| 25 | + state?: string; |
| 26 | + scope?: string; |
| 27 | + prompt?: string; |
| 28 | + nonce?: string; |
| 29 | + throughTalk?: boolean; |
| 30 | + } |
| 31 | + |
| 32 | + /** |
| 33 | + * @see https://developers.kakao.com/docs/latest/ko/kakaologin/js#authorize |
| 34 | + */ |
| 35 | + function authorize(settings: AuthorizeSettings): void; |
| 36 | + |
| 37 | + /** |
| 38 | + * @see https://developers.kakao.com/docs/latest/ko/kakaologin/js#logout |
| 39 | + */ |
| 40 | + function logout(): Promise<void>; |
| 41 | + } |
| 42 | + |
| 43 | + namespace Share { |
| 44 | + interface LinkObject { |
| 45 | + webUrl?: string; |
| 46 | + mobileWebUrl?: string; |
| 47 | + androidExecutionParams?: string; |
| 48 | + iosExecutionParams?: string; |
| 49 | + } |
| 50 | + |
| 51 | + interface ButtonObject { |
| 52 | + title: string; |
| 53 | + link: LinkObject; |
| 54 | + } |
| 55 | + |
| 56 | + interface ContentObject { |
| 57 | + title: string; |
| 58 | + description?: string; |
| 59 | + imageUrl: string; |
| 60 | + link: LinkObject; |
| 61 | + imageWidth?: number; |
| 62 | + imageHeight?: number; |
| 63 | + } |
| 64 | + |
| 65 | + interface SocialObject { |
| 66 | + likeCount?: number; |
| 67 | + commentCount?: number; |
| 68 | + sharedCount?: number; |
| 69 | + viewCount?: number; |
| 70 | + subscriberCount?: number; |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * @see https://developers.kakao.com/docs/latest/ko/kakaotalk-share/js-link#default-template-feed |
| 75 | + */ |
| 76 | + interface DefaultFeedSettings { |
| 77 | + objectType: "feed"; |
| 78 | + content: ContentObject; |
| 79 | + social?: SocialObject; |
| 80 | + buttons?: ButtonObject[]; |
| 81 | + } |
| 82 | + |
| 83 | + /** |
| 84 | + * @see https://developers.kakao.com/docs/latest/ko/kakaotalk-share/js-link#default-template-text |
| 85 | + */ |
| 86 | + interface DefaultTextSettings { |
| 87 | + objectType: "text"; |
| 88 | + text: string; |
| 89 | + link: LinkObject; |
| 90 | + buttons?: ButtonObject[]; |
| 91 | + } |
| 92 | + |
| 93 | + /** |
| 94 | + * @see https://developers.kakao.com/docs/latest/ko/kakaotalk-share/js-link#default-template-commerce |
| 95 | + */ |
| 96 | + interface DefaultCommerceSettings { |
| 97 | + objectType: "commerce"; |
| 98 | + content: ContentObject; |
| 99 | + commerce: { |
| 100 | + regularPrice: number; |
| 101 | + discountPrice?: number; |
| 102 | + discountRate?: number; |
| 103 | + fixedDiscountPrice?: number; |
| 104 | + }; |
| 105 | + buttons?: ButtonObject[]; |
| 106 | + } |
| 107 | + |
| 108 | + type DefaultSettings = DefaultFeedSettings | DefaultTextSettings | DefaultCommerceSettings; |
| 109 | + |
| 110 | + interface CustomSettings { |
| 111 | + templateId: number; |
| 112 | + templateArgs?: Record<string, string>; |
| 113 | + installTalk?: boolean; |
| 114 | + } |
| 115 | + |
| 116 | + interface ScrapSettings { |
| 117 | + requestUrl: string; |
| 118 | + templateId?: number; |
| 119 | + templateArgs?: Record<string, string>; |
| 120 | + } |
| 121 | + |
| 122 | + /** |
| 123 | + * @see https://developers.kakao.com/docs/latest/ko/kakaotalk-share/js-link#send-default |
| 124 | + */ |
| 125 | + function sendDefault(settings: DefaultSettings): Promise<void>; |
| 126 | + |
| 127 | + /** |
| 128 | + * @see https://developers.kakao.com/docs/latest/ko/kakaotalk-share/js-link#send-custom |
| 129 | + */ |
| 130 | + function sendCustom(settings: CustomSettings): Promise<void>; |
| 131 | + |
| 132 | + /** |
| 133 | + * @see https://developers.kakao.com/docs/latest/ko/kakaotalk-share/js-link#send-scrap |
| 134 | + */ |
| 135 | + function sendScrap(settings: ScrapSettings): Promise<void>; |
| 136 | + |
| 137 | + /** |
| 138 | + * @see https://developers.kakao.com/docs/latest/ko/kakaotalk-share/js-link#create-default-button |
| 139 | + */ |
| 140 | + function createDefaultButton( |
| 141 | + settings: DefaultSettings & { container: string | HTMLElement }, |
| 142 | + ): void; |
| 143 | + } |
| 144 | + |
| 145 | + namespace Channel { |
| 146 | + interface ChannelSettings { |
| 147 | + channelPublicId: string; |
| 148 | + } |
| 149 | + |
| 150 | + /** |
| 151 | + * @see https://developers.kakao.com/docs/latest/ko/kakaotalk-channel/js#add-channel |
| 152 | + */ |
| 153 | + function addChannel(settings: ChannelSettings): void; |
| 154 | + |
| 155 | + /** |
| 156 | + * @see https://developers.kakao.com/docs/latest/ko/kakaotalk-channel/js#chat |
| 157 | + */ |
| 158 | + function chat(settings: ChannelSettings): void; |
| 159 | + } |
| 160 | + } |
| 161 | + |
| 162 | + interface Window { |
| 163 | + Kakao: typeof Kakao; |
| 164 | + } |
| 165 | +} |
0 commit comments