Skip to content

Commit

Permalink
Feature/svelte5 (sirgwain#575)
Browse files Browse the repository at this point in the history
* Upgraded to svelte 5 and made changes necessary to compile:
a) Removing self closing tags that can't be self closing

Other issues remain. WIP.

* Fixing some compiler issues

* Fix allowing more tests to run

* Adding playwright to tests in building front end

* Most non-svelte 5 specific errors/warnings are removed

* Updating TechAvatar to runes

* Updating some components
Testing passes on frontend

* Ran migrator to v5
A few issues to still look at.

* Fixed build errors
Fixed prettier config for svelte
removed legacy prevent default

* Prettier run on all code base

* Fixing plugin error due to compilation

* Fixed TransportTasksDialog

* Some fixes

* Updated dialogs to

* no longer bind show. show/hide is handled by Game.svelte
* no longer call GameContext update functions, but instead trigger onOk events that update the game state
* dialogs are opened by shared ShowDialogEvent functions bubbled up to Game.svelte

* Scanner sort of working

* moved waypoint state update logic to GameContext
Scanner logic cleaned up a bit. State could maybe be better.

* Converted Scanner context into a context object
Changed all Props to types instead of interfaces.

* updated a few more svelte files

* finished scanner elements conversion to svelte5
started on all components with `run(() => ` in them.

* removed more `run(() =>` calls
Using HTML*Attributes in props where spreading (where possible)
Removed more event dispatchers

* converted CargoTransferRequest to a type instead of a class. It wasn't reactive when members changed.

* making progress on ship designer
fixed some tiles

* Some fixes to run()

* Some fixes to run()

* cleaned up optional on* events.
fixed highlight issue with ship designer

* converted more tables to svelte5
did some typescript magic on tables

* Removed all custom dispatchers

* No longer hiding engine graph on safari. Svelte 5 fixes it!

* Updated FleetWaypointsTile to be all derived state from properties

* cleaned up run imports. fixed race editor bindings

* cleaned up race bindings a bit

* Fixed fleet composition tile to trigger event when the battle plan is changed, not update fleet orders directly

* Added Game.svelte event for production queue clear, planet mass driver speed update

* Removed state update functions from Fleet tiles. Added local state management for FleetWaypointsTile.
Fixed some types around Popups

* Updated FleetWaypointsTaskTile to use local state and events

* Converted more state update functions into events
Updated Research page to use local state

* removed preventDefault legacy calls

* fixed some issues with plan ui

* fixed guest with no user delete issues

* fixed wasm update after hosting new game issues

* replaced [key:string ]: any; with unknown. Though we should be more explicit about defining types for our ...rest elements

* Updated all svg attribute props to use SVGAttributes<SVGElement>

* fixed some linting issues

* fixed more eslint issues

* fixed more linting. Removed SharedTooltip for now

* goodbye eslint errors!

* made shipdesignspec fuelCapacity optional

* renamed some events to camelCase for consistency

* fixed a few invalid state equality checks

* added back in mistakenly deleted select component

* fixed tests, hopefully

* fixed playwright typo

---------

Co-authored-by: sirgwain <[email protected]>
  • Loading branch information
madebyjeffrey and sirgwain authored Dec 14, 2024
1 parent 3b5dc1b commit a4db098
Show file tree
Hide file tree
Showing 407 changed files with 12,247 additions and 6,837 deletions.
29 changes: 19 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,53 @@
# workflow to build & test on each commit to develop or PR to develop
name: Build
on:
on:
pull_request:
branches:
- 'develop'
push:
branches:
- 'develop'
- 'develop'
jobs:
test:
strategy:
matrix:
go-version: [1.22.x]
node-version: [18]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# build the binary (fast)
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
check-latest: true
cache: true
- run: go test ./...
- run: go test ./...
- run: mkdir -p dist/
- run: go mod tidy && CGO_ENABLED=1 GOARCH=amd64 GOOS=linux go build -ldflags='-s -w -extldflags "-static"' -o dist/craig-stars main.go
- run: make build_wasm

# build the frontend (slow)
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: lts/*
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- run: npm install
- run: npm ci
working-directory: ./frontend
- name: Install Playwright Browsers
run: npx playwright install --with-deps
working-directory: ./frontend
- run: npx playwright test
working-directory: ./frontend
- run: npm run test
working-directory: ./frontend
- run: npm run build
working-directory: ./frontend

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 10
13 changes: 6 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,19 @@ jobs:
strategy:
matrix:
go-version: [1.22.x]
node-version: [18]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
needs: tag
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# get some build metadata we can put in the binary and package.json
- name: Get build time
id: buildTime
run: echo "buildTime=`date +'%y.%m.%d %H:%M:%S'`" >> $GITHUB_OUTPUT

# build the backend and wasm
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
check-latest: true
Expand All @@ -67,12 +66,12 @@ jobs:
- run: tar -cvf ./dist/craig-stars.tgz -C ./dist ./craig-stars

# build the frontend (this is slow)
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: lts/*
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- run: npm install
- run: npm ci
working-directory: ./frontend
- run: jq ".version = \"${{ needs.tag.outputs.version }}\"" package.json > package.json.tmp && mv package.json.tmp package.json
working-directory: ./frontend
Expand All @@ -82,7 +81,7 @@ jobs:
- run: tar -cvf ./dist/frontend.tgz -C frontend/build .

# upload the dist folder to github's artifacts
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: dist-artifacts
path: ./dist/*.tgz
Expand Down
4 changes: 2 additions & 2 deletions cs.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"settings": {
"testing.automaticallyOpenPeekView": "never",
"typescript.tsdk": "frontend/node_modules/typescript/lib",
"goStructTagAutogen.generation": {
"template": "json:\"{{camel}}\"",
"goStructTagAutogen.generation": {
"template": "json:\"{{camel}},omitempty\"",
"json": {
"cases": ["camel"],
"options": ["omitempty", "-"]
Expand Down
12 changes: 6 additions & 6 deletions cs/fleet.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ type FleetOrders struct {

type FleetSpec struct {
ShipDesignSpec
BaseCloakedCargo int `json:"baseCloakedCargo"`
BasePacketSpeed int `json:"basePacketSpeed"`
BaseCloakedCargo int `json:"baseCloakedCargo,omitempty"`
BasePacketSpeed int `json:"basePacketSpeed,omitempty"`
HasMassDriver bool `json:"hasMassDriver,omitempty"`
HasStargate bool `json:"hasStargate,omitempty"`
MassDriver string `json:"massDriver,omitempty"`
MassEmpty int `json:"massEmpty"`
MassEmpty int `json:"massEmpty,omitempty"`
MaxHullMass int `json:"maxHullMass,omitempty"`
MaxRange int `json:"maxRange,omitempty"`
Purposes map[ShipDesignPurpose]bool `json:"purposes"`
Purposes map[ShipDesignPurpose]bool `json:"purposes,omitempty"`
SafeHullMass int `json:"safeHullMass,omitempty"`
SafeRange int `json:"safeRange,omitempty"`
Stargate string `json:"stargate,omitempty"`
TotalShips int `json:"totalShips"`
TotalShips int `json:"totalShips,omitempty"`
}

type Waypoint struct {
Expand Down Expand Up @@ -648,7 +648,7 @@ func ComputeFleetSpec(rules *Rules, player *Player, fleet *Fleet) FleetSpec {
}

// compute the cloaking based on the cloak units and cargo
spec.CloakPercent = computeFleetCloakPercent(&spec, fleet.Cargo.Total() + spec.BaseCloakedCargo, player.Race.Spec.FreeCargoCloaking)
spec.CloakPercent = computeFleetCloakPercent(&spec, fleet.Cargo.Total()+spec.BaseCloakedCargo, player.Race.Spec.FreeCargoCloaking)

if !spec.Starbase {
spec.EstimatedRange = fleet.getEstimatedRange(player, spec.Engine.IdealSpeed, spec.CargoCapacity)
Expand Down
Loading

0 comments on commit a4db098

Please sign in to comment.