Skip to content

Commit 747c96d

Browse files
Merge branch 'dev' into feature/router
2 parents 8138ddb + c1122e3 commit 747c96d

File tree

9 files changed

+84
-25
lines changed

9 files changed

+84
-25
lines changed

CHANGELOG.md

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

3+
## v4.7.0
4+
5+
*20 oct 2021*
6+
7+
- Fixed issues with playing Video as a texture (#189)
8+
- Added (semi private) getter for consumer to VideoPlayer plugin
9+
- Added error handling (by firing an error to the consumer) when play() on the video tag returns an error (with a Promise wrapper fallback for older browsers)
10+
- Added fix that allows periods to be used in a Router hash
11+
12+
## v4.6.1
13+
14+
*30 aug 2021*
15+
16+
- Fixed cleanup after closing an App
317
## v4.6.0
418

519
*16 aug 2021*

docs/changelog.md

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

3+
## v4.7.0
4+
5+
*20 oct 2021*
6+
7+
- Fixed issues with playing Video as a texture (#189)
8+
- Added (semi private) getter for consumer to VideoPlayer plugin
9+
- Added error handling (by firing an error to the consumer) when play() on the video tag returns an error (with a Promise wrapper fallback for older browsers)
10+
- Added fix that allows periods to be used in a Router hash
11+
12+
## v4.6.1
13+
14+
*30 aug 2021*
15+
16+
- Fixed cleanup after closing an App
317
## v4.6.0
418

519
*16 aug 2021*

docs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lightningjs/sdk",
3-
"version": "4.5.0",
3+
"version": "4.7.0",
44
"license": "Apache-2.0",
55
"scripts": {
66
"postinstall": "node ./scripts/postinstall.js",
@@ -23,6 +23,7 @@
2323
"dependencies": {
2424
"@babel/polyfill": "^7.11.5",
2525
"@lightningjs/core": "*",
26+
"@michieljs/execute-as-promise": "^1.0.0",
2627
"deepmerge": "^4.2.2",
2728
"localCookie": "github:WebPlatformForEmbedded/localCookie",
2829
"shelljs": "^0.8.4",

package-lock.json

Lines changed: 4 additions & 4 deletions
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.6.0",
3+
"version": "4.7.0",
44
"license": "Apache-2.0",
55
"scripts": {
66
"postinstall": "node ./scripts/postinstall.js",

src/Application/index.js

Lines changed: 17 additions & 13 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
}
@@ -160,10 +163,7 @@ export default function(App, appData, platformSettings) {
160163
}
161164

162165
closeApp() {
163-
Log.info('Closing App')
164-
165-
Settings.clearSubscribers()
166-
Registry.clear()
166+
Log.info('Signaling App Close')
167167

168168
if (platformSettings.onClose && typeof platformSettings.onClose === 'function') {
169169
platformSettings.onClose(...arguments)
@@ -174,6 +174,10 @@ export default function(App, appData, platformSettings) {
174174

175175
close() {
176176
Log.info('Closing App')
177+
178+
Settings.clearSubscribers()
179+
Registry.clear()
180+
177181
this.childList.remove(this.tag('App'))
178182
this.cleanupFonts()
179183
// force texture garbage collect

src/Router/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,25 @@ const registerListener = () => {
494494
}
495495
})
496496
}
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+
497516
// export API
498517
export default {
499518
startRouter,
@@ -523,6 +542,7 @@ export default {
523542
App: RoutedApp,
524543
// keep backwards compatible
525544
focusPage: restoreFocus,
545+
root: root,
526546
/**
527547
* Deprecated api methods
528548
*/

src/Router/utils/route.js

Lines changed: 2 additions & 2 deletions
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
@@ -150,7 +150,7 @@ export const getValuesFromHash = (hash = '', path) => {
150150
// we already did the matching part
151151
path = stripRegex(path, '')
152152

153-
const getUrlParts = /(\/?:?[\w%\s:-]+)/g
153+
const getUrlParts = /(\/?:?[\w%\s:.-]+)/g
154154
const hashParts = hash.match(getUrlParts) || []
155155
const routeParts = path.match(getUrlParts) || []
156156
const getNamedGroup = /^\/:([\w-]+)\/?/

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)