Skip to content

Commit

Permalink
fix(core): performance improvements to applying state changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mihar-22 committed Aug 17, 2020
1 parent af62e25 commit e3e121b
Show file tree
Hide file tree
Showing 41 changed files with 563 additions and 543 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ jobs:
run: curl -L https://raw.githubusercontent.com/pnpm/self-installer/master/install.js | node
- name: Install dependencies
run: pnpm install
- name: Lint
run: npm run lint
- name: Test
run: pnpm run test:ci --filter @vime/core
- name: Coverage
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"pnpm": ">=5"
},
"scripts": {
"lint": "eslint packages/*/src/**/*.{ts,tsx} packages/*/cypress/**/*.{js,ts} --fix --ignore-path .gitignore",
"lint": "eslint packages/*/src/**/*.{ts,tsx} packages/*/cypress/**/*.{js,ts} --quiet --fix --ignore-path .gitignore",
"script:size": "node scripts/core-dist-size.js"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"cy:run.providers": "cypress run --spec \"cypress/tests/providers/**/*\""
},
"dependencies": {
"stencil-wormhole": "^3.0.1"
"stencil-wormhole": "^3.0.2"
},
"devDependencies": {
"@babel/core": "^7.10.5",
Expand Down
11 changes: 4 additions & 7 deletions packages/core/src/components/core/embed/embed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ export class Embed implements ComponentInterface {
* Emitted when the `embedSrc` or `params` props change. The payload contains the `params`
* serialized into a query string and appended to `embedSrc`.
*/
@Event({ bubbles: false, }) vEmbedSrcChange!: EventEmitter<string>;
@Event({ bubbles: false }) vEmbedSrcChange!: EventEmitter<string>;

/**
* Emitted when a new message is received from the embedded player via `postMessage`.
*/
@Event({ bubbles: false, }) vEmbedMessage!: EventEmitter<any>;
@Event({ bubbles: false }) vEmbedMessage!: EventEmitter<any>;

/**
* Emitted when the embedded player and any new media has loaded.
*/
@Event({ bubbles: false, }) vEmbedLoaded!: EventEmitter<void>;
@Event({ bubbles: false }) vEmbedLoaded!: EventEmitter<void>;

@Watch('preconnections')
preconnectionsChange() {
Expand All @@ -107,11 +107,8 @@ export class Embed implements ComponentInterface {
});
}

connectedCallback() {
this.srcChange();
}

componentWillLoad() {
this.srcChange();
this.genIframeId();
}

Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/components/core/player/Autopause.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { MediaPlayer } from './MediaPlayer';

let players: MediaPlayer[] = [];
let players: HTMLVimePlayerElement[] = [];

export class Autopause {
constructor(private readonly player: MediaPlayer) {
constructor(private readonly player: HTMLVimePlayerElement) {
players.push(player);
}

Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/components/core/player/PlayerEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const isToggleStateEvent = new Set([

// Events that are emitted without the 'Change' postfix.
const hasShortenedEventName = new Set([
PlayerProp.Ready,
PlayerProp.PlaybackStarted,
PlayerProp.PlaybackEnded,
PlayerProp.PlaybackReady,
Expand Down Expand Up @@ -46,6 +47,7 @@ export enum PlayerEvent {
BufferingChange = 'vBufferingChange',
DurationChange = 'vDurationChange',
CurrentTimeChange = 'vCurrentTimeChange',
Ready = 'vReady',
PlaybackReady = 'vPlaybackReady',
PlaybackStarted = 'vPlaybackStarted',
PlaybackEnded = 'vPlaybackEnded',
Expand Down Expand Up @@ -116,6 +118,11 @@ export interface PlayerEvents {
*/
[PlayerEvent.CurrentTimeChange]: EventEmitter<PlayerProps[PlayerProp.CurrentTime]>

/**
* Emitted when the player has loaded and is ready to be interacted with.
*/
[PlayerEvent.Ready]: EventEmitter<void>;

/**
* Emitted when the media is ready to begin playback. The following props are guaranteed to be
* defined when this fires: `mediaTitle`, `currentSrc`, `currentPoster`, `duration`, `mediaType`,
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/components/core/player/PlayerMethod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export enum PlayerMethod {
ExitPiP = 'exitPiP',
ExtendLanguage = 'extendLanguage',
CallAdapter = 'callAdapter',
QueueStateChange = 'queueStateChange'
QueueStateChange = 'queueStateChange',
ToggleCaptionsVisibility = 'toggleCaptionsVisiblity',
}

export interface PlayerMethods {
Expand Down Expand Up @@ -119,6 +120,11 @@ export interface PlayerMethods {
*/
[PlayerMethod.ExitPiP](): Promise<void>

/**
* Toggles the visibility of the captions.
*/
[PlayerMethod.ToggleCaptionsVisibility](isVisible?: boolean): Promise<void>

/**
* Extends the translation map for a given language.
*/
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/components/core/player/PlayerProp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export enum PlayerProp {
CurrentTime = 'currentTime',
Seeking = 'seeking',
Debug = 'debug',
Ready = 'ready',
PlaybackStarted = 'playbackStarted',
PlaybackEnded = 'playbackEnded',
PlaybackRate= 'playbackRate',
Expand Down Expand Up @@ -57,6 +58,7 @@ export type InternalReadonlyPlayerProps = Pick<PlayerProps, PlayerProp.Autoplay
| PlayerProp.Controls
| PlayerProp.Debug
| PlayerProp.Loop
| PlayerProp.Ready
| PlayerProp.IsAudio
| PlayerProp.IsVideo
| PlayerProp.IsMobile
Expand Down Expand Up @@ -102,6 +104,7 @@ const internalReadonly = new Set<InternalReadonlyPlayerProp>([
PlayerProp.Autoplay,
PlayerProp.Controls,
PlayerProp.Loop,
PlayerProp.Ready,
PlayerProp.Debug,
PlayerProp.IsAudio,
PlayerProp.IsVideo,
Expand Down Expand Up @@ -208,6 +211,11 @@ export interface PlayerProps {
*/
[PlayerProp.Autoplay]: boolean

/**
* `@readonly` Whether the player has loaded and is ready to be interacted with.
*/
[PlayerProp.Ready]: boolean

/**
* `@readonly` Whether media is ready for playback to begin.
*/
Expand Down
Loading

0 comments on commit e3e121b

Please sign in to comment.