This repository has been archived by the owner on Jul 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from S-O-L-A-R/reiiyuki/liff-type
Reiiyuki/liff type
- Loading branch information
Showing
4 changed files
with
2,149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,20 @@ | ||
# liff-type | ||
Type definition for LINE Frontend Framework | ||
|
||
### Installation | ||
|
||
``` | ||
npm i -D liff-type | ||
``` | ||
|
||
### Usage | ||
|
||
Apply `/// <reference types="liff-type" />` on top of your file that using `liff` | ||
|
||
E.g. | ||
|
||
```ts | ||
/// <reference types="liff-type" /> | ||
|
||
liff.getProfile() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/// <reference types="@line/bot-sdk" /> | ||
import LINE = require('@line/bot-sdk') | ||
|
||
declare type LiffInitSuccessCallback = ( | ||
data: { | ||
language: string, | ||
context: { | ||
type: string, | ||
viewType: string, | ||
userId: string, | ||
utouId: string, | ||
roomId: string, | ||
groupId: string, | ||
} | ||
} | ||
) => void | ||
|
||
declare type LiffInitErrorCallback = (error: Error) => void | ||
|
||
declare type LIFFPlugins = 'bluetooth' | ||
|
||
declare interface LINEBluetoothRequestDeviceFilter { | ||
deviceId: string | ||
} | ||
|
||
declare interface LIFFRequestDeviceOptions { | ||
filters: LINEBluetoothRequestDeviceFilter[] | ||
} | ||
|
||
declare interface BluetoothRemoteGATTCharacteristic { | ||
service?: BluetoothRemoteGATTService | ||
uuid: string | ||
value: DataView | ||
readValue(): Promise<DataView> | ||
writeValue(value: BufferSource): Promise<void> | ||
startNotifications(): Promise<BluetoothRemoteGATTCharacteristic> | ||
stopNotifications(): Promise<BluetoothRemoteGATTCharacteristic> | ||
addEventListener(eventName: string, event: EventListener): void | ||
removeEventListener(eventName: string): void | ||
} | ||
|
||
declare interface BluetoothRemoteGATTService { | ||
device: BluetoothDevice | ||
uuid: string | ||
getCharacteristic(characteristicUUID: string): Promise<BluetoothRemoteGATTCharacteristic> | ||
} | ||
|
||
declare interface BluetoothRemoteGATTServer { | ||
device: BluetoothDevice | ||
connected: boolean | ||
connect(): Promise<BluetoothRemoteGATTService> | ||
disconnect(): void | ||
getPrimaryService(serviceUUID: string): Promise<BluetoothRemoteGATTService> | ||
} | ||
|
||
declare interface BluetoothDevice { | ||
id: string | ||
name?: string | ||
gatt?: any | ||
watchingAdvertisements: boolean | ||
watchAdvertisements(): Promise<void> | ||
unwatchAdvertisements(): void | ||
addEventListener(eventName: string, event: EventListener): void | ||
removeEventListener(event: EventListener) | ||
} | ||
|
||
declare global { | ||
namespace liff { | ||
function init( | ||
initSuccessCallback: LiffInitSuccessCallback, | ||
errorCallback: LiffInitErrorCallback, | ||
): void; | ||
|
||
function openWindow(params: { | ||
url: string, | ||
external?: boolean | ||
}): void; | ||
|
||
function getAccessToken(): string; | ||
|
||
function getProfile(): Promise<LINE.Profile>; | ||
|
||
function sendMessages(messages: LINE.Message[]): Promise<void>; | ||
|
||
function closeWindow(): void; | ||
|
||
function initPlugins(plugins: LIFFPlugins[]): Promise<void>; | ||
|
||
const bluetooth: { | ||
getAvailability(): Promise<boolean> | ||
requestDevice(options?: LIFFRequestDeviceOptions): Promise<BluetoothDevice> | ||
} | ||
} | ||
} |
Oops, something went wrong.