Skip to content
This repository has been archived by the owner on Jul 4, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1 from S-O-L-A-R/reiiyuki/liff-type
Browse files Browse the repository at this point in the history
Reiiyuki/liff type
  • Loading branch information
ReiiYuki committed Sep 9, 2019
2 parents 7c1523c + 0c29e93 commit 9a371e0
Show file tree
Hide file tree
Showing 4 changed files with 2,149 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
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()
```
94 changes: 94 additions & 0 deletions index.d.ts
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>
}
}
}
Loading

0 comments on commit 9a371e0

Please sign in to comment.