Skip to content

Commit

Permalink
revert namespace config changes
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Jul 4, 2024
1 parent 3a62f54 commit 5fa86fb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 41 deletions.
11 changes: 0 additions & 11 deletions packages/world/ts/config/v2/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,4 @@ export type World = Store & {
readonly deploy: Deploy;
/** Codegen config */
readonly codegen: Codegen;

/** @internal */
readonly internal: {
/**
* Whether or not the MUD project is using multiple namespaces.
* This is used to determine where to generate table libraries, find system contracts, etc.
* We use a separate boolean here because we may also populate a `namespaces` output key for single-namespace projects.
* @internal
*/
readonly multipleNamespaces: boolean;
};
};
7 changes: 2 additions & 5 deletions packages/world/ts/config/v2/world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ export type resolveWorld<world> = evaluate<

export function resolveWorld<const world extends WorldInput>(world: world): resolveWorld<world> {
const scope = extendedScope(world);
const multipleNamespaces = world.namespaces != null;
const namespaces = world.namespaces ?? {};

const resolvedNamespacedTables = Object.fromEntries(
Object.entries(world.namespaces ?? {})
Object.entries(namespaces)
.map(([namespaceKey, namespace]) =>
Object.entries(namespace.tables ?? {}).map(([tableKey, table]) => {
validateTable(table, scope);
Expand All @@ -94,9 +94,6 @@ export function resolveWorld<const world extends WorldInput>(world: world): reso
systems: resolveSystems(world.systems ?? CONFIG_DEFAULTS.systems),
excludeSystems: get(world, "excludeSystems"),
modules,
internal: {
multipleNamespaces,
},
},
CONFIG_DEFAULTS,
) as never;
Expand Down
35 changes: 10 additions & 25 deletions packages/world/ts/config/v2/worldWithShorthands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,17 @@ export function resolveWorldWithShorthands<world extends WorldWithShorthandsInpu
world: world,
): resolveWorldWithShorthands<world> {
const scope = extendedScope(world);
const tables = mapObject(world.tables ?? {}, (table) => {
return isTableShorthandInput(table) ? resolveTableShorthand(table, scope) : table;
});
const namespaces = mapObject(world.namespaces ?? {}, (namespace) => ({
...namespace,
tables: mapObject(namespace.tables ?? {}, (table) => {
return isTableShorthandInput(table) ? resolveTableShorthand(table, scope) : table;
}),
}));

const fullConfig = {
...world,
...(world.tables
? {
tables: mapObject(world.tables, (table) =>
isTableShorthandInput(table) ? resolveTableShorthand(table, scope) : table,
),
}
: null),
...(world.namespaces
? {
namespaces: mapObject(world.namespaces, (namespace) => ({
...namespace,
...(namespace.tables
? {
tables: mapObject(namespace.tables, (table) =>
isTableShorthandInput(table) ? resolveTableShorthand(table, scope) : table,
),
}
: null),
})),
}
: null),
};

const fullConfig = { ...world, tables, namespaces };
validateWorld(fullConfig);

return resolveWorld(fullConfig) as never;
Expand Down

0 comments on commit 5fa86fb

Please sign in to comment.