diff --git a/.eslintrc.js b/.eslintrc.js index 2a1d0bc..a881f38 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -11,7 +11,8 @@ module.exports = { "@vue/eslint-config-prettier" ], parserOptions: { - ecmaVersion: 2020 + ecmaVersion: 2020, + project: "tsconfig.json" }, ignorePatterns: ["src/lib"], rules: { @@ -19,7 +20,14 @@ module.exports = { "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", "vue/script-setup-uses-vars": "warn", "vue/no-mutating-props": "off", - "vue/multi-word-component-names": "off" + "vue/multi-word-component-names": "off", + "@typescript-eslint/strict-boolean-expressions": [ + "error", + { + allowNullableObject: true, + allowNullableBoolean: true + } + ] }, globals: { defineProps: "readonly", diff --git a/.forgejo/workflows/deploy.yaml b/.forgejo/workflows/deploy.yaml new file mode 100644 index 0000000..bc7210a --- /dev/null +++ b/.forgejo/workflows/deploy.yaml @@ -0,0 +1,31 @@ +name: Build and Deploy +on: + push: + branches: + - 'main' + workflow_dispatch: +jobs: + build-and-deploy: + if: github.repository != 'profectus-engine/Profectus' # Don't build placeholder mod on main repo + runs-on: docker + steps: + - name: Setup RSync + run: | + apt-get update + apt-get install -y rsync + + - name: Checkout 🛎️ + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built. + run: | + npm ci + npm run build + + - name: Deploy 🚀 + uses: https://github.com/JamesIves/github-pages-deploy-action@v4.2.5 + with: + branch: pages # The branch the action should deploy to. + folder: dist # The folder the action should deploy. diff --git a/.forgejo/workflows/test.yaml b/.forgejo/workflows/test.yaml new file mode 100644 index 0000000..33df8d8 --- /dev/null +++ b/.forgejo/workflows/test.yaml @@ -0,0 +1,21 @@ +name: Run Tests +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] +jobs: + test: + runs-on: docker + + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + - name: Use Node.js 16.x + uses: actions/setup-node@v3 + with: + node-version: 16.x + - run: npm ci + - run: npm run build --if-present + - run: npm test diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f4210ed..8293b9e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,6 +3,7 @@ on: push: branches: - 'main' + workflow_dispatch: jobs: build-and-deploy: if: github.repository != 'profectus-engine/Profectus' # Don't build placeholder mod on main repo diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c6b970d..c41d085 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,11 +1,11 @@ -name: Build and Deploy +name: Run Tests on: push: branches: [ main ] pull_request: branches: [ main ] jobs: - build: + test: runs-on: ubuntu-latest steps: diff --git a/.vscode/settings.json b/.vscode/settings.json index 77377bd..d46602a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,12 @@ { - "vitest.commandLine": "npx vitest" -} \ No newline at end of file + "vitest.commandLine": "npx vitest", + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + }, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "git.ignoreLimitWarning": true, + "[typescriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "typescript.tsdk": "node_modules/typescript/lib" +} diff --git a/CHANGELOG.md b/CHANGELOG.md index b982041..78e51ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,115 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.6.1] - 2023-05-17 +### Added +- Error boundaries around each layer, and errors now display on the page when in development +- Utility for creating requirement based on whether a conversion has met a requirement +### Changed +- **BREAKING** Formulas/requirements refactor + - spendResources renamed to cumulativeCost + - summedPurchases renamed to directSum + - calculateMaxAffordable now takes optional 'maxBulkAmount' parameter + - cost requirements now pass cumulativeCost, maxBulkAmount, and directSum to calculateMaxAffordable + - Non-integrable and non-invertible formulas will now work in more situations + - Repeatable.maximize is removed + - Challenge.maximize is removed +- Formulas have better typing information now +- Integrate functions now log errors if the variable input is not integrable +- Cyclical proxies now throw errors +- createFormulaPreview is now a JSX function +- Tree nodes are not automatically capitalized anymore +- upgrade.canPurchase now returns false if the upgrade is already bought +- TPS display is simplified and more performant now +### Fixed +- Actions could not be constructed +- Progress bar on actions was misaligned +- Many different issues the Board features (and many changes/improvements) +- Calculating max affordable could sometimes infinite loop +- Non-integrable formulas could cause errors in cost requirements +- estimateTime would not show "never" when production is 0 +- isInvertible and isIntegrable now properly handle nested formulas +- Repeatables' amount display would show the literal text "joinJSX" +- Repeatables would not buy max properly +- Reset buttons were showing wrong "currentAt" vs "nextAt" +- Step-wise formulas not updating their value correctly +- Bonus amount decorator now checks for `amount` property in the post construct callback +### Documentation +- Various typos fixed and a few sections made more thorough + +## [0.6.0] - 2023-04-20 +### Added +- **BREAKING** New requirements system + - Replaces many features' existing requirements with new generic form +- **BREAKING** Formulas, which can be used to calculate buy max for you + - Requirements can use them so repeatables and challenges can be "buy max" without any extra effort + - Conversions now use formulas instead of the old scaling functions system, allowing for arbitrary functions that are much easier to follow + - Modifiers have a new getFormula property +- Feature decorators, which simplify the process of adding extra values to features +- Action feature, which is a clickable with a cooldown +- ETA util (calculates time until a specific amount of a resource, based on its current gain rate) +- createCollapsibleAchievements util +- deleteLowerSaves util +- Minimized layers can now display a component +- submitOnBlur property to Text fields +- showPopups property to achievements +- Mouse/touch events to more onClick listeners +- Example hotkey to starting layer +- Schema for projInfo.json +### Changes +- **BREAKING** Buyables renamed to Repeatables + - Renamed purchaseLimit to limit + - Renamed buyMax to maximize + - Added initialAmount property +- **BREAKING** Persistent refs no longer have redundancies in save object + - Requires referencing persistent refs either through a proxy or by wrapping in `noPersist()` +- **BREAKING** Visibility properties can now take booleans + - Removed showIf util +- **BREAKING** Lazy proxies and options functions now pass the base object in as `this` as well as the first parameter. +- Tweaked settings display +- setupPassiveGeneration will no longer lower the resource +- displayResource now floors resource amounts +- Tweaked modifier displays, incl showing negative modifiers in red +- Hotkeys now appear on key graphic +- Mofifier sections now accept computable strings for title and subtitle +- Every VueFeature's `[Component]` property is now typed as GenericComponent +- Make errors throw objects instead of strings +- Updated b_e +### Fixed +- NaN detection stopped working + - Now specifically only checks persistent refs +- trackTotal would increase the total when loading the save +- PWAs wouldn't show updates +- Board feature no longer working at all +- Some discord links didn't open in new tab +- Adjacent grid cells wouldn't merge +- When fixing old saves, the modVersion would not be updated +- Default layer would display `Dev Speed: 0x` when paused +- Fixed hotkeys not working with shift + numbers +- Fixed console errors about deleted persistent refs not being included in the layer object +- Modifiers wouldn't display small numbers +- Conversions' addSoftcap wouldn't affect currentAt or nextAt +- MainDisplay not respecting style and classes props +- Tabs could sometimes not update correctly +- offlineTime not capping properly +- Tooltips being user-selectable +- Pinnable tooltips causing stack overflow +- Workflows not working with submodules +- Various minor typing issues +### Removed +- **BREAKING** Removed milestones (achievements now have small and large displays) +### Documented +- every single feature +- formulas +- requirements +### Tests +- conversions +- formulas +- modifiers +- requirements + +Contributors: thepaperpilot, escapee, adsaf, ducdat + ## [0.5.2] - 2022-08-22 ### Added - onLoad event diff --git a/README.md b/README.md index e535eb2..5f8c741 100644 --- a/README.md +++ b/README.md @@ -26,11 +26,6 @@ npm run build npm run preview ``` -### Lints and fixes files -``` -npm run lint -``` - ### Runs the tests using vite-jest ``` npm run test diff --git a/package.json b/package.json index 6bb5fc4..7b14824 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,5 @@ { "name": "profectus", - "version": "0.5.2", "private": true, "scripts": { "start": "vite", @@ -51,9 +50,9 @@ "eslint": "^8.6.0", "jsdom": "^20.0.0", "prettier": "^2.5.1", - "typescript": "^4.7.4", + "typescript": "^5.0.2", "unplugin-json-dts": "^1.2.0", - "vitest": "^0.17.1", + "vitest": "^0.29.3", "vue-tsc": "^0.38.1" }, "engines": { diff --git a/src/App.vue b/src/App.vue index 05fa7fd..6a365ef 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,18 +1,25 @@ @@ -49,5 +55,17 @@ const gameComponent = computed(() => { position: absolute; min-height: 100%; height: 100%; + color: var(--foreground); +} + +.error-container { + background: var(--background); + overflow: auto; + width: 100%; + height: 100%; +} + +.error-container > .error { + position: static; } diff --git a/src/components/Error.vue b/src/components/Error.vue new file mode 100644 index 0000000..16c9b6b --- /dev/null +++ b/src/components/Error.vue @@ -0,0 +1,135 @@ + + + + + diff --git a/src/components/Game.vue b/src/components/Game.vue index 6f9bb66..1975696 100644 --- a/src/components/Game.vue +++ b/src/components/Game.vue @@ -4,7 +4,6 @@ v-for="(tab, index) in tabs" :key="index" class="tab" - :ref="`tab-${index}`" :style="unref(layers[tab]?.style)" :class="unref(layers[tab]?.classes)" > @@ -14,7 +13,7 @@ v-if="layerKeys.includes(tab)" v-bind="gatherLayerProps(layers[tab]!)" :index="index" - :tab="() => (($refs[`tab-${index}`] as HTMLElement[] | undefined)?.[0])" + @set-minimized="(value: boolean) => (layers[tab]!.minimized.value = value)" /> @@ -36,8 +35,8 @@ const layerKeys = computed(() => Object.keys(layers)); const useHeader = projInfo.useHeader; function gatherLayerProps(layer: GenericLayer) { - const { display, minimized, minWidth, name, color, minimizable, nodes } = layer; - return { display, minimized, minWidth, name, color, minimizable, nodes }; + const { display, minimized, name, color, minimizable, nodes, minimizedDisplay } = layer; + return { display, minimized, name, color, minimizable, nodes, minimizedDisplay }; } diff --git a/src/components/Hotkey.vue b/src/components/Hotkey.vue new file mode 100644 index 0000000..7e9c876 --- /dev/null +++ b/src/components/Hotkey.vue @@ -0,0 +1,70 @@ + + + + + + + diff --git a/src/components/Info.vue b/src/components/Info.vue index 69a3545..15395bf 100644 --- a/src/components/Info.vue +++ b/src/components/Info.vue @@ -21,19 +21,32 @@
- + discord {{ discordName }}
- + discord - The Paper Pilot Community + Profectus & Friends
- + discord The Modding Tree @@ -67,7 +80,7 @@ const isOpen = ref(false); const timePlayed = computed(() => formatTime(player.timePlayed)); const infoComponent = computed(() => { - return coerceComponent(jsx(() => <>{infoComponents.map(render)})); + return coerceComponent(jsx(() => (<>{infoComponents.map(render)}))); }); defineExpose({ diff --git a/src/components/Layer.vue b/src/components/Layer.vue index a64a255..1857535 100644 --- a/src/components/Layer.vue +++ b/src/components/Layer.vue @@ -1,15 +1,23 @@