Compare commits

..
11 Commits
Author SHA1 Message Date
Brahim Hadriche 9fddd40ff3 Release v0.13.1 (#164) 2023-10-08 12:26:47 -04:00
Brahim Hadriche b489735af9 only regen images on release 2023-10-08 12:11:30 -04:00
Brahim Hadriche 508306c6f4 Refactor image conversion (#163)
* Refactor image conversion

* Docs
2023-10-07 18:21:54 -04:00
Brahim Hadriche 7818f778ea Log video player errors 2023-10-06 09:18:21 -04:00
Brahim Hadriche 6abd18ab85 Handle Popular disabled case (#162) 2023-10-04 18:52:44 -04:00
Brahim Hadriche e8fd7ee35d Fix/bugs (#161)
* Fix for execution timeout

* Multiple bug fixes
2023-10-04 18:16:57 -04:00
Brahim Hadriche deeed05383 Fix button size 2023-10-03 20:46:14 -04:00
Brahim Hadriche 518409cb3f Add todo 2023-10-03 20:41:07 -04:00
Brahim Hadriche a9d7de971b Delete renovate.json 2023-10-03 11:41:13 -04:00
Brahim Hadriche 324543684d Pause/Resume during picture in picture (#156)
* Pause/Resume during picture in picture

* changelog

* changelog
2023-10-02 15:14:24 -04:00
Brahim Hadriche a6f8cb59ee fix filter button again 2023-10-02 15:03:20 -04:00
55 changed files with 446 additions and 140 deletions

No files matched your search

+12
View File
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.13.1] - 2023-10-08
### Added
- Support to pause/play while picture-in-picture
### Fixed
- (potentionally) a bug where many dialogs could cause an execution timeout
- Mutltiple rare crashes when component content is set before component initialization
- Error dialog for loading "Popular" when "Popular" is disabled
## [0.13.0] - 2023-10-02
### Added
+4 -2
View File
@@ -26,7 +26,8 @@
"source/**",
"components/**",
"images/**",
"!images/vector/**",
"!**/*.svg",
"!**/*.svg.meta.json5",
"fonts/**",
"config/**",
"lib/**",
@@ -48,7 +49,8 @@
"../tools/bs-plugins/track-transpiled-plugin.ts",
"../tools/bs-plugins/json-yaml-plugin.ts",
"../tools/bs-plugins/validation-plugin.ts",
"../tools/bs-plugins/logger-plugin.ts"
"../tools/bs-plugins/logger-plugin.ts",
"../tools/bs-plugins/image-gen-plugin.ts"
],
"retainStagingDir": true,
"require": [
+4 -2
View File
@@ -4,7 +4,8 @@
"source/**",
"components/**",
"images/**",
"!images/vector/**",
"!**/*.svg",
"!**/*.svg.meta.json5",
"fonts/**",
"config/**",
"lib/**",
@@ -24,7 +25,8 @@
"../tools/bs-plugins/track-transpiled-plugin.ts",
"../tools/bs-plugins/json-yaml-plugin.ts",
"../tools/bs-plugins/validation-plugin.ts",
"../tools/bs-plugins/logger-plugin.ts"
"../tools/bs-plugins/logger-plugin.ts",
"../tools/bs-plugins/image-gen-plugin.ts"
],
"rooibos": {
"logLevel": 2,
+1 -1
View File
@@ -2,7 +2,7 @@ openapi: 3.0.0
info:
title: Playlet Web API
version: 0.13.0
version: 0.13.1
description:
Playlet Web API is a RESTful API for controlling the Playlet app on
Roku devices. The API is intended to be used by the Playlet web app, but can
+16
View File
@@ -1,6 +1,7 @@
# Playlet Brighterscript Plugins
- [Json5/Yaml support](#json5yaml-support)
- [Convert images](#convert-images)
- [Manifest editing](#manifest-editing)
- [Validation](#validation)
- [Includes](#includes)
@@ -27,6 +28,21 @@ Brightscript can only parse json natively using [ParseJson](https://developer.ro
At the end of the build, the plugin scans for certain files (`jsonc`, `json`, `json5` and `yaml`), and converts them to plain json, while keeping the original file name. That way they are all parsable by the [ParseJson](https://developer.roku.com/en-ca/docs/references/brightscript/language/global-utility-functions.md#parsejsonjsonstring-as-string-flags---as-string-as-object) function, even though their original format is not compatible.
## Convert images
**[Source](/tools/bs-plugins/image-gen-plugin.ts)**
This plugin allows us to convert svg files to png files.
### Why
This is used to convert splash screen, app poster, as well as icons in the app. Having svg images (or vector images in general) as the source of truth is better, in case images need to be modified or resized. Since Roku can't load them, we convert them to png.
### How
Each `.svg` file found will have an associated `.svg.meta.json5` file, which will contain the hash (MD5) of the svg, conversion paramters, and the hash of the output files. This allows us to hash existing files and see if a conversion is needed.
Notice how each `.svg` file can be configured to generate multiple png files. This is especially the case to generate the app artwork (splash screen/poster) with different sizes from the same logo `.svg` file.
## Manifest editing
**[Source](/tools/bs-plugins/manifest-edit-plugin.ts)**
+16 -2
View File
@@ -1,15 +1,16 @@
{
"name": "playlet",
"version": "0.13.0",
"version": "0.13.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "playlet",
"version": "0.13.0",
"version": "0.13.1",
"hasInstallScript": true,
"devDependencies": {
"@rokucommunity/bslint": "^0.8.10",
"@types/crypto-js": "^4.1.2",
"@types/fs-extra": "^11.0.2",
"@types/node": "^20.7.2",
"@types/xml2js": "^0.4.12",
@@ -18,6 +19,7 @@
"brighterscript-formatter": "^1.6.33",
"convert-svg-to-png": "^0.6.4",
"cross-fetch": "^4.0.0",
"crypto-js": "^4.1.1",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"fs-extra": "^11.1.1",
@@ -327,6 +329,12 @@
"integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==",
"dev": true
},
"node_modules/@types/crypto-js": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/@types/crypto-js/-/crypto-js-4.1.2.tgz",
"integrity": "sha512-t33RNmTu5ufG/sorROIafiCVJMx3jz95bXUMoPAZcUD14fxMXnuTzqzXZoxpR0tNx2xpw11Dlmem9vGCsrSOfA==",
"dev": true
},
"node_modules/@types/fs-extra": {
"version": "11.0.2",
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-11.0.2.tgz",
@@ -1507,6 +1515,12 @@
"node": ">= 8"
}
},
"node_modules/crypto-js": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz",
"integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==",
"dev": true
},
"node_modules/css-select": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz",
+3 -2
View File
@@ -1,9 +1,10 @@
{
"name": "playlet",
"version": "0.13.0",
"version": "0.13.1",
"description": "Unofficial Youtube client for Roku",
"devDependencies": {
"@rokucommunity/bslint": "^0.8.10",
"@types/crypto-js": "^4.1.2",
"@types/fs-extra": "^11.0.2",
"@types/node": "^20.7.2",
"@types/xml2js": "^0.4.12",
@@ -12,6 +13,7 @@
"brighterscript-formatter": "^1.6.33",
"convert-svg-to-png": "^0.6.4",
"cross-fetch": "^4.0.0",
"crypto-js": "^4.1.1",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"fs-extra": "^11.1.1",
@@ -52,7 +54,6 @@
"test:build:app": "cd playlet-app && npm run test:build",
"test:lib": "cd playlet-lib && npm run test",
"test:build:lib": "cd playlet-lib && npm run test:build",
"generate-images": "node tools/generate-images.js",
"version-sync": "node tools/version-sync.js",
"manifest-git-hash": "node tools/update-manifest-git-hash.js",
"sign-package": "node tools/sign-package.js",
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-app",
"version": "0.13.0",
"version": "0.13.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "playlet-app",
"version": "0.13.0"
"version": "0.13.1"
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-app",
"version": "0.13.0",
"version": "0.13.1",
"description": "Unofficial Youtube client for Roku",
"scripts": {
"prebuild": "rm -rf build/playlet-app",
@@ -0,0 +1,26 @@
{
inputHash: '0536f51fa72c2e4e368ea0e901aadfc1',
outputs: [
{
outputFilePath: 'src/images/splash-screen_fhd.jpg',
outputHash: 'b15f3a3f1ccc459cbca12cb828b78d16',
width: 1920,
height: 1080,
background: '#242424',
},
{
outputFilePath: 'src/images/splash-screen_hd.jpg',
outputHash: '25e9c4220f8a42101d6333e548e33aa8',
width: 1280,
height: 720,
background: '#242424',
},
{
outputFilePath: 'src/images/splash-screen_sd.jpg',
outputHash: 'c54a2f7fa65f443263806962450f2c04',
width: 720,
height: 480,
background: '#242424',
},
],
}
@@ -0,0 +1,4 @@
{
inputHash: "d61131ccc714d8df0b4514ca76883494",
outputs: [],
}
@@ -0,0 +1,26 @@
{
inputHash: '3452c6ea1c84f59aedf5530bf86a7a51',
outputs: [
{
outputFilePath: 'src/images/channel-poster_fhd.png',
outputHash: 'd644a0db84deed0bcc41a41d08a4ef75',
width: 540,
height: 405,
background: '#FFFFFF',
},
{
outputFilePath: 'src/images/channel-poster_hd.png',
outputHash: 'd07a4ffaa021b55528bee91710f4e9d2',
width: 290,
height: 218,
background: '#FFFFFF',
},
{
outputFilePath: 'src/images/channel-poster_sd.png',
outputHash: '66a311c639f89ff009e4624468282b2f',
width: 246,
height: 140,
background: '#FFFFFF',
},
],
}
+2 -2
View File
@@ -3,13 +3,13 @@ title=Playlet
# Do not update version manually, it is auto updated from package.json
major_version=0
minor_version=13
build_version=00000
build_version=00001
ui_resolutions=hd
## Channel Assets
### Main Menu Icons / Channel Poster Artwork
#### Image sizes are FHD: 540x405px | HD: 290x218px | SD: 214x144px
#### Image sizes are FHD: 540x405px | HD: 290x218px | SD: 246x140px
mm_icon_focus_fhd=pkg:/images/channel-poster_fhd.png
mm_icon_focus_hd=pkg:/images/channel-poster_hd.png
mm_icon_focus_sd=pkg:/images/channel-poster_sd.png
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-lib",
"version": "0.13.0",
"version": "0.13.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "playlet-lib",
"version": "0.13.0"
"version": "0.13.1"
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-lib",
"version": "0.13.0",
"version": "0.13.1",
"description": "Unofficial Youtube client for Roku",
"scripts": {
"prebuild": "rm -rf build/playlet-lib",
@@ -83,7 +83,22 @@ function onKeyEvent(key as string, press as boolean) as boolean
end if
if key = "options"
VideoUtils.ToggleVideoPictureInPicture()
else if key = "back"
return true
end if
if key = "play"
VideoUtils.TogglePause()
end if
if key = "pause"
VideoUtils.PauseVideo()
end if
if key = "playonly"
VideoUtils.ResumeVideo()
end if
if key = "back"
dialog = DialogUtils.ShowDialogButtons("Do you want to exit Playlet?", "Exit", ["Exit", "Cancel"])
dialog.observeField("buttonSelected", FuncName(OnExitDialog), ["buttonSelected"])
return true
@@ -27,7 +27,8 @@
id="thumbnail"
width="100"
height="100"
translation="[2,2]" />
translation="[2,2]"
failedBitmapUri="pkg:/images/thumbnail-missing.jpg" />
<Label
id="authorLabel"
@@ -4,11 +4,10 @@ function Init()
end function
function UpdateMaskSize()
width = m.top.poster.width
height = m.top.poster.height
width = m.top.width
height = m.top.height
maskSize = [width * GetScaleFactor(), height * GetScaleFactor()]
m.top.maskGroup.maskSize = maskSize
m.top.maskSize = [width * GetScaleFactor(), height * GetScaleFactor()]
end function
' MaskGroup component do not scale with with UI resolution
@@ -11,6 +11,7 @@
<field id="loadStatus" type="string" alias="Poster.loadStatus" />
<field id="maskUri" type="uri" value="pkg:/images/circle-mask-500.png" alias="MaskGroup.maskuri" />
<field id="maskSize" type="vector2d" alias="MaskGroup.maskSize" />
</interface>
<children>
<MaskGroup
@@ -12,9 +12,12 @@ namespace DialogUtils
dialog.title = title
dialog.buttons = buttons
if large
deviceInfo = CreateObject("roDeviceInfo")
displaySize = deviceInfo.GetDisplaySize()
dialog.width = displaySize.w - 100
if m._deviceDisplayWidth = invalid
deviceInfo = CreateObject("roDeviceInfo")
displaySize = deviceInfo.GetDisplaySize()
m._deviceDisplayWidth = displaySize.w
end if
dialog.width = m._deviceDisplayWidth - 100
end if
m.top.getScene().dialog = dialog
return dialog
@@ -16,6 +16,7 @@
<script type="text/brightscript" uri="pkg:/source/utils/StringUtils.brs" />
<script type="text/brightscript" uri="pkg:/components/VideoPlayer/VideoUtils.brs" />
<script type="text/brightscript" uri="pkg:/source/utils/FocusManagement.brs" />
<script type="text/brightscript" uri="pkg:/components/Dialog/DialogUtils.brs" />
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
<children>
<AppController id="AppController">
@@ -2,13 +2,15 @@ import "pkg:/source/utils/TimeUtils.bs"
import "pkg:/source/utils/Types.bs"
function Init()
FindChildren()
end function
function FindChildren()
m.titleLabel = m.top.findNode("titleLabel")
m.authorLabel = m.top.findNode("authorLabel")
m.thumbnail = m.top.findNode("thumbnail")
m.durationRect = m.top.FindNode("durationRect")
m.durationLabel = m.top.FindNode("durationLabel")
m.thumbnail.failedBitmapUri = "pkg:/images/thumbnail-missing.jpg"
end function
function OnContentSet() as void
@@ -18,6 +20,10 @@ function OnContentSet() as void
return
end if
if m.titleLabel = invalid
FindChildren()
end if
m.titleLabel.text = content.title
m.authorLabel.text = content.author
@@ -7,7 +7,8 @@
id="thumbnail"
loadDisplayMode="scaleToZoom"
width="190"
height="106">
height="106"
failedBitmapUri="pkg:/images/thumbnail-missing.jpg">
<Rectangle
id="durationRect"
width="60"
@@ -10,7 +10,7 @@
<Button
id="filtersButton"
translation="[160,40]"
minWidth="180"
minWidth="240"
height="48"
showFocusFootprint="true"
iconUri="pkg:/images/icons/filters-white.png"
@@ -7,6 +7,7 @@
<children>
<Button
id="Button"
minWidth="340"
showFocusFootprint="true" />
<Label id="DescriptionLabel"
width="450"
@@ -22,6 +22,8 @@ end function
function PrepareTests() as object
content = CreateObject("roSGNode", "ContentNode")
' TODO:P2 test if video data is reachable (head?)
' TODO:P2 test if video data is reachable in proxy mode (local=true)
content.AppendChild(CreateTestNode("Valid url", IsValidUrl))
content.AppendChild(CreateTestNode("Instance reachable", IsReachable))
content.AppendChild(CreateTestNode("Fetch video details", CanFetchVideoDetails))
@@ -1,11 +1,3 @@
function Init()
m.authorLabel = m.top.FindNode("authorLabel")
m.subCountLabel = m.top.FindNode("subCountLabel")
m.videoCountLabel = m.top.FindNode("videoCountLabel")
m.thumbnail = m.top.FindNode("thumbnail")
m.thumbnail.failedBitmapUri = "pkg:/images/thumbnail-missing.jpg"
end function
function OnContentSet() as void
content = m.top.itemContent
@@ -14,8 +6,8 @@ function OnContentSet() as void
end if
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
m.authorLabel.text = content._author
m.subCountLabel.text = content.subCountText
m.videoCountLabel.text = content.videoCountText
m.thumbnail.uri = content.thumbnail
m.top._author = content._author
m.top.subCountText = content.subCountText
m.top.videoCountText = content.videoCountText
m.top.thumbnail = content.thumbnail
end function
@@ -1,7 +1,11 @@
<component name="ChannelRowCell" extends="Group">
<interface>
<field id="itemContent" type="node" onChange="OnContentSet" />
<field id="type" type="string" value="channel" />
<field id="_author" type="string" alias="authorLabel.text" />
<field id="subCountText" type="string" alias="subCountLabel.text" />
<field id="videoCountText" type="string" alias="videoCountLabel.text" />
<field id="thumbnail" type="uri" alias="thumbnail.uri" />
<field id="itemContent" type="node" onChange="OnContentSet" />
</interface>
<children>
<LayoutGroup
@@ -10,7 +14,8 @@
<CirclePoster
id="thumbnail"
width="196"
height="196" />
height="196"
failedBitmapUri="pkg:/images/thumbnail-missing.jpg" />
<Label
id="authorLabel"
@@ -3,6 +3,10 @@ import "pkg:/source/utils/TimeUtils.bs"
import "pkg:/source/utils/Types.bs"
function Init()
FindChildren()
end function
function FindChildren()
m.titleLabel = m.top.FindNode("titleLabel")
m.authorLabel = m.top.FindNode("authorLabel")
m.viewCountDateLabel = m.top.FindNode("viewCountDateLabel")
@@ -11,7 +15,6 @@ function Init()
m.durationRect = m.top.FindNode("durationRect")
m.durationLabel = m.top.FindNode("durationLabel")
m.thumbnail = m.top.FindNode("thumbnail")
m.thumbnail.failedBitmapUri = "pkg:/images/thumbnail-missing.jpg"
end function
function OnContentSet() as void
@@ -21,6 +24,10 @@ function OnContentSet() as void
return
end if
if m.titleLabel = invalid
FindChildren()
end if
m.titleLabel.text = content.title
m.authorLabel.text = content.author
@@ -10,7 +10,8 @@
id="thumbnail"
loadDisplayMode="scaleToZoom"
width="350"
height="196">
height="196"
failedBitmapUri="pkg:/images/thumbnail-missing.jpg">
<Rectangle
id="durationRect"
width="60"
@@ -36,6 +36,18 @@ function VideoRowListRowContentTask(input as object) as object
success: true
}
end if
' Invidious returns 500 and "{"error":"Closed stream"}" when the Popular feed is disabled
' TODO:P2 check the endpoint.name instead of contentNode.title to avoid conflict with other feeds
if contentNode.title = "Popular" and response.error.instr("Closed stream") > 0
LogWarn("Deleting feed", contentNode.title, "-", response.error)
parent = contentNode.getParent()
parent.removeChild(contentNode)
return {
success: true
}
end if
contentNode.loadState = FeedLoadState.Error
contentNode.title += " (Failed to load)"
return response
@@ -198,10 +198,15 @@ function OnVideoPlayerStateChange() as void
messageLines.push(`errorStr: ${m.top.errorStr}`)
errorInfo = m.top.errorInfo
for each info in errorInfo
messageLines.push(`${info}: ${errorInfo[info]}`)
end for
DialogUtils.ShowDialog(messageLines, `Error playing video ${m.top.content.videoId}`, true)
if errorInfo <> invalid
for each info in errorInfo
messageLines.push(`${info}: ${errorInfo[info]}`)
end for
end if
title = `Error playing video ${m.top.content.videoId}`
LogError(title, messageLines)
DialogUtils.ShowDialog(messageLines, title, true)
' TODO:P1 play next video in the queue after showing the error dialog
VideoUtils.CloseVideo()
end if
@@ -1,3 +1,4 @@
import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/StringUtils.bs"
@@ -6,6 +7,17 @@ namespace VideoUtils
CloseVideo(false)
container = GetVideoContainer()
' There should be no reason for this to be invalid, but there was a crash report
' with this being invalid, so we'll abort playing a video and try to restore focus to the top screen
if container = invalid
LogError("VideoContainer not found! Attempting to restore focus to top screen...")
appController = m.top.getScene().findNode("AppController")
if appController <> invalid
appController@.FocusTopScreen(invalid)
end if
DialogUtils.ShowDialog(`VideoContainer not found!\nPlease try again. If the problem persist, contact Playlet authors.`, "Error playing video")
return
end if
videoPlayer = container.createChild("videoPlayer")
videoPlayer.id = "VideoPlayer"
videoPlayer@.BindNode(invalid)
@@ -81,6 +93,18 @@ namespace VideoUtils
player.control = "resume"
end function
function TogglePause() as void
player = GetVideoPlayer()
if player = invalid
return
end if
if player.state = "playing"
player.control = "pause"
else if player.state = "paused"
player.control = "resume"
end if
end function
end namespace
@@ -141,6 +141,7 @@ namespace Http
if m.headers["Content-Length"] = invalid
m.ready_for_response = true
if m.body.len() > 0
' TODO:P2 send a "411 Length Required" response
LogError("invalid request: request body found, but no Content-Length header")
return false
else
File renamed without changes.

Before

Width:  |  Height:  |  Size: 334 B

After

Width:  |  Height:  |  Size: 334 B

@@ -0,0 +1,11 @@
{
inputHash: 'b88a05052cd01cb7a89bd6802418d79e',
outputs: [
{
outputFilePath: 'src/images/icons/filters-black.png',
outputHash: 'f0a7539ae840c00a2d91292f993bb75e',
width: 64,
height: 64,
},
],
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 334 B

After

Width:  |  Height:  |  Size: 334 B

@@ -0,0 +1,11 @@
{
inputHash: 'df7918a3b43642f707cc0d9fcfd2d9ee',
outputs: [
{
outputFilePath: 'src/images/icons/filters-white.png',
outputHash: '914e2c8da9772c23c24bebbd39c918f2',
width: 64,
height: 64,
},
],
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 330 B

After

Width:  |  Height:  |  Size: 330 B

@@ -0,0 +1,11 @@
{
inputHash: '788d5e9ddc5a26953392afa17a85a05c',
outputs: [
{
outputFilePath: 'src/images/icons/home.png',
outputHash: '3da3ed864137ace837ef2f96a4e5e13d',
width: 64,
height: 64,
},
],
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

@@ -0,0 +1,11 @@
{
inputHash: '92a5720049ca36c38c695969534c2bb5',
outputs: [
{
outputFilePath: 'src/images/icons/info.png',
outputHash: '31b5c5c342ded1bc99b3466c2fbaaf09',
width: 64,
height: 64,
},
],
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 1021 B

After

Width:  |  Height:  |  Size: 1021 B

@@ -0,0 +1,11 @@
{
inputHash: 'e6318f56ce4c0cc637cf0cc3180a2013',
outputs: [
{
outputFilePath: 'src/images/icons/phone.png',
outputHash: '2d7ece94b64fa5a725adeea5a313cbcf',
width: 64,
height: 64,
},
],
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 542 B

After

Width:  |  Height:  |  Size: 542 B

@@ -0,0 +1,11 @@
{
inputHash: 'dede98d4bf3c835836c82c485600108c',
outputs: [
{
outputFilePath: 'src/images/icons/search.png',
outputHash: '5b5fb4128202a1e074b04ee570bbcf69',
width: 64,
height: 64,
},
],
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

@@ -0,0 +1,11 @@
{
inputHash: '11d4a0bfa1ae239216088d825851ec4a',
outputs: [
{
outputFilePath: 'src/images/icons/settings.png',
outputHash: '1b6d024df95af8b002e469453e29a632',
width: 64,
height: 64,
},
],
}
+1 -1
View File
@@ -3,7 +3,7 @@ title=PlayletLib
# Do not update version manually, it is auto updated from package.json
major_version=0
minor_version=13
build_version=00000
build_version=00001
ui_resolutions=hd
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-web",
"version": "0.13.0",
"version": "0.13.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "playlet-web",
"version": "0.13.0",
"version": "0.13.1",
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^2.4.5",
"@tailwindcss/typography": "^0.5.10",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-web",
"version": "0.13.0",
"version": "0.13.1",
"type": "module",
"scripts": {
"dev": "vite",
-7
View File
@@ -1,7 +0,0 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
],
"rangeStrategy": "replace"
}
+116
View File
@@ -0,0 +1,116 @@
// This plugin converts svg files to png/jpeg files
import {
CompilerPlugin, ProgramBuilder,
} from 'brighterscript';
import { readFileSync, renameSync, rmSync, writeFileSync } from 'fs';
import { existsSync } from 'fs-extra';
import { globSync } from 'glob';
import md5 from 'crypto-js/md5';
import { join as joinPath, relative as relativePath } from 'path';
import json5 from 'json5';
const shell = require('shelljs');
const META_EXT = '.meta.json5';
export class ImageGenPlugin implements CompilerPlugin {
public name = 'ImageGenPlugin';
beforeProgramCreate(builder: ProgramBuilder) {
// Debug flag
// @ts-ignore
const debug = !!builder.options.debug;
if (debug) {
// Since the plugin does a lot of scanning of files, it is fine not to run it in debug mode
// The change will be picked up on release
return;
}
const rootDir = builder.options.rootDir!;
const svgFiles = globSync(`**/*.svg`, { cwd: rootDir });
svgFiles.forEach((svg) => {
// Web app can use svg files, no need to convert
if (svg.includes('www')) {
return;
}
const svgFile = relativePath(process.cwd(), joinPath(rootDir, svg));
const metafile = `${svgFile}${META_EXT}`;
if (!existsSync(metafile)) {
this.createDefaultMetaFile(svgFile, metafile);
}
const meta = json5.parse(readFileSync(metafile, 'utf8'));
this.generateImages(svgFile, meta, metafile);
});
}
createDefaultMetaFile(svgFile: string, metafile: string) {
const meta = {
inputHash: '',
outputs: [{
outputFilePath: svgFile.replace('.svg', '.png'),
outputHash: '',
width: 64,
height: 64,
}]
}
writeFileSync(metafile, json5.stringify(meta, null, 2));
}
generateImages(svgFile: string, meta: any, metafile: string) {
let metaChanged = false;
const inputHash = this.checkFileHash(svgFile, meta.inputHash);
if (!inputHash.valid) {
meta.inputHash = inputHash.hash;
metaChanged = true;
}
for (var i in meta.outputs) {
const output = meta.outputs[i];
let outputHash = this.checkFileHash(output.outputFilePath, output.outputHash);
if (inputHash.valid && outputHash.valid) {
continue;
}
this.generateImage(svgFile, output);
outputHash = this.checkFileHash(output.outputFilePath, output.outputHash);
output.outputHash = outputHash.hash;
metaChanged = true;
}
if (metaChanged) {
writeFileSync(metafile, json5.stringify(meta, null, 2));
}
}
generateImage(svgFile: string, output: any) {
shell.exec(`node ../tools/convert-image.js --input "${svgFile}" --options '${JSON.stringify(output)}'`)
}
checkFileHash(file: string, hash: string) {
if (!existsSync(file)) {
return {
valid: false,
hash: ''
}
}
const outputHash = md5(readFileSync(file, 'binary')).toString();
return {
valid: outputHash === hash,
hash: outputHash
}
}
}
export default () => {
return new ImageGenPlugin();
};
+19
View File
@@ -0,0 +1,19 @@
// Description: Converts SVGs to PNGs and resizes them to the correct dimensions.
const { ArgumentParser } = require('argparse')
const { convertFile } = require('convert-svg-to-png');
(async () => {
const parser = new ArgumentParser({
description: 'Sync Youtube profile with Invidious'
});
parser.add_argument('--input', { help: 'Input file path' });
parser.add_argument('--options', { help: 'Options as json string' });
const args = parser.parse_args()
const input = args.input
const options = JSON.parse(args.options)
await convertFile(input, options);
})();
-79
View File
@@ -1,79 +0,0 @@
// Description: Generates images for the project.
// Converts SVGs to PNGs and resizes them to the correct dimensions.
const fs = require('fs');
const path = require('path');
const { convertFile } = require('convert-svg-to-png');
const logoPoster = './playlet-app/src/images/vector/logo-light.svg';
const logoSplash = './playlet-app/src/images/vector/logo-dark.svg';
const logoOutput = {
// Logo
"splash-screen_fhd.jpg": {
width: 1920,
height: 1080,
background: "#242424",
from: logoSplash
},
"splash-screen_hd.jpg": {
width: 1280,
height: 720,
background: "#242424",
from: logoSplash
},
"splash-screen_sd.jpg": {
width: 720,
height: 480,
background: "#242424",
from: logoSplash
},
"channel-poster_fhd.png": {
width: 540,
height: 405,
background: "#FFFFFF",
from: logoPoster
},
"channel-poster_hd.png": {
width: 290,
height: 218,
background: "#FFFFFF",
from: logoPoster
},
"channel-poster_sd.png": {
width: 246,
height: 140,
background: "#FFFFFF",
from: logoPoster
},
};
const iconsInput = './playlet-lib/src/images/vector/icons';
const iconsOutput = './playlet-lib/src/images/icons';
(async () => {
for (var logo in logoOutput) {
await convertFile(logoOutput[logo].from, {
outputFilePath: './playlet-app/src/images/' + logo,
background: logoOutput[logo].background,
height: logoOutput[logo].height,
width: logoOutput[logo].width,
});
console.log(`Generated ${logo}`);
}
const iconFiles = fs.readdirSync(iconsInput);
for (var i in iconFiles) {
const input = path.join(iconsInput, iconFiles[i]);
const output = path.join(iconsOutput, iconFiles[i].replace('.svg', '.png'));
await convertFile(input, {
outputFilePath: output,
width: 64,
height: 64,
});
console.log(`Generated ${output}`);
}
})();