Skip to content

Commit

Permalink
Pre-checkout of earlier commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Eunomiac committed May 11, 2024
1 parent 733612a commit 36b6e39
Show file tree
Hide file tree
Showing 29 changed files with 1,651 additions and 584 deletions.
926 changes: 892 additions & 34 deletions .eslintrc.cjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
"private": true,
"devDependencies": {
"@league-of-foundry-developers/foundry-vtt-types": "^9.280.0",
"@types/yaireo__tagify": "^4.17.0",
"@sveltejs/vite-plugin-svelte": "^3.0.2",
"@tsconfig/node21": "^21.0.1",
"@tsconfig/svelte": "^5.0.2",
"@types/jquery": "^3.5.29",
"@types/node": "^20.11.22",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"@yaireo/tagify": "^4.21.1",
"chokidar": "^3.6.0",
"eslint": "^8.57.0",
"eslint-import-resolver-node": "^0.3.9",
Expand Down Expand Up @@ -51,7 +51,7 @@
"vite-plugin-copy": "^0.1.6"
},
"dependencies": {
"@types/yaireo__tagify": "^4.17.0",
"@yaireo/tagify": "^4.21.1",
"axios": "^1.5.1",
"form-data": "^4.0.0",
"gsap": "^3.12.5",
Expand Down
1 change: 0 additions & 1 deletion src/ts/@types/blades-actor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ declare global {
// }

// Basic & Utility Types for BladesActors
type BladesRandomizer<T extends string = string> = { isLocked: boolean, value: T }
type SubActorData = Partial<BladesActor["system"]>
type AdvancementTrait = ActionTrait|"Ability"|"Upgrade"|"Cohort"|"CohortType"
type Loadout = "heavy"|"normal"|"light"|"encumbered"
Expand Down
2 changes: 1 addition & 1 deletion src/ts/@types/blades-chat.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import BladesPC from "../documents/actors/BladesPC";
import BladesNPC from "../documents/actors/BladesNPC";
import BladesFaction from "../documents/actors/BladesFaction";
import BladesCrew from "../documents/actors/BladesCrew";
import BladesChat from "../classes/BladesChat";
import BladesChatMessage from "../classes/BladesChatMessage";
import {ChatMessageDataSchema} from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs/chatMessageData";
/* eslint-enable @typescript-eslint/no-unused-vars */
// #endregion
Expand Down
4 changes: 2 additions & 2 deletions src/ts/@types/blades-consequence.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ declare global {

export type DisplayType = "base"|"accept"|ResistanceType;

export type ResistSubSchema = {
export interface ResistSubSchema {
name: string,
type: ConsequenceType,
resistSchema?: {
Expand All @@ -42,7 +42,7 @@ declare global {
}
}

export type Schema = {
export interface Schema {
name: string,
type: ConsequenceType,
actionRollData?: BladesRoll.Data,
Expand Down
2 changes: 1 addition & 1 deletion src/ts/@types/blades-document.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ declare global {
static get All(): T extends Actor ? BladesActor[] : BladesItem[];
static Get(docRef: DocRef): (T extends Actor ? BladesActor[] : BladesItem[]) | undefined;
static GetTypeWithTags(type: BladesActorType | BladesItemType, ...tags: BladesTag[]): T extends Actor ? BladesActor[] : BladesItem[];
static IsType<T extends BladesActorType|BladesItemType>(doc: BladesDoc, ...types: T[]): boolean;
static IsType<T extends BladesActorType|BladesItemType>(doc: EntityDoc, ...types: T[]): boolean;

tags: BladesTag[];
hasTag(...tags: BladesTag[]): boolean
Expand Down
173 changes: 64 additions & 109 deletions src/ts/@types/blades-general-types.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
import {AttributeTrait, ActionTrait, District} from "../core/constants";
import BladesItem from "../BladesItem";
// #region IMPORTS ~
import BladesActor from "../BladesActor";
import BladesChat from "../classes/BladesChat";
import BladesItem from "../BladesItem";
import BladesActorSheet from "../sheets/actor/BladesActorSheet";
import BladesItemSheet from "../sheets/item/BladesItemSheet";
// import BladesClockKey, {BladesClock} from "../classes/BladesClockKey";
// import BladesConsequence from "../classes/BladesConsequence";
// import BladesRoll, {BladesRollMod} from "../classes/BladesRoll";
import {gsap} from "gsap/all";

import BladesActiveEffect from "../documents/BladesActiveEffect";
import BladesChatMessage from "../classes/BladesChatMessage";
import BladesDialog from "../classes/BladesDialog";
import BladesRoll from "../classes/BladesRoll";
import BladesScene from "../classes/BladesScene";

import {gsap} from "gsap/all";
// #endregion

// #region CONFIGURATION OF SYSTEM CLASSES
type ActorDoc = BladesActor; // Actor;
type ItemDoc = BladesItem; // Item;
type ActorSheetDoc = BladesActorSheet; // ActorSheet;
type ItemSheetDoc = BladesItemSheet; // ItemSheet;

type ActiveEffectDoc = BladesActiveEffect; // ActiveEffect;
type ChatMessageDoc = BladesChatMessage; // Chat;
type DialogDoc = BladesDialog; // Dialog;
type RollDoc = BladesRoll; // Roll;
type SceneDoc = BladesScene; // Scene;
type UserDoc = User; // User;
// #endregion

// #region UTILITY TYPES
type HexDigit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "A" | "B" | "C" | "D" | "E" | "F";
type MaybeSpace = " " | "";
type FlexComma = `${MaybeSpace},${MaybeSpace}`;
// #endregion

declare global {
// #region MISCELLANEOUS TYPE ALIASES (nonfunctional; for clarity) ~
Expand All @@ -31,18 +54,6 @@ declare global {
// Represents any class constructor with an unknown number of parameters
type AnyClass<T = unknown> = new (...args: unknown[]) => T;

// Represents an integer
type int = number;

// Represents a floating point number
type float = number;

// Represents a positive integer
type posInt = number;

// Represents a positive floating point number
type posFloat = number;

// Represents a key which can be a string, number, or symbol
type key = string | number | symbol;

Expand All @@ -53,13 +64,13 @@ declare global {
type StringLike = string | number | boolean | null | undefined;

// Represents a number represented as a string
type NumString = string;
type NumString = `${number}`;

// Represents an object with number-strings as keys
type StringArray<T> = Record<NumString, T>;

// Represents "true" or "false" as a string
type BoolString = string;
type BoolString = `${boolean}`;

// Represents falsy values and empty objects to be pruned when cleaning list of values
type UncleanValues = false | null | undefined | "" | 0 | Record<string, never> | never[];
Expand All @@ -79,13 +90,14 @@ declare global {
type StringCase = "upper" | "lower" | "sentence" | "title";

// Represents HTML code as a string
type HTMLCode = string;
type HTMLCode = string & {__htmlStringBrand: never};

// Represents a HEX color as a string
type HEXColor = string;
// Represents a HEX color as a string, allowing for six (RGB) or eight (RGBA) uppercase hexadecimal digits
type HexColor = `#${HexDigit}${HexDigit}${HexDigit}` | `#${HexDigit}${HexDigit}${HexDigit}${HexDigit}`;

// Represents an RGB color as a string
type RGBColor = string;
type RGBColor = `rgb(${number}${FlexComma}${number}${FlexComma}${number})` |
`rgba(${number}${FlexComma}${number}${FlexComma}${number}${FlexComma}${number})`;

// Represents a key of a certain type
type KeyOf<T> = keyof T;
Expand All @@ -107,32 +119,30 @@ declare global {

// Represents a check test
type checkTest = ((...args: unknown[]) => unknown) | testFunc<keyFunc> | testFunc<valFunc> | RegExp | number | string;

// #endregion


// Represents a document id as a string
type IDString = string & { __idStringBrand: never };
type IDString = string & {__idStringBrand: never};

// Represents a UUID string, of the form /^[A-Za-z]+\.[A-Za-z0-9]{16}$/
type UUIDString = string & { __uuidStringBrand: never }; // This type is compatible with string, but requires explicit casting, enforcing the UUID pattern.
type UUIDString = string & {__uuidStringBrand: never}; // This type is compatible with string, but requires explicit casting, enforcing the UUID pattern.

// Represents a dotkey
type DotKey = string & { __dotKeyBrand: never };
type DotKey = string & {__dotKeyBrand: never};

// Represents a dotkey appropriate for an update() data object
type TargetKey = string & DotKey & { __targetKeyBrand: never };
type TargetKey = string & DotKey & {__targetKeyBrand: never};

// Represents a dotkey point to a a flag instead of the document schema
type TargetFlagKey = string & DotKey & { __targetFlagKeyBrand: never };
type TargetFlagKey = string & DotKey & {__targetFlagKeyBrand: never};

// Represents a jQuery text term
type jQueryTextTerm = string | number | boolean | (
(this: Element, index: number, text: string) => string | number | boolean
);

// Represents an object describing dimensions of an HTML element, of form {x: number, y: number, width: number, height: number}
type ElemPosData = {x: number, y: number, width: number, height: number};
interface ElemPosData {x: number, y: number, width: number, height: number}

// Represents an object describing dimensions of an HTML element, in the form of a DOMRect object with mutable properties.
type MutableRect = Omit<Mutable<DOMRect>, "toJSON">;
Expand Down Expand Up @@ -164,99 +174,44 @@ declare global {
-readonly [P in keyof T]: T[P];
};

export type gsapConfig = gsap.TweenVars & {
duration: number,
targets: Record<string, JQuery | JQuery[]>
}

export interface GSAPEffect<Defaults extends gsap.TweenVars> {
effect: (
targets: gsap.TweenTarget,
config: Defaults
) => gsap.core.Timeline | gsap.core.Tween,
defaults: Defaults,
extendTimeline?: boolean
}

// Represents a gsap animation
type gsapAnim = gsap.core.Tween | gsap.core.Timeline;

// Represents a generic Blades document
type BladesDoc = BladesActor | BladesItem;
type EntityDoc = ActorDoc | ItemDoc;

// Represents any Blades document sheet
type BladesSheet = BladesActorSheet | BladesItemSheet;
type EntitySheet = ActorSheetDoc | ItemSheetDoc;

// Represents any document that can be the target of a BladesTargetLink subclass.
type BladesLinkDoc = BladesDoc | BladesChat | User;
type TargetLinkDoc = EntityDoc | ChatMessageDoc | UserDoc;

// Represents a reference to a Blades document
type DocRef = string | BladesDoc;
type DocRef = string | EntityDoc;

// Represents a reference to a Blades actor
type ActorRef = string | BladesActor;
type ActorRef = string | ActorDoc;

// Represents a reference to a Blades item
type ItemRef = string | BladesItem;
type ItemRef = string | ItemDoc;

// Utility Types for Variable Template Values
type ValueMax = {max: number, value: number};
interface ValueMax {max: number, value: number}
type NamedValueMax = ValueMax & {name: string};
type RollableStat = AttributeTrait | ActionTrait;

// Component Types for Sheets
type BladesSelectOption<displayType, valueType = string> = {
value: valueType,
display: displayType
};

type BladesCompData = {
class?: string,
label?: string,
labelClass?: string,
tooltip?: string,
tooltipClass?: string,

checkLabel?: string,
checkClasses?: {
active: string,
inactive: string
},
checkTarget?: string,
checkValue?: boolean,

dotline?: BladesDotlineData,
dotlines?: BladesDotlineData[],

compContainer?: {
class?: string,
blocks: Array<Array<Omit<BladesCompData, "compContainer">>>
}
}
type BladesDotlineData = {
data: ValueMax,
dotlineClass?: string,
dotlineLabel?: string,

target?: string,
isLocked?: boolean,

svgKey?: string,
svgFull?: string,
svgEmpty?: string,

iconEmpty?: string,
iconEmptyHover?: string,
iconFull?: string,
iconFullHover?: string,
altIconFull?: string,
altIconFullHover?: string,
altIconStep?: number,

advanceButton?: string
}
type BladesRandomizer<T extends string = string> = {isLocked: boolean, value: T}

// Claims Data for Turf Representation
type BladesClaimData = {
name: string,
flavor?: string,
description: string,
district?: District,
value: boolean,
isTurf: boolean,
connects: {
left: boolean,
right: boolean,
top: boolean,
bottom: boolean
}
}
export declare function randomID(length?: number): IDString;
}
Loading

0 comments on commit 36b6e39

Please sign in to comment.