Create Component Library (#43)

* Move src under playlet-lib

* Update configuration

* Update script

* Update script

* Working version

* Vs code config WIP

* Package lock sync

* Lint fix

* Fix images

* Reuse config files

* Kind of a working setup

* Lock node version

* Rename scripts to tools

* Fix build scripts, lib url system

* Lint fix

* rale

* Fix args and web server

* Load fallbacks and build script cleanups

* Remove unused method

* no message

* no message

* Remove generic message field

* Lint fix

* no message

* Use loading indicator on main app

* Add playlet lib version to settings

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
Brahim Hadricheandgithub-action linter authored and GitHub committed 2023-01-29 16:50:28 -05:00
1 parent 90df81df4b
commit 9d8a3d1cea
156 files changed
+3341 -213

No files matched your search

+2 -1
View File
@@ -3,6 +3,7 @@ out/
node_modules
.vscode/.env
**/roku_modules/**
playlet-lib/src/www
playlet/src/lib/playlet-lib.zip
release/playlet.zip
release/playlet.pkg
src/www
+1
View File
@@ -0,0 +1 @@
engine-strict=true
+15 -16
View File
@@ -10,23 +10,22 @@
"stopOnEntry": false,
"enableDebuggerAutoRecovery": false,
"stopDebuggerOnAppExit": false,
"rootDir": "${workspaceFolder}/dist/build",
"preLaunchTask": "build-dev",
"rootDir": "${workspaceFolder}/dist/build/playlet",
"sourceDirs": [
"${workspaceFolder}/playlet/src",
"${workspaceFolder}/playlet-lib/src"
],
"files": [
"**/*",
],
"preLaunchTask": "build",
"name": "Playlet (dev)",
"injectRdbOnDeviceComponent": true
},
{
"type": "brightscript",
"request": "launch",
"envFile": "${workspaceFolder}/.vscode/.env",
"host": "${env:ROKU_DEV_TARGET}",
"password": "${env:ROKU_DEVPASSWORD}",
"stopOnEntry": false,
"enableDebuggerAutoRecovery": false,
"stopDebuggerOnAppExit": false,
"rootDir": "${workspaceFolder}/dist/build",
"preLaunchTask": "build-prod",
"name": "Playlet (prod)"
"injectRdbOnDeviceComponent": true,
"injectRaleTrackerTask": true,
// TODO: change to ${workspaceFolder}/tools/RALE/TrackerTask.xml
// Once https://github.com/rokucommunity/vscode-brightscript-language/pull/462
// is released (after v2.38.7)
"raleTrackerTaskFileLocation": "/Users/brahim/Roku/playlet/tools/RALE/TrackerTask.xml"
},
{
"command": "npm run dev:web",
+3
View File
@@ -0,0 +1,3 @@
{
"brightscript.output.clearConsoleOnChannelStart": false
}
+22 -15
View File
@@ -2,23 +2,30 @@
"version": "2.0.0",
"tasks": [
{
"label": "build-dev",
"presentation": {
"close": true,
"reveal": "silent",
"revealProblems": "onProblem"
},
"script": "build:dev",
"type": "npm"
"label": "build",
"dependsOn": [
"build-app"
]
},
{
"label": "build-prod",
"presentation": {
"close": true,
"reveal": "silent",
"revealProblems": "onProblem"
},
"script": "build:prod",
"label": "build-app",
"script": "build:app:dev",
"type": "npm",
"dependsOn": [
"build-lib"
]
},
{
"label": "build-lib",
"script": "build:lib:dev",
"type": "npm",
"dependsOn": [
"build-web"
]
},
{
"label": "build-web",
"script": "build:web",
"type": "npm"
}
]
-5
View File
@@ -1,5 +0,0 @@
{
"extends": "config/bsconfig.base.json",
"host": "If your Roku IP is static, you can set it here and remove the host entry from .vscode/launch.json",
"password": ""
}
+6 -5
View File
@@ -12,16 +12,19 @@
"source/**/*",
"components/**/*",
"images/**/*",
"!images/vector/**/*",
"fonts/**/*",
"config/**/*",
"lib/**/*",
"www/**/*.*",
"manifest"
],
"lintConfig": "config/bslint.jsonc",
"lintConfig": "./config/bslint.jsonc",
"plugins": [
"roku-log-bsc-plugin",
"@rokucommunity/bslint",
"../scripts/asynctask-plugin.ts"
"../tools/asynctask-plugin.ts",
"../tools/manifest-bsconst-debug-plugin.ts"
],
"retainStagingDir": true,
"require": [
@@ -32,7 +35,5 @@
"removeComments": false,
"strip": false
},
"rootDir": "../src/",
"sourceMap": true,
"stagingDir": "dist/build"
"sourceMap": true
}
+3
View File
@@ -28,6 +28,9 @@
"semver": "^7.3.8",
"ts-node": "^10.9.1",
"typescript": "^4.9.4"
},
"engines": {
"node": "<19.0.0"
}
},
"node_modules/@cspotcode/source-map-support": {
+21 -16
View File
@@ -16,15 +16,17 @@
"convert-svg-to-png": "^0.6.4",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"ip": "^1.1.8",
"roku-log-bsc-plugin": "^0.7.0",
"ropm": "^0.10.11",
"semver": "^7.3.8",
"ts-node": "^10.9.1",
"typescript": "^4.9.4"
},
"engines": {
"node": "<19.0.0"
},
"ropm": {
"rootDir": "src",
"rootDir": "playlet-lib/src",
"noprefix": [
"roku-requests"
]
@@ -32,23 +34,26 @@
"scripts": {
"dev:web": "cd playlet-web && npm run dev",
"prebuild": "rm -rf dist",
"build:dev": "npm run build:web && npm run build:lib:dev && npm run build:app:dev",
"build:prod": "npm run build:web && npm run build:lib:prod && npm run build:app:prod",
"build:release": "npm run format:fix && npm run lint:fix && npm run manifest-version && npm run generate-images && npm run build:prod && npm run sign-package",
"build:app": "cd playlet && bsc --create-package --lintConfig ../config/bslint.jsonc",
"build:app:dev": "npm run build:app -- --debug=true",
"build:app:prod": "npm run build:app -- --debug=false --sourceMap=false",
"build:lib": "cd playlet-lib && bsc --create-package --lintConfig ../config/bslint.jsonc",
"build:lib:dev": "npm run build:lib -- --debug=true",
"build:lib:prod": "npm run build:lib -- --debug=false --sourceMap=false",
"build:web": "cd playlet-web && npm run build",
"build": "npm run build:web && bsc",
"build:dev": "npm run manifest-symbols -- DEBUG=true && npm run build",
"build:prod": "npm run manifest-symbols -- DEBUG=false && npm run build -- --sourceMap=false",
"build:release": "npm run format:fix && npm run lint:fix && npm run manifest-version && npm run generate-images && npm run build:prod && npm run zip-package && npm run sign-package",
"lint": "bslint --project config/bsconfig.lint.json --lintConfig config/bslint.jsonc",
"lint": "bslint --project playlet-lib/bsconfig.lint.json --lintConfig config/bslint.jsonc && bslint --project playlet/bsconfig.lint.json --lintConfig config/bslint.jsonc",
"lint:fix": "npm run lint -- --fix",
"format:base": "bsfmt \"src/**/*.brs\" \"src/**/*.bs\" \"!src/components/lib/**/*\" \"!src/source/lib/**/*\" \"!**/bslib.brs\" \"!**/roku_modules/**/*\" --bsfmt-path \"config/bsfmt.jsonc\"",
"format:base": "bsfmt \"playlet/src/**/*.brs\" \"playlet/src/**/*.bs\" \"!playlet/src/components/lib/**/*\" \"!playlet/src/source/lib/**/*\" \"!**/bslib.brs\" \"!**/roku_modules/**/*\" \"playlet-lib/src/**/*.brs\" \"playlet-lib/src/**/*.bs\" \"!playlet-lib/src/components/lib/**/*\" \"!playlet-lib/src/source/lib/**/*\" \"!**/bslib.brs\" \"!**/roku_modules/**/*\" --bsfmt-path \"config/bsfmt.jsonc\"",
"format": "npm run format:base -- --check",
"format:fix": "npm run format:base -- --write",
"generate-images": "node scripts/generate-images.js",
"manifest-version": "node scripts/update-manifest-version.js",
"zip-package": "node scripts/zip-package.js",
"sign-package": "node scripts/sign-package.js",
"screenshot": "node scripts/screenshot.js",
"manifest-symbols": "node scripts/update-manifest-symbols.js",
"profile-sync": "node scripts/profile-sync.js",
"generate-images": "node tools/generate-images.js",
"manifest-version": "node tools/update-manifest-version.js",
"sign-package": "node tools/sign-package.js",
"screenshot": "node tools/screenshot.js",
"profile-sync": "node tools/profile-sync.js",
"postinstall": "npx ropm copy && cd playlet-web && npm install"
}
}
}
+6
View File
@@ -0,0 +1,6 @@
{
"extends": "../config/bsconfig.base.json",
"rootDir": "src/",
"stagingDir": "../dist/build/playlet-lib",
"outFile": "../playlet/src/lib/playlet-lib.zip"
}
@@ -1,7 +1,7 @@
{
"createPackage": false,
"deploy": false,
"extends": "bsconfig.base.json",
"extends": "bsconfig.json",
"retainStagingDir": false,
"sourceMap": false
}
File renamed without changes.
@@ -8,8 +8,6 @@ function Init()
m.top.ObserveField("focus", "OnFocusChange")
m.top.ObserveField("refresh", "OnRefresh")
m.top.focus = true
InitContent()
end function
@@ -32,7 +30,7 @@ function InitContent()
}, true)
m.top.content = contentNode
m.defaultLayout = ParseJson(ReadAsciiFile("pkg:/config/default_home_layout.json"))
m.defaultLayout = ParseJson(ReadAsciiFile("libpkg:/config/default_home_layout.json"))
if m.defaultLayout.Count() > 0
m.currentLoadingIndex = 0
@@ -4,20 +4,15 @@ import "pkg:/components/VideoPlayer/Video.bs"
function Init()
log.initializeLogManager(["log_PrintTransport"], 2)
m.top.backgroundColor = "0x242424FF"
m.top.backgroundURI = ""
m.loadingIndicator = m.top.findNode("LoadingIndicator")
m.videoContainer = m.top.findNode("VideoContainer")
m.global.addFields({
loadingIndicator: m.loadingIndicator,
videoContainer: m.videoContainer
})
m.loadingIndicator.visible = true
m.homeGridScreen = m.top.findNode("HomeGridScreen")
m.homeGridScreen.ObserveField("escape", "OnHomeGridScreenEscape")
m.homeGridScreen.SetFocus(true)
m.currentFocued = m.homeGridScreen
m.settingsScreen = m.top.findNode("SettingsScreen")
@@ -28,9 +23,12 @@ function Init()
m.navBar.ObserveField("escapeIndex", "OnNavBarEscape")
m.navBar.ObserveField("focusIndex", "OnNavIndexChange")
m.currentFocued = m.homeGridScreen
InitWebServer()
LaunchArgumentsReceived()
scene = m.top.getScene()
scene.ObserveField("inputArgs", "InputArgumentsReceived")
end function
function InitWebServer()
@@ -97,25 +95,18 @@ function OnWebServerCommand()
end if
end function
function GetIndexOfChild(parent as object, childId as string) as integer
count = parent.getChildCount()
for i = 0 to count - 1
child = parent.getChild(i)
if child.id = childId
return i
end if
end for
return -1
end function
function LaunchArgumentsReceived() as void
? "LaunchArgumentsReceived" m.top.launchArgs
PlayVideoFromArgs(m.top.launchArgs)
scene = m.top.getScene()
launchArgs = scene.launchArgs
? "LaunchArgumentsReceived " launchArgs
PlayVideoFromArgs(launchArgs)
end function
function InputArgumentsReceived() as void
? "InputArgumentsReceived" m.top.inputArgs
PlayVideoFromArgs(m.top.inputArgs)
scene = m.top.getScene()
inputArgs = scene.inputArgs
? "InputArgumentsReceived " inputArgs
PlayVideoFromArgs(inputArgs)
end function
function PlayVideoFromArgs(args as object) as void
@@ -128,8 +119,10 @@ function PlayVideoFromArgs(args as object) as void
' bs:disable-next-line
mediaType = args.mediaType
if contentId <> invalid
sender = m.videoContainer.sender ?? m.currentFocued
PlayVideo(contentId, { sender: sender })
if contentId = invalid
return
end if
sender = m.videoContainer.sender ?? m.currentFocued
PlayVideo(contentId, { sender: sender })
end function
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<component name="MainScene" extends="Group">
<children>
<SearchScreen id="SearchScreen" visible="false" />
<HomeGridScreen id="HomeGridScreen" />
<SettingsScreen id="SettingsScreen" visible="false" />
<NavBar id="NavBar" />
<VideoContainer id="VideoContainer" />
</children>
</component>
@@ -51,7 +51,7 @@ function OnExitDialog(event as object)
buttonIndex = event.GetData()
if buttonIndex = 0 ' Exit
? "EXITING APP"
m.top.GetScene().exitChannel = true
m.top.getScene().exitChannel = true
end if
end function
@@ -1,13 +1,15 @@
import "pkg:/source/utils/General.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/asyncTask/asyncTask.bs"
import "pkg:/components/SettingsScreen/AppVersionTask.bs"
function Init()
m.versionLabel = m.top.findNode("VersionLabel")
m.top.url = `http://${GetLocalIpAddress()}:8888`
appInfo = GetAppInfo()
m.currentVersion = appInfo.version
SetVersionLabel(m.currentVersion, "N/A")
m.appInfo = GetAppInfo()
SetVersionLabel(m.appInfo.version, m.appInfo.lib_version, "N/A")
GetLatestVersion()
end function
@@ -24,11 +26,11 @@ end function
function GetLatestVersion()
StartAsyncTask(AppVersionTask, {}, function(output as object) as void
if output.result.latest <> invalid
SetVersionLabel(m.currentVersion, output.result.latest)
SetVersionLabel(m.appInfo.version, m.appInfo.lib_version, output.result.latest)
end if
end function)
end function
function SetVersionLabel(current as string, latest as string)
m.versionLabel.text = `Version: ${current} | Latest: ${latest}`
function SetVersionLabel(appVersion as string, libVersion as string, latest as string)
m.versionLabel.text = `Playlet: ${appVersion} | Playlet-Lib: ${libVersion} | Latest: ${latest}`
end function
@@ -88,6 +88,12 @@ namespace Http
m.source = Http.HttpResponseSource.GENERATED
end function
function SetBodyDataBuffer(buffer as object)
m.body_buffer = buffer
m.body_buffer_length = m.body_buffer.count()
m.ContentLength(m.body_buffer_length)
end function
function SetBodyDataString(data as string)
m.body_buffer.fromasciistring(data)
m.body_buffer_length = m.body_buffer.count()
@@ -7,8 +7,9 @@ namespace Http
private route
private showDirectories
private showHidden
private fsCheck
function new(route as string, root as string, showDirectories = false as boolean, showHidden = false as boolean)
function new(route as string, root as string, showDirectories = false as boolean, showHidden = false as boolean, fsCheck = true as boolean)
super()
m.log = new log.Logger("HttpStaticFilesRouter")
@@ -16,6 +17,7 @@ namespace Http
m.route = route
m.showDirectories = showDirectories
m.showHidden = showHidden
m.fsCheck = fsCheck
m.Get("*", function(context as object) as boolean
router = context.router
@@ -31,6 +33,19 @@ namespace Http
decoded_path = path_in_route.DecodeUri()
full_path = PathJoin(router.root, decoded_path)
if not router.fsCheck
' libpkg:/ does not work with roFilesystem...
buffer = createObject("roByteArray")
if buffer.ReadFile(full_path) and buffer.count() > 0
mimetype = WebUtils.MimeType(decoded_path)
response.SetBodyDataBuffer(buffer)
response.ContentType(mimetype)
response.http_code = 200
response.source = Http.HttpResponseSource.GENERATED
return true
end if
end if
path = CreateObject("roPath", full_path)
fs = CreateObject("roFilesystem")
@@ -21,7 +21,7 @@ function WebServerLoop()
m.settings = new Http.HttpSettings(m.webServerPort)
' Root at www to get http://IP_ADDRESS:PORT/index.html
m.settings.WwwRoot = "pkg:/www"
m.settings.WwwRoot = "libpkg:/www"
' Short interval to keep polling on web socket messages
m.settings.Timeout = 500
m.server = new Http.HttpServer(m.settings, m)
@@ -43,11 +43,11 @@ function WebServerLoop()
return true
end function)
#if DEBUG
if IsDebugMode()
allowedOrigin = "*"
#else
else
allowedOrigin = `http://${GetLocalIpAddress()}:8888`
#end if
end if
m.server.UseRouter(new Http.CorsMiddleware(allowedOrigin))
#if WEB_SOCKETS
m.server.UseRouter(new Http.WebSocketMiddleware())
@@ -57,13 +57,14 @@ function WebServerLoop()
m.server.UseRouter(new Http.CommandsApiRouter())
m.server.UseRouter(new Http.StateApiRouter())
m.server.UseRouter(new Http.InvidiousRouter())
m.server.UseRouter(new Http.HttpStaticFilesRouter("/", m.settings.WwwRoot))
#if DEBUG
m.server.UseRouter(new Http.HttpStaticFilesRouter("/", m.settings.WwwRoot, false, false, false))
if IsDebugMode()
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/libpkg", "libpkg:/", true, true, false))
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/pkg", "pkg:/", true, true))
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/tmp", "tmp:/", true, true))
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/cachefs", "cachefs:/", true, true))
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/common", "common:/", true, true))
#end if
end if
#if WEB_SERVER_BASIC_AUTH
m.server.UseRouter(new Http.BasicAuthMiddleware())
#end if
@@ -5,4 +5,5 @@
<field id="login" type="boolean" alwaysNotify="true" />
<field id="command" type="string" alwaysNotify="true" />
</interface>
<script type="text/brightscript" uri="pkg:/source/utils/Debug.bs" />
</component>
File renamed without changes.

Before

Width:  |  Height:  |  Size: 292 B

After

Width:  |  Height:  |  Size: 292 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 483 B

After

Width:  |  Height:  |  Size: 483 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 925 B

After

Width:  |  Height:  |  Size: 925 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Loaded 100 of 156 files, more files were not shown because too many files have changed in this diff. Show more