diff --git a/packages/common/src/type-utils/common.ts b/packages/common/src/type-utils/common.ts index f32301b6fe..aae40b4a30 100644 --- a/packages/common/src/type-utils/common.ts +++ b/packages/common/src/type-utils/common.ts @@ -17,3 +17,9 @@ export type OrDefault = T extends undefined ? Default : T; export type OrDefaults = { [key in keyof Defaults]: key extends keyof T ? OrDefault : Defaults[key]; }; + +// Helper type to turn `A | B` into `A & B` +export type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; + +// Helper type to extract and merge the return types of a given union of functions +export type MergeReturnType any> = UnionToIntersection>; diff --git a/packages/config/package.json b/packages/config/package.json index e192e24f3d..b3669839bd 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -11,7 +11,6 @@ "type": "module", "exports": { ".": "./dist/library/index.js", - "./register": "./dist/register/index.js", "./node": "./dist/node/index.js" }, "typesVersions": { @@ -19,9 +18,6 @@ "index": [ "./src/library/index.ts" ], - "register": [ - "./src/register/index.ts" - ], "node": [ "./src/node/index.ts" ] @@ -42,10 +38,12 @@ "esbuild": "^0.17.15", "ethers": "^5.7.2", "find-up": "^6.3.0", + "tapable": "^2.2.1", "zod": "^3.21.4", "zod-validation-error": "^1.3.0" }, "devDependencies": { + "@types/tapable": "^2.2.3", "tsup": "^6.7.0" }, "gitHead": "914a1e0ae4a573d685841ca2ea921435057deb8f" diff --git a/packages/config/src/library/context.ts b/packages/config/src/library/context.ts deleted file mode 100644 index 0eb4575896..0000000000 --- a/packages/config/src/library/context.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { MUDConfigExtender } from "./core"; -import { MUDContextAlreadyCreatedError, MUDContextNotCreatedError } from "./errors"; - -export type GlobalWithMUDCoreContext = typeof global & { - __mudCoreContext: MUDCoreContext; -}; - -export class MUDCoreContext { - static _global = typeof global === "undefined" ? window.global ?? {} : global; - - public static isCreated(): boolean { - const globalWithMUDCoreContext = this._global as GlobalWithMUDCoreContext; - return globalWithMUDCoreContext.__mudCoreContext !== undefined; - } - - public static createContext(): MUDCoreContext { - if (this.isCreated()) { - throw new MUDContextAlreadyCreatedError(); - } - const globalWithMUDCoreContext = this._global as GlobalWithMUDCoreContext; - const context = new MUDCoreContext(); - globalWithMUDCoreContext.__mudCoreContext = context; - return context; - } - - public static getContext(): MUDCoreContext { - const globalWithMUDCoreContext = this._global as GlobalWithMUDCoreContext; - const context = globalWithMUDCoreContext.__mudCoreContext; - if (context === undefined) { - throw new MUDContextNotCreatedError(); - } - return context; - } - - public readonly configExtenders: MUDConfigExtender[] = []; -} diff --git a/packages/config/src/library/core.ts b/packages/config/src/library/core.ts index 5325c5ec7e..8210f77daa 100644 --- a/packages/config/src/library/core.ts +++ b/packages/config/src/library/core.ts @@ -1,27 +1,45 @@ -import { MUDCoreContext } from "./context"; +import { UnionToIntersection } from "@latticexyz/common/type-utils"; +import { MudPlugin, Plugins } from "./types"; -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface MUDCoreUserConfig {} +// Helper type to infer the input types from a plugins config as union (InputA | InputB) +type PluginsInput

= Parameters[0]; -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface MUDCoreConfig {} +/** + * Infer the plugin input types as intersection (InputA & InputB) + */ +export type MergedPluginsInput

= UnionToIntersection>; -export type MUDConfigExtender = (config: MUDCoreConfig) => Record; +/** + * Helper function to typecheck a plugin definition. + */ +export function defineMUDPlugin

(plugin: P): P { + return plugin; +} -/** Resolver that sequentially passes the config through all the plugins */ -export function mudCoreConfig(config: MUDCoreUserConfig): MUDCoreConfig { - // config types can change with plugins, `any` helps avoid errors when typechecking dependencies - // eslint-disable-next-line @typescript-eslint/no-explicit-any - let configAsAny = config as any; - const context = MUDCoreContext.getContext(); - for (const extender of context.configExtenders) { - configAsAny = extender(configAsAny); - } - return configAsAny; +/** + * Helper function to typecheck a config. + */ +export function mudCoreConfig

>(config: { plugins: P } & C) { + return config; } -/** Utility for plugin developers to extend the core config */ -export function extendMUDCoreConfig(extender: MUDConfigExtender) { - const context = MUDCoreContext.getContext(); - context.configExtenders.push(extender); +/** + * Helper function to sequentially apply `expandConfig` of each plugin. + * Use ExpandConfig to strongly type the result. + * + * Usage: + * ``` + * const _typedExpandConfig = expandConfig as ExpandConfig; + * type ExpandedConfig = MergeReturnType>; + * const expandedConfig = expandConfig(config) as ExpandedConfig; + * ``` + * + * TODO explain HKTs and why this can't just return `MergeReturnType>` + */ +export function expandConfig(config: C): Record { + let expanded = config; + for (const plugin of Object.values(config.plugins)) { + expanded = { ...expanded, ...plugin.expandConfig(config) }; + } + return expanded; } diff --git a/packages/config/src/library/index.ts b/packages/config/src/library/index.ts index a7b827f9e4..0dbbb4d8aa 100644 --- a/packages/config/src/library/index.ts +++ b/packages/config/src/library/index.ts @@ -1,8 +1,6 @@ -// Importing library has no side-effects, unlike register -// (library does not create MUDCoreContext when imported) export * from "./commonSchemas"; -export * from "./context"; export * from "./core"; export * from "./dynamicResolution"; export * from "./errors"; +export * from "./types"; export * from "./validation"; diff --git a/packages/config/src/library/types.ts b/packages/config/src/library/types.ts new file mode 100644 index 0000000000..bd55bced86 --- /dev/null +++ b/packages/config/src/library/types.ts @@ -0,0 +1,36 @@ +import { Hook } from "tapable"; + +/* + * Every plugin defines an `Input`, an `Expanded` type, + * and a `expandConfig` function to map from `Input` to `Expanded`. + * To distinguish plugins from each other in TypeScript, they also define a unique `id` string. + */ +export interface MudPlugin { + id: string; + expandConfig: (config: C) => Expanded; + hooks: Record>; +} + +/** + * The core config only expects a map of plugins. + * The config is later expanded by calling the expandConfig method of each + * plugin in order of appearance in the map. We use a map instead of an array, + * because it makes it easier to type check for the existence of expected + * plugins in the map. Object keys order is guaranteed since ES2015, see + * https://www.stefanjudis.com/today-i-learned/property-order-is-predictable-in-javascript-objects-since-es2015/ + */ +export type Config = { plugins: Plugins }; +export type Plugins = Record; + +/* + * Helper type to turn a strongly typed config into a union of + * all `expandConfig` functions defined in the config + * + * Usage: + * ``` + * const _typedExpandConfig = expandConfig as ExpandConfig; + * type ExpandedConfig = MergeReturnType>; + * const expandedConfig = expandConfig(config) as ExpandedConfig; + * ``` + */ +export type ExpandConfig = C["plugins"][keyof C["plugins"]]["expandConfig"]; diff --git a/packages/config/src/register/index.ts b/packages/config/src/register/index.ts deleted file mode 100644 index 28ab49f358..0000000000 --- a/packages/config/src/register/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { mudCoreConfig, resolveTableId } from "../library"; -import { MUDCoreContext } from "../library/context"; - -export { mudCoreConfig, resolveTableId }; - -// Importing this file has side-effects, and it should always be imported before MUD plugins. -// Use this import for defining a MUD config. -// Use the library endpoint instead when writing MUD-based libraries or plugins. -if (!MUDCoreContext.isCreated()) { - MUDCoreContext.createContext(); -} diff --git a/packages/config/tsup.config.ts b/packages/config/tsup.config.ts index 6166e27182..b648d7ba28 100644 --- a/packages/config/tsup.config.ts +++ b/packages/config/tsup.config.ts @@ -1,7 +1,7 @@ import { defineConfig } from "tsup"; export default defineConfig({ - entry: ["src/library/index.ts", "src/register/index.ts", "src/node/index.ts"], + entry: ["src/library/index.ts", "src/node/index.ts"], target: "esnext", format: ["esm"], dts: false, diff --git a/packages/store/mud.config.ts b/packages/store/mud.config.ts index 58a8de8b5a..d52a148c08 100644 --- a/packages/store/mud.config.ts +++ b/packages/store/mud.config.ts @@ -1,6 +1,9 @@ -import { mudConfig } from "./ts/register"; +import { MergeReturnType } from "@latticexyz/common/type-utils"; +import { ExpandConfig, expandConfig } from "@latticexyz/config"; +import { mudConfig, storePlugin } from "./ts"; -export default mudConfig({ +const config = mudConfig({ + plugins: { storePlugin }, storeImportPath: "../../", namespace: "mudstore", enums: { @@ -46,3 +49,7 @@ export default mudConfig({ }, }, }); + +const _typedExpandConfig = expandConfig as ExpandConfig; +type ExpandedConfig = MergeReturnType>; +export default expandConfig(config) as ExpandedConfig; diff --git a/packages/store/package.json b/packages/store/package.json index bbf4b22da0..7665b35c64 100644 --- a/packages/store/package.json +++ b/packages/store/package.json @@ -58,6 +58,7 @@ "@latticexyz/schema-type": "workspace:*", "abitype": "0.8.7", "ethers": "^5.7.2", + "tapable": "^2.2.1", "zod": "^3.21.4" }, "devDependencies": { @@ -65,6 +66,7 @@ "@types/ejs": "^3.1.1", "@types/mocha": "^9.1.1", "@types/node": "^18.15.11", + "@types/tapable": "^2.2.3", "ds-test": "https://github.com/dapphub/ds-test.git#c9ce3f25bde29fc5eb9901842bf02850dfd2d084", "ejs": "^3.1.8", "forge-std": "https://github.com/foundry-rs/forge-std.git#b4f121555729b3afb3c5ffccb62ff4b6e2818fd3", diff --git a/packages/store/ts/config/index.ts b/packages/store/ts/config/index.ts index 5de71694e7..a7f0fdab23 100644 --- a/packages/store/ts/config/index.ts +++ b/packages/store/ts/config/index.ts @@ -1,2 +1,21 @@ export * from "./defaults"; +export * from "./plugin"; export * from "./storeConfig"; + +import { Plugins, MergedPluginsInput } from "@latticexyz/config"; +import { ExtractUserTypes, StringForUnion } from "@latticexyz/common/type-utils"; +import { MUDUserConfig } from "./storeConfig"; + +/** + * Helper function to typecheck a config. + * This is an alternative to mudCoreConfig that uses more generics for type inference of user-defined types. + */ +export function mudConfig< + P extends Plugins, + C extends MergedPluginsInput

, + // (`never` is overridden by inference, so only the defined enums can be used by default) + EnumNames extends StringForUnion = never, + StaticUserTypes extends ExtractUserTypes = ExtractUserTypes +>(config: { plugins: P } & MUDUserConfig): { plugins: P } & C { + return config as any; +} diff --git a/packages/store/ts/config/mudConfig.test-d.ts b/packages/store/ts/config/mudConfig.test-d.ts new file mode 100644 index 0000000000..067a6eda25 --- /dev/null +++ b/packages/store/ts/config/mudConfig.test-d.ts @@ -0,0 +1,86 @@ +import { MergeReturnType } from "@latticexyz/common/type-utils"; +import { expandConfig, ExpandConfig } from "@latticexyz/config"; +import { describe, expectTypeOf } from "vitest"; +import { mudConfig, TABLE_DEFAULTS } from "."; +import { storePlugin } from "./plugin"; + +type DefinedConfig = ReturnType< + typeof mudConfig< + { storePlugin: typeof storePlugin }, + { + tables: { + Table1: { + keySchema: { + a: "Enum1"; + }; + schema: { + b: "Enum2"; + }; + }; + Table2: { + schema: { + a: "uint32"; + }; + }; + }; + enums: { + Enum1: ["E1"]; + Enum2: ["E1"]; + }; + } + > +>; + +const typedExpandConfig = expandConfig as ExpandConfig; +type AutoExpandedConfig = MergeReturnType>; + +type ManuallyExpandedConfig = { + enums: { + Enum1: ["E1"]; + Enum2: ["E1"]; + }; + tables: { + Table1: { + keySchema: { + a: "Enum1"; + }; + schema: { + b: "Enum2"; + }; + directory: typeof TABLE_DEFAULTS.directory; + name: "Table1"; + tableIdArgument: typeof TABLE_DEFAULTS.tableIdArgument; + storeArgument: typeof TABLE_DEFAULTS.storeArgument; + dataStruct: boolean; + ephemeral: typeof TABLE_DEFAULTS.ephemeral; + }; + Table2: { + schema: { + a: "uint32"; + }; + directory: typeof TABLE_DEFAULTS.directory; + name: "Table2"; + tableIdArgument: typeof TABLE_DEFAULTS.tableIdArgument; + storeArgument: typeof TABLE_DEFAULTS.storeArgument; + dataStruct: boolean; + keySchema: typeof TABLE_DEFAULTS.keySchema; + ephemeral: typeof TABLE_DEFAULTS.ephemeral; + }; + }; + namespace: ""; + storeImportPath: "@latticexyz/store/src/"; + userTypesPath: "Types"; + codegenDirectory: "codegen"; +}; + +describe("mudConfig", () => { + // Test possible inference confusion. + // This would fail if you remove `AsDependent` from `MUDUserConfig` + expectTypeOf().toEqualTypeOf(); +}); + +// An extra test to be sure of type equality +// eslint-disable-next-line @typescript-eslint/no-unused-vars +const _test1: AutoExpandedConfig = {} as ManuallyExpandedConfig; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +const _test2: ManuallyExpandedConfig = {} as AutoExpandedConfig; diff --git a/packages/store/ts/config/plugin.ts b/packages/store/ts/config/plugin.ts new file mode 100644 index 0000000000..45fe54af42 --- /dev/null +++ b/packages/store/ts/config/plugin.ts @@ -0,0 +1,28 @@ +import { defineMUDPlugin, fromZodErrorCustom } from "@latticexyz/config"; +import { SyncHook } from "tapable"; +import { ZodError } from "zod"; +import { ExpandStoreUserConfig, StoreUserConfig, zPluginStoreConfig } from "./storeConfig"; + +export function expandConfig(config: C) { + // This function gets called within mudConfig. + // The call order of config extenders depends on the order of their imports. + // Any config validation and transformation should be placed here. + try { + return zPluginStoreConfig.parse(config) as ExpandStoreUserConfig; + } catch (error) { + if (error instanceof ZodError) { + throw fromZodErrorCustom(error, "StoreConfig Validation Error"); + } else { + throw error; + } + } +} + +export const storePlugin = defineMUDPlugin({ + id: "mud-store-plugin", + expandConfig, + hooks: { + preTablegen: new SyncHook(["mudConfig"]), + postTablegen: new SyncHook(["mudConfig"]), + }, +} as const); diff --git a/packages/store/ts/config/storeConfig.test-d.ts b/packages/store/ts/config/storeConfig.test-d.ts index f31cd59f21..836e0f3b5d 100644 --- a/packages/store/ts/config/storeConfig.test-d.ts +++ b/packages/store/ts/config/storeConfig.test-d.ts @@ -1,14 +1,21 @@ +import { MergedPluginsInput } from "@latticexyz/config"; import { describe, expectTypeOf } from "vitest"; import { z } from "zod"; -import { zStoreConfig, MUDUserConfig } from "./storeConfig"; +import { storePlugin } from "./plugin"; +import { zStoreConfig, StoreUserConfig } from "./storeConfig"; describe("StoreUserConfig", () => { + // Check that the plugin uses the correct type + expectTypeOf< + Omit, "plugins"> + >().toEqualTypeOf(); + // Typecheck manual interfaces against zod - expectTypeOf().toEqualTypeOf>(); + expectTypeOf().toEqualTypeOf>(); // type equality isn't deep for optionals - expectTypeOf().toEqualTypeOf["tables"][string]>(); - expectTypeOf[string]>().toEqualTypeOf< + expectTypeOf().toEqualTypeOf["tables"][string]>(); + expectTypeOf[string]>().toEqualTypeOf< NonNullable>["enums"]>[string] >(); // TODO If more nested schemas are added, provide separate tests for them diff --git a/packages/store/ts/config/storeConfig.ts b/packages/store/ts/config/storeConfig.ts index e018f56393..73cc3b60fb 100644 --- a/packages/store/ts/config/storeConfig.ts +++ b/packages/store/ts/config/storeConfig.ts @@ -10,10 +10,10 @@ import type { import { // validation utils getDuplicates, + MergedPluginsInput, parseStaticArray, + Plugins, STORE_SELECTOR_MAX_LENGTH, - // config - MUDCoreUserConfig, // schemas zObjectName, zSelector, @@ -235,30 +235,33 @@ export const zEnumsConfig = z.object({ // zod doesn't preserve doc comments /** MUDCoreUserConfig wrapper to use generics in some options for better type inference */ export type MUDUserConfig< - T extends MUDCoreUserConfig = MUDCoreUserConfig, + P extends Plugins, + C extends MergedPluginsInput

, EnumNames extends StringForUnion = StringForUnion, StaticUserTypes extends ExtractUserTypes = ExtractUserTypes -> = T & - EnumsConfig & { - /** - * Configuration for each table. - * - * The key is the table name (capitalized). - * - * The value: - * - abi or user type for a single-value table. - * - FullTableConfig object for multi-value tables (or for customizable options). - */ - tables: TablesConfig, AsDependent>; - /** The namespace for table ids. Default is "" (ROOT) */ - namespace?: string; - /** Path for store package imports. Default is "@latticexyz/store/src/" */ - storeImportPath?: string; - /** Path to the file where common user types will be generated and imported from. Default is "Types" */ - userTypesPath?: string; - /** Path to the directory where generated files will be placed. (Default is "codegen") */ - codegenDirectory?: string; - }; +> = + // omit some keys to remove an inferred fallback type so typehints work correctly + Omit & + EnumsConfig & { + /** + * Configuration for each table. + * + * The key is the table name (capitalized). + * + * The value: + * - abi or user type for a single-value table. + * - FullTableConfig object for multi-value tables (or for customizable options). + */ + tables: TablesConfig, AsDependent>; + /** The namespace for table ids. Default is "" (ROOT) */ + namespace?: string; + /** Path for store package imports. Default is "@latticexyz/store/src/" */ + storeImportPath?: string; + /** Path to the file where common user types will be generated and imported from. Default is "Types" */ + userTypesPath?: string; + /** Path to the directory where generated files will be placed. (Default is "codegen") */ + codegenDirectory?: string; + }; const StoreConfigUnrefined = z .object({ @@ -279,6 +282,19 @@ export type StoreConfig = z.output; // Catchall preserves other plugins' options export const zPluginStoreConfig = StoreConfigUnrefined.catchall(z.any()).superRefine(validateStoreConfig); +export type ExpandStoreUserConfig = OrDefaults< + C, + { + enums: typeof DEFAULTS.enums; + namespace: typeof DEFAULTS.namespace; + storeImportPath: typeof PATH_DEFAULTS.storeImportPath; + userTypesPath: typeof PATH_DEFAULTS.userTypesPath; + codegenDirectory: typeof PATH_DEFAULTS.codegenDirectory; + } +> & { + tables: ExpandTablesConfig; +}; + /************************************************************************ * * HELPERS diff --git a/packages/store/ts/register/configExtensions.ts b/packages/store/ts/register/configExtensions.ts deleted file mode 100644 index 3daf8b35ab..0000000000 --- a/packages/store/ts/register/configExtensions.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { extendMUDCoreConfig, fromZodErrorCustom } from "@latticexyz/config"; -import { ZodError } from "zod"; -import { zPluginStoreConfig } from "../config"; - -extendMUDCoreConfig((config) => { - // This function gets called within mudConfig. - // The call order of config extenders depends on the order of their imports. - // Any config validation and transformation should be placed here. - try { - return zPluginStoreConfig.parse(config); - } catch (error) { - if (error instanceof ZodError) { - throw fromZodErrorCustom(error, "StoreConfig Validation Error"); - } else { - throw error; - } - } -}); diff --git a/packages/store/ts/register/index.ts b/packages/store/ts/register/index.ts deleted file mode 100644 index 76ff7049aa..0000000000 --- a/packages/store/ts/register/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -// Importing this file has side-effects for MUD config, -// and the order of imports is important in relation to other plugins -// (store should usually be the first plugin) - -// For convenience register and reexport config, to reduce the number of needed imports for users -import "@latticexyz/config/register"; -export { mudCoreConfig, resolveTableId } from "@latticexyz/config/register"; -// Extend core config and types -import "./configExtensions"; -import "./typeExtensions"; - -export { mudConfig } from "./mudConfig"; -export type { ExpandMUDUserConfig } from "./typeExtensions"; diff --git a/packages/store/ts/register/mudConfig.test-d.ts b/packages/store/ts/register/mudConfig.test-d.ts deleted file mode 100644 index 3e0c7c39a0..0000000000 --- a/packages/store/ts/register/mudConfig.test-d.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { describe, expectTypeOf } from "vitest"; -import { mudConfig } from "."; - -describe("mudConfig", () => { - // Test possible inference confusion. - // This would fail if you remove `AsDependent` from `MUDUserConfig` - expectTypeOf< - ReturnType< - typeof mudConfig<{ - tables: { - Table1: { - keySchema: { - a: "Enum1"; - }; - schema: { - b: "Enum2"; - }; - }; - Table2: { - schema: { - a: "uint32"; - }; - }; - }; - enums: { - Enum1: ["E1"]; - Enum2: ["E1"]; - }; - }> - > - >().toEqualTypeOf<{ - enums: { - Enum1: ["E1"]; - Enum2: ["E1"]; - }; - tables: { - Table1: { - keySchema: { - a: "Enum1"; - }; - schema: { - b: "Enum2"; - }; - }; - Table2: { - schema: { - a: "uint32"; - }; - }; - }; - namespace: ""; - storeImportPath: "@latticexyz/store/src/"; - userTypesPath: "Types"; - codegenDirectory: "codegen"; - }>(); -}); diff --git a/packages/store/ts/register/mudConfig.ts b/packages/store/ts/register/mudConfig.ts deleted file mode 100644 index afc08f9dd5..0000000000 --- a/packages/store/ts/register/mudConfig.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { mudCoreConfig, MUDCoreUserConfig } from "@latticexyz/config"; -import { ExtractUserTypes, StringForUnion } from "@latticexyz/common/type-utils"; -import { MUDUserConfig } from ".."; -import { ExpandMUDUserConfig } from "./typeExtensions"; - -/** mudCoreConfig wrapper to use generics in some options for better type inference */ -export function mudConfig< - T extends MUDCoreUserConfig, - // (`never` is overridden by inference, so only the defined enums can be used by default) - EnumNames extends StringForUnion = never, - StaticUserTypes extends ExtractUserTypes = ExtractUserTypes ->(config: MUDUserConfig): ExpandMUDUserConfig { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - return mudCoreConfig(config) as any; -} diff --git a/packages/store/ts/register/typeExtensions.ts b/packages/store/ts/register/typeExtensions.ts deleted file mode 100644 index 88dd09dee4..0000000000 --- a/packages/store/ts/register/typeExtensions.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { OrDefaults } from "@latticexyz/common/type-utils"; -import { MUDCoreUserConfig } from "@latticexyz/config"; -import { ExpandTablesConfig, StoreConfig, StoreUserConfig } from "../config"; -import { DEFAULTS, PATH_DEFAULTS } from "../config/defaults"; - -// Inject non-generic options into the core config. -// Re-exporting an interface of an existing module merges them, adding new options to the interface. -// (typescript has no way to override types) -declare module "@latticexyz/config" { - // Extend the user config type, which represents the config as written by the users. - // Most things are optional here. - // eslint-disable-next-line @typescript-eslint/no-empty-interface - export interface MUDCoreUserConfig extends StoreUserConfig {} - - // Also extend the config type, which represents the configuration after it has been resolved. - // It should not have any optional properties, with the default values applied instead. - // Other plugins receive this resolved config as their input. - // eslint-disable-next-line @typescript-eslint/no-empty-interface - export interface MUDCoreConfig extends StoreConfig {} -} - -// store-specific helper to preserve strong types, depends on store's type extensions to the core config -export interface ExpandMUDUserConfig - extends OrDefaults< - T, - { - enums: typeof DEFAULTS.enums; - namespace: typeof DEFAULTS.namespace; - storeImportPath: typeof PATH_DEFAULTS.storeImportPath; - userTypesPath: typeof PATH_DEFAULTS.userTypesPath; - codegenDirectory: typeof PATH_DEFAULTS.codegenDirectory; - } - > { - tables: ExpandTablesConfig; -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8ec5832cc1..ec549a2705 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.1' +lockfileVersion: '6.0' settings: autoInstallPeers: true @@ -238,6 +238,9 @@ importers: find-up: specifier: ^6.3.0 version: 6.3.0 + tapable: + specifier: ^2.2.1 + version: 2.2.1 zod: specifier: ^3.21.4 version: 3.21.4 @@ -245,6 +248,9 @@ importers: specifier: ^1.3.0 version: 1.3.0(zod@3.21.4) devDependencies: + '@types/tapable': + specifier: ^2.2.3 + version: 2.2.3 tsup: specifier: ^6.7.0 version: 6.7.0(typescript@4.9.5) @@ -931,6 +937,9 @@ importers: ethers: specifier: ^5.7.2 version: 5.7.2 + tapable: + specifier: ^2.2.1 + version: 2.2.1 zod: specifier: ^3.21.4 version: 3.21.4 @@ -947,6 +956,9 @@ importers: '@types/node': specifier: ^18.15.11 version: 18.15.11 + '@types/tapable': + specifier: ^2.2.3 + version: 2.2.3 ds-test: specifier: https://github.com/dapphub/ds-test.git#c9ce3f25bde29fc5eb9901842bf02850dfd2d084 version: github.com/dapphub/ds-test/c9ce3f25bde29fc5eb9901842bf02850dfd2d084 @@ -3798,6 +3810,12 @@ packages: resolution: {integrity: sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==} dev: true + /@types/tapable@2.2.3: + resolution: {integrity: sha512-WA0xhgs1wenECj1psxojjYOIc1Zkn+4gNtuWmF+dcFs5UfsQa8WhWs+8WG4D2RuaX7DufNPU+KsOEF7KqlByuw==} + dependencies: + tapable: 2.2.1 + dev: true + /@types/throttle-debounce@5.0.0: resolution: {integrity: sha512-Pb7k35iCGFcGPECoNE4DYp3Oyf2xcTd3FbFQxXUI9hEYKUl6YX+KLf7HrBmgVcD05nl50LIH6i+80js4iYmWbw==} dev: true @@ -13546,6 +13564,10 @@ packages: - ts-node dev: true + /tapable@2.2.1: + resolution: {integrity: sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==} + engines: {node: '>=6'} + /tar-stream@1.6.2: resolution: {integrity: sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==} engines: {node: '>= 0.8.0'}