-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: bundle NetworkInformation properly
- Loading branch information
Showing
6 changed files
with
97 additions
and
17 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,10 +1,3 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
|
||
// TODO: Remove when `network-information-types` become obsolete | ||
transformIgnorePatterns: ['/node_modules/(!network-information-types/)'], | ||
moduleNameMapper: { | ||
'network-information-types': | ||
'network-information-types/dist-types/index.d.ts', | ||
}, | ||
}; |
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
42 changes: 42 additions & 0 deletions
42
packages/web-api-hooks/src/experimental-types/NetworkInformation.bundled.ts
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,42 @@ | ||
// Source: https://github.com/lacolaco/network-information-types/blob/master/index.d.ts | ||
|
||
// W3C Spec Draft http://wicg.github.io/netinfo/ | ||
// Edition: Draft Community Group Report 20 February 2019 | ||
|
||
// http://wicg.github.io/netinfo/#connection-types | ||
type ConnectionType = | ||
| 'bluetooth' | ||
| 'cellular' | ||
| 'ethernet' | ||
| 'mixed' | ||
| 'none' | ||
| 'other' | ||
| 'unknown' | ||
| 'wifi' | ||
| 'wimax'; | ||
|
||
// http://wicg.github.io/netinfo/#effectiveconnectiontype-enum | ||
type EffectiveConnectionType = '2g' | '3g' | '4g' | 'slow-2g'; | ||
|
||
// http://wicg.github.io/netinfo/#dom-megabit | ||
type Megabit = number; | ||
// http://wicg.github.io/netinfo/#dom-millisecond | ||
type Millisecond = number; | ||
|
||
// http://wicg.github.io/netinfo/#networkinformation-interface | ||
export interface NetworkInformation extends EventTarget { | ||
// http://wicg.github.io/netinfo/#type-attribute | ||
readonly type?: ConnectionType; | ||
// http://wicg.github.io/netinfo/#effectivetype-attribute | ||
readonly effectiveType?: EffectiveConnectionType; | ||
// http://wicg.github.io/netinfo/#downlinkmax-attribute | ||
readonly downlinkMax?: Megabit; | ||
// http://wicg.github.io/netinfo/#downlink-attribute | ||
readonly downlink?: Megabit; | ||
// http://wicg.github.io/netinfo/#rtt-attribute | ||
readonly rtt?: Millisecond; | ||
// http://wicg.github.io/netinfo/#savedata-attribute | ||
readonly saveData?: boolean; | ||
// http://wicg.github.io/netinfo/#handling-changes-to-the-underlying-connection | ||
onchange?: EventListener; | ||
} |
53 changes: 53 additions & 0 deletions
53
packages/web-api-hooks/src/experimental-types/NetworkInformation.d.ts
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,53 @@ | ||
// Source: https://github.com/lacolaco/network-information-types/blob/master/index.d.ts | ||
|
||
// W3C Spec Draft http://wicg.github.io/netinfo/ | ||
// Edition: Draft Community Group Report 20 February 2019 | ||
|
||
// http://wicg.github.io/netinfo/#connection-types | ||
type ConnectionType = | ||
| 'bluetooth' | ||
| 'cellular' | ||
| 'ethernet' | ||
| 'mixed' | ||
| 'none' | ||
| 'other' | ||
| 'unknown' | ||
| 'wifi' | ||
| 'wimax'; | ||
|
||
// http://wicg.github.io/netinfo/#effectiveconnectiontype-enum | ||
type EffectiveConnectionType = '2g' | '3g' | '4g' | 'slow-2g'; | ||
|
||
// http://wicg.github.io/netinfo/#dom-megabit | ||
type Megabit = number; | ||
// http://wicg.github.io/netinfo/#dom-millisecond | ||
type Millisecond = number; | ||
|
||
// http://wicg.github.io/netinfo/#networkinformation-interface | ||
interface NetworkInformation extends EventTarget { | ||
// http://wicg.github.io/netinfo/#type-attribute | ||
readonly type?: ConnectionType; | ||
// http://wicg.github.io/netinfo/#effectivetype-attribute | ||
readonly effectiveType?: EffectiveConnectionType; | ||
// http://wicg.github.io/netinfo/#downlinkmax-attribute | ||
readonly downlinkMax?: Megabit; | ||
// http://wicg.github.io/netinfo/#downlink-attribute | ||
readonly downlink?: Megabit; | ||
// http://wicg.github.io/netinfo/#rtt-attribute | ||
readonly rtt?: Millisecond; | ||
// http://wicg.github.io/netinfo/#savedata-attribute | ||
readonly saveData?: boolean; | ||
// http://wicg.github.io/netinfo/#handling-changes-to-the-underlying-connection | ||
onchange?: EventListener; | ||
} | ||
|
||
// http://wicg.github.io/netinfo/#navigatornetworkinformation-interface | ||
/* eslint-disable @typescript-eslint/no-empty-interface */ | ||
declare interface Navigator extends NavigatorNetworkInformation {} | ||
declare interface WorkerNavigator extends NavigatorNetworkInformation {} | ||
/* eslint-enable @typescript-eslint/no-empty-interface */ | ||
|
||
// http://wicg.github.io/netinfo/#navigatornetworkinformation-interface | ||
declare interface NavigatorNetworkInformation { | ||
readonly connection?: NetworkInformation; | ||
} |
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
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