From ae376237564b33d46229bcb745ed80820d314a29 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 2 Feb 2023 14:55:38 -0500 Subject: [PATCH] json playlet lib urls --- .vscode/launch.json | 22 ++++++++++++- .vscode/tasks.json | 32 ++++++++++++++++--- .../BootstrapScene/BootstrapScene.bs | 27 +++++++--------- playlet/src/source/Registry.bs | 9 ++++++ 4 files changed, 68 insertions(+), 22 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 75d415a8..f9a0524f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -18,12 +18,32 @@ "files": [ "**/*", ], - "preLaunchTask": "build", + "preLaunchTask": "build-dev", "name": "Playlet (dev)", "injectRdbOnDeviceComponent": true, "injectRaleTrackerTask": true, "raleTrackerTaskFileLocation": "${workspaceFolder}/tools/RALE/TrackerTask.xml" }, + { + "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/playlet", + "sourceDirs": [ + "${workspaceFolder}/playlet/src", + "${workspaceFolder}/playlet-lib/src" + ], + "files": [ + "**/*", + ], + "preLaunchTask": "build-prod", + "name": "Playlet (prod)" + }, { "command": "npm run dev:web", "name": "Playlet Web (Dev)", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index e51455a6..0f7d4020 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -2,27 +2,49 @@ "version": "2.0.0", "tasks": [ { - "label": "build", + "label": "build-dev", "dependsOn": [ - "build-app" + "build-app-dev" ] }, { - "label": "build-app", + "label": "build-app-dev", "script": "build:app:dev", "type": "npm", "dependsOn": [ - "build-lib" + "build-lib-dev" ] }, { - "label": "build-lib", + "label": "build-lib-dev", "script": "build:lib:dev", "type": "npm", "dependsOn": [ "build-web" ] }, + { + "label": "build-prod", + "dependsOn": [ + "build-app-prod" + ] + }, + { + "label": "build-app-prod", + "script": "build:app:prod", + "type": "npm", + "dependsOn": [ + "build-lib-prod" + ] + }, + { + "label": "build-lib-prod", + "script": "build:lib:prod", + "type": "npm", + "dependsOn": [ + "build-web" + ] + }, { "label": "build-web", "script": "build:web", diff --git a/playlet/src/components/BootstrapScene/BootstrapScene.bs b/playlet/src/components/BootstrapScene/BootstrapScene.bs index 751897d1..86d6f674 100644 --- a/playlet/src/components/BootstrapScene/BootstrapScene.bs +++ b/playlet/src/components/BootstrapScene/BootstrapScene.bs @@ -15,29 +15,28 @@ function Init() as void end function function GetPlayletLibUrls() as object + savedUrls = GetPlayletLibUrlsFromRegistry() + if savedUrls <> invalid + m.shouldClearRegistryOnLoadFail = true + return savedUrls + end if + github = { type: "github", link: ReadManifestValue("playlet_lib_remote_url") } embedded = { type: "embedded", link: ReadManifestValue("playlet_lib_embedded_url") } - registry = { type: "registry", link: ReadRegistryKey("playlet_lib_url", "Playlet") } #if DEBUG return [embedded] + #else + return [github, embedded] #end if - - urls = [] - - if registry.link <> invalid - urls.Push(registry) - end if - - urls.push(github) - urls.push(embedded) - - return urls end function function LoadPlayletLib() as void if m.playletLibUrlIndex >= m.playletLibUrls.Count() m.loadingIndicator.visible = false + if m.shouldClearRegistryOnLoadFail = true + DeleteRegistryKey("playlet_lib_urls", "Playlet") + end if ShowPlayletLibLoadErrorDialog() return end if @@ -64,10 +63,6 @@ function OnLoadStatusChanged() as void if m.lib.loadStatus = "failed" ?"Playlet lib failed to load from " uri - if m.playletLibUrls[m.playletLibUrlIndex].type = "registry" - ' Delete library url from registry since it failed - DeleteRegistryKey("playlet_lib_url", "Playlet") - end if ' Try next url m.playletLibUrlIndex += 1 LoadPlayletLib() diff --git a/playlet/src/source/Registry.bs b/playlet/src/source/Registry.bs index 7484a8a9..606760c8 100644 --- a/playlet/src/source/Registry.bs +++ b/playlet/src/source/Registry.bs @@ -11,3 +11,12 @@ function DeleteRegistryKey(key as string, section as string) sec.Delete(key) sec.Flush() end function + +function GetPlayletLibUrlsFromRegistry() as object + urlsJson = ReadRegistryKey("playlet_lib_urls", "Playlet") + if urlsJson = invalid + return invalid + end if + urls = ParseJson(urlsJson) + return urls +end function