diff --git a/hardware-concurrency/index.d.ts b/hardware-concurrency/index.d.ts new file mode 100644 index 0000000..c5d2587 --- /dev/null +++ b/hardware-concurrency/index.d.ts @@ -0,0 +1 @@ +export function useHardwareConcurrency(): { unsupported: true } | { unsupported: false, numberOfLogicalProcessors: number } diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..dedf30a --- /dev/null +++ b/index.d.ts @@ -0,0 +1,4 @@ +export * from './hardware-concurrency' +export * from './memory' +export * from './network' +export * from './save-data' diff --git a/memory/index.d.ts b/memory/index.d.ts new file mode 100644 index 0000000..0c947e8 --- /dev/null +++ b/memory/index.d.ts @@ -0,0 +1,10 @@ +export interface MemoryStatus { + deviceMemory: number, + totalJSHeapSize: number | null, + usedJSHeapSize: number | null, + jsHeapSizeLimit: number | null +} + +export function useMemoryStatus(initialMemoryStatus?: MemoryStatus): { unsupported: true } & Partial | { + unsupported: false, +} & MemoryStatus diff --git a/network/index.d.ts b/network/index.d.ts new file mode 100644 index 0000000..bafa128 --- /dev/null +++ b/network/index.d.ts @@ -0,0 +1,6 @@ +export type EffectiveConnectionType = 'slow-2g' | '2g' | '3g' | '4g' + +export function useNetworkStatus(initialEffectiveConnectionType?: EffectiveConnectionType | null): { + unsupported: boolean, + effectiveConnectionType: EffectiveConnectionType | null +} diff --git a/package.json b/package.json index 895ae56..e422baf 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,9 @@ "main": "dist/index.js", "module": "dist/index.module.js", "unpkg": "dist/index.umd.js", + "typings": "index.d.ts", "source": "index.js", + "typings": "index.d.ts", "scripts": { "build": "microbundle", "dev": "microbundle watch", @@ -35,4 +37,4 @@ "react", "performance" ] -} \ No newline at end of file +} diff --git a/save-data/index.d.ts b/save-data/index.d.ts new file mode 100644 index 0000000..9b6eb18 --- /dev/null +++ b/save-data/index.d.ts @@ -0,0 +1 @@ +export function useSaveData(initialSaveDataStatus?: boolean | null): { unsupported: boolean, saveData: boolean | null }