Skip to content

Commit 805784b

Browse files
authored
Merge pull request #285 from rdkcentral/dev
Dev
2 parents 93c7495 + 9e8f72c commit 805784b

File tree

10 files changed

+81
-18
lines changed

10 files changed

+81
-18
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
## v4.8.0
4+
5+
*7 dec 2021*
6+
7+
8+
- Fixed deepmerge breaking provided canvas
9+
- Fixed getting querystring parameters with boot component
10+
- Added dynamic canvas size support
11+
- Added support to accept all characters in hash
12+
- Added `Router.root()` support
13+
- Added `Router.reload()` support
14+
315
## v4.7.0
416

517
*20 oct 2021*

docs/changelog.md

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

3+
## v4.8.0
4+
5+
*7 dec 2021*
6+
7+
8+
- Fixed deepmerge breaking provided canvas
9+
- Fixed getting querystring parameters with boot component
10+
- Added dynamic canvas size support
11+
- Added support to accept all characters in hash
12+
- Added `Router.root()` support
13+
- Added `Router.reload()` support
314
## v4.7.0
415

516
*20 oct 2021*

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lightningjs/sdk",
3-
"version": "4.7.0",
3+
"version": "4.8.0",
44
"license": "Apache-2.0",
55
"scripts": {
66
"postinstall": "node ./scripts/postinstall.js",

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lightningjs/sdk",
3-
"version": "4.7.0",
3+
"version": "4.8.0",
44
"license": "Apache-2.0",
55
"scripts": {
66
"postinstall": "node ./scripts/postinstall.js",

src/Application/index.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import Utils from '../Utils'
3030
import Registry from '../Registry'
3131
import { initColors } from '../Colors'
3232

33-
import { version as sdkVersion } from '../../package.json'
33+
import packageInfo from '../../package.json'
3434

3535
export let AppInstance
3636
export let AppData
@@ -56,12 +56,6 @@ const defaultOptions = {
5656
},
5757
}
5858

59-
if (window.innerHeight === 720) {
60-
defaultOptions.stage['w'] = 1280
61-
defaultOptions.stage['h'] = 720
62-
defaultOptions.stage['precision'] = 0.6666666667
63-
}
64-
6559
const customFontFaces = []
6660

6761
const fontLoader = (fonts, store) =>
@@ -87,9 +81,18 @@ const fontLoader = (fonts, store) =>
8781
})
8882

8983
export default function(App, appData, platformSettings) {
84+
defaultOptions.stage['w'] = platformSettings.width ? platformSettings.width : 1920
85+
defaultOptions.stage['h'] = platformSettings.height ? platformSettings.height : 1080
86+
defaultOptions.stage['precision'] =
87+
(platformSettings.width ? platformSettings.width : 1920) / 1920
88+
9089
return class Application extends Lightning.Application {
9190
constructor(options) {
9291
const config = Deepmerge(defaultOptions, options)
92+
// Deepmerge breaks HTMLCanvasElement, so restore the passed in canvas.
93+
if(options.stage.canvas) {
94+
config.stage.canvas = options.stage.canvas
95+
}
9396
super(config)
9497
this.config = config
9598
}
@@ -126,14 +129,14 @@ export default function(App, appData, platformSettings) {
126129
this._refocus()
127130

128131
Log.info('App version', this.config.version)
129-
Log.info('SDK version', sdkVersion)
132+
Log.info('SDK version', packageInfo.version)
130133

131134
if (platformSettings.showVersion) {
132135
this.childList.a({
133136
ref: 'VersionLabel',
134137
type: VersionLabel,
135138
version: this.config.version,
136-
sdkVersion: sdkVersion,
139+
sdkVersion: packageInfo.version,
137140
zIndex: 1,
138141
})
139142
}

src/Router/index.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,16 @@ const resume = () => {
419419
}
420420
}
421421

422+
/**
423+
* Force reload active hash
424+
*/
425+
const reload = () => {
426+
if (!isNavigating()) {
427+
const hash = getActiveHash()
428+
navigate(hash, { reload: true }, false)
429+
}
430+
}
431+
422432
/**
423433
* Query if the Router is still processing a Request
424434
* @returns {boolean}
@@ -484,6 +494,25 @@ const registerListener = () => {
484494
}
485495
})
486496
}
497+
498+
/**
499+
* Navigate to root hash
500+
*/
501+
const root = () => {
502+
const rootHash = getRootHash()
503+
if (isString(rootHash)) {
504+
navigate(rootHash)
505+
} else if (isFunction(rootHash)) {
506+
rootHash().then(res => {
507+
if (isObject(res)) {
508+
navigate(res.path, res.params)
509+
} else {
510+
navigate(res)
511+
}
512+
})
513+
}
514+
}
515+
487516
// export API
488517
export default {
489518
startRouter,
@@ -508,10 +537,12 @@ export default {
508537
getHistoryState,
509538
replaceHistoryState,
510539
getQueryStringParams,
540+
reload,
511541
symbols,
512542
App: RoutedApp,
513543
// keep backwards compatible
514544
focusPage: restoreFocus,
545+
root: root,
515546
/**
516547
* Deprecated api methods
517548
*/

src/Router/utils/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export const incorrectParams = (cb, route) => {
113113

114114
export const getQueryStringParams = (hash = getActiveHash()) => {
115115
const resumeHash = getResumeHash()
116-
if (hash === '$' || resumeHash) {
116+
if ((hash === '$' || !hash) && resumeHash) {
117117
if (isString(resumeHash)) {
118118
hash = resumeHash
119119
}

src/Router/utils/route.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const getRouteByHash = hash => {
5959
// @todo: clean up on handleHash
6060
hash = hash.replace(/^#/, '')
6161

62-
const getUrlParts = /(\/?:?[@!*\w%\s:-]+)/g
62+
const getUrlParts = /(\/?:?[^/]+)/g
6363
// grab possible candidates from stored routes
6464
const candidates = getRoutesByFloor(getFloor(hash))
6565
// break hash down in chunks

src/VideoPlayer/index.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,23 @@ export const setupVideoTag = () => {
124124
return videoEls[0]
125125
} else {
126126
const videoEl = document.createElement('video')
127+
const platformSettingsWidth = Settings.get('platform', 'width')
128+
? Settings.get('platform', 'width')
129+
: 1920
130+
const platformSettingsHeight = Settings.get('platform', 'height')
131+
? Settings.get('platform', 'height')
132+
: 1080
127133
videoEl.setAttribute('id', 'video-player')
128-
videoEl.setAttribute('width', withPrecision(1920))
129-
videoEl.setAttribute('height', withPrecision(1080))
134+
videoEl.setAttribute('width', withPrecision(platformSettingsWidth))
135+
videoEl.setAttribute('height', withPrecision(platformSettingsHeight))
130136
videoEl.style.position = 'absolute'
131137
videoEl.style.zIndex = '1'
132138
videoEl.style.display = 'none'
133139
videoEl.style.visibility = 'hidden'
134140
videoEl.style.top = withPrecision(0)
135141
videoEl.style.left = withPrecision(0)
136-
videoEl.style.width = withPrecision(1920)
137-
videoEl.style.height = withPrecision(1080)
142+
videoEl.style.width = withPrecision(platformSettingsWidth)
143+
videoEl.style.height = withPrecision(platformSettingsHeight)
138144
document.body.appendChild(videoEl)
139145
return videoEl
140146
}

0 commit comments

Comments
 (0)