This commit is contained in:
2022-07-21 03:28:35 +00:00
parent d7c883d6df
commit 51b34b0e1d
30103 changed files with 4152204 additions and 23 deletions
+9
View File
@@ -0,0 +1,9 @@
import { ClientCallback } from './types';
export declare const callbacks: {};
/**
* Add callback to LIFFEvent listener.
* @export
* @param {string} type
* @param {ClientCallback} callback
*/
export default function addListener(type: string, callback: ClientCallback): void;
+19
View File
@@ -0,0 +1,19 @@
/**
* call()
* Let js pass event and data to client
* and wait for callback
* @export
* @param {string} type - name of event
* @param {*} [params={}] - data object to pass to client
* @param {{ - options
* callbackId?: string - use randomly string by default, use `''` if client needs
* once?: boolean - will remove listener once callback is fired if is true
* }} [options={
* once: true,
* }]
* @returns {Promise<any>}
*/
export default function call(type: string, params?: any, options?: {
callbackId?: string;
once?: boolean;
}): Promise<any>;
+2
View File
@@ -0,0 +1,2 @@
import './customEventPolyFill';
export default function createEvent<T>(detail: T): CustomEvent;
@@ -0,0 +1,3 @@
/**
* https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#Polyfill
*/
+6
View File
@@ -0,0 +1,6 @@
/**
* Wrap window.dispatchEvent
* Expose `window.liff._dispatchEvent()` for client to interact with js
* @param {string} json
*/
export default function dispatch(json: string): void;
+6
View File
@@ -0,0 +1,6 @@
export { default as createEvent } from './createEvent';
export { default as addListener } from './addListener';
export { default as removeListener } from './removeListener';
export { default as dispatch } from './dispatch';
export { default as postMessage } from './postMessage';
export { default as call } from './call';
+8
View File
@@ -0,0 +1,8 @@
/**
* Wrapper of window._liff.postMessage
* @export
* @param {string} type - name of message to client
* @param {{}} [params={}] - object data sent to client
* @param {string} [callbackId=''] - callbackId to identify client callback
*/
export default function postMessage(type: string, params?: {}, callbackId?: string): void;
+7
View File
@@ -0,0 +1,7 @@
import { ClientCallback } from './types';
/**
* Remove callback from LIFFEvent listener.
* @param {string} type [description]
* @param {Function} callback [description]
*/
export default function removeListener(type: string, callback: ClientCallback): void;
+1
View File
@@ -0,0 +1 @@
export declare type ClientCallback = (e: CustomEvent) => void;