diff --git a/src/Morrowind/tools/NIFParseGen.ts b/src/Morrowind/tools/NIFParseGen.ts index 435c185ff..3cbfeec7c 100644 --- a/src/Morrowind/tools/NIFParseGen.ts +++ b/src/Morrowind/tools/NIFParseGen.ts @@ -590,7 +590,7 @@ class EnumValue { public name: string; public value: number; - constructor(context: NifXML, node: Element) { + constructor(context: NifXML, node: dom.Element) { this.name = node.getAttribute("name")!; if (node.hasAttribute("value")) this.value = parseInt(node.getAttribute("value")!); @@ -604,13 +604,13 @@ class Enum implements Type { public storage: Type; public value: EnumValue[] = []; - constructor(context: NifXML, node: Element) { + constructor(context: NifXML, node: dom.Element) { this.name = node.getAttribute("name")!; this.storage = context.getType(node.getAttribute("storage")!); for (let p = node.firstChild; p !== null; p = p.nextSibling) if (p.nodeType === p.ELEMENT_NODE && p.nodeName === "option") - this.value.push(new EnumValue(context, p as Element)); + this.value.push(new EnumValue(context, p as dom.Element)); } public generateBody(): string { @@ -639,7 +639,7 @@ class BitfieldMember { public memberName: string; - constructor(context: NifXML, node: Element) { + constructor(context: NifXML, node: dom.Element) { this.name = node.getAttribute("name")!; this.pos = parseInt(node.getAttribute("pos")!); this.width = parseInt(node.getAttribute("width")!); @@ -655,7 +655,7 @@ class Bitfield extends ClassType { public storage: Type; public member: BitfieldMember[] = []; - constructor(context: NifXML, node: Element) { + constructor(context: NifXML, node: dom.Element) { super(); this.name = node.getAttribute("name")!; @@ -663,7 +663,7 @@ class Bitfield extends ClassType { for (let p = node.firstChild; p !== null; p = p.nextSibling) if (p.nodeType === p.ELEMENT_NODE && p.nodeName === "member") - this.member.push(new BitfieldMember(context, p as Element)); + this.member.push(new BitfieldMember(context, p as dom.Element)); } public generateBody(context: NifXML): string { @@ -731,7 +731,7 @@ class StructField { public runtimeCheckCond = false; public runtimeCheckVerCond = false; - constructor(context: NifXML, node: Element, public parentStruct: Struct) { + constructor(context: NifXML, node: dom.Element, public parentStruct: Struct) { this.rawName = assertExists(node.getAttribute('name')); this.rawType = assertExists(node.getAttribute('type')); this.rawDefault = fixEmpty(node.getAttribute('default')); @@ -892,7 +892,7 @@ class Struct extends ClassType { public fields: StructField[] = []; public isNiObject = false; - constructor(private context: NifXML, private node: Element) { + constructor(private context: NifXML, private node: dom.Element) { super(); this.name = assertExists(node.getAttribute(`name`)); @@ -900,9 +900,9 @@ class Struct extends ClassType { this.generic = node.getAttribute("generic") === "true"; this.isNiObject = node.nodeName === "niobject"; - for (let p: Node | null = node.firstChild; p !== null; p = p.nextSibling) + for (let p: dom.Node | null = node.firstChild; p !== null; p = p.nextSibling) if (p.nodeName === "field") - this.fields.push(new StructField(context, p as Element, this)); + this.fields.push(new StructField(context, p as dom.Element, this)); } public resolve(context: NifXML): void { @@ -1044,7 +1044,7 @@ class NifXML { const str = readFileSync(filePath, { encoding: 'utf8' }); const parser = new dom.DOMParser(); - const doc = parser.parseFromString(str); + const doc = parser.parseFromString(str, 'application/xml'); this.parseXML(doc); this.resolve(); @@ -1091,7 +1091,7 @@ class NifXML { return type; } - private parseElem(p: Element): void { + private parseElem(p: dom.Element): void { if (p.nodeName === "enum" || p.nodeName === "bitflags") { const type = new Enum(this, p); this.registerType(type.name, type); @@ -1106,7 +1106,7 @@ class NifXML { } } - private parseToken(elem: Element): void { + private parseToken(elem: dom.Element): void { const name = assertExists(elem.getAttribute("name")); const attrs = assertExists(elem.getAttribute("attrs")).split(' '); @@ -1127,7 +1127,7 @@ class NifXML { if (p.nodeType !== p.ELEMENT_NODE) continue; - const c = p as Element; + const c = p as dom.Element; if (c.nodeName === name) { const token = assertExists(c.getAttribute("token")); const string = assertExists(c.getAttribute("string")); @@ -1141,12 +1141,12 @@ class NifXML { return assertExists(this.macroRegistry.get(attr)); } - public parseXML(doc: Document): void { - for (let p = doc.documentElement.firstChild; p !== null; p = p.nextSibling) { + public parseXML(doc: dom.Document): void { + for (let p = doc.documentElement!.firstChild; p !== null; p = p.nextSibling) { if (p.nodeType !== p.ELEMENT_NODE) continue; - this.parseElem(p as Element); + this.parseElem(p as dom.Element); } } diff --git a/src/ZeldaWindWaker/Main.ts b/src/ZeldaWindWaker/Main.ts index c1ccba05c..976d0028b 100644 --- a/src/ZeldaWindWaker/Main.ts +++ b/src/ZeldaWindWaker/Main.ts @@ -814,7 +814,7 @@ class SceneDesc { modelCache.fetchObjectData(`Always`); modelCache.fetchStageData(`Stage`); - modelCache.fetchFileData(`extra.crg1_arc`, 8); + modelCache.fetchFileData(`extra.crg1_arc`, 9); modelCache.fetchFileData(`f_pc_profiles.crg1_arc`); const particleArchives = [ diff --git a/src/rustlib.ts b/src/rustlib.ts index eade413d0..5d36c9fb9 100644 --- a/src/rustlib.ts +++ b/src/rustlib.ts @@ -3,6 +3,23 @@ import init, * as rust from '../rust/pkg/noclip_support'; export { rust }; +declare const process: unknown; + export async function loadRustLib() { + if (typeof process !== 'undefined') { + // XXX(jstpierre): This terrible set of workarounds is required on node because fetch doesn't support file URLs. + // We can't use normal require() because rspack is "smart" and will try to bundle it for web, when I really only + // want this code to run in tools mode on node.js. + // https://github.com/nodejs/undici/issues/2751 + + const requireX: any = (globalThis as any)['require']; + const fs = requireX('fs'); + const path = requireX('path'); + const url = requireX('url'); + const wasmPath = path.join(path.dirname(url.fileURLToPath(import.meta.url)), '../rust/pkg/noclip_support_bg.wasm'); + const wasm = fs.readFileSync(wasmPath); + rust.initSync(wasm); + } + await init(); } diff --git a/tslint.json b/tslint.json deleted file mode 100644 index 8cc594618..000000000 --- a/tslint.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "defaultSeverity": "error", - "extends": [ - "tslint:recommended" - ], - "jsRules": {}, - "rules": { - "curly": false, - "max-classes-per-file": [false], - "no-angle-bracket-type-assertion": false, - "interface-name": false, - "no-bitwise": false, - "no-console": false, - "quotemark": false, - "whitespace": false, - "variable-name": false, - "class-name": false, - "max-line-length": false - }, - "rulesDirectory": [] -} \ No newline at end of file