Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
ae7c70e
Added v2 changes
Abhishk123 Mar 19, 2025
59bf7c5
Addressed the comments
Abhishk123 Mar 20, 2025
45d2bae
fixed unit testcases
Abhishk123 Mar 20, 2025
554cb71
Merge branch 'dev' into biDirectionalEventHandlin
Eswar2103 May 15, 2025
8309f81
Firebolt v2 event changes
Eswar2103 May 20, 2025
06a0541
V1 event changes
Eswar2103 May 31, 2025
022acf3
Updated import of Transport for v1 and v2
Eswar2103 Jun 3, 2025
b52c336
Alias correction
Eswar2103 Jun 3, 2025
f0ac7c9
Code Optimisation
Eswar2103 Jun 3, 2025
87dd097
Removed console logs
Eswar2103 Jun 3, 2025
16e1f20
Added comments
Eswar2103 Jun 3, 2025
c05ec38
Fixed unit testcases
Eswar2103 Jun 5, 2025
984bee2
Added comments for unit testcases
Eswar2103 Jun 5, 2025
11a32dc
Changed function names and removed un-necessary maps
Eswar2103 Jun 9, 2025
50552d4
Added awaits for async functions
Eswar2103 Jun 9, 2025
3bc50f3
improved condition check
Eswar2103 Jun 12, 2025
10dcea2
Added null checks
Eswar2103 Jun 12, 2025
ff1bf95
Resolve merge conflicts
Eswar2103 Jun 23, 2025
74ef8c6
Merge pull request #285 from rdkcentral/biDirectionalEventHandlin
Eswar2103 Jun 23, 2025
fa9952e
Fetch sdk version from package.json
Eswar2103 Jun 24, 2025
dc26a19
Removed unnecesary comments
Eswar2103 Jun 24, 2025
23e97f8
store sdkversion in variable instead of env
Eswar2103 Jun 24, 2025
8392a49
Merge branch 'dev' into FIREBOLT-V2
Eswar2103 Jul 14, 2025
b09a10f
Merge branch 'dev' into FIREBOLT-V2
Eswar2103 Sep 24, 2025
ca774d9
Update sdk version to 1.8.0 next
Eswar2103 Sep 24, 2025
0fd2471
Update regex pattern
Eswar2103 Sep 24, 2025
c2f7236
Resolve merge conflicts
Eswar2103 Sep 30, 2025
588d303
Fix unit testcases failures
Eswar2103 Sep 30, 2025
55cd3c6
Merge branch 'dev' into FIREBOLT-V2
Abhishk123 Oct 1, 2025
7cdd50b
Resolve merge conflicts
Eswar2103 Nov 17, 2025
6e2a9ac
console log of IS_BIDIRECTIONAL_SDK env
Eswar2103 Nov 17, 2025
137a0fe
Resolved merge conflicts
Abhishk123 Nov 25, 2025
a0e9f36
Updated sdk version
Abhishk123 Nov 25, 2025
ced7f92
Added changes in event registration
Abhishk123 Dec 1, 2025
212588b
Added minor changes
Abhishk123 Dec 1, 2025
5c84ae2
Added minor change
Abhishk123 Dec 1, 2025
889a03c
fixed lint error
Abhishk123 Dec 1, 2025
83e1838
t pushMerge branch 'FIREBOLT-V2' of https://github.com/rdkcentral/fir…
Abhishk123 Dec 1, 2025
b7ba8b2
Update package.json
Abhishk123 Jan 12, 2026
a7b056a
Resolve merge conflicts
Eswar2103 Jan 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"description": "Reference App to demonstrate Firebolt APIs and Lifecycle",
"dependencies": {
"@apidevtools/json-schema-ref-parser": "9.1.2",
"@firebolt-js/discovery-sdk": "1.7.0",
"@firebolt-js/manage-sdk": "1.7.0",
"@firebolt-js/sdk": "1.7.0",
"@firebolt-js/discovery-sdk": "1.8.0-next-major.4",
"@firebolt-js/manage-sdk": "1.8.0-next-major.4",
"@firebolt-js/sdk": "1.8.0-next-major.4",
"@lightningjs/core": "2.11.0",
"@lightningjs/sdk": "5.5.6",
"@lightningjs/ui-components": "2.25.1",
Expand Down
6 changes: 6 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { withAnnouncer } from '@lightningjs/ui-components';
const Base = withAnnouncer(lng.Application);
import Toast, { eventEmitter } from './Toast';
import IntentReader from 'IntentReader';
const packagejson = require('../package.json');

export default class App extends Base {
static _template() {
Expand Down Expand Up @@ -90,6 +91,10 @@ export default class App extends Base {
this.accessibilityCheck(voiceAnnouncement);
});
this.toastStates = [];
const sdkVersionFromPackageJson = packagejson.dependencies['@firebolt-js/sdk'];
const pattern = /^([2-9]|\d{2,})\.\d+\.\d+$|^1\.(8|9|\d{2,})\.\d+/;
process.env.IS_BIDIRECTIONAL_SDK = pattern.test(sdkVersionFromPackageJson);
console.log('process.env.IS_BIDIRECTIONAL_SDK----:', process.env.IS_BIDIRECTIONAL_SDK);
this.overlayed = false;
this.overlayDismissTimer = null;
const appUrl = window.location;
Expand Down Expand Up @@ -126,6 +131,7 @@ export default class App extends Base {
process.env.PUBSUB_SUBSCRIBE_TOPIC_SUFFIX = new URLSearchParams(appUrl.search).get('pubSubSubscribeSuffix');
process.env.PUBSUB_PUBLISH_TOPIC_SUFFIX = new URLSearchParams(appUrl.search).get('pubSubPublishSuffix');
process.env.REGION = new URLSearchParams(appUrl.search).get('region');
process.env.SDK_VERSION = new URLSearchParams(appUrl.search).get('sdkVersion');

if (platform) {
process.env.PLATFORM = platform;
Expand Down
539 changes: 396 additions & 143 deletions src/EventInvocation.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/FireboltExampleInvoker.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,12 @@ export default class FireboltExampleInvoker {
return await methodFn(...params);
} else if (method.match(/^on[A-Z][a-zA-Z]+$/) && moduleClass.listen) {
let id;
let event = method[2].toLowerCase() + method.substr(3);
console.log('params:', params);
const event = method[2].toLowerCase() + method.substr(3);
if (process.env.IS_BIDIRECTIONAL_SDK === true || (typeof process.env.IS_BIDIRECTIONAL_SDK === 'string' && process.env.IS_BIDIRECTIONAL_SDK.toLowerCase() === 'true')) {
event = method;
}

if (params.length == 1 && params[0] === true) {
id = await moduleClass.listen(event, (e) => {
logger.error(e, 'invoke');
Expand Down
6 changes: 5 additions & 1 deletion src/FireboltTransportInvoker.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

import Transport from '@firebolt-js/sdk/dist/lib/Transport';
import Transport from 'Transport';
const logger = require('./utils/Logger')('FireboltTransportInvoker.js');
let getInvoker;

try {
getInvoker = require('../plugins/FireboltExtensionInvoker').getInvoker;
} catch (err) {
Expand Down Expand Up @@ -51,7 +52,10 @@ export default class FireboltTransportInvoker {
const invoker = getInvoker(sdk);
if (sdk && invoker) {
return await invoker.send(module, method, jsonParams);
} else if (process.env.IS_BIDIRECTIONAL_SDK === true || (typeof process.env.IS_BIDIRECTIONAL_SDK === 'string' && process.env.IS_BIDIRECTIONAL_SDK.toLowerCase() === 'true')) {
return await Transport.request(`${module}.${method}`, jsonParams);
} else {
// Default to transport
return await Transport.send(module, method, jsonParams);
}
} else {
Expand Down
36 changes: 30 additions & 6 deletions src/LifeCycleHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,35 @@ export default class LifecycleHistory {
async init(appInstance = null) {
lifecycleValidation = process.env.LIFECYCLE_VALIDATION;
const lifecycleModule = await assignModuleCapitalization('Lifecycle');
await Lifecycle.listen('inactive', this._recordHistory.bind(this, lifecycleModule + '.onInactive'));
await Lifecycle.listen('foreground', this._recordHistory.bind(this, lifecycleModule + '.onForeground'));
Lifecycle.listen('background', this._recordHistory.bind(this, lifecycleModule + '.onBackground'));
Lifecycle.listen('suspended', this._recordHistory.bind(this, lifecycleModule + '.onSuspended'));
Lifecycle.listen('unloading', async (event) => {
const isBidirectionalSdk = String(process.env.IS_BIDIRECTIONAL_SDK).toLowerCase() === 'true';
const eventNames = isBidirectionalSdk
? {
inactive: 'onInactive',
foreground: 'onForeground',
background: 'onBackground',
suspended: 'onSuspended',
unloading: 'onUnloading',
navigateTo: 'onNavigateTo',
}
: {
inactive: 'inactive',
foreground: 'foreground',
background: 'background',
suspended: 'suspended',
unloading: 'unloading',
navigateTo: 'navigateTo',
};
const inactiveEvent = eventNames.inactive;
const foregroundEvent = eventNames.foreground;
const backgroundEvent = eventNames.background;
const suspendedEvent = eventNames.suspended;
const unloadingEvent = eventNames.unloading;
const navigateToEvent = eventNames.navigateTo;
await Lifecycle.listen(inactiveEvent, this._recordHistory.bind(this, lifecycleModule + '.onInactive'));
await Lifecycle.listen(foregroundEvent, this._recordHistory.bind(this, lifecycleModule + '.onForeground'));
Lifecycle.listen(backgroundEvent, this._recordHistory.bind(this, lifecycleModule + '.onBackground'));
Lifecycle.listen(suspendedEvent, this._recordHistory.bind(this, lifecycleModule + '.onSuspended'));
Lifecycle.listen(unloadingEvent, async (event) => {
let schemaResult, validationResult;
await getschemaValidationDone(lifecycleModule + '.onUnloading', event, 'core').then((res) => {
schemaResult = res;
Expand Down Expand Up @@ -100,7 +124,7 @@ export default class LifecycleHistory {
}
}
// register for Discovery.onNavigateTo event
Discovery.listen('navigateTo', async (event) => {
Discovery.listen(navigateToEvent, async (event) => {
logger.info('Printing onNavigate To event received: ' + JSON.stringify(event));

try {
Expand Down
16 changes: 14 additions & 2 deletions src/MediaView.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,27 @@ export default class MediaView extends lng.Component {

_init() {
const p = this.tag('Player');
Lifecycle.listen('inactive', (event) => {
const isBidirectionalSdk = String(process.env.IS_BIDIRECTIONAL_SDK).toLowerCase() === 'true';
const eventNames = isBidirectionalSdk
? {
inactive: 'onInactive',
foreground: 'onForeground',
}
: {
inactive: 'inactive',
foreground: 'foreground',
};
const inactiveEvent = eventNames.inactive;
const foregroundEvent = eventNames.foreground;
Lifecycle.listen(inactiveEvent, (event) => {
if (event.state && this.tag('Row.ToggleInactive').checked) {
if (p.isPlaying()) {
logger.info('Unpausing video', '_init');
p.playPause();
}
}
});
Lifecycle.listen('foreground', (event) => {
Lifecycle.listen(foregroundEvent, (event) => {
if (event.state && this.tag('Row.ToggleInactive').checked) {
const p = this.tag('Player');
if (!p.isPlaying()) {
Expand Down
2 changes: 2 additions & 0 deletions src/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,6 @@ export const CONSTANTS = {
SLA_VALIDATION_INTENT: 'sla-validation',
OPENRPC_URL: 'https://rdkcentral.github.io/firebolt/requirements/latest/specifications/firebolt-open-rpc.json',
DEFAULT_SLA: 300,
CLEARED_LISTENERS: 'Cleared Listeners',
NO_ACTIVE_LISTENERS: 'No active listeners',
};
2 changes: 1 addition & 1 deletion src/pubsub/handlers/ClearEventListeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class ClearEventListeners extends BaseHandler {

async handle(message) {
const eventInvokerInfo = new EventInvocation();
const validationReport = eventInvokerInfo.clearAllListeners();
const validationReport = await eventInvokerInfo.clearAllListeners();
return JSON.stringify({ report: validationReport });
}
}
1 change: 1 addition & 0 deletions src/pubsub/handlers/RegisterEventHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default class RegisterEventHandler extends BaseHandler {
if (message.context) {
process.env.COMMUNICATION_MODE = message.context.communicationMode;
}
process.env.IS_NOT_SUPPORTED_API = message.isNotSupportedApi;
const eventInvokerInfo = new EventInvocation();
let sdkType;
if (!message.params.event.includes('_')) {
Expand Down
2 changes: 1 addition & 1 deletion src/pubsub/handlers/clearEventHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class clearEventHandler extends BaseHandler {
process.env.SDK_TYPE = sdkType;
}
try {
const validationReport = eventInvokerInfo.clearEventListeners(message.params.event);
const validationReport = await eventInvokerInfo.clearEventListeners(message.params.event);
return JSON.stringify({ report: validationReport });
} catch (e) {
const result = {
Expand Down
1 change: 1 addition & 0 deletions test/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module.exports = {
'^CensorData$': '<rootDir>/../src/source/censorData.json',
'^RunTestHandler$': '<rootDir>/../src/pubsub/handlers/RunTestHandler.js',
},
resolver: '<rootDir>/jest.transport-resolver.js',
transform: {
'^.+\\.[tj]s$': 'babel-jest',
'^.+\\.mjs$': 'babel-jest',
Expand Down
2 changes: 2 additions & 0 deletions test/jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ jest.mock('../src/constant', () => {
SLA_VALIDATION_INTENT: 'sla-validation',
OPENRPC_URL: 'https://rdkcentral.github.io/firebolt/requirements/latest/specifications/firebolt-open-rpc.json',
DEFAULT_SLA: 300,
CLEARED_LISTENERS: 'Cleared Listeners',
NO_ACTIVE_LISTENERS: 'No active listeners',
};

return { CONSTANTS };
Expand Down
25 changes: 25 additions & 0 deletions test/jest.transport-resolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const fs = require('fs');
const path = require('path');

module.exports = (request, options) => {
const defaultResolve = options.defaultResolver;
// Check if the module to resolve is 'Transport'
if (request === 'Transport') {
try {
// Get the list of files in the specified directory
const files = fs.readdirSync('node_modules/@firebolt-js/sdk/dist/lib/');
// If the 'Gateway' file exists, then the sdk version is 2.0.0 or later, so resolve to 'Gateway' path
if (files.includes('Gateway')) {
console.log('Using Gateway from @firebolt-js/sdk');
return path.resolve(__dirname, '../node_modules/@firebolt-js/sdk/dist/lib/Gateway/index.mjs');
} else {
console.log('Using Transport from @firebolt-js/sdk');
return path.resolve(__dirname, '../node_modules/@firebolt-js/sdk/dist/lib/Transport/index.mjs');
}
} catch (err) {
console.error(`Error resolving files: ${err.message}`);
return defaultResolve(request, options);
}
}
return defaultResolve(request, options);
};
Loading