Skip to content

Commit

Permalink
fix: convert back to esmodules to work with libwrapper better
Browse files Browse the repository at this point in the history
  • Loading branch information
akrigline committed Aug 1, 2021
1 parent baf2b07 commit b067bf1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
3 changes: 1 addition & 2 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"url": "https://github.com/orgs/ElfFriend-DnD"
}
],
"scripts": [
"/scripts/libWrapperShim.js",
"esmodules": [
"/scripts/document-sheet-registrar.js"
],
"url": "https://github.com/League-of-Foundry-Developers/document-sheet-registrar",
Expand Down
22 changes: 12 additions & 10 deletions scripts/document-sheet-registrar.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { libWrapper } from './libWrapperShim.js'

/**
* Creates a shim that allows for the registration of custom document sheets.
*
Expand Down Expand Up @@ -33,15 +35,15 @@ class DocumentSheetRegistrar {
.filter(([key, config]) => config.sheetClass && config.collection)
.map(([key, config]) => {
/** @return {DocumentMap} */
return {
return {
name: key,
class: config.documentClass,
collection: config.collection
}
});
}


/**
* Initialize all of the document sheet registrars.
*
Expand All @@ -52,14 +54,14 @@ class DocumentSheetRegistrar {
for (let doc of this.documentTypes) {
// Skip any collection that already has a sheet registration method
if (doc.collection.registerSheet) continue;

this.initializeDocumentSheet(doc);
}
}


/**
* Set up the nessesary configuration objects and methods for
* Set up the nessesary configuration objects and methods for
* sheet registration of this document type.
*
* @static
Expand All @@ -69,7 +71,7 @@ class DocumentSheetRegistrar {
static initializeDocumentSheet(doc) {
// Skip Folder because it has types already and doesn't seem that useful
if (doc.name == "Folder") return;

// Set the base type for this document class
doc.class.prototype.type = "base";

Expand All @@ -83,7 +85,7 @@ class DocumentSheetRegistrar {
this.configureSheetClasses(doc);
}


/**
* Creates a new sheetClasses config object for this document type.
*
Expand All @@ -102,7 +104,7 @@ class DocumentSheetRegistrar {
}
}
}

/**
* Adds a register and unregister method to the document collection.
*
Expand Down Expand Up @@ -149,12 +151,12 @@ class DocumentSheetRegistrar {
}
}


/**
* Retrieve the sheet class for the document. @see Actor._getSheetClass
*
* @static
* @return {*}
* @return {*}
* @memberof DocumentSheetRegistrar
*/
static _getSheetClass() {
Expand Down
2 changes: 1 addition & 1 deletion scripts/libWrapperShim.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ Hooks.once('init', () => {
Object.defineProperty(obj, fn_name, descriptor);
}
}
});
});

0 comments on commit b067bf1

Please sign in to comment.