-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
February 2023 Release of the APL 2023.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
- Loading branch information
1 parent
160ee98
commit 395ca65
Showing
34 changed files
with
989 additions
and
210 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
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,83 @@ | ||
/*! | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import APLRenderer from './APLRenderer'; | ||
import { EventType } from './enums/EventType'; | ||
import { DataSourceFetchRequest } from './events/DataSourceFetchRequest'; | ||
import { ExtensionEvent } from './events/ExtensionEvent'; | ||
import { Finish } from './events/Finish'; | ||
import { Focus } from './events/Focus'; | ||
import { LineHighlight } from './events/LineHighlight'; | ||
import { MediaRequest } from './events/MediaRequest'; | ||
import { OpenUrl } from './events/OpenUrl'; | ||
import { ReInflate} from './events/ReInflate'; | ||
import { RequestLineBounds } from './events/RequestLineBounds'; | ||
import { SendEvent } from './events/SendEvent'; | ||
|
||
/** | ||
* Creates and executes a command | ||
* @param event The core engine event | ||
* @param renderer A reference to the renderer instance | ||
* @internal | ||
*/ | ||
export const commandFactory = (event: APL.Event, renderer: APLRenderer) => { | ||
if (factoryMap[event.getType()]) { | ||
return factoryMap[event.getType()](event, renderer); | ||
} | ||
throw new Error(`Cannot create command with type ${event.getType()}`); | ||
}; | ||
|
||
const factoryMap = { | ||
[EventType.kEventTypeSendEvent]: (event: APL.Event, renderer: APLRenderer) => { | ||
const command = new SendEvent(event, renderer); | ||
command.execute(); | ||
return command; | ||
}, | ||
[EventType.kEventTypeRequestLineBounds]: (event: APL.Event, renderer: APLRenderer) => { | ||
const command = new RequestLineBounds(event, renderer); | ||
command.execute(); | ||
return command; | ||
}, | ||
[EventType.kEventTypeLineHighlight]: (event: APL.Event, renderer: APLRenderer) => { | ||
const command = new LineHighlight(event, renderer); | ||
command.execute(); | ||
return command; | ||
}, | ||
[EventType.kEventTypeReinflate]: (event: APL.Event, renderer: APLRenderer) => { | ||
const command = new ReInflate(event, renderer); | ||
command.execute(); | ||
return command; | ||
}, | ||
[EventType.kEventTypeFinish]: (event: APL.Event, renderer: APLRenderer) => { | ||
const command = new Finish(event, renderer); | ||
command.execute(); | ||
return command; | ||
}, | ||
[EventType.kEventTypeFocus]: (event: APL.Event, renderer: APLRenderer) => { | ||
const command = new Focus(event, renderer); | ||
command.execute(); | ||
return command; | ||
}, | ||
[EventType.kEventTypeOpenURL]: (event: APL.Event, renderer: APLRenderer) => { | ||
const command = new OpenUrl(event, renderer); | ||
command.execute(); | ||
return command; | ||
}, | ||
[EventType.kEventTypeDataSourceFetchRequest]: (event: APL.Event, renderer: APLRenderer) => { | ||
const command = new DataSourceFetchRequest(event, renderer); | ||
command.execute(); | ||
return command; | ||
}, | ||
[EventType.kEventTypeExtension]: (event: APL.Event, renderer: APLRenderer) => { | ||
const command = new ExtensionEvent(event, renderer); | ||
command.execute(); | ||
return command; | ||
}, | ||
[EventType.kEventTypeMediaRequest]: (event: APL.Event, renderer: APLRenderer) => { | ||
const command = new MediaRequest(event, renderer); | ||
command.execute(); | ||
return command; | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
'use strict'; | ||
|
||
import { Filter, generateSVGFeImage, isIndexOutOfBound } from '../../utils/FilterUtils'; | ||
import { SVG_NS, uuidv4 } from '../Component'; | ||
import { BITMAP_IMAGE_REGEX_CHECK, IBaseFilter, IImageFilterElement } from './ImageFilter'; | ||
|
||
/** | ||
* @ignore | ||
*/ | ||
export interface IBlur extends IBaseFilter { | ||
radius: number; | ||
source: number; | ||
} | ||
|
||
/* | ||
* Apply a Gaussian blur with a specified radius. The new image is appended to the end of the array. | ||
* Specs: https://developer.amazon.com/en-US/docs/alexa/alexa-presentation-language/apl-filters.html#blur | ||
* Utilize svg <feGaussianBlur> filter | ||
* https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feGaussianBlur | ||
*/ | ||
export function getBlurFilter(filter: Filter, imageSrcArray: string[]): IImageFilterElement | undefined { | ||
const blurId: string = uuidv4().toString(); | ||
let filterImageArray: SVGFEImageElement[] = []; | ||
const blur: SVGElement = document.createElementNS(SVG_NS, 'feGaussianBlur'); | ||
blur.setAttributeNS('', 'stdDeviation', (filter as IBlur).radius.toString()); | ||
blur.setAttributeNS('', 'result', blurId); | ||
/* | ||
* All filters that operate on a single image have a default image source property of -1; | ||
* that is, by default they take as input the last image in the image array. | ||
*/ | ||
let index: number = (filter as IBlur).source; | ||
|
||
// Negative case : index outside source array bounds. return undefined | ||
if (isIndexOutOfBound(index, imageSrcArray.length)) { | ||
return undefined; | ||
} | ||
if (index < 0) { | ||
index += imageSrcArray.length; | ||
} | ||
const imageId: string = imageSrcArray[index]; | ||
if (imageId.match(BITMAP_IMAGE_REGEX_CHECK)) { | ||
filterImageArray = generateSVGFeImage(imageId, blur); | ||
} else { | ||
blur.setAttributeNS('', 'in', imageId); | ||
} | ||
return { filterId: blurId, filterElement: blur, filterImageArray }; | ||
} |
Oops, something went wrong.