Skip to content

Commit

Permalink
APL-CORE: November 2023 Release of APL 2023.3 compilant core engine (…
Browse files Browse the repository at this point in the history
…2023.3.0)

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
amzn-admfox committed Nov 27, 2023
1 parent e3a15ae commit 6ac06f5
Show file tree
Hide file tree
Showing 238 changed files with 15,149 additions and 2,986 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## [2023.3]

This release adds support for version 2023.3 of the APL specification.

### Added

- Add Log command
- Support conditional imports
- Support gradient as Frame background
- Add duration control for scrolling animations
- Add onChildrenChanged handler to Multichild component
- Add data field expansion for Sequential and Parallel commands
- Alpha feature: Support autosizing of Host component

### Changed

- Bug fixes
- Performance improvements

## [2023.2]

This release adds support for version 2023.2 of the APL specification.
Expand Down
25 changes: 21 additions & 4 deletions aplcore/include/apl/action/arrayaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,38 @@ namespace apl {
class ArrayAction : public Action {
public:
static std::shared_ptr<ArrayAction> make(const TimersPtr& timers,
std::shared_ptr<const ArrayCommand>&& command,
const ContextPtr& context,
std::shared_ptr<const CoreCommand>&& command,
CommandData&& data,
bool fastMode) {
auto ptr = std::make_shared<ArrayAction>(timers, std::move(command), fastMode);
auto ptr = std::make_shared<ArrayAction>(
timers, context, std::move(command), std::move(data), fastMode);
ptr->advance();
return ptr;
}

ArrayAction(const TimersPtr& timers, std::shared_ptr<const ArrayCommand>&& command, bool fastMode);
static std::shared_ptr<ArrayAction> make(const TimersPtr& timers,
std::shared_ptr<const CoreCommand>&& command,
bool fastMode) {
return make(timers, command->context(), std::move(command),
CommandData(command->data()), fastMode);
}

ArrayAction(
const TimersPtr& timers,
const ContextPtr& context,
std::shared_ptr<const CoreCommand>&& command,
CommandData&& data,
bool fastMode);

private:
void advance();

private:
const std::shared_ptr<const ArrayCommand> mCommand;
const std::shared_ptr<const CoreCommand> mCommand;
const bool mFastMode;
ContextPtr mContext;
CommandData mData;

size_t mNextIndex;

Expand Down
6 changes: 4 additions & 2 deletions aplcore/include/apl/action/autopageaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class AutoPageAction : public ResourceHoldingAction {
const ComponentPtr& container,
int start,
int end,
apl_time_t duration);
apl_duration_t duration,
apl_duration_t transitionDuration);

void freeze() override;
bool rehydrate(const CoreDocumentContext& context) override;
Expand All @@ -52,7 +53,8 @@ class AutoPageAction : public ResourceHoldingAction {
size_t mCurrentIndex;
size_t mNextIndex;
size_t mEndIndex;
apl_time_t mDuration;
apl_duration_t mDuration;
apl_duration_t mTransitionDuration;
};

} // namespace apl
Expand Down
8 changes: 5 additions & 3 deletions aplcore/include/apl/action/scrollaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,26 @@ class ScrollAction : public AnimatedScrollAction {
/**
* @param timers Timer reference.
* @param command Command that spawned this action.
* @param duration scrolling duration, -1 to use runtime-default.
* @return A scroll action or null if not needed.
*/
static std::shared_ptr<ScrollAction> make(const TimersPtr& timers,
const std::shared_ptr<CoreCommand>& command);
const std::shared_ptr<CoreCommand>& command,
apl_duration_t duration);

/**
* @param timers Timer reference.
* @param context context ot run this action in.
* @param target component to perform action on.
* @param targetDistance Object containing Dimension representing distance to be scrolled.
* @param duration scrolling duration.
* @param duration scrolling duration, -1 to use runtime-default.
* @return The scroll action or null if it is not needed.
*/
static std::shared_ptr<ScrollAction> make(const TimersPtr& timers,
const ContextPtr& context,
const CoreComponentPtr& target,
const Object& targetDistance,
apl_duration_t duration = -1);
apl_duration_t duration);

ScrollAction(const TimersPtr& timers,
const ContextPtr& context,
Expand Down
4 changes: 3 additions & 1 deletion aplcore/include/apl/action/scrolltoaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ class ScrollToAction : public AnimatedScrollAction {
* @param timers Timer reference.
* @param command Command that spawned this action.
* @param target Component to scroll to.
* @param duration Scrolling duration.
* @return The scroll to action or null if it is not needed.
*/
static std::shared_ptr<ScrollToAction> make(const TimersPtr& timers,
const std::shared_ptr<CoreCommand>& command,
const CoreComponentPtr& target = nullptr);
const CoreComponentPtr& target = nullptr,
apl_duration_t duration = -1);
/**
* Called from SpeakItem during line highlight mode.
* @param timers Timer reference.
Expand Down
4 changes: 3 additions & 1 deletion aplcore/include/apl/action/setpageaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class SetPageAction : public ResourceHoldingAction {

SetPageAction(const TimersPtr& timers,
const std::shared_ptr<CoreCommand>& command,
const CoreComponentPtr& target);
const CoreComponentPtr& target,
apl_duration_t transitionDuration);

void freeze() override;
bool rehydrate(const CoreDocumentContext& context) override;
Expand All @@ -45,6 +46,7 @@ class SetPageAction : public ResourceHoldingAction {
std::shared_ptr<CoreCommand> mCommand;
CoreComponentPtr mTarget;
int mTargetIndex;
apl_duration_t mTransitionDuration;
};

} // namespace apl
Expand Down
2 changes: 1 addition & 1 deletion aplcore/include/apl/command/arraycommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ArrayCommand : public CoreCommand {
std::string name() const override { return "ArrayCommand"; }
ActionPtr execute(const TimersPtr& timers, bool fastMode) override;

bool finishAllOnTerminate() const { return mFinishAllOnTerminate; }
bool finishAllOnTerminate() const override { return mFinishAllOnTerminate; }

private:
bool mFinishAllOnTerminate;
Expand Down
5 changes: 5 additions & 0 deletions aplcore/include/apl/command/commandfactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ class CommandFactory : public NonCopyable {
CommandPtr inflate(const ContextPtr& context, CommandData&& commandData, const CoreComponentPtr& base);

CommandPtr inflate(CommandData&& commandData, const std::shared_ptr<const CoreCommand>& parent);

CommandPtr inflate(
const ContextPtr& context,
CommandData&& commandData,
const std::shared_ptr<const CoreCommand>& parent);
protected:
CommandFactory() = default;;

Expand Down
14 changes: 14 additions & 0 deletions aplcore/include/apl/command/commandproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ enum CommandType {
kCommandTypeCustomEvent,
kCommandTypeInsertItem,
kCommandTypeRemoveItem,
kCommandTypeLog,
};

enum CommandScrollAlign {
Expand Down Expand Up @@ -94,6 +95,14 @@ enum CommandReason {
kCommandReasonExit
};

enum CommandLogLevel {
kCommandLogLevelDebug,
kCommandLogLevelInfo,
kCommandLogLevelWarn,
kCommandLogLevelError,
kCommandLogLevelCritical
};

enum CommandPropertyKey {
kCommandPropertyAlign,
kCommandPropertyArguments,
Expand All @@ -116,6 +125,8 @@ enum CommandPropertyKey {
kCommandPropertyHighlightMode,
kCommandPropertyIndex,
kCommandPropertyItem,
kCommandPropertyLevel,
kCommandPropertyMessage,
kCommandPropertyMinimumDwellTime,
kCommandPropertyOnFail,
kCommandPropertyOtherwise,
Expand All @@ -130,6 +141,8 @@ enum CommandPropertyKey {
kCommandPropertySource,
kCommandPropertyStart,
kCommandPropertyState,
kCommandPropertyTargetDuration,
kCommandPropertyTransitionDuration,
kCommandPropertyValue,
};

Expand All @@ -142,6 +155,7 @@ extern Bimap<int, std::string> sCommandAudioTrackMap;
extern Bimap<int, std::string> sControlMediaMap;
extern Bimap<int, std::string> sCommandRepeatModeMap;
extern Bimap<int, std::string> sCommandReasonMap;
extern Bimap<int, std::string> sCommandLogLevelMap;

using CommandBag = ObjectBag<sCommandPropertyBimap>;

Expand Down
1 change: 1 addition & 0 deletions aplcore/include/apl/command/corecommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class CoreCommand : public Command {
const Properties& properties() const { return mProperties; }

virtual const CommandPropDefSet& propDefSet() const;
virtual bool finishAllOnTerminate() const { return false; }

void freeze() final;
bool rehydrate(const CoreDocumentContext& context) final;
Expand Down
3 changes: 3 additions & 0 deletions aplcore/include/apl/command/insertitemcommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class InsertItemCommand : public TemplatedCommand<InsertItemCommand> {
CommandType type() const override { return kCommandTypeInsertItem; }

ActionPtr execute(const TimersPtr& timers, bool fastMode) override;

private:
ContextPtr buildBaseChildContext(int insertIndex) const;
};

} // namespace apl
Expand Down
41 changes: 41 additions & 0 deletions aplcore/include/apl/command/logcommand.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

#ifndef _APL_LOG_COMMAND_H
#define _APL_LOG_COMMAND_H

#include "apl/command/corecommand.h"

namespace apl {

class LogCommand : public TemplatedCommand<LogCommand> {
public:
COMMAND_CONSTRUCTOR(LogCommand);

const CommandPropDefSet& propDefSet() const override;

CommandType type() const override { return kCommandTypeLog; }

ActionPtr execute(const TimersPtr& timers, bool fastMode) override;

private:
rapidjson::Document mDocument;
rapidjson::Value mSource;
rapidjson::Value mArguments;
};

} // namespace apl

#endif // _APL_LOG_COMMAND_H
4 changes: 3 additions & 1 deletion aplcore/include/apl/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ using apl_duration_t = double;
// Common definitions of shared pointer data structures. We define the XXXPtr variations
// here so they can be conveniently used from any source file.

class AccessibilityAction;
class Action;
class AudioPlayer;
class AudioPlayerFactory;
Expand Down Expand Up @@ -96,6 +97,7 @@ class TextMeasurement;
class Timers;
class UIDObject;

using AccessibilityActionPtr = std::shared_ptr<AccessibilityAction>;
using ActionPtr = std::shared_ptr<Action>;
using AudioPlayerFactoryPtr = std::shared_ptr<AudioPlayerFactory>;
using AudioPlayerPtr = std::shared_ptr<AudioPlayer>;
Expand All @@ -107,10 +109,10 @@ using ContentPtr = std::shared_ptr<Content>;
using ContextPtr = std::shared_ptr<Context>;
using ContextDataPtr = std::shared_ptr<ContextData>;
using CoreComponentPtr = std::shared_ptr<CoreComponent>;
using ConstCoreComponentPtr = std::shared_ptr<const CoreComponent>;
using CoreDocumentContextPtr = std::shared_ptr<CoreDocumentContext>;
using CoreRootContextPtr = std::shared_ptr<CoreRootContext>;
using DataSourceProviderPtr = std::shared_ptr<DataSourceProvider>;
using DataSourcePtr = std::shared_ptr<DataSource>;
using DependantPtr = std::shared_ptr<Dependant>;
using DocumentConfigPtr = std::shared_ptr<DocumentConfig>;
using DocumentContextDataPtr = std::shared_ptr<DocumentContextData>;
Expand Down
3 changes: 2 additions & 1 deletion aplcore/include/apl/component/actionablecomponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ActionableComponent : public CoreComponent {
* @param component Pointer to cast.
* @return Casted pointer to this type, nullptr if not possible.
*/
static std::shared_ptr<ActionableComponent> cast(const std::shared_ptr<Component>& component);
static std::shared_ptr<ActionableComponent> cast(const ComponentPtr& component);

/// CoreComponent overrides
bool isActionable() const override { return true; }
Expand All @@ -81,6 +81,7 @@ class ActionableComponent : public CoreComponent {
CoreComponent(context, std::move(properties), path), mGesturesDisabled(false) {}

bool processGestures(const PointerEvent& event, apl_time_t timestamp) override;
void getSupportedStandardAccessibilityActions(std::map<std::string, bool>& result) const override;
void invokeStandardAccessibilityAction(const std::string& name) override;

#ifdef SCENEGRAPH
Expand Down
4 changes: 2 additions & 2 deletions aplcore/include/apl/component/componenteventsourcewrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ namespace apl {
*/
class ComponentEventSourceWrapper : public ComponentEventWrapper {
public:
static std::shared_ptr<ComponentEventSourceWrapper> create(const std::shared_ptr<const CoreComponent>& component,
static std::shared_ptr<ComponentEventSourceWrapper> create(const ConstCoreComponentPtr& component,
std::string handler,
const Object& value);

explicit ComponentEventSourceWrapper(const std::shared_ptr<const CoreComponent>& component)
explicit ComponentEventSourceWrapper(const ConstCoreComponentPtr& component)
: ComponentEventWrapper(component) {}

std::string toDebugString() const override { return "ComponentEventSourceWrapper<>"; }
Expand Down
4 changes: 2 additions & 2 deletions aplcore/include/apl/component/componenteventtargetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ namespace apl {
*/
class ComponentEventTargetWrapper : public ComponentEventWrapper {
public:
static std::shared_ptr<ComponentEventTargetWrapper> create(const std::shared_ptr<const CoreComponent>& component);
static std::shared_ptr<ComponentEventTargetWrapper> create(const ConstCoreComponentPtr& component);

explicit ComponentEventTargetWrapper(const std::shared_ptr<const CoreComponent>& component)
explicit ComponentEventTargetWrapper(const ConstCoreComponentPtr& component)
: ComponentEventWrapper(component) {}

std::string toDebugString() const override { return "ComponentEventTargetWrapper<>"; }
Expand Down
4 changes: 2 additions & 2 deletions aplcore/include/apl/component/componenteventwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ComponentEventTargetWrapper;
*/
class ComponentEventWrapper : public ObjectData {
public:
explicit ComponentEventWrapper(const std::shared_ptr<const CoreComponent>& component);
explicit ComponentEventWrapper(const ConstCoreComponentPtr& component);

Object get(const std::string& key) const override;
Object opt(const std::string& key, const Object& def) const override;
Expand All @@ -42,7 +42,7 @@ class ComponentEventWrapper : public ObjectData {

const ObjectMap& getMap() const override;

std::shared_ptr<const CoreComponent> getComponent() const { return mComponent.lock(); }
ConstCoreComponentPtr getComponent() const { return mComponent.lock(); }

virtual bool operator==(const ComponentEventWrapper& rhs) const = 0;
virtual bool operator==(const ComponentEventSourceWrapper& rhs) const { return false; }
Expand Down
Loading

0 comments on commit 6ac06f5

Please sign in to comment.