update to ts and cloudflare pages
Publish / release (push) Successful in 2m13s

This commit is contained in:
2025-12-16 02:01:08 -08:00
parent b5779bfd70
commit 9c07d2345d
10 changed files with 1775 additions and 157 deletions
+13 -36
View File
@@ -1,43 +1,20 @@
# Simple workflow for deploying static content to GitHub Pages name: Publish
name: Deploy static content to Pages
on: on:
# Runs on pushes targeting the default branch
push: push:
branches: ["sugoi"] tags:
- "*"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs: jobs:
# Single deploy job since we're just deploying release:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - uses: actions/checkout@v5
uses: actions/checkout@v4 - uses: actions/setup-node@v6
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with: with:
# Upload entire repository node-version: latest
path: '.' - run: npm ci
- name: Deploy to GitHub Pages - run: npx tsc
id: deployment - run: npx wrangler pages deploy dist --project-name twitch-subathon-countdown
uses: actions/deploy-pages@v4 env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
+2 -1
View File
@@ -1 +1,2 @@
node_modules node_modules
dist/js
View File
View File
-5
View File
@@ -16,11 +16,6 @@
<p id="timeText">00:00:00</p> <p id="timeText">00:00:00</p>
</div> </div>
</div> </div>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js"
integrity="sha256-yr4fRk/GU1ehYJPAs8P4JlTgu0Hdsp4ZKrx8bDEDC3I="
crossorigin="anonymous">
</script>
<script type="module" src="js/script.js"></script> <script type="module" src="js/script.js"></script>
</body> </body>
</html> </html>
+1716 -85
View File
File diff suppressed because it is too large Load Diff
+9 -1
View File
@@ -1,7 +1,15 @@
{ {
"devDependencies": { "devDependencies": {
"@types/web": "^0.0.301",
"typescript": "^5.9.3",
"wrangler": "^4.54.0"
},
"dependencies": {
"@twurple/api": "^7.2.1", "@twurple/api": "^7.2.1",
"@twurple/eventsub-ws": "^7.2.1", "@twurple/eventsub-ws": "^7.2.1",
"twitch-cloud-ebs": "github:sugoidogo/twitch-cloud-ebs" "js-util": "https://gitea.sugoidogo.com/sugoidogo/js-util/releases/download/0.1.0/js-util.tgz",
"localforage": "^1.10.0",
"socket.io-client": "^4.8.1",
"twitch-cloud-ebs": "https://gitea.sugoidogo.com/sugoidogo/twitch-cloud-ebs/releases/download/1.1.3/twitch-cloud-ebs.tgz"
} }
} }
+14 -17
View File
@@ -1,26 +1,23 @@
const status_div = document.querySelector('div#status') const status_div = document.querySelector('div#status')!
onerror = function (error) { onerror = function (error) {
status_div.innerHTML = error.message status_div.innerHTML = error.toString()
//throw new Error(null,{cause:error}) throw error
} }
onunhandledrejection = (event) => onerror(event.reason) onunhandledrejection = (event) => onerror!(event.reason)
import AuthProvider from 'https://ebs.sugoidogo.com/SugoiAuthProvider.mjs' import { SugoiAuthProvider, WebStorage } from 'twitch-cloud-ebs'
import WebStorage from 'https://ebs.sugoidogo.com/WebStorage.mjs' const origin = 'https://ebs.sugoidogo.com'
const client_id = 'ib2n7v7mur7ab2mcxv7rjju2ctsyoi' const client_id = 'ib2n7v7mur7ab2mcxv7rjju2ctsyoi'
const scope = 'moderator:read:followers channel:read:subscriptions bits:read channel:read:charity chat:read chat:edit moderation:read channel:manage:moderators user:read:chat' const scope = 'moderator:read:followers channel:read:subscriptions bits:read channel:read:charity chat:read chat:edit moderation:read channel:manage:moderators user:read:chat'
/** @type {import('../node_modules/twitch-cloud-ebs/static/SugoiAuthProvider.mjs').default} */ const authProvider = new SugoiAuthProvider(client_id, origin)
const authProvider = new AuthProvider(client_id)
const tokens=await authProvider.addUser(...scope.split(' ')) const tokens=await authProvider.addUser(...scope.split(' '))
/** @type {import('../node_modules/twitch-cloud-ebs/static/WebStorage.mjs').default} */ const webStorage = new WebStorage(authProvider, undefined, origin)
const webStorage = new WebStorage(authProvider)
document.querySelector('#timer-link').href += '?refresh_token=' + tokens.refresh_token document.querySelector<HTMLAnchorElement>('#timer-link').href += '?refresh_token=' + tokens.refresh_token
status_div.innerHTML = 'Loading settings...' status_div.innerHTML = 'Loading settings...'
const FormDataDeep = await import('https://sugoidogo.github.io/js-util/FormDataDeep.mjs')
const config = await webStorage.fetch('config.json') const config = await webStorage.fetch('config.json')
.then(async response => { .then(async response => {
if (response.ok) { if (response.ok) {
@@ -30,15 +27,15 @@ const config = await webStorage.fetch('config.json')
return {} return {}
} }
} }
console.warn(response.code, await response.text()) console.warn(response.status, await response.text())
return {} return {}
} }
).then(config => { ).then(config => {
for (const checkbox of document.querySelectorAll('input[type=checkbox]')) { for (const checkbox of document.querySelectorAll<HTMLInputElement>('input[type=checkbox]')) {
checkbox.checked = false checkbox.checked = false
} }
for (const key in config) { for (const key in config) {
const input = document.querySelector('[name=' + key + ']') const input = document.querySelector<HTMLInputElement>('[name=' + key + ']')
if (!input) { if (!input) {
continue continue
} }
@@ -50,10 +47,10 @@ const config = await webStorage.fetch('config.json')
} }
}) })
status_div.innerHTML = 'Ready!' status_div.innerHTML = 'Ready!'
document.querySelector('form#config').onsubmit =async function (event) { document.querySelector<HTMLFormElement>('form#config').onsubmit = async function (event) {
event.preventDefault() event.preventDefault()
status_div.innerHTML = 'Saving settings...' status_div.innerHTML = 'Saving settings...'
const config = Object.fromEntries(new FormData(event.target)) const config = Object.fromEntries(new FormData(event.target as HTMLFormElement))
await webStorage.fetch('config.json', { await webStorage.fetch('config.json', {
method: 'POST', method: 'POST',
body: JSON.stringify(config) body: JSON.stringify(config)
+9 -12
View File
@@ -1,21 +1,16 @@
import AuthProvider from 'https://ebs.sugoidogo.com/SugoiAuthProvider.mjs' import { SugoiAuthProvider, WebStorage } from 'twitch-cloud-ebs'
import WebStorage from 'https://ebs.sugoidogo.com/WebStorage.mjs' import { ApiClient } from '@twurple/api'
import { ApiClient } from 'https://cdn.jsdelivr.net/npm/@twurple/api@7/+esm' import { EventSubWsListener } from '@twurple/eventsub-ws'
import { EventSubWsListener } from 'https://cdn.jsdelivr.net/npm/@twurple/eventsub-ws@7/+esm'
const client_id = 'ib2n7v7mur7ab2mcxv7rjju2ctsyoi' const client_id = 'ib2n7v7mur7ab2mcxv7rjju2ctsyoi'
/** @type {import('../node_modules/twitch-cloud-ebs/static/SugoiAuthProvider.mjs').default} */ const authProvider = new SugoiAuthProvider(client_id)
const authProvider = new AuthProvider(client_id)
/** @type {import('../node_modules/twitch-cloud-ebs/static/WebStorage.mjs').default} */
const webStorage = new WebStorage(authProvider) const webStorage = new WebStorage(authProvider)
/** @type {import('@twurple/api').ApiClient} */
const apiClient = new ApiClient({ authProvider }) const apiClient = new ApiClient({ authProvider })
/** @type {import('@twurple/eventsub-ws').EventSubWsListener} */
const eventSub = new EventSubWsListener({ apiClient }) const eventSub = new EventSubWsListener({ apiClient })
const timer=document.querySelector('#timeText') const timer=document.querySelector('#timeText')
let tokens,time_started,time_passed,time_total,config,localforage,streamelements let tokens,time_started,time_passed,time_total,config,streamelements
window.onanimationend=function(event){ window.onanimationend=function(event){
event.target.remove() event.target.remove()
@@ -141,6 +136,8 @@ function updateTime(){
requestAnimationFrame(updateTime) requestAnimationFrame(updateTime)
} }
import { io } from 'socket.io-client'
function init_streamelements(){ function init_streamelements(){
streamelements=io('https://realtime.streamelements.com',{transports: ['websocket']}) streamelements=io('https://realtime.streamelements.com',{transports: ['websocket']})
streamelements.on('disconnect',init_streamelements) streamelements.on('disconnect',init_streamelements)
@@ -163,8 +160,8 @@ function init_streamelements(){
} }
// init localforage // init localforage
localforage = (await import('https://cdn.jsdelivr.net/npm/localforage/+esm')).default import * as localForage from 'localforage'
localforage = localforage.createInstance({ name: 'sugoi-subathon-countdown' }) const localforage = localForage.createInstance({ name: 'sugoi-subathon-countdown' })
// init timer display // init timer display
time_started = await localforage.getItem('time_started') time_started = await localforage.getItem('time_started')
time_passed = await localforage.getItem('time_passed') time_passed = await localforage.getItem('time_passed')
+12
View File
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "es2022",
"module": "es2022",
"lib": ["ESNext"],
"moduleResolution": "node",
"sourceMap": true,
"inlineSources": true,
"outDir": "dist/js"
},
"include": ["src"]
}