Skip to content

Commit 955c5fa

Browse files
committed
May 2022 Release of the APL 2022.1 compliant APL Viewhost Web
For more details on this release refer to CHANGELOG.md To learn about APL see: https://developer.amazon.com/docs/alexa-presentation-language/understand-apl.html
1 parent 20ad8fe commit 955c5fa

30 files changed

+365
-134
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Changelog for apl-viewhost-web
22

3+
## [2022.1]
4+
5+
This release adds support for version 2022.1 of the APL specification. Please also see APL Core Library for changes: [apl-core-library CHANGELOG](https://github.com/alexa/apl-core-library/blob/master/CHANGELOG.md)
6+
7+
### Added
8+
9+
- Added muted property to video component
10+
- Exposed scrollCommandDuration
11+
12+
### Changed
13+
14+
- Improved support for HLS video
15+
- Scale factor can be specified independently per renderer
16+
- Changed clipping behaviour for documents using APL <= 1.5 for backwards compatibility
17+
- Bug fixes
18+
319
## [1.9.0]
420

521
This release adds support for version 1.9 of the APL specification. Please also see APL Core Library for changes: [apl-core-library CHANGELOG](https://github.com/alexa/apl-core-library/blob/master/CHANGELOG.md)

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ option(WEBSOCKET "Build Websocket Server" OFF)
1212
option(EMSCRIPTEN_SOURCEMAPS "Builds source maps." OFF)
1313
option(WASM_PROFILING "WASM profiling mode." OFF)
1414

15+
if(WASM)
16+
# make sure we enable exception support when building APL core, since PEGTL
17+
# relies on it
18+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
19+
endif()
20+
1521
if(${APL_CORE_PATH} STREQUAL "OFF")
1622
set(APL_CORE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../APLCoreEngine)
1723
endif()

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Alexa Presentation Language (APL) Viewhost Web
22

33
<p>
4-
<a href="https://github.com/alexa/apl-viewhost-web/tree/v1.9.0" alt="version">
5-
<img src="https://img.shields.io/badge/stable%20version-1.9.0-brightgreen" /></a>
6-
<a href="https://github.com/alexa/apl-core-library/tree/v1.9.1" alt="APLCore">
7-
<img src="https://img.shields.io/badge/apl%20core%20library-1.9.1-navy" /></a>
4+
<a href="https://github.com/alexa/apl-viewhost-web/tree/v2022.1" alt="version">
5+
<img src="https://img.shields.io/badge/stable%20version-2022.1-brightgreen" /></a>
6+
<a href="https://github.com/alexa/apl-core-library/tree/v2022.1" alt="APLCore">
7+
<img src="https://img.shields.io/badge/apl%20core%20library-2022.1-navy" /></a>
88
</p>
99

1010
## Introduction

js/apl-html/lib/dts/Context.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ declare namespace APL {
4444

4545
public setBackground(background: APL.IBackground): void;
4646

47-
public getDataSourceContext(): string;
47+
public getDataSourceContext(): Promise<string>;
4848

49-
public getVisualContext(): string;
49+
public getVisualContext(): Promise<string>;
5050

5151
public clearPending(): void;
5252

js/apl-html/src/APLRenderer.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { IExtensionManager } from './extensions/IExtensionManager';
2323
import { ILogger } from './logging/ILogger';
2424
import { LoggerFactory } from './logging/LoggerFactory';
2525
import { AudioPlayerFactory } from './media/audio/AudioPlayer';
26+
import { createAplVersionUtils } from './utils/AplVersionUtils';
2627
import { browserIsEdge } from './utils/BrowserUtils';
2728
import { ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, ARROW_UP, ENTER_KEY, HttpStatusCodes } from './utils/Constant';
2829
import { isDisplayState } from './utils/DisplayStateUtils';
@@ -31,6 +32,8 @@ import { fetchMediaResource } from './utils/MediaRequestUtils';
3132

3233
const agentName = 'AplWebRenderer';
3334
const agentVersion = '1.0.0';
35+
const MAX_LEGACY_CLIPPING_APL_VERSION = '1.5';
36+
3437
// For touch enabled browser, touch event will be followed by a mouse event after 300ms-500ms up to browser.
3538
// This will cause issue which triggers click or press events twice.
3639
// setup a 500ms gap between two events.
@@ -301,6 +304,12 @@ export default abstract class APLRenderer<Options = any> {
301304
*/
302305
public abstract getLegacyKaraoke(): boolean;
303306

307+
/**
308+
* @internal
309+
* @ignore
310+
*/
311+
protected abstract getDocumentAplVersion(): string;
312+
304313
/** A reference to the APL root context */
305314
public context: APL.Context;
306315

@@ -910,6 +919,19 @@ export default abstract class APLRenderer<Options = any> {
910919
}
911920
}
912921

922+
/**
923+
* @internal
924+
* @ignore
925+
*/
926+
public getLegacyClippingEnabled(): boolean {
927+
const aplVersionUtils = createAplVersionUtils();
928+
929+
const documentAplVersion: number = aplVersionUtils.getVersionCode(this.getDocumentAplVersion());
930+
const legacyClippingAplVersion: number = aplVersionUtils.getVersionCode(MAX_LEGACY_CLIPPING_APL_VERSION);
931+
932+
return documentAplVersion <= legacyClippingAplVersion;
933+
}
934+
913935
/**
914936
* @internal
915937
* @ignore

js/apl-html/src/components/Component.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {applyAplRectToStyle, applyPaddingToStyle} from './helpers/StylesUtil';
2929
*/
3030
const COMPONENT_TYPE_MAP = {
3131
[ComponentType.kComponentTypeContainer]: 'Container',
32+
[ComponentType.kComponentTypeEditText]: 'EditText',
3233
[ComponentType.kComponentTypeFrame]: 'Frame',
3334
[ComponentType.kComponentTypeImage]: 'Image',
3435
[ComponentType.kComponentTypePager]: 'Pager',
@@ -46,6 +47,22 @@ const SUPPORTED_LAYOUT_DIRECTIONS = {
4647
[LayoutDirection.kLayoutDirectionRTL]: 'rtl'
4748
};
4849

50+
const LEGACY_CLIPPING_COMPONENTS_SET = new Set([
51+
ComponentType.kComponentTypeFrame,
52+
ComponentType.kComponentTypePager,
53+
ComponentType.kComponentTypeScrollView,
54+
ComponentType.kComponentTypeSequence,
55+
ComponentType.kComponentTypeGridSequence
56+
]);
57+
58+
const NO_CLIPPING_COMPONENTS_SET = new Set([
59+
ComponentType.kComponentTypeEditText,
60+
ComponentType.kComponentTypeImage,
61+
ComponentType.kComponentTypeText,
62+
ComponentType.kComponentTypeTouchWrapper,
63+
ComponentType.kComponentTypeVideo
64+
]);
65+
4966
export const SVG_NS = 'http://www.w3.org/2000/svg';
5067
export const uuidv4 = require('uuid/v4');
5168
export const IDENTITY_TRANSFORM = 'matrix(1.000000,0.000000,0.000000,1.000000,0.000000,0.000000)';
@@ -151,6 +168,7 @@ export abstract class Component<PropsType = IGenericPropType> extends EventEmitt
151168
'-moz-box-sizing': 'border-box',
152169
'box-sizing': 'border-box'
153170
});
171+
this.checkComponentTypeAndEnableClipping();
154172
this.id = component.getUniqueId();
155173
this.$container.attr('id', this.id);
156174

@@ -415,6 +433,9 @@ export abstract class Component<PropsType = IGenericPropType> extends EventEmitt
415433
* Resizes child component to fit parent component when applicable
416434
*/
417435
private sizeToFit(): void {
436+
if (this.renderer && this.renderer.getLegacyClippingEnabled()) {
437+
return;
438+
}
418439
// adjust bounds
419440
const componentHasBounds = !!this.bounds;
420441
const componentHasParent = !!this.parent;
@@ -702,4 +723,33 @@ export abstract class Component<PropsType = IGenericPropType> extends EventEmitt
702723
}
703724
return '';
704725
}
726+
727+
/**
728+
* Enable clipping if version is <= 1.5 or if component is part the legacy-clipping set.
729+
* Never enable clipping for if component is part of the no-clipping set.
730+
*
731+
*/
732+
private checkComponentTypeAndEnableClipping() {
733+
const componentType = this.component.getType();
734+
735+
// Don't clip for these components
736+
if (NO_CLIPPING_COMPONENTS_SET.has(componentType)) {
737+
return;
738+
}
739+
740+
const isParentLegacy = this.parent && LEGACY_CLIPPING_COMPONENTS_SET.has(this.parent.component.getType());
741+
const isLegacyComponentType: boolean = LEGACY_CLIPPING_COMPONENTS_SET.has(componentType);
742+
const isLegacyAplVersion: boolean = this.renderer && this.renderer.getLegacyClippingEnabled();
743+
744+
if (isLegacyComponentType || isParentLegacy || !isLegacyAplVersion) {
745+
this.enableClipping();
746+
}
747+
}
748+
749+
/**
750+
* Enable clipping
751+
*/
752+
protected enableClipping() {
753+
this.$container.css('overflow', 'hidden');
754+
}
705755
}

js/apl-html/src/components/Container.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ import { Component, FactoryFunction } from './Component';
1212
export class Container extends Component {
1313
constructor(renderer: APLRenderer, component: APL.Component, factory: FactoryFunction, parent?: Component) {
1414
super(renderer, component, factory, parent);
15-
16-
this.$container.css({
17-
overflow: 'hidden'
18-
});
1915
}
2016

2117
protected isLayout(): boolean {

js/apl-html/src/components/Frame.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ export class Frame extends Component<IFrameProperties> {
2525
constructor(renderer: APLRenderer, component: APL.Component, factory: FactoryFunction, parent?: Component) {
2626
super(renderer, component, factory, parent);
2727
this.$container.css({
28-
'border-style': 'solid',
29-
'overflow': 'hidden'
28+
'border-style': 'solid'
3029
});
3130
this.propExecutor
3231
(this.setBackgroundColor, PropertyKey.kPropertyBackgroundColor)

js/apl-html/src/components/MultiChildScrollable.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export abstract class MultiChildScrollable extends Scrollable<IMultiChildScrolla
3636

3737
public init() {
3838
super.init();
39-
this.$container.css('overflow', 'hidden');
4039
}
4140

4241
protected allowFocus(requestedDistance: number, moveTo: HTMLDivElement) {

js/apl-html/src/components/ScrollView.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export class ScrollView extends Scrollable<IScrollViewProperties> {
2828

2929
public init() {
3030
super.init();
31-
this.$container.css('overflow', 'hidden');
3231
}
3332

3433
/**

0 commit comments

Comments
 (0)