Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include external polyfills in shim (#184)
* Create shims for IO, Resize, WebAnimations, pointer events and fetch * Add runtime has checks for IO, Resize and pointer events * Use shim implementation in framework * Only run tests the leverage dom shims in browser * Tweaks and units * fix functional tests * fix has logic for pointer events * fix tests
- Loading branch information
Showing
17 changed files
with
299 additions
and
169 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,5 @@ | ||
import global from './global'; | ||
`!has('build-elide')`; | ||
import 'intersection-observer'; | ||
|
||
export default global.IntersectionObserver as typeof IntersectionObserver; |
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,12 @@ | ||
import global from './global'; | ||
import has from '../../src/has/has'; | ||
`!has('build-elide')`; | ||
import ResizeObserver from 'resize-observer-polyfill'; | ||
|
||
if (!has('build-elide')) { | ||
if (!global.ResizeObserver) { | ||
global.ResizeObserver = ResizeObserver; | ||
} | ||
} | ||
|
||
export default global.ResizeObserver as typeof ResizeObserver; |
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,120 @@ | ||
import global from './global'; | ||
`!has('build-elide')`; | ||
import 'web-animations-js/web-animations-next-lite.min'; | ||
|
||
export type AnimationEffectTimingFillMode = 'none' | 'forwards' | 'backwards' | 'both' | 'auto'; | ||
export type AnimationEffectTimingPlaybackDirection = 'normal' | 'reverse' | 'alternate' | 'alternate-reverse'; | ||
export type AnimationPlayState = 'idle' | 'running' | 'paused' | 'finished'; | ||
|
||
export interface AnimationPlaybackEvent { | ||
target: Animation; | ||
readonly currentTime: number | null; | ||
readonly timelineTime: number | null; | ||
type: string; | ||
bubbles: boolean; | ||
cancelable: boolean; | ||
currentTarget: Animation; | ||
defaultPrevented: boolean; | ||
eventPhase: number; | ||
timeStamp: number; | ||
} | ||
|
||
export interface AnimationPlaybackEventInit extends EventInit { | ||
currentTime?: number | null; | ||
timelineTime?: number | null; | ||
} | ||
|
||
declare var AnimationPlaybackEvent: { | ||
prototype: AnimationPlaybackEvent; | ||
new (type: string, eventInitDict?: AnimationPlaybackEventInit): AnimationPlaybackEvent; | ||
}; | ||
|
||
export interface AnimationKeyFrame { | ||
easing?: string | string[]; | ||
offset?: number | Array<number | null> | null; | ||
opacity?: number | number[]; | ||
transform?: string | string[]; | ||
} | ||
|
||
export interface AnimationTimeline { | ||
readonly currentTime: number | null; | ||
getAnimations(): Animation[]; | ||
play(effect: KeyframeEffect): Animation; | ||
} | ||
|
||
export interface AnimationEffectTiming { | ||
delay?: number; | ||
direction?: AnimationEffectTimingPlaybackDirection; | ||
duration?: number; | ||
easing?: string; | ||
endDelay?: number; | ||
fill?: AnimationEffectTimingFillMode; | ||
iterationStart?: number; | ||
iterations?: number; | ||
playbackRate?: number; | ||
} | ||
|
||
export interface AnimationEffectReadOnly { | ||
readonly timing: number; | ||
getComputedTiming(): ComputedTimingProperties; | ||
} | ||
|
||
export interface ComputedTimingProperties { | ||
endTime: number; | ||
activeDuration: number; | ||
localTime: number | null; | ||
progress: number | null; | ||
currentIteration: number | null; | ||
} | ||
|
||
export interface KeyframeEffect extends AnimationEffectReadOnly { | ||
activeDuration: number; | ||
onsample: (timeFraction: number | null, effect: KeyframeEffect, animation: Animation) => void | undefined; | ||
parent: KeyframeEffect | null; | ||
target: HTMLElement; | ||
timing: number; | ||
getComputedTiming(): ComputedTimingProperties; | ||
getFrames(): AnimationKeyFrame[]; | ||
remove(): void; | ||
} | ||
|
||
export interface KeyframeEffectConstructor { | ||
prototype: KeyframeEffect; | ||
new ( | ||
target: HTMLElement, | ||
effect: AnimationKeyFrame | AnimationKeyFrame[], | ||
timing: number | AnimationEffectTiming, | ||
id?: string | ||
): KeyframeEffect; | ||
} | ||
|
||
export type AnimationEventListener = (this: Animation, evt: AnimationPlaybackEvent) => any; | ||
|
||
export interface Animation extends EventTarget { | ||
currentTime: number | null; | ||
id: string; | ||
oncancel: AnimationEventListener; | ||
onfinish: AnimationEventListener; | ||
readonly playState: AnimationPlayState; | ||
playbackRate: number; | ||
startTime: number; | ||
cancel(): void; | ||
finish(): void; | ||
pause(): void; | ||
play(): void; | ||
reverse(): void; | ||
addEventListener(type: 'finish' | 'cancel', handler: EventListener): void; | ||
removeEventListener(type: 'finish' | 'cancel', handler: EventListener): void; | ||
effect: AnimationEffectReadOnly; | ||
readonly finished: Promise<Animation>; | ||
readonly ready: Promise<Animation>; | ||
timeline: AnimationTimeline; | ||
} | ||
|
||
export interface AnimationConstructor { | ||
prototype: Animation; | ||
new (effect?: AnimationEffectReadOnly, timeline?: AnimationTimeline): Animation; | ||
} | ||
|
||
export const Animation = global.Animation as AnimationConstructor; | ||
export const KeyframeEffect = global.KeyframeEffect as KeyframeEffectConstructor; |
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,5 @@ | ||
import global from './global'; | ||
`!has('fetch')`; | ||
import 'whatwg-fetch'; | ||
|
||
export default global.fetch as (input: RequestInfo, init?: RequestInit) => Promise<Response>; |
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,2 @@ | ||
`!has('build-elide')`; | ||
import 'pepjs'; |
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
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
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
Oops, something went wrong.