|
|
|
@ -32,12 +32,12 @@ function createTypeTracker() {
|
|
|
|
|
throw new Error(`Type '${name}' already exists (from module '${module.name}', already defined by module '${existingEntry.source.name}')`);
|
|
|
|
|
} else {
|
|
|
|
|
typeFactories[name] = {
|
|
|
|
|
__moduleID: getModuleID(module),
|
|
|
|
|
source: module,
|
|
|
|
|
// No context provided to type factory functions for now, since they are not allowed to be async for now anyway
|
|
|
|
|
// FIXME: Maybe add a warning if the user returns a Promise from a factory, asking them to file a bug if they really need it?
|
|
|
|
|
// func: wrapModuleFunction(module, factory)
|
|
|
|
|
func: async function (... args) {
|
|
|
|
|
let instance = await factory(... args);
|
|
|
|
|
func: async function (args, context) {
|
|
|
|
|
// NOTE: We pass through the context here without modifying it; because a module-specific context will be injected from the main runtime
|
|
|
|
|
let instance = await factory(args, context);
|
|
|
|
|
|
|
|
|
|
if (instance !== InvalidObject) {
|
|
|
|
|
// We need to patch every created object, so that the correct context gets injected into its type-specific methods when they are called
|
|
|
|
|