WIP: Feature Rewrite #87

Draft
thepaperpilot wants to merge 35 commits from feat/ure-rewrite into main
7 changed files with 31 additions and 15 deletions
Showing only changes of commit 052a01d3f7 - Show all commits

16
package-lock.json generated
View file

@ -38,6 +38,7 @@
"@ivanv/vue-collapse-transition": "^1.0.2", "@ivanv/vue-collapse-transition": "^1.0.2",
"@rushstack/eslint-patch": "^1.7.2", "@rushstack/eslint-patch": "^1.7.2",
"@types/lz-string": "^1.5.0", "@types/lz-string": "^1.5.0",
"@types/node": "^22.7.6",
"@typescript-eslint/parser": "^7.2.0", "@typescript-eslint/parser": "^7.2.0",
"@vue/eslint-config-prettier": "^9.0.0", "@vue/eslint-config-prettier": "^9.0.0",
"@vue/eslint-config-typescript": "^13.0.0", "@vue/eslint-config-typescript": "^13.0.0",
@ -2060,6 +2061,15 @@
"lz-string": "*" "lz-string": "*"
} }
}, },
"node_modules/@types/node": {
"version": "22.7.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.6.tgz",
"integrity": "sha512-/d7Rnj0/ExXDMcioS78/kf1lMzYk4BZV8MZGTBKzTGZ6/406ukkbYlIsZmMPhcR5KlkunDHQLrtAVmSq7r+mSw==",
"devOptional": true,
"dependencies": {
"undici-types": "~6.19.2"
}
},
"node_modules/@types/offscreencanvas": { "node_modules/@types/offscreencanvas": {
"version": "2019.7.3", "version": "2019.7.3",
"resolved": "https://registry.npmjs.org/@types/offscreencanvas/-/offscreencanvas-2019.7.3.tgz", "resolved": "https://registry.npmjs.org/@types/offscreencanvas/-/offscreencanvas-2019.7.3.tgz",
@ -6860,6 +6870,12 @@
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/undici-types": {
"version": "6.19.8",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz",
"integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==",
"devOptional": true
},
"node_modules/unicode-canonical-property-names-ecmascript": { "node_modules/unicode-canonical-property-names-ecmascript": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.1.tgz", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.1.tgz",

View file

@ -45,6 +45,7 @@
"@ivanv/vue-collapse-transition": "^1.0.2", "@ivanv/vue-collapse-transition": "^1.0.2",
"@rushstack/eslint-patch": "^1.7.2", "@rushstack/eslint-patch": "^1.7.2",
"@types/lz-string": "^1.5.0", "@types/lz-string": "^1.5.0",
"@types/node": "^22.7.6",
"@typescript-eslint/parser": "^7.2.0", "@typescript-eslint/parser": "^7.2.0",
"@vue/eslint-config-prettier": "^9.0.0", "@vue/eslint-config-prettier": "^9.0.0",
"@vue/eslint-config-typescript": "^13.0.0", "@vue/eslint-config-typescript": "^13.0.0",

View file

@ -15,13 +15,13 @@ const emit = defineEmits<{
}>(); }>();
const activated = ref(false); const activated = ref(false);
const activatedTimeout = ref<NodeJS.Timer | null>(null); const activatedTimeout = ref<NodeJS.Timeout | null>(null);
function click() { function click() {
emit("click"); emit("click");
// Give feedback to user // Give feedback to user
if (activatedTimeout.value) { if (activatedTimeout.value != null) {
clearTimeout(activatedTimeout.value); clearTimeout(activatedTimeout.value);
} }
activated.value = false; activated.value = false;

View file

@ -1,5 +1,3 @@
import Board from "./Board.vue";
import Draggable from "./Draggable.vue";
import { Component, GatherProps, GenericComponent, jsx } from "features/feature"; import { Component, GatherProps, GenericComponent, jsx } from "features/feature";
import { globalBus } from "game/events"; import { globalBus } from "game/events";
import { Persistent, persistent } from "game/persistence"; import { Persistent, persistent } from "game/persistence";
@ -11,6 +9,9 @@ import { VueFeature } from "util/vue";
import type { ComponentPublicInstance, Ref } from "vue"; import type { ComponentPublicInstance, Ref } from "vue";
import { computed, nextTick, ref, unref, watchEffect } from "vue"; import { computed, nextTick, ref, unref, watchEffect } from "vue";
import panZoom from "vue-panzoom"; import panZoom from "vue-panzoom";
import { JSX } from "vue/jsx-runtime";
import Board from "./Board.vue";
import Draggable from "./Draggable.vue";
// Register panzoom so it can be used in Board.vue // Register panzoom so it can be used in Board.vue
globalBus.on("setupVue", app => panZoom.install(app)); globalBus.on("setupVue", app => panZoom.install(app));

View file

@ -8,7 +8,7 @@ import { watch } from "vue";
import player from "./player"; import player from "./player";
import state from "./state"; import state from "./state";
let intervalID: NodeJS.Timer | null = null; let intervalID: NodeJS.Timeout | null = null;
function update() { function update() {
const now = Date.now(); const now = Date.now();

View file

@ -172,6 +172,7 @@ function syncSaves(
const localSave = localStorage.getItem(id) ?? ""; const localSave = localStorage.getItem(id) ?? "";
const parsedLocalSave = JSON.parse(decodeSave(localSave) ?? ""); const parsedLocalSave = JSON.parse(decodeSave(localSave) ?? "");
const slot = availableSlots.values().next().value; const slot = availableSlots.values().next().value;
if (slot == null) return;
galaxy.value galaxy.value
?.save(slot, localSave, parsedLocalSave.name) ?.save(slot, localSave, parsedLocalSave.name)
.then(() => syncedSaves.value.push(parsedLocalSave.id)) .then(() => syncedSaves.value.push(parsedLocalSave.id))

View file

@ -126,17 +126,17 @@ export function setupHoldToClick(
stop: VoidFunction; stop: VoidFunction;
handleHolding: VoidFunction; handleHolding: VoidFunction;
} { } {
const interval = ref<NodeJS.Timer | null>(null); const interval = ref<NodeJS.Timeout | null>(null);
const event = ref<MouseEvent | TouchEvent | undefined>(undefined); const event = ref<MouseEvent | TouchEvent | undefined>(undefined);
function start(e: MouseEvent | TouchEvent) { function start(e: MouseEvent | TouchEvent) {
if (!interval.value) { if (interval.value == null) {
interval.value = setInterval(handleHolding, 250); interval.value = setInterval(handleHolding, 250);
} }
event.value = e; event.value = e;
} }
function stop() { function stop() {
if (interval.value) { if (interval.value != null) {
clearInterval(interval.value); clearInterval(interval.value);
interval.value = null; interval.value = null;
} }
@ -245,11 +245,8 @@ export function trackHover(element: VueFeature): Ref<boolean> {
} }
export function kebabifyObject(object: Record<string, unknown>) { export function kebabifyObject(object: Record<string, unknown>) {
return Object.keys(object).reduce( return Object.keys(object).reduce((acc, curr) => {
(acc, curr) => { acc[camelToKebab(curr)] = object[curr];
acc[camelToKebab(curr)] = object[curr]; return acc;
return acc; }, {} as Record<string, unknown>);
},
{} as Record<string, unknown>
);
} }