Bug Report
Litexa generates the following code:
...
switch (request.type) {
case 'IntentRequest':
case 'LaunchRequest':
...
case 'Connections.Response':
...
default:
stateContext.intent = request.type;
stateContext.handoffIntent = true;
stateContext.handoffState = stateContext.currentState;
stateContext.nextState = null;
handled = false;
for (extensionName in extensionRequests) {
requests = extensionRequests[extensionName];
if (request.type in requests) {
handled = true;
func = requests[request.type];
if (typeof func === 'function') {
func(request);
}
}
}
if (ref18 = request.type, indexOf.call(litexa.extendedEventNames, ref18) >= 0) {
handled = true;
}
if (!handled) {
throw new Error(`unrecognized event type: ${request.type}`);
}
}
return initializeExtensionObjects(stateContext);
}
...
Notice that initializeExtensionObjects is called after the switch statement, this means that the extension types are not added unless a built in request.type is called first.
Litexa Version
0.7.1
Current Behavior
Custom request.type is not installed unless a built in intent is called first.
Expected Behavior
Custom request.type should be installed immediately rather than defer until after the first request.
Steps to Reproduce
Create a custom extension
//litexa.extension.js
module.exports = function (options, lib) {
return {
runtime: {
apiName: "MyExtension", // extension namespace: see 'userFacing' below, for application
source: require("./handler.js")// source code for extension handler
}
}
}
// handler.js
module.exports = function (context) {
return {
requests: {
'CustomIntentRequest': function (request) {
console.log("i wont be installed until after a built in request type");
}
}
}
Additional Information
This is easily resolve by moving initializeExtensionObjects to before the switch statement.
...
// MOVED HERE
initializeExtensionObjects(stateContext);
switch (request.type) {
case 'IntentRequest':
case 'LaunchRequest':
...
case 'Connections.Response':
...
default:
stateContext.intent = request.type;
stateContext.handoffIntent = true;
stateContext.handoffState = stateContext.currentState;
stateContext.nextState = null;
handled = false;
for (extensionName in extensionRequests) {
requests = extensionRequests[extensionName];
if (request.type in requests) {
handled = true;
func = requests[request.type];
if (typeof func === 'function') {
func(request);
}
}
}
if (ref18 = request.type, indexOf.call(litexa.extendedEventNames, ref18) >= 0) {
handled = true;
}
if (!handled) {
throw new Error(`unrecognized event type: ${request.type}`);
}
}
return
}
...
Bug Report
Litexa generates the following code:
Notice that
initializeExtensionObjectsis called after the switch statement, this means that the extension types are not added unless a built inrequest.typeis called first.Litexa Version
0.7.1Current Behavior
Custom
request.typeis not installed unless a built in intent is called first.Expected Behavior
Custom
request.typeshould be installed immediately rather than defer until after the first request.Steps to Reproduce
Create a custom extension
Additional Information
This is easily resolve by moving
initializeExtensionObjectsto before the switch statement.