Add scriptManager and zDebugger

This commit is contained in:
Zetaphor 2023-09-18 15:12:15 -03:00
parent cc6d0eda60
commit 39d76788d5
12 changed files with 2255 additions and 0 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 575 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 575 B

View file

@ -0,0 +1,852 @@
/*
! tailwindcss v3.3.3 | MIT License | https://tailwindcss.com
*/
/*
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
*/
*,
::before,
::after {
box-sizing: border-box;
/* 1 */
border-width: 0;
/* 2 */
border-style: solid;
/* 2 */
border-color: #e5e7eb;
/* 2 */
}
::before,
::after {
--tw-content: '';
}
/*
1. Use a consistent sensible line-height in all browsers.
2. Prevent adjustments of font size after orientation changes in iOS.
3. Use a more readable tab size.
4. Use the user's configured `sans` font-family by default.
5. Use the user's configured `sans` font-feature-settings by default.
6. Use the user's configured `sans` font-variation-settings by default.
*/
html {
line-height: 1.5;
/* 1 */
-webkit-text-size-adjust: 100%;
/* 2 */
-moz-tab-size: 4;
/* 3 */
-o-tab-size: 4;
tab-size: 4;
/* 3 */
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
/* 4 */
font-feature-settings: normal;
/* 5 */
font-variation-settings: normal;
/* 6 */
}
/*
1. Remove the margin in all browsers.
2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.
*/
body {
margin: 0;
/* 1 */
line-height: inherit;
/* 2 */
}
/*
1. Add the correct height in Firefox.
2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
3. Ensure horizontal rules are visible by default.
*/
hr {
height: 0;
/* 1 */
color: inherit;
/* 2 */
border-top-width: 1px;
/* 3 */
}
/*
Add the correct text decoration in Chrome, Edge, and Safari.
*/
abbr:where([title]) {
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
}
/*
Remove the default font size and weight for headings.
*/
h1,
h2,
h3,
h4,
h5,
h6 {
font-size: inherit;
font-weight: inherit;
}
/*
Reset links to optimize for opt-in styling instead of opt-out.
*/
a {
color: inherit;
text-decoration: inherit;
}
/*
Add the correct font weight in Edge and Safari.
*/
b,
strong {
font-weight: bolder;
}
/*
1. Use the user's configured `mono` font family by default.
2. Correct the odd `em` font sizing in all browsers.
*/
code,
kbd,
samp,
pre {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
/* 1 */
font-size: 1em;
/* 2 */
}
/*
Add the correct font size in all browsers.
*/
small {
font-size: 80%;
}
/*
Prevent `sub` and `sup` elements from affecting the line height in all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
/*
1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
3. Remove gaps between table borders by default.
*/
table {
text-indent: 0;
/* 1 */
border-color: inherit;
/* 2 */
border-collapse: collapse;
/* 3 */
}
/*
1. Change the font styles in all browsers.
2. Remove the margin in Firefox and Safari.
3. Remove default padding in all browsers.
*/
button,
input,
optgroup,
select,
textarea {
font-family: inherit;
/* 1 */
font-feature-settings: inherit;
/* 1 */
font-variation-settings: inherit;
/* 1 */
font-size: 100%;
/* 1 */
font-weight: inherit;
/* 1 */
line-height: inherit;
/* 1 */
color: inherit;
/* 1 */
margin: 0;
/* 2 */
padding: 0;
/* 3 */
}
/*
Remove the inheritance of text transform in Edge and Firefox.
*/
button,
select {
text-transform: none;
}
/*
1. Correct the inability to style clickable types in iOS and Safari.
2. Remove default button styles.
*/
button,
[type='button'],
[type='reset'],
[type='submit'] {
-webkit-appearance: button;
/* 1 */
background-color: transparent;
/* 2 */
background-image: none;
/* 2 */
}
/*
Use the modern Firefox focus style for all focusable elements.
*/
:-moz-focusring {
outline: auto;
}
/*
Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)
*/
:-moz-ui-invalid {
box-shadow: none;
}
/*
Add the correct vertical alignment in Chrome and Firefox.
*/
progress {
vertical-align: baseline;
}
/*
Correct the cursor style of increment and decrement buttons in Safari.
*/
::-webkit-inner-spin-button,
::-webkit-outer-spin-button {
height: auto;
}
/*
1. Correct the odd appearance in Chrome and Safari.
2. Correct the outline style in Safari.
*/
[type='search'] {
-webkit-appearance: textfield;
/* 1 */
outline-offset: -2px;
/* 2 */
}
/*
Remove the inner padding in Chrome and Safari on macOS.
*/
::-webkit-search-decoration {
-webkit-appearance: none;
}
/*
1. Correct the inability to style clickable types in iOS and Safari.
2. Change font properties to `inherit` in Safari.
*/
::-webkit-file-upload-button {
-webkit-appearance: button;
/* 1 */
font: inherit;
/* 2 */
}
/*
Add the correct display in Chrome and Safari.
*/
summary {
display: list-item;
}
/*
Removes the default spacing and border for appropriate elements.
*/
blockquote,
dl,
dd,
h1,
h2,
h3,
h4,
h5,
h6,
hr,
figure,
p,
pre {
margin: 0;
}
fieldset {
margin: 0;
padding: 0;
}
legend {
padding: 0;
}
ol,
ul,
menu {
list-style: none;
margin: 0;
padding: 0;
}
/*
Reset default styling for dialogs.
*/
dialog {
padding: 0;
}
/*
Prevent resizing textareas horizontally by default.
*/
textarea {
resize: vertical;
}
/*
1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)
2. Set the default placeholder color to the user's configured gray 400 color.
*/
input::-moz-placeholder, textarea::-moz-placeholder {
opacity: 1;
/* 1 */
color: #9ca3af;
/* 2 */
}
input::placeholder,
textarea::placeholder {
opacity: 1;
/* 1 */
color: #9ca3af;
/* 2 */
}
/*
Set the default cursor for buttons.
*/
button,
[role="button"] {
cursor: pointer;
}
/*
Make sure disabled buttons don't get the pointer cursor.
*/
:disabled {
cursor: default;
}
/*
1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)
2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)
This can trigger a poorly considered lint error in some tools but is included by design.
*/
img,
svg,
video,
canvas,
audio,
iframe,
embed,
object {
display: block;
/* 1 */
vertical-align: middle;
/* 2 */
}
/*
Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)
*/
img,
video {
max-width: 100%;
height: auto;
}
/* Make elements with the HTML hidden attribute stay hidden by default */
[hidden] {
display: none;
}
*, ::before, ::after {
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
--tw-gradient-from-position: ;
--tw-gradient-via-position: ;
--tw-gradient-to-position: ;
--tw-ordinal: ;
--tw-slashed-zero: ;
--tw-numeric-figure: ;
--tw-numeric-spacing: ;
--tw-numeric-fraction: ;
--tw-ring-inset: ;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgb(59 130 246 / 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
--tw-blur: ;
--tw-brightness: ;
--tw-contrast: ;
--tw-grayscale: ;
--tw-hue-rotate: ;
--tw-invert: ;
--tw-saturate: ;
--tw-sepia: ;
--tw-drop-shadow: ;
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
}
::backdrop {
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
--tw-gradient-from-position: ;
--tw-gradient-via-position: ;
--tw-gradient-to-position: ;
--tw-ordinal: ;
--tw-slashed-zero: ;
--tw-numeric-figure: ;
--tw-numeric-spacing: ;
--tw-numeric-fraction: ;
--tw-ring-inset: ;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgb(59 130 246 / 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
--tw-blur: ;
--tw-brightness: ;
--tw-contrast: ;
--tw-grayscale: ;
--tw-hue-rotate: ;
--tw-invert: ;
--tw-saturate: ;
--tw-sepia: ;
--tw-drop-shadow: ;
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
}
.visible {
visibility: visible;
}
.mx-0 {
margin-left: 0px;
margin-right: 0px;
}
.mx-0\.5 {
margin-left: 0.125rem;
margin-right: 0.125rem;
}
.mx-2 {
margin-left: 0.5rem;
margin-right: 0.5rem;
}
.mt-1 {
margin-top: 0.25rem;
}
.mt-2 {
margin-top: 0.5rem;
}
.block {
display: block;
}
.flex {
display: flex;
}
.h-12 {
height: 3rem;
}
.h-full {
height: 100%;
}
.h-screen {
height: 100vh;
}
.min-h-\[50\%\] {
min-height: 50%;
}
.w-12 {
width: 3rem;
}
.w-full {
width: 100%;
}
.flex-shrink-0 {
flex-shrink: 0;
}
.flex-grow {
flex-grow: 1;
}
.transform {
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
}
.select-none {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.flex-col {
flex-direction: column;
}
.justify-center {
justify-content: center;
}
.justify-between {
justify-content: space-between;
}
.space-x-2 > :not([hidden]) ~ :not([hidden]) {
--tw-space-x-reverse: 0;
margin-right: calc(0.5rem * var(--tw-space-x-reverse));
margin-left: calc(0.5rem * calc(1 - var(--tw-space-x-reverse)));
}
.overflow-y-scroll {
overflow-y: scroll;
}
.truncate {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.rounded-lg {
border-radius: 0.5rem;
}
.rounded-md {
border-radius: 0.375rem;
}
.rounded-sm {
border-radius: 0.125rem;
}
.rounded-t-lg {
border-top-left-radius: 0.5rem;
border-top-right-radius: 0.5rem;
}
.border-2 {
border-width: 2px;
}
.border-x-2 {
border-left-width: 2px;
border-right-width: 2px;
}
.border-b-2 {
border-bottom-width: 2px;
}
.border-t-2 {
border-top-width: 2px;
}
.border-stone-200 {
--tw-border-opacity: 1;
border-color: rgb(231 229 228 / var(--tw-border-opacity));
}
.border-stone-500 {
--tw-border-opacity: 1;
border-color: rgb(120 113 108 / var(--tw-border-opacity));
}
.border-stone-600 {
--tw-border-opacity: 1;
border-color: rgb(87 83 78 / var(--tw-border-opacity));
}
.bg-cyan-600 {
--tw-bg-opacity: 1;
background-color: rgb(8 145 178 / var(--tw-bg-opacity));
}
.bg-cyan-950 {
--tw-bg-opacity: 1;
background-color: rgb(8 51 68 / var(--tw-bg-opacity));
}
.bg-gray-800 {
--tw-bg-opacity: 1;
background-color: rgb(31 41 55 / var(--tw-bg-opacity));
}
.bg-gray-900 {
--tw-bg-opacity: 1;
background-color: rgb(17 24 39 / var(--tw-bg-opacity));
}
.bg-green-600 {
--tw-bg-opacity: 1;
background-color: rgb(22 163 74 / var(--tw-bg-opacity));
}
.bg-green-950 {
--tw-bg-opacity: 1;
background-color: rgb(5 46 22 / var(--tw-bg-opacity));
}
.bg-red-600 {
--tw-bg-opacity: 1;
background-color: rgb(220 38 38 / var(--tw-bg-opacity));
}
.bg-red-700 {
--tw-bg-opacity: 1;
background-color: rgb(185 28 28 / var(--tw-bg-opacity));
}
.bg-red-950 {
--tw-bg-opacity: 1;
background-color: rgb(69 10 10 / var(--tw-bg-opacity));
}
.bg-slate-400 {
--tw-bg-opacity: 1;
background-color: rgb(148 163 184 / var(--tw-bg-opacity));
}
.bg-slate-700 {
--tw-bg-opacity: 1;
background-color: rgb(51 65 85 / var(--tw-bg-opacity));
}
.bg-stone-600 {
--tw-bg-opacity: 1;
background-color: rgb(87 83 78 / var(--tw-bg-opacity));
}
.bg-yellow-600 {
--tw-bg-opacity: 1;
background-color: rgb(202 138 4 / var(--tw-bg-opacity));
}
.bg-yellow-950 {
--tw-bg-opacity: 1;
background-color: rgb(66 32 6 / var(--tw-bg-opacity));
}
.fill-gray-100 {
fill: #f3f4f6;
}
.fill-stone-300 {
fill: #d6d3d1;
}
.stroke-stone-200 {
stroke: #e7e5e4;
}
.stroke-stone-300 {
stroke: #d6d3d1;
}
.p-2 {
padding: 0.5rem;
}
.px-2 {
padding-left: 0.5rem;
padding-right: 0.5rem;
}
.px-6 {
padding-left: 1.5rem;
padding-right: 1.5rem;
}
.py-2 {
padding-top: 0.5rem;
padding-bottom: 0.5rem;
}
.pb-1 {
padding-bottom: 0.25rem;
}
.text-center {
text-align: center;
}
.text-lg {
font-size: 1.125rem;
line-height: 1.75rem;
}
.text-sm {
font-size: 0.875rem;
line-height: 1.25rem;
}
.font-bold {
font-weight: 700;
}
.italic {
font-style: italic;
}
.text-stone-200 {
--tw-text-opacity: 1;
color: rgb(231 229 228 / var(--tw-text-opacity));
}
.text-stone-300 {
--tw-text-opacity: 1;
color: rgb(214 211 209 / var(--tw-text-opacity));
}
.text-white {
--tw-text-opacity: 1;
color: rgb(255 255 255 / var(--tw-text-opacity));
}
.filter {
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
}
.hover\:bg-slate-800:hover {
--tw-bg-opacity: 1;
background-color: rgb(30 41 59 / var(--tw-bg-opacity));
}
.hover\:fill-stone-900:hover {
fill: #1c1917;
}
.hover\:stroke-stone-300:hover {
stroke: #d6d3d1;
}

View file

@ -0,0 +1,323 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="output.css">
<!-- <script src="https://cdn.tailwindcss.com"></script> -->
<script src="cash.min.js"></script>
</head>
<body class="bg-gray-800">
<div class="flex flex-col h-screen">
<div class="w-full flex flex-col">
<div class="flex justify-between text-center text-white select-none mx-2">
<div data-tab="running"
class="script-tab flex-grow bg-green-600 rounded-t-lg py-2 text-lg font-bold mx-0.5 border-t-2 border-x-2 border-stone-200">
Running</div>
<div data-tab="stopped"
class="script-tab flex-grow bg-red-950 rounded-t-lg py-2 text-md mx-0.5 border-t-2 border-x-2 border-stone-600">
Stopped
</div>
<div data-tab="saved"
class="script-tab flex-grow bg-yellow-950 rounded-t-lg py-2 text-md mx-0.5 border-t-2 border-x-2 border-stone-600">
Saved
</div>
</div>
</div>
<div class="flex flex-col h-full flex-grow min-h-[50%] overflow-y-scroll">
<div class="script-view flex-grow bg-gray-900 rounded-md w-full border-2 border-stone-500"
data-view="running">
<div class="pb-1 flex justify-center mt-1">
<input id="btnLoadNew" class="bg-slate-400 text-stone-200 px-6 py-2 mx-2 rounded-md" type="button"
value="Load From URL">
<input id="btnReloadAll" class="bg-cyan-600 text-stone-200 px-6 py-2 mx-2 rounded-md" type="button"
value="Reload All">
<input id="btnLoadDefaults" class="bg-stone-600 text-stone-200 px-6 py-2 mx-2 rounded-md"
type="button" value="Load Defaults">
<input id="btnStopAll" class="bg-red-700 text-stone-200 px-6 py-2 mx-2 rounded-md" type="button"
value="Stop All">
</div>
<div data-list="running"></div>
</div>
<div class="script-view flex-grow bg-gray-900 rounded-md w-full border-2 border-stone-500"
data-view="stopped" style="display: none">
<p id="stoppedScriptMessage" class="text-white text-center mt-2">Running scripts that were stopped will be displayed here.<br /><span class="italic">This list is reset when this window is closed.</span></p>
<div data-list="stopped">
</div>
</div>
<div class="script-view flex-grow bg-gray-900 rounded-md w-full border-2 border-stone-500" data-view="saved"
style="display: none">
<p id="savedScriptMessage" class="text-white text-center mt-2">Saved scripts will be displayed here.<br /><span class="italic">This list is persisted across restarts.</span></p>
<div data-list="saved">
Saved
</div>
</div>
</div>
</div>
<script>
const channel = "application.zetaphor.scriptManager"
const scriptViews = $('.script-view')
const stoppedScriptMessage = $('#stoppedScriptMessage')
const savedScriptMessage= $('#savedScriptMessage')
const defaultScripts = [
'defaultScripts.js',
'app-more.js',
'FloofChat.js',
'notificationCore.js',
'controllerScripts.js',
'simplifiedNametag.js'
]
const activeColors = {
'running': 'bg-green-600',
'stopped': 'bg-red-700',
'saved': 'bg-yellow-600',
'help': 'bg-cyan-600',
}
const inactiveColors = {
'running': 'bg-green-950',
'stopped': 'bg-red-950',
'saved': 'bg-yellow-950',
'help': 'bg-cyan-950',
}
var currentTab = 'running'
let runningScripts = []
let stoppedScripts = []
let savedScripts = []
if (typeof EventBridge !== 'undefined') {
EventBridge.scriptEventReceived.connect(function (message) {
let messageObj = JSON.parse(message)
if (typeof messageObj.channel === 'undefined') return
if (messageObj.action == 'scripts_update') {
runningScripts = messageObj.data
} else if (messageObj.action == 'saved_update') {
savedScripts = messageObj.data
console.log("received saved list")
}
rebuildScriptsLists()
})
}
document.addEventListener('DOMContentLoaded', function () {
sendWebEvent('refresh_scripts')
sendWebEvent('get_saved')
})
$('#btnReloadAll').on("click", function () {
for (let i = 0; i < runningScripts.length; i++) {
sendWebEvent('reload_script', runningScripts[i]['url'])
}
})
$('#btnStopAll').on("click", function () {
const currentScripts = runningScripts
for (let i = 0; i < currentScripts.length; i++) {
if (currentScripts[i]['name'] !== 'scriptManager.js') {
stopRunningScript(currentScripts[i]['name'], currentScripts[i]['url'])
}
}
})
$('#btnLoadDefaults').on("click", function () {
loadScript('defaultScripts.js', 'file:///~//defaultScripts.js')
setTimeout(function() {
sendWebEvent('refresh_scripts')
}, 1000)
})
$('#btnLoadNew').on("click", function () {
sendWebEvent('prompt_load')
})
$('.script-tab').on('click', function () {
const newType = this.getAttribute('data-tab')
if (newType === currentTab) return
const activeTab = $(`[data-tab="${currentTab}"]`)
const activeType = activeTab.attr('data-tab')
const newTab = $(`[data-tab="${newType}"]`)
activeTab.removeClass(`font-bold border-stone-200 ${activeColors[activeType]}`)
activeTab.addClass(`border-stone-600 ${inactiveColors[activeType]}`)
newTab.removeClass(`border-stone-600 ${inactiveColors[newType]}`)
newTab.addClass(`font-bold border-stone-200 ${activeColors[newType]}`)
currentTab = newType
scriptViews.hide()
$(`[data-view="${currentTab}"]`).show()
})
$('[data-list]').on('click', function (event) {
let target = $(event.target)
let scriptName = ''
let buttonType = ''
let scriptUrl = ''
if (event.target.nodeName === 'path') {
scriptName = event.target.parentElement.getAttribute('data-script')
scriptUrl = event.target.parentElement.getAttribute('data-script-url')
buttonType = event.target.parentElement.getAttribute('data-btn-type')
} else if (event.target.nodeName === 'svg') {
scriptName = event.target.getAttribute('data-script')
scriptUrl = event.target.getAttribute('data-script-url')
buttonType = event.target.getAttribute('data-btn-type')
}
if (buttonType === 'save') toggleSaved(scriptName, scriptUrl)
else if (buttonType === 'stop') stopRunningScript(scriptName, scriptUrl)
else if (buttonType === 'reload') sendWebEvent('reload_script', scriptUrl)
else if (buttonType === 'load') loadScript(scriptName, scriptUrl)
rebuildScriptsLists()
})
function sendWebEvent(action, data = null) {
const eventData = {
"channel": channel,
"action": action,
"data": data
}
EventBridge.emitWebEvent(JSON.stringify(eventData))
}
function buildRunningScriptList() {
$('[data-list="running"]').empty()
for (let i = 0; i < runningScripts.length; i++) {
const saved = savedScripts.some(script => script.name === runningScripts[i]['name'])
addRunningScript(runningScripts[i], saved)
}
}
function buildSavedScriptList() {
$('[data-list="saved"]').empty()
for (let i = 0; i < savedScripts.length; i++) {
addSavedScript(savedScripts[i])
}
if (savedScripts.length) savedScriptMessage.hide()
else savedScriptMessage.show()
}
function buildStoppedScriptList() {
$('[data-list="stopped"]').empty()
for (let i = 0; i < stoppedScripts.length; i++) {
addStoppedScript(stoppedScripts[i])
}
if (stoppedScripts.length) stoppedScriptMessage.hide()
else stoppedScriptMessage.show()
}
function rebuildScriptsLists() {
buildRunningScriptList()
buildStoppedScriptList()
buildSavedScriptList()
}
function addRunningScript(script, saved) {
let scriptUrl = script.url
const displayName = script.name.split('.js')[0]
if (scriptUrl.includes('file:///')) scriptUrl = 'scripts/' + scriptUrl.split('file:///~//')[1]
const newItem = $(
`<div class="flex justify-between rounded-sm bg-slate-700 hover:bg-slate-800 text-white p-2 border-b-2 border-stone-500" data-script="${script.name.toLowerCase()}">
<div class="flex-grow select-none">
<span class="font-bold block">${displayName} ${defaultScripts.includes(script.name) ? ' <span class="text-stone-300 text-sm italic">(System Default)</span>' : ''}</span>
<span class="text-stone-300 truncate w-full text-sm">${scriptUrl}</span>
</div>
<div class="flex space-x-2 flex-shrink-0">
<svg data-btn-type="save" ${saved ? 'style="display:none"' : ''} data-script-url="${script.url}" class="px-2 py-2 rounded-lg w-12 h-12 bg-yellow-600 stroke-stone-200 fill-gray-100 hover:stroke-stone-300 hover:fill-stone-900" data-script="${script.name}" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="15 0 75 100"><path d="M83.5 92.3c-1 0-2.1-.4-3-1.2L50.8 59.7a1 1 0 0 0-1.4 0l-30 31.4a4 4 0 0 1-7-2.8V11.7a4 4 0 0 1 4-4h67.1a4 4 0 0 1 4 4v76.6A4 4 0 0 1 85 92l-1.5.3zM50 49.1a4 4 0 0 1 3 1.2l24.8 26a1 1 0 0 0 1.7-.6v-60h-59v60a1 1 0 0 0 1.7.7l24.8-26a4 4 0 0 1 3-1.3z"/></svg>
<svg data-btn-type="save" ${saved ? '' : 'style="display:none"'} data-script="${script.name}" data-script-url="${script.url}" class="px-2 py-2 rounded-lg w-12 h-12 bg-yellow-600 stroke-stone-300 fill-stone-300 hover:stroke-stone-300 hover:fill-stone-900" xmlns="http://www.w3.org/2000/svg" viewBox="15 0 75 100"><path d="M83.5 92.3c-1 0-2.1-.4-3-1.2L50.8 59.7a1 1 0 0 0-1.4 0l-30 31.4a4 4 0 0 1-7-2.8V11.7a4 4 0 0 1 4-4h67.1a4 4 0 0 1 4 4v76.6c0 1.6-1 3-2.5 3.7l-1.5.3Z"/></svg>
<svg data-btn-type="reload" data-script="${script.name}" data-script-url="${script.url}" class="px-2 py-2 rounded-lg w-12 h-12 bg-cyan-600 stroke-stone-200 fill-gray-100 hover:stroke-stone-300 hover:fill-stone-900" xmlns="http://www.w3.org/2000/svg" viewBox="8 0 75 100"><path d="M84.5 75.1A46 46 0 0 0 45.9 4 45.8 45.8 0 0 0 0 49.7 46 46 0 0 0 43.8 96a46.4 46.4 0 0 0 27.3-7.6 5.4 5.4 0 0 1-6-4.5l-.7-4.5A34.9 34.9 0 0 1 11 50a34.8 34.8 0 1 1 62.6 21 1.4 1.4 0 0 1-2.6-.6l-2.6-14.6c-.6-3.6-6-2.6-5.3 1l4.7 26.7a2.5 2.5 0 0 0 3 2.1l26.8-4.7c3.6-.6 2.7-6-.9-5.4l-11 2a1.4 1.4 0 0 1-1.3-2.3Z"/></svg>
<svg data-btn-type="stop" data-script="${script.name}" data-script-url="${script.url}" class="px-2 py-2 rounded-lg w-12 h-12 bg-red-600 stroke-stone-200 fill-gray-100 hover:stroke-stone-300 hover:fill-stone-900" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="-155 95 75 100"><path d="m-74.9 117.2-27.3 27.8 27.3 27.8-14.2 14-27.1-27.5-27 27.5-14.3-14 27.3-27.8-27.3-27.8 14.3-14 27 27.5 27.1-27.5z"/></svg>
</div>
</div>`
);
$('[data-list="running"]').append(newItem)
}
function addSavedScript(script) {
let scriptUrl = script.url
const displayName = script.name.split('.js')[0]
const running = runningScripts.find(runningScript => runningScript.name === script.name)
if (scriptUrl.includes('file:///')) scriptUrl = 'scripts/' + scriptUrl.split('file:///~//')[1]
const newItem = $(
`<div class="flex justify-between rounded-sm bg-slate-700 hover:bg-slate-800 text-white p-2 border-b-2 border-stone-500" data-script="${script.name.toLowerCase()}">
<div class="flex-grow">
<span class="font-bold block">${displayName} ${defaultScripts.includes(script.name) ? ' <span class="text-stone-300 text-sm italic">(Default)</span>' : ''}</span>
<span class="text-stone-300 truncate w-full text-sm">${scriptUrl}</span>
</div>
<div class="flex space-x-2 flex-shrink-0">
<svg data-btn-type="save" data-script="${script.name}" data-script-url="${script.url}" class="px-2 py-2 rounded-lg w-12 h-12 bg-yellow-600 stroke-stone-300 fill-stone-300 hover:stroke-stone-300 hover:fill-stone-900" xmlns="http://www.w3.org/2000/svg" viewBox="15 0 75 100"><path d="M83.5 92.3c-1 0-2.1-.4-3-1.2L50.8 59.7a1 1 0 0 0-1.4 0l-30 31.4a4 4 0 0 1-7-2.8V11.7a4 4 0 0 1 4-4h67.1a4 4 0 0 1 4 4v76.6c0 1.6-1 3-2.5 3.7l-1.5.3Z"/></svg>
<svg data-btn-type="reload" ${running ? '' : 'style="display:none"'} data-script="${script.name}" data-script-url="${script.url}" class="px-2 py-2 rounded-lg w-12 h-12 bg-cyan-600 stroke-stone-200 fill-gray-100 hover:stroke-stone-300 hover:fill-stone-900" xmlns="http://www.w3.org/2000/svg" viewBox="8 0 75 100"><path d="M84.5 75.1A46 46 0 0 0 45.9 4 45.8 45.8 0 0 0 0 49.7 46 46 0 0 0 43.8 96a46.4 46.4 0 0 0 27.3-7.6 5.4 5.4 0 0 1-6-4.5l-.7-4.5A34.9 34.9 0 0 1 11 50a34.8 34.8 0 1 1 62.6 21 1.4 1.4 0 0 1-2.6-.6l-2.6-14.6c-.6-3.6-6-2.6-5.3 1l4.7 26.7a2.5 2.5 0 0 0 3 2.1l26.8-4.7c3.6-.6 2.7-6-.9-5.4l-11 2a1.4 1.4 0 0 1-1.3-2.3Z"/></svg>
<svg data-btn-type="load" ${running ? 'style="display:none"' : ''} data-script="${script.name}" data-script-url="${script.url}" class="px-2 py-2 rounded-lg w-12 h-12 bg-cyan-600 stroke-stone-200 fill-gray-100 hover:stroke-stone-300 hover:fill-stone-900" xmlns="http://www.w3.org/2000/svg" viewBox="35 25 25 50"><path d="M33.8 982.4a1 1 0 0 0-.8 1v38a1 1 0 0 0 1.5.8l32-19a1 1 0 0 0 0-1.7l-32-19a1 1 0 0 0-.7-.1Z" color="#000" overflow="visible" style="text-indent:0;text-transform:none;block-progression:tb" transform="translate(0 -952.4)"/></svg>
<svg ${running ? '' : 'style="display:none"'} data-btn-type="stop" data-script="${script.name}" data-script-url="${script.url}" class="px-2 py-2 rounded-lg w-12 h-12 bg-red-600 stroke-stone-200 fill-gray-100 hover:stroke-stone-300 hover:fill-stone-900" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="-155 95 75 100"><path d="m-74.9 117.2-27.3 27.8 27.3 27.8-14.2 14-27.1-27.5-27 27.5-14.3-14 27.3-27.8-27.3-27.8 14.3-14 27 27.5 27.1-27.5z"/></svg>
</div>
</div>`
);
$('[data-list="saved"]').append(newItem)
}
function addStoppedScript(script) {
let scriptUrl = script.url
const displayName = script.name.split('.js')[0]
if (scriptUrl.includes('file:///')) scriptUrl = 'scripts/' + scriptUrl.split('file:///~//')[1]
const newItem = $(
`<div class="flex justify-between rounded-sm bg-slate-700 hover:bg-slate-800 text-white p-2 border-b-2 border-stone-500" data-script="${script.name.toLowerCase()}">
<div class="flex-grow">
<span class="font-bold block">${displayName} ${defaultScripts.includes(script.name) ? ' <span class="text-stone-300 text-sm italic">(Default)</span>' : ''}</span>
<span class="text-stone-300 truncate w-full text-sm">${scriptUrl}</span>
</div>
<div class="flex space-x-2 flex-shrink-0">
<svg ${savedScripts.includes(script.name) ? 'style="display:none"' : ''} class="btn-save px-2 py-2 rounded-lg w-12 h-12 bg-yellow-600 stroke-stone-200 fill-gray-100 hover:stroke-stone-300 hover:fill-stone-900" data-script="${script.name}" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="15 0 75 100"><path d="M83.5 92.3c-1 0-2.1-.4-3-1.2L50.8 59.7a1 1 0 0 0-1.4 0l-30 31.4a4 4 0 0 1-7-2.8V11.7a4 4 0 0 1 4-4h67.1a4 4 0 0 1 4 4v76.6A4 4 0 0 1 85 92l-1.5.3zM50 49.1a4 4 0 0 1 3 1.2l24.8 26a1 1 0 0 0 1.7-.6v-60h-59v60a1 1 0 0 0 1.7.7l24.8-26a4 4 0 0 1 3-1.3z"/></svg>
<svg ${savedScripts.includes(script.name) ? '' : 'style="display:none"'} data-script="${script.name}" class="btn-save px-2 py-2 rounded-lg w-12 h-12 bg-yellow-600 stroke-stone-300 fill-stone-300 hover:stroke-stone-300 hover:fill-stone-900" xmlns="http://www.w3.org/2000/svg" viewBox="15 0 75 100"><path d="M83.5 92.3c-1 0-2.1-.4-3-1.2L50.8 59.7a1 1 0 0 0-1.4 0l-30 31.4a4 4 0 0 1-7-2.8V11.7a4 4 0 0 1 4-4h67.1a4 4 0 0 1 4 4v76.6c0 1.6-1 3-2.5 3.7l-1.5.3Z"/></svg>
<svg data-btn-type="load" data-script="${script.name}" data-script-url="${script.url}" class="px-2 py-2 rounded-lg w-12 h-12 bg-cyan-600 stroke-stone-200 fill-gray-100 hover:stroke-stone-300 hover:fill-stone-900" xmlns="http://www.w3.org/2000/svg" viewBox="35 25 25 50"><path d="M33.8 982.4a1 1 0 0 0-.8 1v38a1 1 0 0 0 1.5.8l32-19a1 1 0 0 0 0-1.7l-32-19a1 1 0 0 0-.7-.1Z" color="#000" overflow="visible" style="text-indent:0;text-transform:none;block-progression:tb" transform="translate(0 -952.4)"/></svg>
</div>
</div>`
);
$('[data-list="stopped"]').append(newItem)
}
function toggleSaved(name, url) {
const saved = savedScripts.some(script => script.name === name)
if (saved) {
savedScripts = savedScripts.filter(script => script.name !== name)
} else savedScripts.push({
name: name,
url: url
})
rebuildScriptsLists()
sendWebEvent('set_saved', savedScripts)
}
function loadScript(name, url) {
sendWebEvent('load_script', url)
runningScripts.push({
name: name,
url: url
})
let removedScript = null
stoppedScripts = stoppedScripts.filter(item => {
if (item.name === name) {
removedScript = item
return false
}
return true
})
rebuildScriptsLists()
}
function stopRunningScript(name, url) {
let removedScript = null
runningScripts = runningScripts.filter(item => {
if (item.name === name) {
removedScript = item
return false
}
return true
})
sendWebEvent('stop_script', url)
stoppedScripts.push(removedScript)
rebuildScriptsLists()
}
</script>
</body>
</html>

View file

@ -0,0 +1,104 @@
(function () {
const jsMainFileName = "scriptManager.js"
const ROOT = Script.resolvePath('').split(jsMainFileName)[0]
const APP_NAME = "SCRIPTS"
const APP_URL = ROOT + `scriptManager.html?t=${Math.floor(Date.now() / 1000)}`
const APP_ICON_INACTIVE = ROOT + "icon-inactive.png"
const APP_ICON_ACTIVE = ROOT + "icon-active.png"
let appStatus = false
const channel = "application.zetaphor.scriptManager"
const tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system")
let overlayWebWindow = null
const button = tablet.addButton({
text: APP_NAME,
icon: APP_ICON_INACTIVE,
activeIcon: APP_ICON_ACTIVE
})
function clicked() {
if (appStatus === true) {
overlayWebWindow.webEventReceived.disconnect(onWebEventReceived)
appStatus = false
} else {
overlayWebWindow = new OverlayWebWindow({
title: "Scripts Manager",
source: Script.resolvePath(APP_URL),
width: 850,
height: 500
})
overlayWebWindow.webEventReceived.connect(onWebEventReceived)
overlayWebWindow.closed.connect(function () {
appStatus = false
button.editProperties({
isActive: appStatus
})
})
appStatus = true
}
button.editProperties({
isActive: appStatus
})
}
function onWebEventReceived(message) {
if (typeof message === "string") {
const input = JSON.parse(message)
if (input.channel !== channel) return
if (input.action == 'refresh_scripts') {
const runningScripts = ScriptDiscoveryService.getRunning()
sendWebEvent('scripts_update', runningScripts)
} else if (input.action == 'stop_script') {
let scriptUrl = input.data
if (scriptUrl.startsWith('scripts/')) scriptUrl = 'file:///~//' + scriptUrl
ScriptDiscoveryService.stopScript(scriptUrl)
} else if (input.action == 'reload_script') {
let scriptUrl = input.data
if (scriptUrl.startsWith('scripts/')) scriptUrl = 'file:///~//' + scriptUrl
ScriptDiscoveryService.stopScript(scriptUrl)
ScriptDiscoveryService.loadScript(scriptUrl)
} else if (input.action == 'load_script') {
// TODO: Need to pass flag to determine if script should be reloaded on restart
ScriptDiscoveryService.loadScript(input.data, false, false, false, true)
} else if (input.action == 'get_saved') {
const savedScripts = Settings.getValue("zScriptManager/SavedScripts", [])
sendWebEvent('saved_update', savedScripts)
} else if (input.action == 'set_saved') {
Settings.setValue("zScriptManager/SavedScripts", input.data)
} else if (input.action == 'prompt_load') {
url = Window.prompt("Enter the URL to a javascript file to load", "")
ScriptDiscoveryService.loadScript(url, false, false, false, true)
Script.setTimeout(function () {
const runningScripts = ScriptDiscoveryService.getRunning()
sendWebEvent('scripts_update', runningScripts)
}, 1000)
}
}
}
function sendWebEvent(action, data = null) {
const eventData = {
"channel": channel,
"action": action,
"data": data
}
overlayWebWindow.emitScriptEvent(JSON.stringify(eventData))
}
function cleanup() {
if (appStatus) {
tablet.gotoHomeScreen()
tablet.webEventReceived.disconnect(onWebEventReceived)
}
tablet.removeButton(button)
}
button.clicked.connect(clicked)
Script.scriptEnding.connect(cleanup)
}())

6
applications/zDebugger/cash.min.js vendored Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 702 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

View file

@ -0,0 +1,715 @@
/*
! tailwindcss v3.3.3 | MIT License | https://tailwindcss.com
*/
/*
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
*/
*,
::before,
::after {
box-sizing: border-box;
/* 1 */
border-width: 0;
/* 2 */
border-style: solid;
/* 2 */
border-color: #e5e7eb;
/* 2 */
}
::before,
::after {
--tw-content: '';
}
/*
1. Use a consistent sensible line-height in all browsers.
2. Prevent adjustments of font size after orientation changes in iOS.
3. Use a more readable tab size.
4. Use the user's configured `sans` font-family by default.
5. Use the user's configured `sans` font-feature-settings by default.
6. Use the user's configured `sans` font-variation-settings by default.
*/
html {
line-height: 1.5;
/* 1 */
-webkit-text-size-adjust: 100%;
/* 2 */
-moz-tab-size: 4;
/* 3 */
-o-tab-size: 4;
tab-size: 4;
/* 3 */
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
/* 4 */
font-feature-settings: normal;
/* 5 */
font-variation-settings: normal;
/* 6 */
}
/*
1. Remove the margin in all browsers.
2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.
*/
body {
margin: 0;
/* 1 */
line-height: inherit;
/* 2 */
}
/*
1. Add the correct height in Firefox.
2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
3. Ensure horizontal rules are visible by default.
*/
hr {
height: 0;
/* 1 */
color: inherit;
/* 2 */
border-top-width: 1px;
/* 3 */
}
/*
Add the correct text decoration in Chrome, Edge, and Safari.
*/
abbr:where([title]) {
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
}
/*
Remove the default font size and weight for headings.
*/
h1,
h2,
h3,
h4,
h5,
h6 {
font-size: inherit;
font-weight: inherit;
}
/*
Reset links to optimize for opt-in styling instead of opt-out.
*/
a {
color: inherit;
text-decoration: inherit;
}
/*
Add the correct font weight in Edge and Safari.
*/
b,
strong {
font-weight: bolder;
}
/*
1. Use the user's configured `mono` font family by default.
2. Correct the odd `em` font sizing in all browsers.
*/
code,
kbd,
samp,
pre {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
/* 1 */
font-size: 1em;
/* 2 */
}
/*
Add the correct font size in all browsers.
*/
small {
font-size: 80%;
}
/*
Prevent `sub` and `sup` elements from affecting the line height in all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
/*
1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
3. Remove gaps between table borders by default.
*/
table {
text-indent: 0;
/* 1 */
border-color: inherit;
/* 2 */
border-collapse: collapse;
/* 3 */
}
/*
1. Change the font styles in all browsers.
2. Remove the margin in Firefox and Safari.
3. Remove default padding in all browsers.
*/
button,
input,
optgroup,
select,
textarea {
font-family: inherit;
/* 1 */
font-feature-settings: inherit;
/* 1 */
font-variation-settings: inherit;
/* 1 */
font-size: 100%;
/* 1 */
font-weight: inherit;
/* 1 */
line-height: inherit;
/* 1 */
color: inherit;
/* 1 */
margin: 0;
/* 2 */
padding: 0;
/* 3 */
}
/*
Remove the inheritance of text transform in Edge and Firefox.
*/
button,
select {
text-transform: none;
}
/*
1. Correct the inability to style clickable types in iOS and Safari.
2. Remove default button styles.
*/
button,
[type='button'],
[type='reset'],
[type='submit'] {
-webkit-appearance: button;
/* 1 */
background-color: transparent;
/* 2 */
background-image: none;
/* 2 */
}
/*
Use the modern Firefox focus style for all focusable elements.
*/
:-moz-focusring {
outline: auto;
}
/*
Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)
*/
:-moz-ui-invalid {
box-shadow: none;
}
/*
Add the correct vertical alignment in Chrome and Firefox.
*/
progress {
vertical-align: baseline;
}
/*
Correct the cursor style of increment and decrement buttons in Safari.
*/
::-webkit-inner-spin-button,
::-webkit-outer-spin-button {
height: auto;
}
/*
1. Correct the odd appearance in Chrome and Safari.
2. Correct the outline style in Safari.
*/
[type='search'] {
-webkit-appearance: textfield;
/* 1 */
outline-offset: -2px;
/* 2 */
}
/*
Remove the inner padding in Chrome and Safari on macOS.
*/
::-webkit-search-decoration {
-webkit-appearance: none;
}
/*
1. Correct the inability to style clickable types in iOS and Safari.
2. Change font properties to `inherit` in Safari.
*/
::-webkit-file-upload-button {
-webkit-appearance: button;
/* 1 */
font: inherit;
/* 2 */
}
/*
Add the correct display in Chrome and Safari.
*/
summary {
display: list-item;
}
/*
Removes the default spacing and border for appropriate elements.
*/
blockquote,
dl,
dd,
h1,
h2,
h3,
h4,
h5,
h6,
hr,
figure,
p,
pre {
margin: 0;
}
fieldset {
margin: 0;
padding: 0;
}
legend {
padding: 0;
}
ol,
ul,
menu {
list-style: none;
margin: 0;
padding: 0;
}
/*
Reset default styling for dialogs.
*/
dialog {
padding: 0;
}
/*
Prevent resizing textareas horizontally by default.
*/
textarea {
resize: vertical;
}
/*
1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)
2. Set the default placeholder color to the user's configured gray 400 color.
*/
input::-moz-placeholder, textarea::-moz-placeholder {
opacity: 1;
/* 1 */
color: #9ca3af;
/* 2 */
}
input::placeholder,
textarea::placeholder {
opacity: 1;
/* 1 */
color: #9ca3af;
/* 2 */
}
/*
Set the default cursor for buttons.
*/
button,
[role="button"] {
cursor: pointer;
}
/*
Make sure disabled buttons don't get the pointer cursor.
*/
:disabled {
cursor: default;
}
/*
1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)
2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)
This can trigger a poorly considered lint error in some tools but is included by design.
*/
img,
svg,
video,
canvas,
audio,
iframe,
embed,
object {
display: block;
/* 1 */
vertical-align: middle;
/* 2 */
}
/*
Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)
*/
img,
video {
max-width: 100%;
height: auto;
}
/* Make elements with the HTML hidden attribute stay hidden by default */
[hidden] {
display: none;
}
*, ::before, ::after {
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
--tw-gradient-from-position: ;
--tw-gradient-via-position: ;
--tw-gradient-to-position: ;
--tw-ordinal: ;
--tw-slashed-zero: ;
--tw-numeric-figure: ;
--tw-numeric-spacing: ;
--tw-numeric-fraction: ;
--tw-ring-inset: ;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgb(59 130 246 / 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
--tw-blur: ;
--tw-brightness: ;
--tw-contrast: ;
--tw-grayscale: ;
--tw-hue-rotate: ;
--tw-invert: ;
--tw-saturate: ;
--tw-sepia: ;
--tw-drop-shadow: ;
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
}
::backdrop {
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
--tw-gradient-from-position: ;
--tw-gradient-via-position: ;
--tw-gradient-to-position: ;
--tw-ordinal: ;
--tw-slashed-zero: ;
--tw-numeric-figure: ;
--tw-numeric-spacing: ;
--tw-numeric-fraction: ;
--tw-ring-inset: ;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgb(59 130 246 / 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
--tw-blur: ;
--tw-brightness: ;
--tw-contrast: ;
--tw-grayscale: ;
--tw-hue-rotate: ;
--tw-invert: ;
--tw-saturate: ;
--tw-sepia: ;
--tw-drop-shadow: ;
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
}
.fixed {
position: fixed;
}
.mr-0 {
margin-right: 0px;
}
.mr-0\.5 {
margin-right: 0.125rem;
}
.mt-1 {
margin-top: 0.25rem;
}
.mt-12 {
margin-top: 3rem;
}
.mt-2 {
margin-top: 0.5rem;
}
.flex {
display: flex;
}
.h-6 {
height: 1.5rem;
}
.h-screen {
height: 100vh;
}
.min-h-\[50\%\] {
min-height: 50%;
}
.w-6 {
width: 1.5rem;
}
.w-full {
width: 100%;
}
.flex-grow {
flex-grow: 1;
}
.cursor-pointer {
cursor: pointer;
}
.flex-col {
flex-direction: column;
}
.items-center {
align-items: center;
}
.justify-between {
justify-content: space-between;
}
.rounded-md {
border-radius: 0.375rem;
}
.rounded-sm {
border-radius: 0.125rem;
}
.border-2 {
border-width: 2px;
}
.border-b-2 {
border-bottom-width: 2px;
}
.border-stone-500 {
--tw-border-opacity: 1;
border-color: rgb(120 113 108 / var(--tw-border-opacity));
}
.bg-cyan-500 {
--tw-bg-opacity: 1;
background-color: rgb(6 182 212 / var(--tw-bg-opacity));
}
.bg-gray-600 {
--tw-bg-opacity: 1;
background-color: rgb(75 85 99 / var(--tw-bg-opacity));
}
.bg-gray-800 {
--tw-bg-opacity: 1;
background-color: rgb(31 41 55 / var(--tw-bg-opacity));
}
.bg-gray-900 {
--tw-bg-opacity: 1;
background-color: rgb(17 24 39 / var(--tw-bg-opacity));
}
.bg-rose-500 {
--tw-bg-opacity: 1;
background-color: rgb(244 63 94 / var(--tw-bg-opacity));
}
.bg-slate-400 {
--tw-bg-opacity: 1;
background-color: rgb(148 163 184 / var(--tw-bg-opacity));
}
.bg-slate-700 {
--tw-bg-opacity: 1;
background-color: rgb(51 65 85 / var(--tw-bg-opacity));
}
.bg-stone-700 {
--tw-bg-opacity: 1;
background-color: rgb(68 64 60 / var(--tw-bg-opacity));
}
.bg-yellow-500 {
--tw-bg-opacity: 1;
background-color: rgb(234 179 8 / var(--tw-bg-opacity));
}
.p-2 {
padding: 0.5rem;
}
.p-3 {
padding: 0.75rem;
}
.px-3 {
padding-left: 0.75rem;
padding-right: 0.75rem;
}
.py-2 {
padding-top: 0.5rem;
padding-bottom: 0.5rem;
}
.py-3 {
padding-top: 0.75rem;
padding-bottom: 0.75rem;
}
.pt-16 {
padding-top: 4rem;
}
.italic {
font-style: italic;
}
.text-stone-400 {
--tw-text-opacity: 1;
color: rgb(168 162 158 / var(--tw-text-opacity));
}
.text-stone-500 {
--tw-text-opacity: 1;
color: rgb(120 113 108 / var(--tw-text-opacity));
}
.text-white {
--tw-text-opacity: 1;
color: rgb(255 255 255 / var(--tw-text-opacity));
}

View file

@ -0,0 +1,152 @@
<html>
<head>
<title>zDebugger</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="output.css">
<!-- <script src="https://cdn.tailwindcss.com"></script> -->
<script src="cash.min.js"></script>
</head>
<body class="bg-gray-800">
<div class="flex flex-col h-screen">
<div class="w-full flex flex-col px-3 py-3 fixed bg-gray-800 border-b-2 border-stone-500">
<input id="filterContentInput" class="w-full bg-gray-600 text-white p-3 rounded-md" type="text"
placeholder="Filter logs...">
<div class="flex justify-between mt-2">
<input class="debug-button bg-cyan-500 px-3 py-2 rounded-md cursor-pointer" type="button" value="Info"
debug-type="info" debug-message="Testing info button">
<input class="debug-button bg-slate-400 px-3 py-2 rounded-md cursor-pointer" type="button" value="Print"
debug-type="print" debug-message="Testing print button">
<input class="debug-button bg-rose-500 px-3 py-2 rounded-md cursor-pointer" type="button" value="Error"
debug-type="error" debug-message="Testing error button">
<input class="debug-button bg-yellow-500 px-3 py-2 rounded-md cursor-pointer" type="button" value="Warn"
debug-type="warn" debug-message="Testing warn button">
<input id="clearButton" class="bg-stone-700 text-white px-3 py-2 rounded-md cursor-pointer" type="button"
value="Clear">
</div>
</div>
<div id="logs" class="flex-grow bg-gray-900 rounded-md mt-12 pt-16 w-full border-2 border-stone-500 min-h-[50%]">
</div>
</div>
<script>
console.log('Loaded the page')
const debugButtons = $(".debug-button")
const clearButton = $("#clearButton")
const logsEl = $('#logs')
// const filterSourceEl = $('#filterSourceInput')
const filterContentEl = $('#filterContentInput')
const rawChannel = "application.zetaphor.zDebugger.raw"
// const requireChannel = "application.zetaphor.zDebugger.require"
let logs = []
const visibleStates = {
info: true,
warn: true,
error: true,
print: true
}
const typeColors = {
'info': 'cyan-500',
'print': 'slate-400',
'error': 'rose-500',
'warn': 'yellow-500'
}
const disabledColors = {
'info': 'cyan-700',
'print': 'slate-600',
'error': 'rose-700',
'warn': 'yellow-700'
}
svgScript = `<svg class="w-6 h-6 mr-0.5 background" xmlns="http://www.w3.org/2000/svg" viewBox="3 -0.5 19 24"><path d="M12.6 6 9.5 17.4l2 .6 3-11.6-2-.6zm4.7.3L23 12l-5.7 5.7-1.4-1.5 4.3-4.2-4.3-4.2zm-10.6 0L1 12l5.7 5.7L8 16.2 3.8 12l4.3-4.2z" color="#000" paint-order="fill markers stroke" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;font-variation-settings:normal;inline-size:0;isolation:auto;mix-blend-mode:normal;shape-margin:0;shape-padding:0;solid-color:#000;text-decoration-color:#000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/></svg>`
svgError = `<svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" viewBox="-1 -2 28 28"><path d="M15.3 22.8H8.7a2.7 2.7 0 0 1-2-.9l-4.6-4.6a2.7 2.7 0 0 1-.9-2V8.7a2.7 2.7 0 0 1 .9-2l4.6-4.6a2.7 2.7 0 0 1 2-.9h6.6a2.7 2.7 0 0 1 2 .9L22 6.7a2.7 2.7 0 0 1 .8 2v6.6a2.7 2.7 0 0 1-.8 2L17.3 22a2.7 2.7 0 0 1-2 .8Zm-6.6-20a1.3 1.3 0 0 0-.9.3L3.1 7.8a1.3 1.3 0 0 0-.3.9v6.6a1.3 1.3 0 0 0 .3.9l4.7 4.7a1.3 1.3 0 0 0 .9.4h6.6a1.3 1.3 0 0 0 .9-.4l4.7-4.7a1.3 1.3 0 0 0 .4-.9V8.7a1.3 1.3 0 0 0-.4-.9l-4.7-4.7a1.3 1.3 0 0 0-.9-.3Zm4 10.4v-7a.8.8 0 0 0-1.4 0v7a.8.8 0 0 0 1.4 0Zm-.7 5.3a1.3 1.3 0 1 1 1.3-1.3 1.3 1.3 0 0 1-1.3 1.3Z"/></svg>`
svgInfo = `<svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 -4 24 30.9"><path d="M12.4 0C5.6 0 0 5.6 0 12.4s5.6 12.4 12.4 12.4 12.4-5.6 12.4-12.4S19.1 0 12.4 0zm0 23.2c-5.9 0-10.8-4.9-10.8-10.8S6.5 1.6 12.4 1.6s10.8 4.9 10.8 10.8-4.9 10.8-10.8 10.8z" class="st0"/><path d="M13.5 18.2c0 .5-.4 1-1 1h-.3a1 1 0 0 1-1-1V9.9c0-.5.4-1 1-1h.3c.5 0 1 .4 1 1v8.3z" class="st0"/><circle cx="12.4" cy="6.7" r="1.1" class="st0"/></svg>`
if (typeof EventBridge !== 'undefined') {
EventBridge.scriptEventReceived.connect(function (message) {
let messageObj = JSON.parse(message)
if (typeof messageObj.channel === 'undefined') return
if (messageObj.channel === rawChannel) {
messageObj['time'] = getTime()
logs.push(messageObj)
buildLogs()
} else if (messageObj.channel === requireChannel) {
console.log('Saw require channel message')
}
})
}
function getTime() {
const now = new Date()
const hours = String(now.getHours()).padStart(2, '0')
const minutes = String(now.getMinutes()).padStart(2, '0')
const seconds = String(now.getSeconds()).padStart(2, '0')
return `${hours}:${minutes}:${seconds}`
}
function buildLogs() {
logsEl.empty()
const filterText = filterContentEl.val().toLowerCase()
for (let i = 0; i < logs.length; i++) {
if (visibleStates[logs[i]['type']] && (!filterText || logs[i]['message'].toLowerCase().includes(filterText))) {
addRawLog(logs[i])
}
}
}
function addRawLog(data) {
let svg = svgScript
if (data.type === 'error') svg = svgError
else if (data.type === 'info') svg = svgInfo
let newItem = $(
`<div class="rounded-sm bg-slate-700 text-white p-2 border-b-2 border-stone-500" data-type="${data.type}"" data-script="${data.source.toLowerCase()}">
<div class="flex items-center">
<span class="stroke-${typeColors[data.type]} fill-${typeColors[data.type]}">${svg}</span>
<span class="text-stone-500">${data.time}</span>&nbsp;-&nbsp;<span class="text-stone-400 italic">${data.source}</span>
</div>
<div class="mt-1">
<span>${data.message}</span></div>
</div>
</div>`
);
$('#logs').append(newItem)
}
filterContentEl.on("keyup", function () {
buildLogs()
})
clearButton.on("click", function () {
logs = []
logsEl.empty()
})
debugButtons.on("click", function () {
const type = this.getAttribute('debug-type')
visibleStates[type] = !visibleStates[type]
if (visibleStates[type]) {
this.classList.remove(`bg-${disabledColors[type]}`)
this.classList.add(`bg-${typeColors[type]}`)
$(`[data-type="${type}"]`).show()
} else {
this.classList.remove(`bg-${typeColors[type]}`)
this.classList.add(`bg-${disabledColors[type]}`)
$(`[data-type="${type}"]`).hide()
}
// addRawLog({
// type: this.getAttribute("debug-type"),
// source: `${this.getAttribute("debug-type").toUpperCase()} button`,
// message: this.getAttribute("debug-message")
// })
})
</script>
</body>
</html>

View file

@ -0,0 +1,97 @@
"use strict";
(function () {
const jsMainFileName = "zDebugger.js"
const ROOT = Script.resolvePath('').split(jsMainFileName)[0]
const APP_NAME = "ZDEBUG"
const APP_URL = ROOT + `zDebugger.html?t=${Math.floor(Date.now() / 1000)}`
const APP_ICON_INACTIVE = ROOT + "icon-inactive.png"
const APP_ICON_ACTIVE = ROOT + "icon-active.png"
const rawChannel = "application.zetaphor.zDebugger.raw"
const receiveChannel = "application.zetaphor.zDebugger.receive"
const tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system")
let appActive = false
let overlayWebWindow = null
const button = tablet.addButton({
text: APP_NAME,
icon: APP_ICON_INACTIVE,
activeIcon: APP_ICON_ACTIVE,
sortOrder: 3
})
function clicked() {
if (appActive) {
overlayWebWindow.webEventReceived.disconnect(onWebEventReceived)
appActive = false
} else {
overlayWebWindow = new OverlayWebWindow({
title: "zDebugger",
source: Script.resolvePath(APP_URL),
width: 850,
height: 500
})
overlayWebWindow.webEventReceived.connect(onWebEventReceived)
overlayWebWindow.closed.connect(function () {
button.editProperties({
isActive: false
})
})
ScriptDiscoveryService.printedMessage.connect(function (message, source) {
logRawMessage('print', source, message)
})
ScriptDiscoveryService.errorMessage.connect(function (message, source) {
logRawMessage('error', source, message)
})
ScriptDiscoveryService.infoMessage.connect(function (message, source) {
logRawMessage('info', source, message)
})
ScriptDiscoveryService.warningMessage.connect(function (message, source) {
logRawMessage('warn', source, message)
})
}
button.editProperties({
isActive: true
})
}
function logRawMessage(type, source, message) {
const eventData = {
channel: rawChannel,
type: type,
source: source,
message: message
}
overlayWebWindow.emitScriptEvent(JSON.stringify(eventData))
}
button.clicked.connect(clicked)
function onWebEventReceived(message) {
if (typeof message === "string") {
let eventObj = JSON.parse(message)
if (eventObj.channel === receiveChannel) {
console.info('ZDEBUG-RECEIVE:', message)
}
}
}
function cleanup() {
if (appActive) {
overlayWebWindow.webEventReceived.disconnect(onWebEventReceived)
}
tablet.removeButton(button)
}
// Script.setInterval(function () {
// print("Print message");
// }, 3000);
Script.scriptEnding.connect(cleanup)
}())