diff --git a/examples/minimal/packages/plugin-example/.gitignore b/examples/minimal/packages/plugin-example/.gitignore deleted file mode 100644 index 8556908b69..0000000000 --- a/examples/minimal/packages/plugin-example/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -dist/ -out/ -cache/ -node_modules/ -artifacts/ diff --git a/examples/minimal/packages/plugin-example/package.json b/examples/minimal/packages/plugin-example/package.json deleted file mode 100644 index 9e1558d858..0000000000 --- a/examples/minimal/packages/plugin-example/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "plugin-example", - "version": "0.0.0", - "private": true, - "license": "MIT", - "type": "module", - "exports": { - ".": "./dist/ts/library/index.js", - "./register": "./dist/ts/register/index.js" - }, - "typesVersions": { - "*": { - "index": [ - "./ts/library/index.ts" - ], - "register": [ - "./ts/register/index.ts" - ] - } - }, - "scripts": { - "build": "pnpm run build:js", - "build:js": "tsup", - "clean": "pnpm run clean:js", - "clean:js": "rimraf dist", - "test": "tsc --noEmit" - }, - "dependencies": { - "@latticexyz/common": "link:../../../../packages/common", - "@latticexyz/config": "link:../../../../packages/config", - "@latticexyz/store": "link:../../../../packages/store", - "@latticexyz/world": "link:../../../../packages/world", - "zod": "^3.21.4" - }, - "devDependencies": { - "@types/node": "^18.15.11", - "rimraf": "^3.0.2", - "tsup": "^6.7.0", - "typescript": "5.4.2" - } -} diff --git a/examples/minimal/packages/plugin-example/ts/library/config.ts b/examples/minimal/packages/plugin-example/ts/library/config.ts deleted file mode 100644 index 7c21728c7f..0000000000 --- a/examples/minimal/packages/plugin-example/ts/library/config.ts +++ /dev/null @@ -1,11 +0,0 @@ -// configExtensions.ts -import { z } from "zod"; -import { DEFAULTS } from "./defaults"; - -// (if your zod schema is complicated, you should put it in a separate library with any other logic) -export const zMyPluginConfig = z - .object({ - myNewConfigOption: z.boolean().default(DEFAULTS.myNewConfigOption), - }) - // Catchall preserves other plugins' options - .catchall(z.any()); diff --git a/examples/minimal/packages/plugin-example/ts/library/defaults.ts b/examples/minimal/packages/plugin-example/ts/library/defaults.ts deleted file mode 100644 index 61ff913653..0000000000 --- a/examples/minimal/packages/plugin-example/ts/library/defaults.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const DEFAULTS = { - myNewConfigOption: true, -} as const; diff --git a/examples/minimal/packages/plugin-example/ts/library/index.ts b/examples/minimal/packages/plugin-example/ts/library/index.ts deleted file mode 100644 index 5867998163..0000000000 --- a/examples/minimal/packages/plugin-example/ts/library/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./defaults"; -export * from "./config"; -export * from "./types"; diff --git a/examples/minimal/packages/plugin-example/ts/library/types.ts b/examples/minimal/packages/plugin-example/ts/library/types.ts deleted file mode 100644 index d83d249712..0000000000 --- a/examples/minimal/packages/plugin-example/ts/library/types.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { z } from "zod"; -import { zMyPluginConfig } from "./config"; - -// zod doesn't preserve doc comments -export interface MyPluginUserConfig { - /** Add a description for your option */ - myNewConfigOption?: boolean; -} - -export type MyPluginConfig = z.output; diff --git a/examples/minimal/packages/plugin-example/ts/register/configExtensions.ts b/examples/minimal/packages/plugin-example/ts/register/configExtensions.ts deleted file mode 100644 index 4e5bd7ac33..0000000000 --- a/examples/minimal/packages/plugin-example/ts/register/configExtensions.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { extendMUDCoreConfig, fromZodErrorCustom } from "@latticexyz/config/library"; -import { ZodError } from "zod"; -import { zMyPluginConfig } from "../library"; - -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 zMyPluginConfig.parse(config); - } catch (error) { - if (error instanceof ZodError) { - throw fromZodErrorCustom(error, "MyPluginConfig Validation Error"); - } else { - throw error; - } - } -}); diff --git a/examples/minimal/packages/plugin-example/ts/register/index.ts b/examples/minimal/packages/plugin-example/ts/register/index.ts deleted file mode 100644 index 92ea4688eb..0000000000 --- a/examples/minimal/packages/plugin-example/ts/register/index.ts +++ /dev/null @@ -1,7 +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, followed by world) - -// Extend core config and types -import "./configExtensions"; -import "./typeExtensions"; diff --git a/examples/minimal/packages/plugin-example/ts/register/typeExtensions.ts b/examples/minimal/packages/plugin-example/ts/register/typeExtensions.ts deleted file mode 100644 index dff95c32ce..0000000000 --- a/examples/minimal/packages/plugin-example/ts/register/typeExtensions.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { OrDefaults } from "@latticexyz/common/type-utils"; -import { MUDCoreUserConfig } from "@latticexyz/config/library"; -import { DEFAULTS, MyPluginUserConfig, MyPluginConfig } from "../library"; - -import "@latticexyz/world/register"; - -// Inject the plugin 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/library" { - // 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 MyPluginUserConfig {} - - // 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 may receive this resolved config as their input. - // eslint-disable-next-line @typescript-eslint/no-empty-interface - export interface MUDCoreConfig extends MyPluginConfig {} -} - -declare module "@latticexyz/store/register" { - // eslint-disable-next-line @typescript-eslint/no-empty-interface - export interface ExpandMUDUserConfig - extends OrDefaults< - T, - { - myNewConfigOption: typeof DEFAULTS.myNewConfigOption; - } - > {} -} diff --git a/examples/minimal/packages/plugin-example/tsconfig.json b/examples/minimal/packages/plugin-example/tsconfig.json deleted file mode 100644 index 0600b17e05..0000000000 --- a/examples/minimal/packages/plugin-example/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - /* Visit https://aka.ms/tsconfig.json to read more about this file */ - "target": "es2021", - "types": ["node"], - "module": "esnext", - "moduleResolution": "node", - "declaration": true, - "sourceMap": true, - "outDir": "dist", - "isolatedModules": true, - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "strict": true, - "skipLibCheck": true - }, - "include": ["ts"] -} diff --git a/examples/minimal/packages/plugin-example/tsup.config.ts b/examples/minimal/packages/plugin-example/tsup.config.ts deleted file mode 100644 index c13db6face..0000000000 --- a/examples/minimal/packages/plugin-example/tsup.config.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { defineConfig } from "tsup"; - -export default defineConfig({ - entry: ["ts/library/index.ts", "ts/register/index.ts"], - target: "esnext", - format: ["esm"], - dts: false, - sourcemap: true, - clean: true, - minify: true, -});