-
Notifications
You must be signed in to change notification settings - Fork 4
Add CI workflow config and fix lint issues #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Krakabek
wants to merge
1
commit into
main
Choose a base branch
from
dr-setup-ci
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: ['main'] | ||
| pull_request: | ||
| branches: ['main'] | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v7.0.0 | ||
| - name: Install Node.js | ||
| uses: actions/setup-node@v6.4.0 | ||
| with: | ||
| node-version: 22.20.0 | ||
| - name: Install Dependencies | ||
| run: npm install --no-fund | ||
| - parallel: | ||
| - name: Typecheck | ||
| run: npm run test:types | ||
| - name: Lint | ||
| run: npm run lint | ||
| - name: Unit Test | ||
| run: npm run test:unit | ||
| - name: Build | ||
| run: npm run build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this patterns seems questionable but i recognize fixing it is out of scope for this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import type { InitResponse } from '../shared/api'; | |
|
|
||
| declare global { | ||
| interface Window { | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| Module: any; | ||
| GM_tick?: (time: number) => void; | ||
| onGameSetWindowSize?: (width: number, height: number) => void; | ||
|
|
@@ -10,19 +11,28 @@ declare global { | |
| log_next_game_state?: () => void; | ||
| wallpaper_update_config?: (config: string) => void; | ||
| wallpaper_reset_config?: () => void; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| setAddAsyncMethod?: (method: any) => void; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| setJSExceptionHandler?: (handler: any) => void; | ||
| hasJSExceptionHandler?: () => boolean; | ||
| doJSExceptionHandler?: (exceptionJSON: string) => void; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| setWadLoadCallback?: (callback: any) => void; | ||
| onFirstFrameRendered?: () => void; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| triggerAd?: (adId: string, ...callbacks: any[]) => void; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| triggerPayment?: (itemId: string, callback: any) => void; | ||
| toggleElement?: (id: string) => void; | ||
| set_acceptable_rollback?: (frames: number) => void; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| report_stats?: (statsData: any) => void; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| g_pAddAsyncMethod?: any; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| g_pJSExceptionHandler?: any; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| g_pWadLoadCallback?: any; | ||
| } | ||
| } | ||
|
|
@@ -45,7 +55,8 @@ class GameLoader { | |
| private loadingElement: HTMLElement; | ||
| private startingHeight?: number; | ||
| private startingWidth?: number; | ||
| private startingAspect?: number; | ||
| // Used by the aspect-ratio example in ensureAspectRatio (see below). | ||
| // private startingAspect?: number; | ||
|
|
||
| constructor() { | ||
| this.statusElement = document.getElementById('status') as HTMLElement; | ||
|
|
@@ -62,7 +73,7 @@ class GameLoader { | |
|
|
||
| this.setupModule(); | ||
| this.setupResizeObserver(); | ||
| this.loadGame(); | ||
| void this.loadGame(); | ||
| } | ||
|
|
||
| private setupModule() { | ||
|
|
@@ -150,7 +161,7 @@ class GameLoader { | |
| console.log(`Window size set to width: ${width}, height: ${height}`); | ||
| this.startingHeight = height; | ||
| this.startingWidth = width; | ||
| this.startingAspect = this.startingWidth / this.startingHeight; | ||
| // this.startingAspect = this.startingWidth / this.startingHeight; | ||
| }; | ||
|
|
||
| const resizeObserver = new ResizeObserver(() => { | ||
|
|
@@ -174,23 +185,30 @@ class GameLoader { | |
|
|
||
| this.canvasElement.classList.add('active'); | ||
|
|
||
| const maxWidth = window.innerWidth; | ||
| const maxHeight = window.innerHeight; | ||
| let newHeight: number, newWidth: number; | ||
|
|
||
| const heightQuotient = this.startingHeight / maxHeight; | ||
| const widthQuotient = this.startingWidth / maxWidth; | ||
|
|
||
| if (heightQuotient > widthQuotient) { | ||
| newHeight = maxHeight; | ||
| newWidth = newHeight * this.startingAspect!; | ||
| } else { | ||
| newWidth = maxWidth; | ||
| newHeight = newWidth / this.startingAspect!; | ||
| } | ||
|
|
||
| this.canvasElement.style.height = '100%'; //`${newHeight}px`; | ||
| this.canvasElement.style.width = '100%'; //`${newWidth}px`; | ||
| // Example: compute dimensions that preserve the game's starting aspect | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need this for GameMaker to function properly? |
||
| // ratio within the current viewport. Currently the canvas is simply | ||
| // stretched to 100%, but this snippet is kept for reference. | ||
| // | ||
| // const maxWidth = window.innerWidth; | ||
| // const maxHeight = window.innerHeight; | ||
| // let newHeight: number, newWidth: number; | ||
| // | ||
| // const heightQuotient = this.startingHeight / maxHeight; | ||
| // const widthQuotient = this.startingWidth / maxWidth; | ||
| // | ||
| // if (heightQuotient > widthQuotient) { | ||
| // newHeight = maxHeight; | ||
| // newWidth = newHeight * this.startingAspect!; | ||
| // } else { | ||
| // newWidth = maxWidth; | ||
| // newHeight = newWidth / this.startingAspect!; | ||
| // } | ||
| // | ||
| // this.canvasElement.style.height = `${newHeight}px`; | ||
| // this.canvasElement.style.width = `${newWidth}px`; | ||
|
|
||
| this.canvasElement.style.height = '100%'; | ||
| this.canvasElement.style.width = '100%'; | ||
| } | ||
|
|
||
| private async loadRunnerManifest(): Promise<void> { | ||
|
|
@@ -247,13 +265,15 @@ class GameLoader { | |
| private setupGameMakerGlobals() { | ||
| // GameMaker async method support - make variables globally accessible | ||
| window.g_pAddAsyncMethod = -1; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| window.setAddAsyncMethod = (asyncMethod: any) => { | ||
| window.g_pAddAsyncMethod = asyncMethod; | ||
| console.log('setAddAsyncMethod called with:', asyncMethod); | ||
| }; | ||
|
|
||
| // Exception handling - make variables globally accessible | ||
| window.g_pJSExceptionHandler = undefined; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| window.setJSExceptionHandler = (exceptionHandler: any) => { | ||
| if (typeof exceptionHandler === 'function') { | ||
| window.g_pJSExceptionHandler = exceptionHandler; | ||
|
|
@@ -276,6 +296,7 @@ class GameLoader { | |
|
|
||
| // WAD/Resource loading - make variables globally accessible | ||
| window.g_pWadLoadCallback = undefined; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| window.setWadLoadCallback = (wadLoadCallback: any) => { | ||
| window.g_pWadLoadCallback = wadLoadCallback; | ||
| }; | ||
|
|
@@ -285,6 +306,7 @@ class GameLoader { | |
| }; | ||
|
|
||
| // Ad system stubs | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| window.triggerAd = (adId: string, ...callbacks: any[]) => { | ||
| console.log('triggerAd called with adId:', adId); | ||
| // For now, just call the callbacks to simulate ad completion | ||
|
|
@@ -293,6 +315,7 @@ class GameLoader { | |
| } | ||
| }; | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| window.triggerPayment = (itemId: string, callback: any) => { | ||
| console.log('triggerPayment called with itemId:', itemId); | ||
| // Simulate payment completion | ||
|
|
@@ -317,6 +340,7 @@ class GameLoader { | |
| console.log('Set acceptable rollback frames:', frames); | ||
| }; | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| window.report_stats = (statsData: any) => { | ||
| console.log('Game stats reported:', statsData); | ||
| }; | ||
|
|
@@ -335,18 +359,22 @@ class GameLoader { | |
|
|
||
| // Mock accelerometer API to prevent permissions policy violations | ||
| if (!('DeviceMotionEvent' in window)) { | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| (window as any).DeviceMotionEvent = class MockDeviceMotionEvent extends ( | ||
| Event | ||
| ) { | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| constructor(type: string, eventInitDict?: any) { | ||
| super(type, eventInitDict); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| if (!('DeviceOrientationEvent' in window)) { | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| (window as any).DeviceOrientationEvent = | ||
| class MockDeviceOrientationEvent extends Event { | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| constructor(type: string, eventInitDict?: any) { | ||
| super(type, eventInitDict); | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i didn't follow why the version of Node is incremented but differs in some of the templates. can we unify these?