Compare commits

...
15 Commits
Author SHA1 Message Date
Brahim Hadriche bb0a0725d6 Release 0.20.2 (#311) 2024-02-26 18:57:52 -05:00
Brahim Hadriche f2ffb42876 refactor url encoded form requests 2024-02-26 18:44:57 -05:00
Brahim Hadriche edbfc86e56 changelog 2024-02-26 09:47:18 -05:00
Brahim Hadriche b25eaafc82 Fix for sponsorblock highlight label 2024-02-26 09:46:20 -05:00
Brahim Hadriche ef9c653ad7 Device connected notification only show once every half hour per device to avoid spam 2024-02-25 22:16:01 -05:00
Andrey LazarevichandBrahim Hadriche e9f015bb19 OK button as Play/Pause (#307)
* OK button as Play/Pause

First OK press now shows Video UI.
It's achievable via hidden Roku Video node property `showUI`, which allows you to override how trickplay should be displayed by specifying parts of the UI to be rendered (like 'titleAndTime', 'trickplayBar', e.t.c). A timer is started every time custom UI is shown to prevent UI from staying forever.

Second OK press while UI is visible pauses the video (pause poster animation is not added yet).

However, since we shouldn't break default OK button actions, we must track whether user is seeking in video UI and if they do, fallback to Video internal OK handler.

Also, auto-formatted VideoPlayer.xml

* fix comment typo

* move HideUI function slightly higher

* Addressed the feedback:

* Add a workaround to leave Live video behavior intact (no pause, ok simply switches UI back and forth)
* Hide UI when minimizing to avoid a bug where title and time element could stay forver
* More aggressive `isSeeking` detection, so every left/right/ff/rw button press would cause us to fall back to default OK button handler

* More accurate liveNow handling

* Changelog

---------

Co-authored-by: Brahim Hadriche <brahim.hadriche@gmail.com>
2024-02-25 20:05:11 -05:00
Brahim Hadriche 544671f246 remove old todo 2024-02-25 19:55:13 -05:00
Brahim Hadriche f45ba30979 Colored logs for debugging (#308)
* Colored logs for debugging

* disable colors
2024-02-25 19:06:27 -05:00
Brahim Hadriche 4953e4481f Rename files for consistency 2024-02-24 19:08:43 -05:00
Brahim Hadriche c7b0815768 New focus 9 patch textures 2024-02-24 19:03:12 -05:00
Brahim Hadriche 4ab7f74a4e More adjustments to context menu 2024-02-24 16:58:18 -05:00
Brahim Hadriche 96916f6c37 Formatting 2024-02-24 11:44:03 -05:00
Brahim Hadriche eafad684b6 Small improvement 2024-02-24 11:40:52 -05:00
Brahim Hadriche 14d3e38aeb Tweaks to remote screen UI 2024-02-23 22:21:44 -05:00
afe281c094 [chore] update dependencies (#306)
* update dependencies

* Update package.json

* lock file

---------

Co-authored-by: iBicha <iBicha@users.noreply.github.com>
Co-authored-by: Brahim Hadriche <brahim.hadriche@gmail.com>
2024-02-23 20:04:14 -05:00
45 changed files with 847 additions and 245 deletions

No files matched your search

+16
View File
@@ -5,6 +5,22 @@ 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.20.2] - 2024-02-26
### Added
- Small improvement in the context menu of the Playlist view
- Videos can be paused and resumed using the `Ok` remote button
### Fixed
- `Device connected` notification only show once every 30 minutes per device to avoid spam
- SponsorBlock category "highlight" was not visible in chapter label
### Changed
- UI focus images are now with rounded corners, and with a slight glow
## [0.20.1] - 2024-02-23
### Fixed
+1 -1
View File
@@ -2,7 +2,7 @@ openapi: 3.0.0
info:
title: Playlet Web API
version: 0.20.1
version: 0.20.2
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
+14 -14
View File
@@ -1,18 +1,18 @@
{
"name": "playlet",
"version": "0.20.1",
"version": "0.20.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "playlet",
"version": "0.20.1",
"version": "0.20.2",
"hasInstallScript": true,
"devDependencies": {
"@rokucommunity/bslint": "^0.8.17",
"@types/crypto-js": "^4.2.2",
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.11.19",
"@types/node": "^20.11.20",
"@types/xml2js": "^0.4.14",
"argparse": "^2.0.1",
"brighterscript": "0.65.22",
@@ -20,12 +20,12 @@
"convert-svg-to-png": "^0.6.4",
"cross-fetch": "^4.0.0",
"crypto-js": "^4.2.0",
"dotenv": "^16.4.4",
"dotenv": "^16.4.5",
"express": "^4.18.2",
"fs-extra": "^11.2.0",
"glob": "^10.3.10",
"imap": "^0.8.19",
"ip": "^1.1.8",
"ip": "^2.0.1",
"json5": "^2.2.3",
"mailparser": "^3.6.7",
"roku-deploy": "^3.11.2",
@@ -370,9 +370,9 @@
}
},
"node_modules/@types/node": {
"version": "20.11.19",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.19.tgz",
"integrity": "sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ==",
"version": "20.11.20",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.20.tgz",
"integrity": "sha512-7/rR21OS+fq8IyHTgtLkDK949uzsa6n8BkziAKtPVpugIkO6D+/ooXMvzXxDnZrmtXVfjb1bKQafYpb8s89LOg==",
"dev": true,
"dependencies": {
"undici-types": "~5.26.4"
@@ -1706,9 +1706,9 @@
}
},
"node_modules/dotenv": {
"version": "16.4.4",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.4.tgz",
"integrity": "sha512-XvPXc8XAQThSjAbY6cQ/9PcBXmFoWuw1sQ3b8HqUCR6ziGXjkTi//kB9SWa2UwqlgdAIuRqAa/9hVljzPehbYg==",
"version": "16.4.5",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz",
"integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==",
"dev": true,
"engines": {
"node": ">=12"
@@ -2592,9 +2592,9 @@
}
},
"node_modules/ip": {
"version": "1.1.8",
"resolved": "https://registry.npmjs.org/ip/-/ip-1.1.8.tgz",
"integrity": "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz",
"integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==",
"dev": true
},
"node_modules/ipaddr.js": {
+4 -4
View File
@@ -1,12 +1,12 @@
{
"name": "playlet",
"version": "0.20.1",
"version": "0.20.2",
"description": "Unofficial YouTube client for Roku",
"devDependencies": {
"@rokucommunity/bslint": "^0.8.17",
"@types/crypto-js": "^4.2.2",
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.11.19",
"@types/node": "^20.11.20",
"@types/xml2js": "^0.4.14",
"argparse": "^2.0.1",
"brighterscript": "0.65.22",
@@ -14,12 +14,12 @@
"convert-svg-to-png": "^0.6.4",
"cross-fetch": "^4.0.0",
"crypto-js": "^4.2.0",
"dotenv": "^16.4.4",
"dotenv": "^16.4.5",
"express": "^4.18.2",
"fs-extra": "^11.2.0",
"glob": "^10.3.10",
"imap": "^0.8.19",
"ip": "^1.1.8",
"ip": "^2.0.1",
"json5": "^2.2.3",
"mailparser": "^3.6.7",
"roku-deploy": "^3.11.2",
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-app",
"version": "0.20.1",
"version": "0.20.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "playlet-app",
"version": "0.20.1"
"version": "0.20.2"
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-app",
"version": "0.20.1",
"version": "0.20.2",
"description": "Unofficial YouTube client for Roku",
"scripts": {
"prebuild": "rm -rf build/playlet-app",
+1 -1
View File
@@ -3,7 +3,7 @@ title=Playlet
# Do not update version manually, it is auto updated from package.json
major_version=0
minor_version=20
build_version=00001
build_version=00002
ui_resolutions=hd
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-lib",
"version": "0.20.1",
"version": "0.20.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "playlet-lib",
"version": "0.20.1"
"version": "0.20.2"
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-lib",
"version": "0.20.1",
"version": "0.20.2",
"description": "Unofficial YouTube client for Roku",
"scripts": {
"prebuild": "rm -rf build/playlet-lib",
@@ -61,7 +61,7 @@
showRowLabel="[true]"
rowFocusAnimationStyle="floatingfocus"
variableWidthItems="true"
focusBitmapUri="pkg:/images/focus_grid.9.png" />
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png" />
<Animation
id="scrollAnimation"
@@ -71,8 +71,6 @@ import "pkg:/source/utils/Types.bs"
' - "Remove group from Bookmarks"
' - "Reload bookmarks" - DONE
'
' TODO:P1 Playlist item seletected from the bookmarks need to play as a playlist, not as a single video
' TODO:P1 Context menu might need to be scrollable (both horizontally and vertically)
' TODO:P1 Context menu might need sections. Example:
' In a Channel view, while selecting a playlist:
' - Channel
@@ -1,3 +1,4 @@
import "pkg:/source/utils/MathUtils.bs"
import "pkg:/source/utils/Types.bs"
' Based on https://github.com/jellyfin/jellyfin-roku/blob/unstable/components/IconButton.brs
@@ -40,16 +41,11 @@ function setIconSize()
height = m.top.height
width = m.top.width
if height > 0 and width > 0
' TODO: Use smallest number between them
m.buttonIcon.height = m.top.height
iconSize = MathUtils.Min(height, width) - m.top.padding
m.buttonIcon.height = iconSize
m.buttonIcon.width = iconSize
if m.top.padding > 0
m.buttonIcon.height = m.buttonIcon.height - m.top.padding
end if
m.buttonIcon.width = m.buttonIcon.height
m.buttonIcon.translation = [((width - m.buttonIcon.width) / 2), ((height - m.buttonIcon.height) / 2)]
m.buttonIcon.translation = [((width - iconSize) / 2), ((height - iconSize) / 2)]
m.buttonText.translation = [-5, height]
m.buttonText.width = width + 10
end if
@@ -143,9 +143,6 @@ function OnItemLongPressed(index as integer) as void
LogInfo("Long press: playlist:", playlistId, "video:", videoId)
' TODO:P1 handle case of opening the channel
' - Owner of a video
' - Owner of a playlist
contextMenuProviders = [m.top]
ContextMenuUtils.Open(contextMenuProviders, m.appController, video)
end function
@@ -173,8 +170,20 @@ function GetContextMenuOptionsForItem(video as object) as object
ContextMenuUtils.CreateOption("Queue video", m.videoQueue, "FuncAddToQueueVideo", [video]),
]
if not StringUtils.IsNullOrEmpty(playlist.authorId)
options.push(ContextMenuUtils.CreateOption("Open channel", m.top, "OpenPlaylistChannel", [playlist]))
playlistAuthorId = playlist.authorId
videoAuthorId = video.authorId
if not StringUtils.IsNullOrEmpty(playlistAuthorId) or not StringUtils.IsNullOrEmpty(videoAuthorId)
if playlistAuthorId = videoAuthorId
options.push(ContextMenuUtils.CreateOption("Open channel", m.top, "OpenPlaylistChannel", [playlist]))
else
if not StringUtils.IsNullOrEmpty(playlistAuthorId)
options.push(ContextMenuUtils.CreateOption("Open playlist channel", m.top, "OpenPlaylistChannel", [playlist]))
end if
if not StringUtils.IsNullOrEmpty(videoAuthorId)
options.push(ContextMenuUtils.CreateOption("Open video channel", m.top, "OpenVideoChannel", [video]))
end if
end if
end if
options.append(m.bookmarks@.GetMenuForPlaylist(playlist))
@@ -193,6 +202,16 @@ function OpenPlaylistChannel(playlist as object) as void
ChannelUtils.Open(channel)
end function
function OpenVideoChannel(video as object) as void
authorId = video.authorId
if StringUtils.IsNullOrEmpty(authorId)
LogWarn("Invalid authorId:", authorId)
return
end if
channel = InvidiousContent.ToChannelContentNode(invalid, { authorId: authorId }, invalid)
ChannelUtils.Open(channel)
end function
'TODO:P1 a playlist could have been opened from the bookmarks, which can be as old as 3 days
' We should make a request in this case, and let the cache handle freshness.
function LoadPlaylistIfNeeded() as void
@@ -6,6 +6,7 @@
<field id="videoQueue" type="node" bind="/VideoQueue" />
<field id="bookmarks" type="node" bind="/Bookmarks" />
<function name="OpenPlaylistChannel" />
<function name="OpenVideoChannel" />
</interface>
<children>
<Rectangle
@@ -56,8 +57,8 @@
numColumns="1"
numRows="5"
vertFocusAnimationStyle="floatingFocus"
translation="[620,90]" />
translation="[620,90]"
focusBitmapUri="pkg:/images/focus-glow-padding-27.9.png" />
</Poster>
</children>
</component>
@@ -31,7 +31,7 @@
showRowLabel="[true]"
rowFocusAnimationStyle="floatingfocus"
variableWidthItems="true"
focusBitmapUri="pkg:/images/focus_grid.9.png"
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png"
/>
</Group>
</children>
@@ -20,7 +20,7 @@
showRowLabel="[true]"
rowFocusAnimationStyle="floatingfocus"
variableWidthItems="true"
focusBitmapUri="pkg:/images/focus_grid.9.png"
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png"
/>
</children>
</component>
@@ -19,6 +19,7 @@ function Init()
m.linkWithTvPanel = m.top.findNode("LinkWithTvPanel")
m.wifiNameLabel = m.top.findNode("WifiNameLabel")
m.wifiInstructionWithDeviceNameLabel = m.top.findNode("WifiInstructionWithDeviceNameLabel")
m.linkCodeLabel = m.top.findNode("LinkCodeLabel")
end function
@@ -128,6 +129,8 @@ function OnLinkWithWifiPanelVisibleChanged() as void
else
m.wifiNameLabel.text = "N/A"
end if
m.wifiInstructionWithDeviceNameLabel.text = `Tap the cast icon and select "${m.loungeService.deviceName}"`
end function
function OnLinkWithTvPanelVisibleChanged()
@@ -147,6 +150,7 @@ function GeneratePairingCode()
m.linkCodeTask.cancel = true
end if
m.linkCodeLabel.text = "Loading..."
m.linkCodeTask = AsyncTask.Start(Tasks.LoungeGenerateManualPairingCodeTask, {
loungeService: m.loungeService
loungeToken: m.loungeService.loungeToken
@@ -91,6 +91,7 @@
font="font:SmallSystemFont"
text="3." />
<Label
id="WifiInstructionWithDeviceNameLabel"
font="font:SmallSystemFont"
width="380"
wrap="true"
@@ -46,7 +46,7 @@
showRowLabel="[true]"
rowFocusAnimationStyle="floatingfocus"
variableWidthItems="true"
focusBitmapUri="pkg:/images/focus_grid.9.png"
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png"
/>
<Animation
id="scrollAnimation"
@@ -30,12 +30,13 @@
<MarkupGrid
id="instances"
itemComponentName="InvidiousPublicInstancesListItem"
itemSize="[860,16]"
itemSize="[810,16]"
itemSpacing="[0,20]"
numColumns="1"
numRows="7"
vertFocusAnimationStyle="floatingFocus"
translation="[0,46]" />
translation="[0,46]"
focusBitmapUri="pkg:/images/white-border.9.png" />
</children>
</component>
@@ -42,7 +42,7 @@
<Label
id="healthLabel"
font="font:SmallestSystemFont"
width="100"
width="60"
translation="[750,0]" />
</children>
</component>
@@ -11,7 +11,7 @@ function Init()
m.top.iconUri = ""
m.top.focusedIconUri = ""
m.top.focusBitmapUri = "pkg:/images/white.9.png"
m.top.focusFootprintBitmapUri = "pkg:/images/white_border.9.png"
m.top.focusFootprintBitmapUri = "pkg:/images/white-border.9.png"
m.top.showFocusFootprint = true
m.top.observeField("focusedChild", FuncName(OnFocusedChildChange))
end function
@@ -13,6 +13,11 @@ import "pkg:/source/utils/UrlUtils.bs"
const COMMAND_HANDLER_PREFIX = "_Handle_"
' Apparently devices can be connected and disconnected very frequently.
' We don't want to spam the user with notifications, so we'll only show a notification
' if the last notification was more than 30 minutes ago.
const CONNECT_NOTIFICATION_MIN_INTERVAL_SECONDS = 1800
class LoungeApi
public loungeServiceNode
@@ -57,13 +62,13 @@ class LoungeApi
commandHandlers[COMMAND_TYPE_DPAD_COMMAND] = m.HandleIgnoreCommand
commandHandlers[COMMAND_TYPE_VOICE_COMMAND] = m.HandleIgnoreCommand
commandHandlers[COMMAND_TYPE_ON_USER_ACTIVITY] = m.HandleIgnoreCommand
commandHandlers[COMMAND_TYPE_REMOTE_DISCONNECTED] = m.HandleIgnoreCommand
commandHandlers[COMMAND_TYPE_GET_NOW_PLAYING] = m.HandleGetPlayingNow
commandHandlers[COMMAND_TYPE_SESSION_ID] = m.HandleSessionId
commandHandlers[COMMAND_TYPE_G_SESSION_ID] = m.HandleGSessionId
commandHandlers[COMMAND_TYPE_LOUNGE_STATUS] = m.HandleLoungeStatus
commandHandlers[COMMAND_TYPE_REMOTE_CONNECTED] = m.HandleRemoteConnected
commandHandlers[COMMAND_TYPE_REMOTE_DISCONNECTED] = m.HandleRemoteDisconnected
commandHandlers[COMMAND_TYPE_SET_VOLUME] = m.HandleSetVolume
commandHandlers[COMMAND_TYPE_SET_PLAYLIST] = m.HandleSetPlaylist
commandHandlers[COMMAND_TYPE_UPDATE_PLAYLIST] = m.HandleUpdatePlaylist
@@ -94,6 +99,7 @@ class LoungeApi
end if
request = HttpClient.Get("https://www.youtube.com/api/lounge/pairing/generate_screen_id")
response = request.Await()
if not response.IsSuccess()
error = `Failed to get screen id. Please restart playlet to use the cast function.\n${response.ErrorMessage()}`
@@ -101,6 +107,7 @@ class LoungeApi
DialogUtils.ShowDialog(error, "Lounge service setup error")
return invalid
end if
id = response.Text()
if not IsString(id)
error = `Failed to get screen id. Please restart playlet to use the cast function.\nNot a valid screen id: ${id}`
@@ -108,6 +115,7 @@ class LoungeApi
DialogUtils.ShowDialog(error, "Lounge service setup error")
return invalid
end if
m.screenId = id
return id
end function
@@ -117,9 +125,11 @@ class LoungeApi
return m.loungeToken
end if
form = UrlUtils.GetUrlEncodedForm({ "screen_ids": m.screenId })
request = HttpClient.Post("https://www.youtube.com/api/lounge/pairing/get_lounge_token_batch", form)
request.Header("Content-Type", "application/x-www-form-urlencoded")
request = HttpClient.Post("https://www.youtube.com/api/lounge/pairing/get_lounge_token_batch", "")
request.UrlEncodedForm({
"screen_ids": m.screenId
})
response = request.Await()
if not response.IsSuccess()
error = `Failed to get lounge token. Please restart playlet to use the cast function.\n${response.ErrorMessage()}`
@@ -143,7 +153,6 @@ class LoungeApi
end function
function GetSessionData() as boolean
baseUrl = "https://www.youtube.com/api/lounge/bc/bind"
queryParams = {
"device": "LOUNGE_SCREEN"
"theme": "cl"
@@ -161,10 +170,11 @@ class LoungeApi
queryParams["loungeIdToken"] = m.loungeToken
queryParams["zx"] = m.Zx()
url = UrlUtils.BuildUrl(baseUrl, invalid, queryParams)
request = HttpClient.Post(url, "count=0")
request.Header("Content-Type", "application/x-www-form-urlencoded")
request = HttpClient.Post("https://www.youtube.com/api/lounge/bc/bind", "")
request.QueryParams(queryParams)
request.UrlEncodedForm({
"count": 0
})
response = request.Await()
if not response.IsSuccess()
@@ -340,7 +350,7 @@ class LoungeApi
for each device in devices
if m.devices.DoesExist(device.id)
device.lastConnectEventType = m.devices[device.id].lastConnectEventType
device.lastConnectNotificationTime = m.devices[device.id].lastConnectNotificationTime
end if
m.devices[device.id] = device
end for
@@ -362,11 +372,14 @@ class LoungeApi
m.devices[id] = newDevice
if ValidString(newDevice.lastConnectEventType) = commandType
nowSeconds = TimeUtils.Now().AsSeconds()
lastConnectNotificationInterval = nowSeconds - ValidInt(newDevice.lastConnectNotificationTime)
if lastConnectNotificationInterval < CONNECT_NOTIFICATION_MIN_INTERVAL_SECONDS
LogInfo("Skipping connect notification. Last connect notification interval:", lastConnectNotificationInterval, "seconds")
return
end if
newDevice.lastConnectEventType = commandType
newDevice.lastConnectNotificationTime = nowSeconds
userName = newDevice.user
deviceName = newDevice.name
@@ -375,21 +388,6 @@ class LoungeApi
LoungeDeviceConnected.ShowNotifcation(m.notificationsNode, deviceName, userName, userAvatarUri)
end function
function HandleRemoteDisconnected(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object) as void
LogInfo(commandType, FormatJson(commandArgs))
newDevice = commandArgs
id = newDevice.id
if StringUtils.IsNullOrEmpty(id)
return
end if
if not m.devices.DoesExist(id)
return
end if
m.devices[id].lastConnectEventType = commandType
end function
function HandleSetVolume(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object) as void
player = m.videoQueueNode.player
if player = invalid
@@ -442,7 +440,6 @@ class LoungeApi
return
end if
baseUrl = "https://www.youtube.com/api/lounge/bc/bind"
queryParams = {
"device": "LOUNGE_SCREEN"
"theme": "cl"
@@ -469,8 +466,6 @@ class LoungeApi
queryParams["AID"] = messages[0].commandId
end if
url = UrlUtils.BuildUrl(baseUrl, invalid, queryParams)
postData = [
{ key: "count", value: messages.Count() }
{ key: "ofs", value: loungeData.ofs }
@@ -494,9 +489,10 @@ class LoungeApi
LogDebug("Sending messages:", postData)
body = UrlUtils.GetUrlEncodedForm(postData)
request = HttpClient.Post(url, body)
request.Header("Content-Type", "application/x-www-form-urlencoded")
request = HttpClient.Post("https://www.youtube.com/api/lounge/bc/bind", "")
request.QueryParams(queryParams)
request.UrlEncodedForm(postData)
request.Send()
' we do not need to wait for requests to finish, we check on them later
@@ -23,15 +23,15 @@ function LoungeGenerateManualPairingCodeTask(input as object) as object
input.loungeToken = loungeService.loungeToken
end if
bodyParams = {
form = {
"lounge_token": input.loungeToken
"screen_id": input.screenId
"screen_name": input.screenName
"device_id": input.deviceId
}
for each key in bodyParams
if StringUtils.IsNullOrEmpty(bodyParams[key])
for each key in form
if StringUtils.IsNullOrEmpty(form[key])
return {
"success": false
"error": key + " is empty"
@@ -39,14 +39,11 @@ function LoungeGenerateManualPairingCodeTask(input as object) as object
end if
end for
bodyParams["access_type"] = "permanent"
bodyParams["app"] = "Playlet"
form["access_type"] = "permanent"
form["app"] = "Playlet"
baseUrl = "https://www.youtube.com/api/lounge/pairing/get_pairing_code?ctx=pair"
body = UrlUtils.GetUrlEncodedForm(bodyParams)
request = HttpClient.Post(baseUrl, body)
request.Header("Content-Type", "application/x-www-form-urlencoded")
request = HttpClient.Post("https://www.youtube.com/api/lounge/pairing/get_pairing_code?ctx=pair", "")
request.UrlEncodedForm(form)
response = request.Await()
if not response.IsSuccess()
@@ -1,7 +1,5 @@
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/components/Services/LoungeService/LoungeApi.bs"
' TODO:P0
' 1. Add a section about the lounge in the privacy policy
function Init()
m.top.functionName = "LoungeServiceLoop"
@@ -154,17 +154,22 @@ function GetContextMenuOptionsForItem(rowItem as object) as object
options.push(ContextMenuUtils.CreateOption("Play", m.videoQueue, "FuncPlayVideo", [rowItem]))
options.push(ContextMenuUtils.CreateOption("Queue", m.videoQueue, "FuncAddToQueueVideo", [rowItem]))
item = ContextMenuUtils.CreateOption("Open channel", m.top, "OpenVideoChannel", [rowItem])
options.push(item)
authorId = rowItem.authorId
if not StringUtils.IsNullOrEmpty(authorId)
options.push(ContextMenuUtils.CreateOption("Open channel", m.top, "OpenVideoChannel", [rowItem]))
end if
else if rowItem.type = "playlist"
options.push(ContextMenuUtils.CreateOption("Play", m.videoQueue, "FuncPlayPlaylist", [rowItem, 0]))
options.push(ContextMenuUtils.CreateOption("Queue", m.videoQueue, "FuncAddToQueuePlaylist", [rowItem]))
item = ContextMenuUtils.CreateOption("Open", m.top, "OpenPlaylist", [rowItem])
options.push(item)
options.push(ContextMenuUtils.CreateOption("Open playlist", m.top, "OpenPlaylist", [rowItem]))
authorId = rowItem.authorId
if not StringUtils.IsNullOrEmpty(authorId)
options.push(ContextMenuUtils.CreateOption("Open channel", m.top, "OpenPlaylistChannel", [rowItem]))
end if
else if rowItem.type = "channel"
item = ContextMenuUtils.CreateOption("Open", m.top, "OpenChannel", [rowItem])
options.push(item)
options.push(ContextMenuUtils.CreateOption("Open", m.top, "OpenChannel", [rowItem]))
else
LogWarn("Unknown long pressed item type:", rowItem.type)
return []
@@ -191,6 +196,16 @@ function OpenVideoChannel(video as object) as void
ChannelUtils.Open(channel)
end function
function OpenPlaylistChannel(playlist as object) as void
authorId = playlist.authorId
if StringUtils.IsNullOrEmpty(authorId)
LogWarn("Invalid authorId:", authorId)
return
end if
channel = InvidiousContent.ToChannelContentNode(invalid, { authorId: authorId }, invalid)
ChannelUtils.Open(channel)
end function
function Refresh(unsued as dynamic)
InitContent()
end function
@@ -11,6 +11,7 @@
<function name="OpenPlaylist" />
<function name="OpenChannel" />
<function name="OpenVideoChannel" />
<function name="OpenPlaylistChannel" />
<function name="Refresh" />
</interface>
</component>
@@ -63,12 +63,38 @@ namespace SponsorBlock
function UpdateSponsorBlockChapter(time as double) as void
segments = m.skipSegments
for each segment in segments
category = segment["category"]
segmentRange = segment["segment"]
segmentStart = segmentRange[0]
segmentEnd = segmentRange[1]
' Usually segmentStart and segmentEnd are equal for poi_highlight
' We pad the duration for poi_highlight segments so that the chapter label
' can be visible when seeking in trickplay
if category = "poi_highlight"
segmentPaddedDuration = 5
duration = m.top.duration
if duration > 0
if duration < 120
segmentPaddedDuration = 1
else if duration < 300
segmentPaddedDuration = 2
else if duration < 900
segmentPaddedDuration = 5
else
segmentPaddedDuration = 10
end if
end if
segmentDuration = Abs(segmentEnd - segmentStart)
padding = Abs(segmentPaddedDuration - segmentDuration) / 2
segmentStart = segmentStart - padding
segmentEnd = segmentEnd + padding
end if
if (segmentStart <= time) and (segmentEnd >= time)
m.top.chapter = m.sponsorBlockService.SegmentTitle(segment["category"])
m.top.chapter = m.sponsorBlockService.SegmentTitle(category)
return
end if
end for
@@ -34,6 +34,7 @@ function VideoContentTask(input as object) as object
contentNode.title = metadata.title
contentNode.secondaryTitle = metadata.author
contentNode.live = metadata.liveNow
streamUrls = CreateStreamUrls(metadata, service, preferencesNode, playletServerPort)
contentNode.url = streamUrls[0]
@@ -156,10 +157,6 @@ function AddInstanceToUrlIfNeeded(streamUrls as object, instance as string)
end for
end function
' TODO:P2
' Captions are rate limited https://github.com/iv-org/invidious/issues/2567
' It's possible to loop through a list of backup instances hoping to find working subtitles.
' Caveat: searching for a working caption could cause a delay in the video player start.
function SetCaptions(metadata as object, service as object, contentNode as object) as void
if metadata.captions.Count() = 0
return
@@ -16,6 +16,8 @@ function Init()
m.fullScreenHintLabel = m.top.findNode("fullScreenHintLabel")
m.fullScreenHintTimer = m.top.findNode("fullScreenHintTimer")
m.fullScreenHintTimer.ObserveField("fire", FuncName(OnFullScreenHintTimer))
m.trickplayUITimer = m.top.findNode("trickplayUITimer")
m.trickplayUITimer.ObserveField("fire", FuncName(OnTrickplayUITimer))
' videoPlayingSuccess indicates if we started playing a video successfully
' We use it to detect if we should try another link for a video, or if another error
@@ -26,6 +28,13 @@ function Init()
' still trying to find a working stream url
m.ignoreNextFinishedState = false
' Indicates that we're currently paused and seeking position
m.isSeekingPosition = false
' Checks if current RokuOS version has showUI field in Video node
m.showUIEnabled = m.top.hasField("showUI")
LogInfo(`Custom OK handler is ${m.showUIEnabled ? "enabled" : "disabled"}`)
' asyncStopSemantics available since Roku OS 12.5
' It is set to true because stopping synchronously causes timeout and crash
' Usually we would need to wait for the video state to move to "stopping" then to "stopped"
@@ -50,6 +59,7 @@ function OnNodeReady()
m.fullScreenHint.translation = [0, minRect.height - m.fullScreenHint.height]
' TODO:P2 show a loading spinner if video is loading minimized
' Probably only worth doing after the video player is redone
m.top.enableUI = m.container.fullscreen
m.top.showFullScreenHint = not m.container.fullscreen
@@ -169,6 +179,12 @@ function OnVideoPlayerStateChange() as void
state = m.top.state
content = m.top.content
' Reset isSeekingPosition when started to play the video
if state = "playing"
m.isSeekingPosition = false
end if
' If we successfully played the video, then any error that comes later is not due to a 403 (FORBIDDEN).
' This is to reduce false positives, as we do not want retry another link if the first link is working fine.
if state = "playing" and not m.videoPlayingSuccess
@@ -243,6 +259,69 @@ function OnVideoFinished() as void
end if
end function
function IsLiveVideo() as boolean
if m.top.content <> invalid
return m.top.content.live
end if
return false
end function
function ShowUIAndStartTimer()
if m.showUIEnabled
m.top.showUI = { "show": true, "trickPlaybar": true, "titleAndTime": true, "trickplayBackgroundOverlay": true, "focusTrickplayBar": false }
m.trickplayUITimer.control = "start"
end if
end function
function HideUIAndStopTimer()
if m.showUIEnabled
m.top.showUI = { "show": false, "focusTrickplayBar": false }
m.trickplayUITimer.control = "stop"
end if
end function
function HandleOKPress() as boolean
if not m.showUIEnabled
return false
end if
handled = false
state = m.top.state
uiVisible = m.top.trickPlaybar.visible
isLive = IsLiveVideo()
LogInfo(`Handling OK button: state = ${state}, uiVisible = ${uiVisible} isLive = ${isLive}`)
if state = "playing"
if not uiVisible
' Video is playing and UI is not visible, show it
ShowUIAndStartTimer()
else if not isLive
' Trickplay bar is visible and video is currently played, pause it and retain the UI
m.trickplayUITimer.control = "stop"
m.top.control = "pause"
ShowUIAndStartTimer()
else
HideUIAndStopTimer()
end if
handled = true
else if state = "paused"
' Exit early if we're in seeking mode to avoid messing up internal Video node state
if m.isSeekingPosition
return false
end if
if not uiVisible
' Video is paused and UI is not visible, show it
ShowUIAndStartTimer()
else
' Video is currently paused with visible UI, resume it and hide UI
HideUIAndStopTimer()
m.top.control = "resume"
end if
handled = true
end if
return handled
end function
function OnkeyEvent(key as string, press as boolean) as boolean
if press = false
return false
@@ -260,6 +339,19 @@ function OnkeyEvent(key as string, press as boolean) as boolean
m.videoQueue.closePlayer = true
return true
end if
if key = "OK"
return HandleOKPress()
end if
if key = "left" or key = "right" or key = "rewind" or key = "fastforward"
' We're paused and one of the buttons is pressed: left, right ff, rw.
' That means we're seeking position. Check that in HandleOKPress and exit early
m.isSeekingPosition = true
end if
' Always stop UI timer when pressing any button to avoid UI being hidden twice
m.trickplayUITimer.control = "stop"
return false
end function
@@ -281,6 +373,8 @@ function SetupAnimation()
end function
function OnFullScreenChange()
HideUIAndStopTimer()
m.widthInterpolator.reverse = m.container.fullscreen
m.heightInterpolator.reverse = m.container.fullscreen
m.translationInterpolator.reverse = m.container.fullscreen
@@ -312,6 +406,10 @@ function OnShowFullScreenHint() as void
m.fullScreenHintTimer.control = "start"
end function
function OnTrickplayUITimer()
HideUIAndStopTimer()
end function
function OnFullScreenHintTimer()
showFullScreenHint = m.top.showFullScreenHint
m.fullScreenHint.visible = showFullScreenHint
@@ -16,53 +16,17 @@
<function name="Close" />
</interface>
<children>
<Label
id="chapterLabel"
width="350"
height="25"
horizAlign="center"
vertAlign="center"
font="font:SmallestSystemFont"
/>
<Timer
id="chapterLabelTimer"
repeat="true"
duration="0.25"
/>
<Animation id="minimizeAnimation"
duration="0.3"
optional="true">
<FloatFieldInterpolator
id="widthInterpolator"
key="[0.0, 0.5, 1.0]"
fieldToInterp="VideoPlayer.width" />
<FloatFieldInterpolator
id="heightInterpolator"
key="[0.0, 0.5, 1.0]"
fieldToInterp="VideoPlayer.height" />
<Vector2DFieldInterpolator
id="translationInterpolator"
key="[0.0, 0.5, 1.0]"
fieldToInterp="VideoPlayer.translation" />
<Label id="chapterLabel" width="350" height="25" horizAlign="center" vertAlign="center" font="font:SmallestSystemFont" />
<Timer id="chapterLabelTimer" repeat="true" duration="0.25" />
<Animation id="minimizeAnimation" duration="0.3" optional="true">
<FloatFieldInterpolator id="widthInterpolator" key="[0.0, 0.5, 1.0]" fieldToInterp="VideoPlayer.width" />
<FloatFieldInterpolator id="heightInterpolator" key="[0.0, 0.5, 1.0]" fieldToInterp="VideoPlayer.height" />
<Vector2DFieldInterpolator id="translationInterpolator" key="[0.0, 0.5, 1.0]" fieldToInterp="VideoPlayer.translation" />
</Animation>
<Rectangle
id="fullScreenHint"
height="26"
color="0x000000"
opacity="0.8"
visible="false">
<Label
id="fullScreenHintLabel"
text="Press Options (*) for full screen"
height="26"
color="0xFFFFFF"
horizAlign="center"
vertAlign="center"
font="font:SmallestSystemFont"
/>
<Timer
id="fullScreenHintTimer"
duration="5" />
<Rectangle id="fullScreenHint" height="26" color="0x000000" opacity="0.8" visible="false">
<Label id="fullScreenHintLabel" text="Press Options (*) for full screen" height="26" color="0xFFFFFF" horizAlign="center" vertAlign="center" font="font:SmallestSystemFont" />
<Timer id="fullScreenHintTimer" duration="5" />
<Timer id="trickplayUITimer" duration="5" />
</Rectangle>
</children>
</component>
@@ -44,7 +44,8 @@
numColumns="1"
numRows="6"
vertFocusAnimationStyle="floatingFocus"
translation="[20,90]" />
translation="[20,90]"
focusBitmapUri="pkg:/images/focus-glow-padding-27.9.png" />
</Rectangle>
<Animation id="showAnimation"
@@ -56,12 +56,14 @@ function SetHighlight() as void
contentIndex = content.queueIndex
index = m.top.index
if contentIndex = index
highlighted = contentIndex = index
if highlighted
' bs:disable-next-line LINT3023
m.top.thumbnailBlendColor = "#FFFFFFFF"
m.top.highlightUri = "pkg:/images/focus_grid.9.png"
else
m.top.thumbnailBlendColor = "#606060FF"
m.top.highlightUri = ""
end if
m.top.highlightVisible = highlighted
end function
@@ -5,7 +5,7 @@
<field id="title" type="string" alias="titleLabel.text" />
<field id="thumbnailUri" type="uri" alias="thumbnailPoster.uri" />
<field id="thumbnailBlendColor" type="color" alias="thumbnailPoster.blendColor" />
<field id="highlightUri" type="uri" alias="highlightPoster.uri" />
<field id="highlightVisible" type="boolean" alias="highlightPoster.visible" />
<field id="duration" type="string" alias="durationLabel.text" />
<field id="durationRectVisible" type="boolean" alias="durationRect.visible" />
</interface>
@@ -36,9 +36,9 @@
<Poster
id="highlightPoster"
blendColor="0xFF1C30"
uri="pkg:/images/queue-highlight.9.png"
width="164"
height="94" />
<Label
id="titleLabel"
width="260"
@@ -77,18 +77,15 @@ namespace Http
end if
end if
registerUrl = "https://www.youtube.com/api/lounge/pairing/register_pairing_code"
registerBody = {
req = HttpClient.Post("https://www.youtube.com/api/lounge/pairing/register_pairing_code", "")
req.UrlEncodedForm({
"app": "Playlet"
"pairing_code": pairingCode
"screen_id": m.loungeService.screenId
"screen_name": m.deviceName
"device_id": m.deviceId
}
})
body = UrlUtils.GetUrlEncodedForm(registerBody)
req = HttpClient.Post(registerUrl, body)
req.Header("Content-Type", "application/x-www-form-urlencoded")
res = req.Await()
if not res.IsSuccess()
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 292 B

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1017 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

+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=20
build_version=00001
build_version=00002
ui_resolutions=hd
@@ -211,6 +211,12 @@ namespace HttpClient
return m
end function
function UrlEncodedForm(form as object) as HttpRequest
m.Body(UrlUtils.GetUrlEncodedForm(form))
m.Header("Content-Type", "application/x-www-form-urlencoded")
return m
end function
function TimeoutSeconds(timeoutSeconds as integer) as HttpRequest
m._timeoutSeconds = timeoutSeconds
return m
+496 -66
View File
@@ -1,30 +1,30 @@
{
"name": "playlet-web",
"version": "0.20.1",
"version": "0.20.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "playlet-web",
"version": "0.20.1",
"version": "0.20.2",
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^3.0.2",
"@tailwindcss/typography": "^0.5.10",
"@tsconfig/svelte": "^5.0.2",
"@vitejs/plugin-legacy": "^5.3.0",
"@vitejs/plugin-legacy": "^5.3.1",
"autoprefixer": "^10.4.17",
"daisyui": "^4.7.2",
"dotenv": "^16.4.4",
"ip": "^1.1.8",
"dotenv": "^16.4.5",
"ip": "^2.0.1",
"postcss": "^8.4.35",
"svelte": "^4.2.11",
"svelte": "^4.2.12",
"svelte-check": "^3.6.4",
"svelte-preprocess": "^5.1.3",
"tailwindcss": "^3.4.1",
"terser": "^5.27.1",
"terser": "^5.28.1",
"tslib": "^2.6.2",
"typescript": "^5.3.3",
"vite": "^5.1.3",
"vite": "^5.1.4",
"vite-tsconfig-paths": "^4.3.1"
}
},
@@ -1716,6 +1716,23 @@
"node": ">=4"
}
},
"node_modules/@esbuild/aix-ppc64": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.20.1.tgz",
"integrity": "sha512-m55cpeupQ2DbuRGQMMZDzbv9J9PgVelPjlcmM5kxHnrBdBx6REaEd7LamYV7Dm8N7rCyR/XwU6rVP8ploKtIkA==",
"cpu": [
"ppc64"
],
"dev": true,
"optional": true,
"os": [
"aix"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/android-arm": {
"version": "0.19.6",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.6.tgz",
@@ -2390,17 +2407,17 @@
"dev": true
},
"node_modules/@vitejs/plugin-legacy": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/@vitejs/plugin-legacy/-/plugin-legacy-5.3.0.tgz",
"integrity": "sha512-BhW+WcJmEgW5G/1UQRiVQ7wz9/ZPnxqzExT9n0zAk4RlqQQ/26udIeXzdU8+03AGnaF61wmZlCspexgEnxFWMA==",
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/@vitejs/plugin-legacy/-/plugin-legacy-5.3.1.tgz",
"integrity": "sha512-ymCuZo8Bu7gSO85I3E/3SNnaQ64gFdVpTqxqhl8YeasJChDxN8D3IKYByC+AsxwoeO2AE59wy4PPILM/A03TIQ==",
"dev": true,
"dependencies": {
"@babel/core": "^7.23.7",
"@babel/preset-env": "^7.23.8",
"browserslist": "^4.22.2",
"core-js": "^3.35.0",
"esbuild-plugin-browserslist": "^0.10.0",
"magic-string": "^0.30.5",
"@babel/core": "^7.23.9",
"@babel/preset-env": "^7.23.9",
"browserslist": "^4.23.0",
"core-js": "^3.36.0",
"esbuild-plugin-browserslist": "^0.11.1",
"magic-string": "^0.30.7",
"regenerator-runtime": "^0.14.1",
"systemjs": "^6.14.3"
},
@@ -2415,6 +2432,436 @@
"vite": "^5.0.0"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/android-arm": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.20.1.tgz",
"integrity": "sha512-4j0+G27/2ZXGWR5okcJi7pQYhmkVgb4D7UKwxcqrjhvp5TKWx3cUjgB1CGj1mfdmJBQ9VnUGgUhign+FPF2Zgw==",
"cpu": [
"arm"
],
"dev": true,
"optional": true,
"os": [
"android"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/android-arm64": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.20.1.tgz",
"integrity": "sha512-hCnXNF0HM6AjowP+Zou0ZJMWWa1VkD77BXe959zERgGJBBxB+sV+J9f/rcjeg2c5bsukD/n17RKWXGFCO5dD5A==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"android"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/android-x64": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.20.1.tgz",
"integrity": "sha512-MSfZMBoAsnhpS+2yMFYIQUPs8Z19ajwfuaSZx+tSl09xrHZCjbeXXMsUF/0oq7ojxYEpsSo4c0SfjxOYXRbpaA==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"android"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/darwin-arm64": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.20.1.tgz",
"integrity": "sha512-Ylk6rzgMD8klUklGPzS414UQLa5NPXZD5tf8JmQU8GQrj6BrFA/Ic9tb2zRe1kOZyCbGl+e8VMbDRazCEBqPvA==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"darwin"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/darwin-x64": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.20.1.tgz",
"integrity": "sha512-pFIfj7U2w5sMp52wTY1XVOdoxw+GDwy9FsK3OFz4BpMAjvZVs0dT1VXs8aQm22nhwoIWUmIRaE+4xow8xfIDZA==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"darwin"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/freebsd-arm64": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.20.1.tgz",
"integrity": "sha512-UyW1WZvHDuM4xDz0jWun4qtQFauNdXjXOtIy7SYdf7pbxSWWVlqhnR/T2TpX6LX5NI62spt0a3ldIIEkPM6RHw==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"freebsd"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/freebsd-x64": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.20.1.tgz",
"integrity": "sha512-itPwCw5C+Jh/c624vcDd9kRCCZVpzpQn8dtwoYIt2TJF3S9xJLiRohnnNrKwREvcZYx0n8sCSbvGH349XkcQeg==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"freebsd"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/linux-arm": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.20.1.tgz",
"integrity": "sha512-LojC28v3+IhIbfQ+Vu4Ut5n3wKcgTu6POKIHN9Wpt0HnfgUGlBuyDDQR4jWZUZFyYLiz4RBBBmfU6sNfn6RhLw==",
"cpu": [
"arm"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/linux-arm64": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.20.1.tgz",
"integrity": "sha512-cX8WdlF6Cnvw/DO9/X7XLH2J6CkBnz7Twjpk56cshk9sjYVcuh4sXQBy5bmTwzBjNVZze2yaV1vtcJS04LbN8w==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/linux-ia32": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.20.1.tgz",
"integrity": "sha512-4H/sQCy1mnnGkUt/xszaLlYJVTz3W9ep52xEefGtd6yXDQbz/5fZE5dFLUgsPdbUOQANcVUa5iO6g3nyy5BJiw==",
"cpu": [
"ia32"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/linux-loong64": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.20.1.tgz",
"integrity": "sha512-c0jgtB+sRHCciVXlyjDcWb2FUuzlGVRwGXgI+3WqKOIuoo8AmZAddzeOHeYLtD+dmtHw3B4Xo9wAUdjlfW5yYA==",
"cpu": [
"loong64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/linux-mips64el": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.20.1.tgz",
"integrity": "sha512-TgFyCfIxSujyuqdZKDZ3yTwWiGv+KnlOeXXitCQ+trDODJ+ZtGOzLkSWngynP0HZnTsDyBbPy7GWVXWaEl6lhA==",
"cpu": [
"mips64el"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/linux-ppc64": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.20.1.tgz",
"integrity": "sha512-b+yuD1IUeL+Y93PmFZDZFIElwbmFfIKLKlYI8M6tRyzE6u7oEP7onGk0vZRh8wfVGC2dZoy0EqX1V8qok4qHaw==",
"cpu": [
"ppc64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/linux-riscv64": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.20.1.tgz",
"integrity": "sha512-wpDlpE0oRKZwX+GfomcALcouqjjV8MIX8DyTrxfyCfXxoKQSDm45CZr9fanJ4F6ckD4yDEPT98SrjvLwIqUCgg==",
"cpu": [
"riscv64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/linux-s390x": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.20.1.tgz",
"integrity": "sha512-5BepC2Au80EohQ2dBpyTquqGCES7++p7G+7lXe1bAIvMdXm4YYcEfZtQrP4gaoZ96Wv1Ute61CEHFU7h4FMueQ==",
"cpu": [
"s390x"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/linux-x64": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.20.1.tgz",
"integrity": "sha512-5gRPk7pKuaIB+tmH+yKd2aQTRpqlf1E4f/mC+tawIm/CGJemZcHZpp2ic8oD83nKgUPMEd0fNanrnFljiruuyA==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/netbsd-x64": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.20.1.tgz",
"integrity": "sha512-4fL68JdrLV2nVW2AaWZBv3XEm3Ae3NZn/7qy2KGAt3dexAgSVT+Hc97JKSZnqezgMlv9x6KV0ZkZY7UO5cNLCg==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"netbsd"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/openbsd-x64": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.20.1.tgz",
"integrity": "sha512-GhRuXlvRE+twf2ES+8REbeCb/zeikNqwD3+6S5y5/x+DYbAQUNl0HNBs4RQJqrechS4v4MruEr8ZtAin/hK5iw==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"openbsd"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/sunos-x64": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.20.1.tgz",
"integrity": "sha512-ZnWEyCM0G1Ex6JtsygvC3KUUrlDXqOihw8RicRuQAzw+c4f1D66YlPNNV3rkjVW90zXVsHwZYWbJh3v+oQFM9Q==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"sunos"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/win32-arm64": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.20.1.tgz",
"integrity": "sha512-QZ6gXue0vVQY2Oon9WyLFCdSuYbXSoxaZrPuJ4c20j6ICedfsDilNPYfHLlMH7vGfU5DQR0czHLmJvH4Nzis/A==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/win32-ia32": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.20.1.tgz",
"integrity": "sha512-HzcJa1NcSWTAU0MJIxOho8JftNp9YALui3o+Ny7hCh0v5f90nprly1U3Sj1Ldj/CvKKdvvFsCRvDkpsEMp4DNw==",
"cpu": [
"ia32"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/@esbuild/win32-x64": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.20.1.tgz",
"integrity": "sha512-0MBh53o6XtI6ctDnRMeQ+xoCN8kD2qI1rY1KgF/xdWQwoFeKou7puvDfV8/Wv4Ctx2rRpET/gGdz3YlNtNACSA==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/esbuild": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.20.1.tgz",
"integrity": "sha512-OJwEgrpWm/PCMsLVWXKqvcjme3bHNpOgN7Tb6cQnR5n0TPbQx1/Xrn7rqM+wn17bYeT6MGB5sn1Bh5YiGi70nA==",
"dev": true,
"hasInstallScript": true,
"peer": true,
"bin": {
"esbuild": "bin/esbuild"
},
"engines": {
"node": ">=12"
},
"optionalDependencies": {
"@esbuild/aix-ppc64": "0.20.1",
"@esbuild/android-arm": "0.20.1",
"@esbuild/android-arm64": "0.20.1",
"@esbuild/android-x64": "0.20.1",
"@esbuild/darwin-arm64": "0.20.1",
"@esbuild/darwin-x64": "0.20.1",
"@esbuild/freebsd-arm64": "0.20.1",
"@esbuild/freebsd-x64": "0.20.1",
"@esbuild/linux-arm": "0.20.1",
"@esbuild/linux-arm64": "0.20.1",
"@esbuild/linux-ia32": "0.20.1",
"@esbuild/linux-loong64": "0.20.1",
"@esbuild/linux-mips64el": "0.20.1",
"@esbuild/linux-ppc64": "0.20.1",
"@esbuild/linux-riscv64": "0.20.1",
"@esbuild/linux-s390x": "0.20.1",
"@esbuild/linux-x64": "0.20.1",
"@esbuild/netbsd-x64": "0.20.1",
"@esbuild/openbsd-x64": "0.20.1",
"@esbuild/sunos-x64": "0.20.1",
"@esbuild/win32-arm64": "0.20.1",
"@esbuild/win32-ia32": "0.20.1",
"@esbuild/win32-x64": "0.20.1"
}
},
"node_modules/@vitejs/plugin-legacy/node_modules/esbuild-plugin-browserslist": {
"version": "0.11.1",
"resolved": "https://registry.npmjs.org/esbuild-plugin-browserslist/-/esbuild-plugin-browserslist-0.11.1.tgz",
"integrity": "sha512-yNdZRdDBEbm0PT4q2bJBhXvnwakXG5mG8ipiwGe5SRDPnKa7L7kQm2tHuBMowBtcFz6kRtZTv5njK7PJwU+tCQ==",
"dev": true,
"dependencies": {
"debug": "^4.3.4",
"zod": "^3.21.4"
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"browserslist": "^4.21.8",
"esbuild": "~0.20.0"
}
},
"node_modules/acorn": {
"version": "8.11.2",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz",
@@ -2596,9 +3043,9 @@
}
},
"node_modules/browserslist": {
"version": "4.22.2",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.2.tgz",
"integrity": "sha512-0UgcrvQmBDvZHFGdYUehrCNIazki7/lUP3kkoi/r3YB2amZbFM9J43ZRkJTXBUZK4gmx56+Sqk9+Vs9mwZx9+A==",
"version": "4.23.0",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.0.tgz",
"integrity": "sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ==",
"dev": true,
"funding": [
{
@@ -2615,8 +3062,8 @@
}
],
"dependencies": {
"caniuse-lite": "^1.0.30001565",
"electron-to-chromium": "^1.4.601",
"caniuse-lite": "^1.0.30001587",
"electron-to-chromium": "^1.4.668",
"node-releases": "^2.0.14",
"update-browserslist-db": "^1.0.13"
},
@@ -2661,9 +3108,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001579",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001579.tgz",
"integrity": "sha512-u5AUVkixruKHJjw/pj9wISlcMpgFWzSrczLZbrqBSxukQixmg0SJ5sZTpvaFvxU0HoQKd4yoyAogyrAz9pzJnA==",
"version": "1.0.30001589",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001589.tgz",
"integrity": "sha512-vNQWS6kI+q6sBlHbh71IIeC+sRwK2N3EDySc/updIGhIee2x5z00J4c1242/5/d6EpEMdOnk/m+6tuk4/tcsqg==",
"dev": true,
"funding": [
{
@@ -2771,9 +3218,9 @@
"dev": true
},
"node_modules/core-js": {
"version": "3.35.1",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.35.1.tgz",
"integrity": "sha512-IgdsbxNyMskrTFxa9lWHyMwAJU5gXOPP+1yO+K59d50VLVAIDAbs7gIv705KzALModfK3ZrSZTPNpC0PQgIZuw==",
"version": "3.36.0",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.36.0.tgz",
"integrity": "sha512-mt7+TUBbTFg5+GngsAxeKBTl5/VS0guFeJacYge9OmHb+m058UwwIm41SE9T4Den7ClatV57B6TYTuJ0CX1MAw==",
"dev": true,
"hasInstallScript": true,
"funding": {
@@ -2914,9 +3361,9 @@
"dev": true
},
"node_modules/dotenv": {
"version": "16.4.4",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.4.tgz",
"integrity": "sha512-XvPXc8XAQThSjAbY6cQ/9PcBXmFoWuw1sQ3b8HqUCR6ziGXjkTi//kB9SWa2UwqlgdAIuRqAa/9hVljzPehbYg==",
"version": "16.4.5",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz",
"integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==",
"dev": true,
"engines": {
"node": ">=12"
@@ -2926,9 +3373,9 @@
}
},
"node_modules/electron-to-chromium": {
"version": "1.4.614",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.614.tgz",
"integrity": "sha512-X4ze/9Sc3QWs6h92yerwqv7aB/uU8vCjZcrMjA8N9R1pjMFRe44dLsck5FzLilOYvcXuDn93B+bpGYyufc70gQ==",
"version": "1.4.681",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.681.tgz",
"integrity": "sha512-1PpuqJUFWoXZ1E54m8bsLPVYwIVCRzvaL+n5cjigGga4z854abDnFRc+cTa2th4S79kyGqya/1xoR7h+Y5G5lg==",
"dev": true
},
"node_modules/es6-promise": {
@@ -2974,23 +3421,6 @@
"@esbuild/win32-x64": "0.19.6"
}
},
"node_modules/esbuild-plugin-browserslist": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/esbuild-plugin-browserslist/-/esbuild-plugin-browserslist-0.10.0.tgz",
"integrity": "sha512-rZWFcp3l+73xDiJB+Vl9UqP1VVs+L4E0lygbwJl6UTmW2qQago7DLT56hBu0vocH/TtZsAcRHj0+qHqkkB5Gww==",
"dev": true,
"dependencies": {
"debug": "^4.3.4",
"zod": "^3.21.4"
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"browserslist": "^4.21.8",
"esbuild": "~0.19.2"
}
},
"node_modules/escalade": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
@@ -3228,9 +3658,9 @@
"dev": true
},
"node_modules/ip": {
"version": "1.1.8",
"resolved": "https://registry.npmjs.org/ip/-/ip-1.1.8.tgz",
"integrity": "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz",
"integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==",
"dev": true
},
"node_modules/is-binary-path": {
@@ -3399,9 +3829,9 @@
}
},
"node_modules/magic-string": {
"version": "0.30.5",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.5.tgz",
"integrity": "sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==",
"version": "0.30.7",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.7.tgz",
"integrity": "sha512-8vBuFF/I/+OSLRmdf2wwFCJCz+nSn0m6DPvGH1fS/KiQoSaR+sETbov0eIk9KhEKy8CYqIkIAnbohxT/4H0kuA==",
"dev": true,
"dependencies": {
"@jridgewell/sourcemap-codec": "^1.4.15"
@@ -4174,9 +4604,9 @@
}
},
"node_modules/svelte": {
"version": "4.2.11",
"resolved": "https://registry.npmjs.org/svelte/-/svelte-4.2.11.tgz",
"integrity": "sha512-YIQk3J4X89wOLhjsqIW8tqY3JHPuBdtdOIkASP2PZeAMcSW9RsIjQzMesCrxOF3gdWYC0mKknlKF7OqmLM+Zqg==",
"version": "4.2.12",
"resolved": "https://registry.npmjs.org/svelte/-/svelte-4.2.12.tgz",
"integrity": "sha512-d8+wsh5TfPwqVzbm4/HCXC783/KPHV60NvwitJnyTA5lWn1elhXMNWhXGCJ7PwPa8qFUnyJNIyuIRt2mT0WMug==",
"dev": true,
"dependencies": {
"@ampproject/remapping": "^2.2.1",
@@ -4364,9 +4794,9 @@
}
},
"node_modules/terser": {
"version": "5.27.1",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.27.1.tgz",
"integrity": "sha512-29wAr6UU/oQpnTw5HoadwjUZnFQXGdOfj0LjZ4sVxzqwHh/QVkvr7m8y9WoR4iN3FRitVduTc6KdjcW38Npsug==",
"version": "5.28.1",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.28.1.tgz",
"integrity": "sha512-wM+bZp54v/E9eRRGXb5ZFDvinrJIOaTapx3WUokyVGZu5ucVCK55zEgGd5Dl2fSr3jUo5sDiERErUWLY6QPFyA==",
"dev": true,
"dependencies": {
"@jridgewell/source-map": "^0.3.3",
@@ -4542,9 +4972,9 @@
"dev": true
},
"node_modules/vite": {
"version": "5.1.3",
"resolved": "https://registry.npmjs.org/vite/-/vite-5.1.3.tgz",
"integrity": "sha512-UfmUD36DKkqhi/F75RrxvPpry+9+tTkrXfMNZD+SboZqBCMsxKtO52XeGzzuh7ioz+Eo/SYDBbdb0Z7vgcDJew==",
"version": "5.1.4",
"resolved": "https://registry.npmjs.org/vite/-/vite-5.1.4.tgz",
"integrity": "sha512-n+MPqzq+d9nMVTKyewqw6kSt+R3CkvF9QAKY8obiQn8g1fwTscKxyfaYnC632HtBXAQGc1Yjomphwn1dtwGAHg==",
"dev": true,
"dependencies": {
"esbuild": "^0.19.3",
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-web",
"version": "0.20.1",
"version": "0.20.2",
"type": "module",
"scripts": {
"dev": "vite",
@@ -12,20 +12,20 @@
"@sveltejs/vite-plugin-svelte": "^3.0.2",
"@tailwindcss/typography": "^0.5.10",
"@tsconfig/svelte": "^5.0.2",
"@vitejs/plugin-legacy": "^5.3.0",
"@vitejs/plugin-legacy": "^5.3.1",
"autoprefixer": "^10.4.17",
"daisyui": "^4.7.2",
"dotenv": "^16.4.4",
"ip": "^1.1.8",
"dotenv": "^16.4.5",
"ip": "^2.0.1",
"postcss": "^8.4.35",
"svelte": "^4.2.11",
"svelte": "^4.2.12",
"svelte-check": "^3.6.4",
"svelte-preprocess": "^5.1.3",
"tailwindcss": "^3.4.1",
"terser": "^5.27.1",
"terser": "^5.28.1",
"tslib": "^2.6.2",
"typescript": "^5.3.3",
"vite": "^5.1.3",
"vite": "^5.1.4",
"vite-tsconfig-paths": "^4.3.1"
}
}
+43 -5
View File
@@ -84,7 +84,9 @@ export class LoggerPlugin implements CompilerPlugin {
}
}
this.generateLoggingFile(program, usedLogFunctions);
// @ts-ignore
const isDebug = !!program.options.debug;
this.generateLoggingFile(program, usedLogFunctions, isDebug);
}
beforeFileTranspile(event: BeforeFileTranspileEvent<BscFile>) {
@@ -133,20 +135,20 @@ export class LoggerPlugin implements CompilerPlugin {
}
}
generateLoggingFile(program: Program, usedLogFunctions: Map<string, LogFunction>) {
generateLoggingFile(program: Program, usedLogFunctions: Map<string, LogFunction>, isDebug: boolean) {
const file = program.getFile(loggingFilePath);
let content = file.fileContents;
content += '\n\' Start of auto-generated functions\n'
usedLogFunctions.forEach((logFunction, newFunctionName) => {
content += this.generateLoggingFunction(newFunctionName, logFunction.name, logFunction.argCount);
content += this.generateLoggingFunction(newFunctionName, logFunction.name, logFunction.argCount, isDebug);
});
content += '\n\' End of auto-generated functions\n'
program.setFile(loggingFilePath, content)
}
generateLoggingFunction(newFunctionName: string, level: string, argCount: number) {
generateLoggingFunction(newFunctionName: string, level: string, argCount: number, isDebug: boolean) {
const args: string[] = [];
const argsParams: string[] = [];
for (let i = 0; i < argCount; i++) {
@@ -160,13 +162,49 @@ export class LoggerPlugin implements CompilerPlugin {
const func = logFunctions[level as 'LogError' | 'LogWarn' | 'LogInfo' | 'LogDebug'];
// https://github.com/microsoft/vscode/issues/571
const USE_COLOR = false;
const RED = '[31m';
const YELLOW = '[33m';
const GREEN = '[32m';
const BOLD = '[1m';
const BOLD_RED = '[1;31m';
const BOLD_YELLOW = '[1;33m';
const BOLD_GREEN = '[1;32m';
const CLEAR = '[0m';
let logLine = '';
if (isDebug && USE_COLOR) {
switch (func.stringLevel) {
case 'ERROR':
logLine = `Chr(27) + "${BOLD_RED}" + "[${func.stringLevel}]" + Chr(27) + "${RED}" + ${msg} + Chr(27) + "${CLEAR}"`;
break;
case 'WARN':
logLine = `Chr(27) + "${BOLD_YELLOW}" + "[${func.stringLevel}]" + Chr(27) + "${YELLOW}" + ${msg} + Chr(27) + "${CLEAR}"`;
break;
case 'INFO':
logLine = `Chr(27) + "${BOLD}" + "[${func.stringLevel}]" + Chr(27) + "${CLEAR}" + ${msg}`;
break;
case 'DEBUG':
logLine = `Chr(27) + "${BOLD_GREEN}" + "[${func.stringLevel}]" + Chr(27) + "${GREEN}" + ${msg} + Chr(27) + "${CLEAR}"`;
break;
default:
throw new Error(`Unknown log level: ${func.stringLevel}`);
}
}
else {
logLine = `"[${func.stringLevel}]" + ${msg}`
}
return `
function ${newFunctionName}(${args.join(', ')}) as void
logger = m.global.logger
if logger.logLevel < ${func.level}
return
end if
logger.logLine = "[${func.stringLevel}]" + ${msg}
logger.logLine = ${logLine}
end function
`;
}