Skip to content

Commit

Permalink
Merge pull request #392 from rsek/dependency-update
Browse files Browse the repository at this point in the history
Dependency update (FVTT types v9, etc)
  • Loading branch information
ben authored Jun 17, 2022
2 parents 136a410 + 54ebb5f commit 8eb3bed
Show file tree
Hide file tree
Showing 24 changed files with 13,218 additions and 9,955 deletions.
12 changes: 10 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
"@typescript-eslint/no-unused-vars": [1, { "argsIgnorePattern": "^_" }],
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-explicit-any": "off"
}
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-interface": "off"
},
"overrides": [
{"files": ["*.js"],
"rules": {
"@typescript-eslint/no-var-requires": "off"
}
}
]
}
22,891 changes: 13,049 additions & 9,842 deletions package-lock.json

Large diffs are not rendered by default.

50 changes: 26 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,39 @@
"vue2-editor": "^2.10.3"
},
"devDependencies": {
"@league-of-foundry-developers/foundry-vtt-types": "^0.8.8-0",
"@types/webpack-env": "^1.16.0",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"autoprefixer": "^10.2.6",
"clean-webpack-plugin": "^4.0.0-alpha.0",
"copy-webpack-plugin": "^9.0.0",
"@league-of-foundry-developers/foundry-vtt-types": "^9.269.0",
"@types/webpack-env": "^1.17.0",
"@typescript-eslint/eslint-plugin": "^5.28.0",
"@typescript-eslint/parser": "^5.28.0",
"@typescript/analyze-trace": "^0.9.0",
"autoprefixer": "^10.4.7",
"clean-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^5.2.6",
"eslint": "^7.28.0",
"eslint-config-prettier": "^8.3.0",
"eslint-webpack-plugin": "^2.5.4",
"less": "^3.13.1",
"less-loader": "^9.0.0",
"marked": "^4.0.10",
"node-fetch": "^2.6.7",
"eslint": "^8.17.0",
"eslint-config-prettier": "^8.5.0",
"eslint-webpack-plugin": "^3.1.1",
"less": "^4.1.3",
"less-loader": "^11.0.0",
"marked": "^4.0.17",
"node-fetch": "^3.2.6",
"null-loader": "^4.0.1",
"postcss-loader": "^5.3.0",
"prettier": "^2.3.1",
"postcss-loader": "^7.0.0",
"prettier": "^2.7.1",
"quill": "^1.3.7",
"quill-image-uploader": "^1.2.2",
"raw-loader": "^4.0.2",
"source-map-loader": "^3.0.0",
"string-replace-loader": "^3.0.2",
"style-loader": "^2.0.0",
"ts-loader": "^9.2.3",
"typescript": "^4.3.2",
"source-map-loader": "^4.0.0",
"string-replace-loader": "^3.1.0",
"style-loader": "^3.3.1",
"ts-loader": "^9.3.0",
"typescript": "^4.7.3",
"vue": "^2.6.14",
"vue-loader": "^15.9.8",
"vue-template-compiler": "^2.6.14",
"webpack": "^5.38.1",
"webpack-cli": "^4.7.0",
"webpack-dev-server": "^3.11.2",
"webpack": "^5.73.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.9.2",
"webpack-import-glob-loader": "^1.6.3"
},
"browserslist": [
Expand Down
10 changes: 9 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,15 @@ Hooks.once('ready', async () => {
})

Hooks.once('setup', () => {
Roll.prototype.render = async function (chatOptions = {}) {
Roll.prototype.render = async function (
chatOptions: {
user?: string | undefined
flavor?: string | undefined
template?: string | undefined
isPrivate?: boolean | undefined
blind?: boolean | undefined
} = {}
) {
const template = 'systems/foundry-ironsworn/templates/chat/default-roll.hbs'
chatOptions = mergeObject(
{
Expand Down
2 changes: 1 addition & 1 deletion src/module/actor/sheets/charactermovesheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export class CharacterMoveSheet extends FormApplication<
const entry = pack?.index.find((x: any) => x.name == tableName)
if (entry) {
table = (await pack.getDocument((entry as any)._id)) as
| RollTable
| StoredDocument<RollTable>
| undefined
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/module/applications/createActorDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IronswornActor } from '../actor/actor'
import { getFoundrySFTableByDfId } from '../dataforged'
import { IronswornSettings } from '../helpers/settings'

interface CreateActorDialogOptions extends FormApplication.Options {
interface CreateActorDialogOptions extends FormApplicationOptions {
folder: string
}

Expand All @@ -26,7 +26,7 @@ export class CreateActorDialog extends FormApplication<CreateActorDialogOptions>
],
width: 650,
height: 200,
} as FormApplication.Options)
} as FormApplicationOptions)
}

getData(_options?: Application.RenderOptions): any {
Expand Down
6 changes: 3 additions & 3 deletions src/module/applications/firstStartDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { IronswornSettings } from '../helpers/settings'
import { SFSettingTruthsDialogVue } from './vueSfSettingTruthsDialog'
import { WorldTruthsDialog } from './worldTruthsDialog'

export class FirstStartDialog extends FormApplication<FormApplication.Options> {
export class FirstStartDialog extends FormApplication<FormApplicationOptions> {
constructor() {
super({})
}

static get defaultOptions(): FormApplication.Options {
static get defaultOptions(): FormApplicationOptions {
return mergeObject(super.defaultOptions, {
title: game.i18n.localize('IRONSWORN.First Start.Welcome'),
template: 'systems/foundry-ironsworn/templates/first-start.hbs',
Expand All @@ -21,7 +21,7 @@ export class FirstStartDialog extends FormApplication<FormApplication.Options> {
],
width: 600,
height: 700,
} as FormApplication.Options)
} as FormApplicationOptions)
}

async _updateObject() {
Expand Down
2 changes: 1 addition & 1 deletion src/module/applications/sf/editSectorApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export class EditSectorDialog extends VueApplication {
super({})
}

static get defaultOptions(): Application.Options {
static get defaultOptions(): ApplicationOptions {
return mergeObject(super.defaultOptions, {
title: game.i18n.localize('IRONSWORN.Sector'),
template: 'systems/foundry-ironsworn/templates/edit-sector.hbs',
Expand Down
4 changes: 2 additions & 2 deletions src/module/applications/sfSettingTruthsDialog.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IronswornSettings } from '../helpers/settings'

export class SFSettingTruthsDialog extends FormApplication<FormApplication.Options> {
export class SFSettingTruthsDialog extends FormApplication<FormApplicationOptions> {
constructor() {
super({})
}
Expand All @@ -19,7 +19,7 @@ export class SFSettingTruthsDialog extends FormApplication<FormApplication.Optio
],
width: 600,
height: 700,
} as FormApplication.Options)
} as FormApplicationOptions)
}

async _updateObject() {
Expand Down
2 changes: 1 addition & 1 deletion src/module/applications/vueSfSettingTruthsDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export class SFSettingTruthsDialogVue extends VueApplication {
super({})
}

static get defaultOptions(): Application.Options {
static get defaultOptions(): ApplicationOptions {
return mergeObject(super.defaultOptions, {
title: game.i18n.localize('IRONSWORN.SFSettingTruthsTitle'),
template: 'systems/foundry-ironsworn/templates/sf-truths-vue.hbs',
Expand Down
2 changes: 1 addition & 1 deletion src/module/applications/vueapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class VueApplication extends Application {
this._vm = null
}

static get defaultOptions(): Application.Options {
static get defaultOptions(): ApplicationOptions {
return mergeObject(super.defaultOptions, {
classes: [
'ironsworn',
Expand Down
4 changes: 2 additions & 2 deletions src/module/applications/worldTruthsDialog.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IronswornSettings } from '../helpers/settings'

export class WorldTruthsDialog extends FormApplication<FormApplication.Options> {
export class WorldTruthsDialog extends FormApplication<FormApplicationOptions> {
constructor() {
super({})
}
Expand All @@ -19,7 +19,7 @@ export class WorldTruthsDialog extends FormApplication<FormApplication.Options>
],
width: 600,
height: 700,
} as FormApplication.Options)
} as FormApplicationOptions)
}

async _updateObject() {
Expand Down
14 changes: 9 additions & 5 deletions src/module/chat/chatrollhelpers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Evaluated } from '@league-of-foundry-developers/foundry-vtt-types/src/foundry/client/dice/roll.js'
import { compact, sortBy } from 'lodash'
import { marked } from 'marked'
import { IronswornActor } from '../actor/actor'
Expand Down Expand Up @@ -416,7 +417,10 @@ export async function rollAndDisplayOracleResult(
}

// Do the random roll
const tableDraw = await (table as any).draw({ displayChat: false })
// FIXME this typing is pretty gross, but exists as a workaround for an error in the LoFD typings package (as of 17 Jun 2022). it can be removed once that's fixed.
const tableDraw = await table.draw({
displayChat: false,
} as RollTable.DrawOptions)

// Parse the table rows
const tableRows = sortBy(
Expand All @@ -430,10 +434,10 @@ export async function rollAndDisplayOracleResult(
)

// Grab the relevant rows
const roll = tableDraw.roll as Roll
const roll = tableDraw.roll as Evaluated<Roll>
const resultRow = tableRows.find(
(x) => x.low <= roll.result && roll.result <= x.high
)
(x) => x.low <= roll.total && roll.total <= x.high
) as { low: number; high: number; text: string; selected: boolean }
const resultIdx = tableRows.indexOf(resultRow)
const displayRows = compact([
tableRows[resultIdx - 1],
Expand Down Expand Up @@ -475,5 +479,5 @@ export async function rollAndDisplayOracleResult(
await ChatMessage.create(messageData)

// Return the raw text
return resultRow.text
return resultRow?.text
}
22 changes: 14 additions & 8 deletions src/module/dataforged.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { marked } from 'marked'
import { IronswornItem } from './item/item'
import shajs from 'sha.js'
import { cachedDocumentsForPack } from './features/pack-cache'
import { RollTableDataConstructorData } from '@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs/rollTableData.js'
import { TableResultDataConstructorData } from '@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs/tableResultData.js'

function getLegacyRank(numericRank) {
switch (numericRank) {
Expand Down Expand Up @@ -62,19 +64,21 @@ export function hash(str: string): string {

export async function getFoundrySFTableByDfId(
dfid: string
): Promise<RollTable | undefined> {
): Promise<StoredDocument<RollTable> | undefined> {
const documents = await cachedDocumentsForPack(
'foundry-ironsworn.starforgedoracles'
)
return documents?.find((x) => x.id === hashLookup(dfid))
return documents?.find((x) => x.id === hashLookup(dfid)) as(StoredDocument<RollTable> | undefined)
}
export async function getFoundryISTableByDfId(
dfid: string
): Promise<RollTable | undefined> {
): Promise<StoredDocument<RollTable> | undefined> {
const documents = await cachedDocumentsForPack(
'foundry-ironsworn.ironswornoracles'
)
return documents?.find((x) => x.id === hashLookup(dfid))
return documents?.find((x) => x.id === hashLookup(dfid)) as
| StoredDocument<RollTable>
| undefined
}

export async function getFoundryMoveByDfId(
Expand Down Expand Up @@ -336,7 +340,7 @@ async function processAssets(idMap: { [key: string]: string }) {
}

async function processOracles(idMap: { [key: string]: string }) {
const oraclesToCreate = [] as Record<string, unknown>[]
const oraclesToCreate: RollTableDataConstructorData[] = []
// Oracles JSON is a tree we wish to iterate through depth first adding
// parents prior to their children, and children in order
async function processOracle(oracle: IOracle) {
Expand Down Expand Up @@ -367,7 +371,7 @@ async function processOracles(idMap: { [key: string]: string }) {
_id: idMap[tableRow.$id ?? ''],
range: [tableRow.Floor, tableRow.Ceiling],
text: tableRow.Result && renderLinksInStr(text, idMap),
}
} as TableResultDataConstructorData
}).filter((x) => x.range[0] !== null),
})
}
Expand Down Expand Up @@ -444,7 +448,7 @@ async function processEncounters(idMap: { [key: string]: string }) {

async function processFoes() {
const foesPack = game.packs.get('foundry-ironsworn.starforgedencounters')
const foeItems = await foesPack?.getDocuments()
const foeItems = (await foesPack?.getDocuments()) as StoredDocument<IronswornItem>[]
for (const foeItem of foeItems ?? []) {
const actor = await IronswornActor.create(
{
Expand All @@ -454,6 +458,8 @@ async function processFoes() {
},
{ pack: 'foundry-ironsworn.foeactorssf' }
)
await actor?.createEmbeddedDocuments('Item', [foeItem.data])
await actor?.createEmbeddedDocuments('Item', [
foeItem.data as unknown as Record<string, unknown>,
])
}
}
14 changes: 9 additions & 5 deletions src/module/datasworn.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { ItemDataConstructorData } from '@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs/itemData'
import { RollTableDataConstructorData } from '@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs/rollTableData.js'
import { TableResultDataConstructorData } from '@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs/tableResultData.js'
import { IOracle, IOracleCategory, ironsworn, IRow } from 'dataforged'
import { max } from 'lodash'
import { marked } from 'marked'
import { IronswornActor } from './actor/actor'
import { hash } from './dataforged'
import { IronswornItem } from './item/item.js'

const THEME_IMAGES = {
Ancient: 'icons/environment/wilderness/carved-standing-stone.webp',
Expand Down Expand Up @@ -270,7 +273,8 @@ export async function importFromDatasworn() {

// Foe actors
const foesPack = game.packs.get('foundry-ironsworn.ironswornfoes')
const foeItems = await foesPack?.getDocuments()
const foeItems =
(await foesPack?.getDocuments()) as StoredDocument<IronswornItem>[]
for (const foeItem of foeItems ?? []) {
const actor = await IronswornActor.create(
{
Expand All @@ -280,18 +284,18 @@ export async function importFromDatasworn() {
},
{ pack: 'foundry-ironsworn.foeactorsis' }
)
await actor?.createEmbeddedDocuments('Item', [foeItem.data])
await actor?.createEmbeddedDocuments('Item', [foeItem.data as unknown as Record<string, unknown>])
}

// Oracles from Dataforged
const oraclesToCreate = [] as Record<string, unknown>[]
const oraclesToCreate: RollTableDataConstructorData[] = []
function tableData(
table: IRow[],
$id: string,
name: string,
category: string,
description: string
) {
): RollTableDataConstructorData {
const renderedDescription = marked.parseInline(description ?? '')
const maxRoll = max(table.map((x) => x.Ceiling || 0)) //oracle.Table && maxBy(oracle.Table, (x) => x.Ceiling)?.Ceiling
return {
Expand All @@ -316,7 +320,7 @@ export async function importFromDatasworn() {
return {
range: [tableRow.Floor, tableRow.Ceiling],
text: tableRow.Result && text,
}
} as TableResultDataConstructorData
})
.filter((x) => x.range[0] !== null),
}
Expand Down
2 changes: 1 addition & 1 deletion src/module/features/compendium-categories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function registerCompendiumCategoryHook() {
el.dataset.documentId
)) as RollTable
if (table?.data?.flags?.category) {
const cat = table.data.flags.category
const cat = (table.data.flags.category as string)
.replace(/(Starforged|Ironsworn)\/Oracles\//, '')
.replace(/_/g, ' ')
$(el).append(
Expand Down
2 changes: 1 addition & 1 deletion src/module/features/customoracles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ async function augmentWithFolderContents(node: OracleTreeNode) {
for (const table of folder.contents) {
newNode.children.push({
...emptyNode(),
tables: [table],
tables: [table as RollTable],
displayName: table.name ?? '(table)',
})
}
Expand Down
Loading

0 comments on commit 8eb3bed

Please sign in to comment.