From f717fe8db286c0048ea4dd6b9424da70c58c25f0 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sun, 2 Apr 2023 21:42:17 -0500 Subject: [PATCH] Make every component use GenericComponent some projects seem to require this and others not? --- src/features/achievements/achievement.tsx | 5 +++-- src/features/bars/bar.ts | 4 ++-- src/features/boards/board.ts | 6 +++--- src/features/challenges/challenge.tsx | 12 +++++++++--- src/features/clickables/clickable.ts | 4 ++-- src/features/grids/grid.ts | 12 +++++++++--- src/features/infoboxes/infobox.ts | 12 +++++++++--- src/features/links/links.ts | 6 +++--- src/features/milestones/milestone.tsx | 4 ++-- src/features/repeatable.tsx | 12 +++++++++--- src/features/tabs/tab.ts | 12 +++++++++--- src/features/tabs/tabFamily.ts | 16 +++++++++++----- src/features/trees/tree.ts | 16 +++++++++++----- src/features/upgrades/upgrade.ts | 4 ++-- 14 files changed, 84 insertions(+), 41 deletions(-) diff --git a/src/features/achievements/achievement.tsx b/src/features/achievements/achievement.tsx index 7daaf7e..4776fd1 100644 --- a/src/features/achievements/achievement.tsx +++ b/src/features/achievements/achievement.tsx @@ -3,6 +3,7 @@ import { CoercableComponent, Component, GatherProps, + GenericComponent, getUniqueID, isVisible, OptionsFunc, @@ -48,7 +49,7 @@ export interface BaseAchievement { earned: Persistent; complete: VoidFunction; type: typeof AchievementType; - [Component]: typeof AchievementComponent; + [Component]: GenericComponent; [GatherProps]: () => Record; } @@ -79,7 +80,7 @@ export function createAchievement( const achievement = optionsFunc?.() ?? ({} as ReturnType>); achievement.id = getUniqueID("achievement-"); achievement.type = AchievementType; - achievement[Component] = AchievementComponent; + achievement[Component] = AchievementComponent as GenericComponent; achievement.earned = earned; achievement.complete = function () { diff --git a/src/features/bars/bar.ts b/src/features/bars/bar.ts index f0436f4..bab5887 100644 --- a/src/features/bars/bar.ts +++ b/src/features/bars/bar.ts @@ -40,7 +40,7 @@ export interface BarOptions { export interface BaseBar { id: string; type: typeof BarType; - [Component]: typeof BarComponent; + [Component]: GenericComponent; [GatherProps]: () => Record; } @@ -77,7 +77,7 @@ export function createBar( const bar = optionsFunc(); bar.id = getUniqueID("bar-"); bar.type = BarType; - bar[Component] = BarComponent; + bar[Component] = BarComponent as GenericComponent; processComputable(bar as T, "visibility"); setDefault(bar, "visibility", Visibility.Visible); diff --git a/src/features/boards/board.ts b/src/features/boards/board.ts index cc17d2e..528bc26 100644 --- a/src/features/boards/board.ts +++ b/src/features/boards/board.ts @@ -1,5 +1,5 @@ import BoardComponent from "features/boards/Board.vue"; -import type { OptionsFunc, Replace, StyleValue } from "features/feature"; +import type { GenericComponent, OptionsFunc, Replace, StyleValue } from "features/feature"; import { Component, findFeatures, @@ -178,7 +178,7 @@ export interface BaseBoard { selectedAction: Ref; mousePosition: Ref<{ x: number; y: number } | null>; type: typeof BoardType; - [Component]: typeof BoardComponent; + [Component]: GenericComponent; [GatherProps]: () => Record; } @@ -221,7 +221,7 @@ export function createBoard( const board = optionsFunc(); board.id = getUniqueID("board-"); board.type = BoardType; - board[Component] = BoardComponent; + board[Component] = BoardComponent as GenericComponent; if (board.state) { deletePersistent(state); diff --git a/src/features/challenges/challenge.tsx b/src/features/challenges/challenge.tsx index 34f850c..2925595 100644 --- a/src/features/challenges/challenge.tsx +++ b/src/features/challenges/challenge.tsx @@ -1,7 +1,13 @@ import { isArray } from "@vue/shared"; import Toggle from "components/fields/Toggle.vue"; import ChallengeComponent from "features/challenges/Challenge.vue"; -import type { CoercableComponent, OptionsFunc, Replace, StyleValue } from "features/feature"; +import type { + CoercableComponent, + GenericComponent, + OptionsFunc, + Replace, + StyleValue +} from "features/feature"; import { Component, GatherProps, @@ -67,7 +73,7 @@ export interface BaseChallenge { toggle: VoidFunction; complete: (remainInChallenge?: boolean) => void; type: typeof ChallengeType; - [Component]: typeof ChallengeComponent; + [Component]: GenericComponent; [GatherProps]: () => Record; } @@ -106,7 +112,7 @@ export function createChallenge( challenge.id = getUniqueID("challenge-"); challenge.type = ChallengeType; - challenge[Component] = ChallengeComponent; + challenge[Component] = ChallengeComponent as GenericComponent; challenge.completions = completions; challenge.active = active; diff --git a/src/features/clickables/clickable.ts b/src/features/clickables/clickable.ts index c7c83e3..b44854b 100644 --- a/src/features/clickables/clickable.ts +++ b/src/features/clickables/clickable.ts @@ -42,7 +42,7 @@ export interface ClickableOptions { export interface BaseClickable { id: string; type: typeof ClickableType; - [Component]: typeof ClickableComponent; + [Component]: GenericComponent; [GatherProps]: () => Record; } @@ -73,7 +73,7 @@ export function createClickable( const clickable = optionsFunc?.() ?? ({} as ReturnType>); clickable.id = getUniqueID("clickable-"); clickable.type = ClickableType; - clickable[Component] = ClickableComponent; + clickable[Component] = ClickableComponent as GenericComponent; processComputable(clickable as T, "visibility"); setDefault(clickable, "visibility", Visibility.Visible); diff --git a/src/features/grids/grid.ts b/src/features/grids/grid.ts index 53fd7fb..b7899ae 100644 --- a/src/features/grids/grid.ts +++ b/src/features/grids/grid.ts @@ -1,4 +1,10 @@ -import type { CoercableComponent, OptionsFunc, Replace, StyleValue } from "features/feature"; +import type { + CoercableComponent, + GenericComponent, + OptionsFunc, + Replace, + StyleValue +} from "features/feature"; import { Component, GatherProps, getUniqueID, setDefault, Visibility } from "features/feature"; import GridComponent from "features/grids/Grid.vue"; import type { Persistent, State } from "game/persistence"; @@ -206,7 +212,7 @@ export interface BaseGrid { cells: Record; cellState: Persistent>; type: typeof GridType; - [Component]: typeof GridComponent; + [Component]: GenericComponent; [GatherProps]: () => Record; } @@ -242,7 +248,7 @@ export function createGrid( return createLazyProxy(() => { const grid = optionsFunc(); grid.id = getUniqueID("grid-"); - grid[Component] = GridComponent; + grid[Component] = GridComponent as GenericComponent; grid.cellState = cellState; diff --git a/src/features/infoboxes/infobox.ts b/src/features/infoboxes/infobox.ts index 81d7bf6..ccd2bd3 100644 --- a/src/features/infoboxes/infobox.ts +++ b/src/features/infoboxes/infobox.ts @@ -1,4 +1,10 @@ -import type { CoercableComponent, OptionsFunc, Replace, StyleValue } from "features/feature"; +import type { + CoercableComponent, + GenericComponent, + OptionsFunc, + Replace, + StyleValue +} from "features/feature"; import { Component, GatherProps, getUniqueID, setDefault, Visibility } from "features/feature"; import InfoboxComponent from "features/infoboxes/Infobox.vue"; import type { Persistent } from "game/persistence"; @@ -30,7 +36,7 @@ export interface BaseInfobox { id: string; collapsed: Persistent; type: typeof InfoboxType; - [Component]: typeof InfoboxComponent; + [Component]: GenericComponent; [GatherProps]: () => Record; } @@ -63,7 +69,7 @@ export function createInfobox( const infobox = optionsFunc(); infobox.id = getUniqueID("infobox-"); infobox.type = InfoboxType; - infobox[Component] = InfoboxComponent; + infobox[Component] = InfoboxComponent as GenericComponent; infobox.collapsed = collapsed; diff --git a/src/features/links/links.ts b/src/features/links/links.ts index 5ab8779..77ea0ba 100644 --- a/src/features/links/links.ts +++ b/src/features/links/links.ts @@ -1,4 +1,4 @@ -import type { OptionsFunc, Replace } from "features/feature"; +import type { GenericComponent, OptionsFunc, Replace } from "features/feature"; import { GatherProps, Component } from "features/feature"; import type { Position } from "game/layers"; import type { Computable, GetComputableType, ProcessedComputable } from "util/computed"; @@ -22,7 +22,7 @@ export interface LinksOptions { export interface BaseLinks { type: typeof LinksType; - [Component]: typeof LinksComponent; + [Component]: GenericComponent; [GatherProps]: () => Record; } @@ -46,7 +46,7 @@ export function createLinks( return createLazyProxy(() => { const links = optionsFunc(); links.type = LinksType; - links[Component] = LinksComponent; + links[Component] = LinksComponent as GenericComponent; processComputable(links as T, "links"); diff --git a/src/features/milestones/milestone.tsx b/src/features/milestones/milestone.tsx index 30cd243..0a973db 100644 --- a/src/features/milestones/milestone.tsx +++ b/src/features/milestones/milestone.tsx @@ -69,7 +69,7 @@ export interface BaseMilestone { earned: Persistent; complete: VoidFunction; type: typeof MilestoneType; - [Component]: typeof MilestoneComponent; + [Component]: GenericComponent; [GatherProps]: () => Record; } @@ -99,7 +99,7 @@ export function createMilestone( const milestone = optionsFunc?.() ?? ({} as ReturnType>); milestone.id = getUniqueID("milestone-"); milestone.type = MilestoneType; - milestone[Component] = MilestoneComponent; + milestone[Component] = MilestoneComponent as GenericComponent; milestone.earned = earned; milestone.complete = function () { diff --git a/src/features/repeatable.tsx b/src/features/repeatable.tsx index b442068..ec338eb 100644 --- a/src/features/repeatable.tsx +++ b/src/features/repeatable.tsx @@ -1,6 +1,12 @@ import { isArray } from "@vue/shared"; import ClickableComponent from "features/clickables/Clickable.vue"; -import type { CoercableComponent, OptionsFunc, Replace, StyleValue } from "features/feature"; +import type { + CoercableComponent, + GenericComponent, + OptionsFunc, + Replace, + StyleValue +} from "features/feature"; import { Component, GatherProps, getUniqueID, jsx, setDefault, Visibility } from "features/feature"; import { DefaultValue, Persistent, persistent } from "game/persistence"; import { @@ -88,7 +94,7 @@ export interface BaseRepeatable { /** A symbol that helps identify features of the same type. */ type: typeof RepeatableType; /** The Vue component used to render this feature. */ - [Component]: typeof ClickableComponent; + [Component]: GenericComponent; /** A function to gather the props the vue component requires for this feature. */ [GatherProps]: () => Record; } @@ -131,7 +137,7 @@ export function createRepeatable( repeatable.id = getUniqueID("repeatable-"); repeatable.type = RepeatableType; - repeatable[Component] = ClickableComponent; + repeatable[Component] = ClickableComponent as GenericComponent; repeatable.amount = amount; repeatable.amount[DefaultValue] = repeatable.initialAmount ?? 0; diff --git a/src/features/tabs/tab.ts b/src/features/tabs/tab.ts index 3f205fc..6917009 100644 --- a/src/features/tabs/tab.ts +++ b/src/features/tabs/tab.ts @@ -1,4 +1,10 @@ -import type { CoercableComponent, OptionsFunc, Replace, StyleValue } from "features/feature"; +import type { + CoercableComponent, + GenericComponent, + OptionsFunc, + Replace, + StyleValue +} from "features/feature"; import { Component, GatherProps, getUniqueID } from "features/feature"; import TabComponent from "features/tabs/Tab.vue"; import type { Computable, GetComputableType } from "util/computed"; @@ -15,7 +21,7 @@ export interface TabOptions { export interface BaseTab { id: string; type: typeof TabType; - [Component]: typeof TabComponent; + [Component]: GenericComponent; [GatherProps]: () => Record; } @@ -37,7 +43,7 @@ export function createTab( const tab = optionsFunc(); tab.id = getUniqueID("tab-"); tab.type = TabType; - tab[Component] = TabComponent; + tab[Component] = TabComponent as GenericComponent; tab[GatherProps] = function (this: GenericTab) { const { display } = this; diff --git a/src/features/tabs/tabFamily.ts b/src/features/tabs/tabFamily.ts index 9652f3d..32df1e7 100644 --- a/src/features/tabs/tabFamily.ts +++ b/src/features/tabs/tabFamily.ts @@ -1,4 +1,10 @@ -import type { CoercableComponent, OptionsFunc, Replace, StyleValue } from "features/feature"; +import type { + CoercableComponent, + GenericComponent, + OptionsFunc, + Replace, + StyleValue +} from "features/feature"; import { Component, GatherProps, @@ -37,7 +43,7 @@ export interface TabButtonOptions { export interface BaseTabButton { type: typeof TabButtonType; - [Component]: typeof TabButtonComponent; + [Component]: GenericComponent; } export type TabButton = Replace< @@ -73,7 +79,7 @@ export interface BaseTabFamily { activeTab: Ref; selected: Persistent; type: typeof TabFamilyType; - [Component]: typeof TabFamilyComponent; + [Component]: GenericComponent; [GatherProps]: () => Record; } @@ -107,13 +113,13 @@ export function createTabFamily( tabFamily.id = getUniqueID("tabFamily-"); tabFamily.type = TabFamilyType; - tabFamily[Component] = TabFamilyComponent; + tabFamily[Component] = TabFamilyComponent as GenericComponent; tabFamily.tabs = Object.keys(tabs).reduce>( (parsedTabs, tab) => { const tabButton: TabButtonOptions & Partial = tabs[tab](); tabButton.type = TabButtonType; - tabButton[Component] = TabButtonComponent; + tabButton[Component] = TabButtonComponent as GenericComponent; processComputable(tabButton as TabButtonOptions, "visibility"); setDefault(tabButton, "visibility", Visibility.Visible); diff --git a/src/features/trees/tree.ts b/src/features/trees/tree.ts index bcbf333..a3efba7 100644 --- a/src/features/trees/tree.ts +++ b/src/features/trees/tree.ts @@ -1,4 +1,10 @@ -import type { CoercableComponent, OptionsFunc, Replace, StyleValue } from "features/feature"; +import type { + CoercableComponent, + GenericComponent, + OptionsFunc, + Replace, + StyleValue +} from "features/feature"; import { Component, GatherProps, getUniqueID, setDefault, Visibility } from "features/feature"; import type { Link } from "features/links/links"; import type { GenericReset } from "features/reset"; @@ -39,7 +45,7 @@ export interface TreeNodeOptions { export interface BaseTreeNode { id: string; type: typeof TreeNodeType; - [Component]: typeof TreeNodeComponent; + [Component]: GenericComponent; [GatherProps]: () => Record; } @@ -72,7 +78,7 @@ export function createTreeNode( const treeNode = optionsFunc?.() ?? ({} as ReturnType>); treeNode.id = getUniqueID("treeNode-"); treeNode.type = TreeNodeType; - treeNode[Component] = TreeNodeComponent; + treeNode[Component] = TreeNodeComponent as GenericComponent; processComputable(treeNode as T, "visibility"); setDefault(treeNode, "visibility", Visibility.Visible); @@ -157,7 +163,7 @@ export interface BaseTree { isResetting: Ref; resettingNode: Ref; type: typeof TreeType; - [Component]: typeof TreeComponent; + [Component]: GenericComponent; [GatherProps]: () => Record; } @@ -186,7 +192,7 @@ export function createTree( const tree = optionsFunc(); tree.id = getUniqueID("tree-"); tree.type = TreeType; - tree[Component] = TreeComponent; + tree[Component] = TreeComponent as GenericComponent; tree.isResetting = ref(false); tree.resettingNode = shallowRef(null); diff --git a/src/features/upgrades/upgrade.ts b/src/features/upgrades/upgrade.ts index 924e28f..5bcf5df 100644 --- a/src/features/upgrades/upgrade.ts +++ b/src/features/upgrades/upgrade.ts @@ -61,7 +61,7 @@ export interface BaseUpgrade { canPurchase: Ref; purchase: VoidFunction; type: typeof UpgradeType; - [Component]: typeof UpgradeComponent; + [Component]: GenericComponent; [GatherProps]: () => Record; } @@ -92,7 +92,7 @@ export function createUpgrade( const upgrade = optionsFunc(); upgrade.id = getUniqueID("upgrade-"); upgrade.type = UpgradeType; - upgrade[Component] = UpgradeComponent; + upgrade[Component] = UpgradeComponent as GenericComponent; upgrade.bought = bought; upgrade.canPurchase = computed(() => requirementsMet(upgrade.requirements));