diff --git a/types/redux-state-sync/index.d.ts b/types/redux-state-sync/index.d.ts new file mode 100644 index 0000000000..e71097df17 --- /dev/null +++ b/types/redux-state-sync/index.d.ts @@ -0,0 +1,58 @@ +// Type definitions for redux-state-sync 2.0 +// Project: https://github.com/AOHUA/redux-state-sync#readme +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export as namespace ReduxStateSync; + +import { Store, Reducer, Middleware, Action, AnyAction } from "redux" +import BroadcastChannel from "broadcast-channel" + +export let lastUuid: number; +export const GET_INIT_STATE: string; +export const SEND_INIT_STATE: string; +export const RECEIVE_INIT_STATE: string; + +type Stamp = { + $uuid: string + $wuid: string +} +export type StampedAction = Stamp & AnyAction + +export interface Config { + channel?: string + predicate?: Function | null + blacklist?: Array + whitelist?: Array + broadcastChannelOption?: object | null +} + +export interface MessageListenerConfig { + channel: BroadcastChannel + dispatch: (action: AnyAction | StampedAction) => void + allowed: (type?: string) => boolean +} + +export const defaultConfig: Config; +export const WINDOW_STATE_SYNC_ID: string; +export let isMessageListenerCreated: boolean; + +export function myMethod(a: string): string; +export function myOtherMethod(a: number): number; + +export function getIniteState(): AnyAction; +export function sendIniteState(): AnyAction; +export function receiveIniteState(store: Store): AnyAction; +export function s4(): string; +export function guid(): string; + +export function generateUuidForAction(action: AnyAction): StampedAction +export function isActionAllowed (config: Config): (type?: any) => boolean +export function createMessageListener (config: MessageListenerConfig): void +export function createStateSyncMiddleware (config?: Config): Middleware +export function withReduxStateSync ( + appReducer: Reducer +): (state: any, action: AnyAction) => Reducer +export function initStateWithPrevTab ( + store: Store +): Store \ No newline at end of file diff --git a/types/redux-state-sync/redux-state-sync-tests.ts b/types/redux-state-sync/redux-state-sync-tests.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/types/redux-state-sync/tsconfig.json b/types/redux-state-sync/tsconfig.json new file mode 100644 index 0000000000..e3c2cd0f00 --- /dev/null +++ b/types/redux-state-sync/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "redux-state-sync-tests.ts" + ] +} diff --git a/types/redux-state-sync/tslint.json b/types/redux-state-sync/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/redux-state-sync/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }