Skip to content

Commit

Permalink
Some Bug Fixes Related To Document Associations
Browse files Browse the repository at this point in the history
  • Loading branch information
BellCubeDev committed Mar 20, 2024
1 parent 2fe5df1 commit 28030b7
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "module",
"name": "fomod",
"description": "A library for creating, parsing, editing, and validating XML-based Fomod installers, widely popularized in the Bethesda modding scene",
"version": "0.2.3",
"version": "0.2.4",
"main": "dist/index.js",
"repository": "https://github.com/BellCubeDev/fomod-js/",
"bugs": {
Expand Down
3 changes: 2 additions & 1 deletion src/definitions/lib/FlagInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export class FlagInstance<TIsOption extends boolean, TWrite extends (TIsOption e

/** Attaches this flag instance to a document */
attachDocument(document: Document) {
console.log('Attaching flag isntance to document', this, document);
this.documents.add(document);

let instancesForDoc = FlagInstancesByDocument.get(document);
Expand Down Expand Up @@ -121,6 +122,6 @@ export class FlagInstance<TIsOption extends boolean, TWrite extends (TIsOption e
}

associateWithDocument(document: Document) {
this.attachDocument(document);
if (!this.documents.has(document)) this.attachDocument(document);
}
}
2 changes: 1 addition & 1 deletion src/definitions/module/Install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export class Install<TStrict extends boolean> extends XmlRepresentation<TStrict>
}

associateWithDocument(document: Document) {
this.attachDocument(document);
if (!this.documents.has(document)) this.attachDocument(document);
}

decommission(currentDocument?: Document) {
Expand Down
4 changes: 3 additions & 1 deletion src/definitions/module/Option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ export class Option<TStrict extends boolean> extends XmlRepresentation<TStrict>
const name = baseName + `--${suffix}`;

if (!existingFlagNames.has(name)) {
return new FlagSetter(new FlagInstance(name, config.optionSelectedValue ?? DefaultFomodDocumentConfig.optionSelectedValue, true));
const setter = new FlagSetter(new FlagInstance(name, config.optionSelectedValue ?? DefaultFomodDocumentConfig.optionSelectedValue, true));
setter.associateWithDocument(document);
return setter;
}

return tryNextName(suffix + 1n);
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/module/dependencies/DependenciesGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class DependenciesGroup<TTagName extends DependencyTagName, TStrict exten
}

associateWithDocument(document: Document) {
this.dependencies.forEach(d => d.associateWithDocument(document));
this.dependencies.forEach(d => d.associateWithDocument?.(document));
}

override asElement(document: Document, config: FomodDocumentConfig = {}, knownOptions: Option<boolean>[] = []): Element {
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@

// Output Options
"alwaysStrict": true,
"removeComments": true,
//"removeComments": true, -- removed JSDoc comments
"importsNotUsedAsValues": "remove",

"declarationMap": true,
"sourceMap": true,
"sourceRoot": "https://raw.githubusercontent.com/BellCubeDev/fomod-js/main/",

// Type Checking: Maximum Carnage
"strict": true,
Expand Down

0 comments on commit 28030b7

Please sign in to comment.