Skip to content

Commit

Permalink
feat(store,world): update exports (#2485)
Browse files Browse the repository at this point in the history
holic authored Mar 20, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 252a185 commit f24fac2
Showing 56 changed files with 145 additions and 85 deletions.
2 changes: 1 addition & 1 deletion packages/cli/scripts/generate-test-tables.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from "path";
import { tablegen } from "@latticexyz/store/codegen";
import { defineStore } from "@latticexyz/store/config/v2";
import { defineStore } from "@latticexyz/store";
import { getRemappings, getSrcDirectory } from "@latticexyz/common/foundry";

// This config is used only for tests.
2 changes: 1 addition & 1 deletion packages/cli/src/commands/tablegen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from "path";
import type { CommandModule } from "yargs";
import { loadConfig } from "@latticexyz/config/node";
import { Store as StoreConfig } from "@latticexyz/store/config/v2";
import { Store as StoreConfig } from "@latticexyz/store";
import { tablegen } from "@latticexyz/store/codegen";
import { getRemappings, getSrcDirectory } from "@latticexyz/common/foundry";

2 changes: 1 addition & 1 deletion packages/cli/src/commands/trace.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import { ethers } from "ethers";
import { loadConfig } from "@latticexyz/config/node";
import { MUDError } from "@latticexyz/common/errors";
import { cast, getRpcUrl, getSrcDirectory } from "@latticexyz/common/foundry";
import { resolveWorldConfig } from "@latticexyz/world";
import { resolveWorldConfig } from "@latticexyz/world/internal";
import IBaseWorldAbi from "@latticexyz/world/out/IBaseWorld.sol/IBaseWorld.abi.json" assert { type: "json" };
import worldConfig from "@latticexyz/world/mud.config";
import { resourceToHex } from "@latticexyz/common";
6 changes: 4 additions & 2 deletions packages/cli/src/deploy/common.ts
Original file line number Diff line number Diff line change
@@ -4,8 +4,10 @@ import worldConfig from "@latticexyz/world/mud.config";
import IBaseWorldAbi from "@latticexyz/world/out/IBaseWorld.sol/IBaseWorld.abi.json" assert { type: "json" };
import IModuleAbi from "@latticexyz/world-modules/out/IModule.sol/IModule.abi.json" assert { type: "json" };
import { Tables, configToTables } from "./configToTables";
import { StoreConfig, helloStoreEvent } from "@latticexyz/store";
import { WorldConfig, helloWorldEvent } from "@latticexyz/world";
import { helloStoreEvent } from "@latticexyz/store";
import { StoreConfig } from "@latticexyz/store/internal";
import { helloWorldEvent } from "@latticexyz/world";
import { WorldConfig } from "@latticexyz/world/internal";
import { storeToV1 } from "@latticexyz/store/config/v2";
import { worldToV1 } from "@latticexyz/world/config/v2";

2 changes: 1 addition & 1 deletion packages/cli/src/deploy/configToTables.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { resourceToHex } from "@latticexyz/common";
import { KeySchema, ValueSchema } from "@latticexyz/protocol-parser/internal";
import { SchemaAbiType, StaticAbiType } from "@latticexyz/schema-type/internal";
import { StoreConfig, resolveUserTypes } from "@latticexyz/store";
import { StoreConfig, resolveUserTypes } from "@latticexyz/store/internal";
import { Hex } from "viem";

// TODO: we shouldn't need this file once our config parsing returns nicely formed tables
2 changes: 1 addition & 1 deletion packages/cli/src/deploy/resolveConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from "path";
import { resolveWorldConfig } from "@latticexyz/world";
import { resolveWorldConfig } from "@latticexyz/world/internal";
import { Config, ConfigInput, Library, Module, System, WorldFunction } from "./common";
import { resourceToHex } from "@latticexyz/common";
import { resolveWithContext } from "@latticexyz/config/library";
2 changes: 1 addition & 1 deletion packages/dev-tools/src/common.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Observable } from "rxjs";
import { Abi, Block, Chain, PublicClient, Transport, WalletClient } from "viem";
import { Store as StoreConfig } from "@latticexyz/store/config/v2";
import { Store as StoreConfig } from "@latticexyz/store";
import { StorageAdapterBlock } from "@latticexyz/store-sync";
import { ZustandStore } from "@latticexyz/store-sync/zustand";
import { ContractWrite } from "@latticexyz/common";
2 changes: 1 addition & 1 deletion packages/dev-tools/src/zustand/TableDataTable.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Table } from "@latticexyz/store";
import { Table } from "@latticexyz/store/internal";
import { useRecords } from "./useRecords";
import { FieldValue } from "./FieldValue";

2 changes: 1 addition & 1 deletion packages/dev-tools/src/zustand/useRecords.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Table } from "@latticexyz/store";
import { Table } from "@latticexyz/store/internal";
import { useDevToolsContext } from "../DevToolsContext";
import { useEffect, useState } from "react";
import { TableRecord } from "@latticexyz/store-sync/zustand";
2 changes: 1 addition & 1 deletion packages/dev-tools/src/zustand/useTables.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Table } from "@latticexyz/store";
import { Table } from "@latticexyz/store/internal";
import { useDevToolsContext } from "../DevToolsContext";
import { useEffect, useState } from "react";

1 change: 1 addition & 0 deletions packages/query/package.json
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@
},
"dependencies": {
"@latticexyz/common": "workspace:*",
"@latticexyz/config": "workspace:*",
"@latticexyz/schema-type": "workspace:*",
"@latticexyz/store": "workspace:*",
"viem": "2.7.12"
4 changes: 2 additions & 2 deletions packages/query/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Hex } from "viem";
import { StaticPrimitiveType, DynamicPrimitiveType, SchemaAbiType } from "@latticexyz/schema-type/internal";
import { satisfy } from "@latticexyz/common/type-utils";
import { SchemaToPrimitives } from "@latticexyz/store";
import { Table } from "@latticexyz/store/config/v2";
import { SchemaToPrimitives } from "@latticexyz/store/internal";
import { Table } from "@latticexyz/config";

/**
* These types represent the "over the wire" protocol (i.e. JSON) for the query API.
4 changes: 2 additions & 2 deletions packages/query/src/common.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { StaticPrimitiveType } from "@latticexyz/schema-type/internal";
import { SchemaToPrimitives } from "@latticexyz/store";
import { Table } from "@latticexyz/store/config/v2";
import { SchemaToPrimitives } from "@latticexyz/store/internal";
import { Table } from "@latticexyz/config";
import { Hex } from "viem";

export type TableRecord<table extends Table> = {
2 changes: 1 addition & 1 deletion packages/query/src/findSubjects.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { encodeAbiParameters } from "viem";
import { Table } from "@latticexyz/store/config/v2";
import { Table } from "@latticexyz/config";
import { groupBy, uniqueBy } from "@latticexyz/common/utils";
import { Query, SubjectRecords } from "./api";
import { matchRecords } from "./matchRecords";
2 changes: 1 addition & 1 deletion packages/query/src/matchRecords.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Table } from "@latticexyz/store/config/v2";
import { Table } from "@latticexyz/config";
import { ComparisonCondition, ConditionLiteral, QueryCondition } from "./api";
import { TableRecord } from "./common";

1 change: 1 addition & 0 deletions packages/store-sync/package.json
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@
"dependencies": {
"@latticexyz/block-logs-stream": "workspace:*",
"@latticexyz/common": "workspace:*",
"@latticexyz/config": "workspace:*",
"@latticexyz/protocol-parser": "workspace:*",
"@latticexyz/query": "workspace:*",
"@latticexyz/recs": "workspace:*",
6 changes: 4 additions & 2 deletions packages/store-sync/src/common.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Address, Block, Hex, Log, PublicClient } from "viem";
import { StoreEventsAbiItem, StoreEventsAbi, resolveConfig } from "@latticexyz/store";
import { StoreEventsAbiItem, StoreEventsAbi } from "@latticexyz/store";
import { resolveConfig } from "@latticexyz/store/internal";
import { Observable } from "rxjs";
import { UnionPick } from "@latticexyz/common/type-utils";
import { KeySchema, TableRecord, ValueSchema } from "@latticexyz/protocol-parser/internal";
import storeConfig from "@latticexyz/store/mud.config";
import worldConfig from "@latticexyz/world/mud.config";
import { flattenSchema } from "./flattenSchema";
import { Store as StoreConfig, storeToV1 } from "@latticexyz/store/config/v2";
import { Store as StoreConfig } from "@latticexyz/store";
import { storeToV1 } from "@latticexyz/store/config/v2";

/** @internal Temporary workaround until we redo our config parsing and can pull this directly from the config (https://github.com/latticexyz/mud/issues/1668) */
export const storeTables = resolveConfig(storeToV1(storeConfig)).tables;
2 changes: 1 addition & 1 deletion packages/store-sync/src/createStoreSync.ts
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ import { SyncStep } from "./SyncStep";
import { bigIntMax, chunk, isDefined, waitForIdle } from "@latticexyz/common/utils";
import { getSnapshot } from "./getSnapshot";
import { fetchAndStoreLogs } from "./fetchAndStoreLogs";
import { Store as StoreConfig } from "@latticexyz/store/config/v2";
import { Store as StoreConfig } from "@latticexyz/store";

const debug = parentDebug.extend("createStoreSync");

2 changes: 1 addition & 1 deletion packages/store-sync/src/flattenSchema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mapObject } from "@latticexyz/common/utils";
import { ValueSchema } from "@latticexyz/store";
import { ValueSchema } from "@latticexyz/store/internal";

export function flattenSchema<schema extends ValueSchema>(
schema: schema,
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { Hex, PublicClient, concatHex, getAddress } from "viem";
import { PgDatabase, QueryResultHKT } from "drizzle-orm/pg-core";
import { and, eq } from "drizzle-orm";
import { buildTable } from "./buildTable";
import { Store as StoreConfig } from "@latticexyz/store/config/v2";
import { Store as StoreConfig } from "@latticexyz/store";
import { debug } from "./debug";
import { StorageAdapter, StorageAdapterBlock } from "../common";
import { isTableRegistrationLog } from "../isTableRegistrationLog";
2 changes: 1 addition & 1 deletion packages/store-sync/src/postgres-decoded/syncToPostgres.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Store as StoreConfig } from "@latticexyz/store/config/v2";
import { Store as StoreConfig } from "@latticexyz/store";
import { PgDatabase } from "drizzle-orm/pg-core";
import { SyncOptions, SyncResult } from "../common";
import { createStorageAdapter } from "./createStorageAdapter";
2 changes: 1 addition & 1 deletion packages/store-sync/src/postgres/createStorageAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PublicClient, encodePacked, size } from "viem";
import { PgDatabase, QueryResultHKT } from "drizzle-orm/pg-core";
import { and, eq } from "drizzle-orm";
import { Store as StoreConfig } from "@latticexyz/store/config/v2";
import { Store as StoreConfig } from "@latticexyz/store";
import { debug } from "./debug";
import { tables } from "./tables";
import { spliceHex } from "@latticexyz/common";
2 changes: 1 addition & 1 deletion packages/store-sync/src/postgres/syncToPostgres.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Store as StoreConfig } from "@latticexyz/store/config/v2";
import { Store as StoreConfig } from "@latticexyz/store";
import { PgDatabase } from "drizzle-orm/pg-core";
import { SyncOptions, SyncResult } from "../common";
import { createStorageAdapter } from "./createStorageAdapter";
3 changes: 2 additions & 1 deletion packages/store-sync/src/query-cache/common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Store, Table } from "@latticexyz/store/config/v2";
import { Store } from "@latticexyz/store";
import { Table } from "@latticexyz/config";
import { SchemaAbiType, SchemaAbiTypeToPrimitiveType } from "@latticexyz/schema-type/internal";
import { ComparisonCondition, InCondition } from "@latticexyz/query";

4 changes: 2 additions & 2 deletions packages/store-sync/src/query-cache/createStore.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { StoreApi, UseBoundStore, create } from "zustand";
import { Table } from "@latticexyz/store/config/v2";
import { Table } from "@latticexyz/config";
import { Tables } from "./common";
import { Hex } from "viem";
import { StaticPrimitiveType } from "@latticexyz/schema-type/internal";
import { SchemaToPrimitives } from "@latticexyz/store";
import { SchemaToPrimitives } from "@latticexyz/store/internal";
import { getKeySchema, getValueSchema } from "@latticexyz/protocol-parser/internal";

export type RawTableRecord<table extends Table = Table> = {
2 changes: 1 addition & 1 deletion packages/store-sync/src/query-cache/syncToQueryCache.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SyncOptions, SyncResult } from "../common";
import { createStoreSync } from "../createStoreSync";
import { Address } from "viem";
import { Store } from "@latticexyz/store/config/v2";
import { Store } from "@latticexyz/store";
import { createStore } from "./createStore";
import { createStorageAdapter } from "./createStorageAdapter";

3 changes: 2 additions & 1 deletion packages/store-sync/src/recs/recsStorage.test.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@ import { groupLogsByBlockNumber } from "@latticexyz/block-logs-stream";
import { StoreEventsLog } from "../common";
import { singletonEntity } from "./singletonEntity";
import { RpcLog, formatLog, decodeEventLog, Hex } from "viem";
import { resolveConfig, storeEventsAbi } from "@latticexyz/store";
import { storeEventsAbi } from "@latticexyz/store";
import { resolveConfig } from "@latticexyz/store/internal";
import { storeToV1 } from "@latticexyz/store/config/v2";

const tables = resolveConfig(storeToV1(mudConfig)).tables;
2 changes: 1 addition & 1 deletion packages/store-sync/src/recs/recsStorage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Table, resolveConfig } from "@latticexyz/store";
import { Table, resolveConfig } from "@latticexyz/store/internal";
import { debug } from "./debug";
import { World as RecsWorld, getComponentValue, hasComponent, removeComponent, setComponent } from "@latticexyz/recs";
import { defineInternalComponents } from "./defineInternalComponents";
5 changes: 3 additions & 2 deletions packages/store-sync/src/recs/syncToRecs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Table, ResolvedStoreConfig, resolveConfig } from "@latticexyz/store";
import { Store as StoreConfig, storeToV1 } from "@latticexyz/store/config/v2";
import { Table, ResolvedStoreConfig, resolveConfig } from "@latticexyz/store/internal";
import { Store as StoreConfig } from "@latticexyz/store";
import { storeToV1 } from "@latticexyz/store/config/v2";
import { Component as RecsComponent, World as RecsWorld, getComponentValue, setComponent } from "@latticexyz/recs";
import { SyncOptions, SyncResult } from "../common";
import { RecsStorageAdapter, recsStorage } from "./recsStorage";
2 changes: 1 addition & 1 deletion packages/store-sync/src/recs/tableToComponent.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { Component, Type, World, defineComponent } from "@latticexyz/recs";
import { StoreComponentMetadata } from "./common";
import { SchemaAbiTypeToRecsType, schemaAbiTypeToRecsType } from "./schemaAbiTypeToRecsType";
import { SchemaAbiType } from "@latticexyz/schema-type/internal";
import { Table } from "@latticexyz/store";
import { Table } from "@latticexyz/store/internal";
import { mapObject } from "@latticexyz/common/utils";
import { ResourceLabel, resourceToLabel } from "@latticexyz/common";

2 changes: 1 addition & 1 deletion packages/store-sync/src/recs/tablesToComponents.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Table } from "@latticexyz/store";
import { Table } from "@latticexyz/store/internal";
import { TableToComponent, tableToComponent } from "./tableToComponent";
import { mapObject } from "@latticexyz/common/utils";
import { World } from "@latticexyz/recs";
2 changes: 1 addition & 1 deletion packages/store-sync/src/sqlite/sqliteStorage.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import { BaseSQLiteDatabase } from "drizzle-orm/sqlite-core";
import { and, eq, sql } from "drizzle-orm";
import { sqliteTableToSql } from "./sqliteTableToSql";
import { buildTable } from "./buildTable";
import { Store as StoreConfig } from "@latticexyz/store/config/v2";
import { Store as StoreConfig } from "@latticexyz/store";
import { debug } from "./debug";
import { getTableName } from "./getTableName";
import { chainState, mudStoreTables } from "./internalTables";
2 changes: 1 addition & 1 deletion packages/store-sync/src/sqlite/syncToSqlite.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Store as StoreConfig } from "@latticexyz/store/config/v2";
import { Store as StoreConfig } from "@latticexyz/store";
import { BaseSQLiteDatabase } from "drizzle-orm/sqlite-core";
import { SyncOptions, SyncResult } from "../common";
import { sqliteStorage } from "./sqliteStorage";
2 changes: 1 addition & 1 deletion packages/store-sync/src/zustand/common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Table, SchemaToPrimitives } from "@latticexyz/store";
import { Table, SchemaToPrimitives } from "@latticexyz/store/internal";
import { Hex } from "viem";

export type RawRecord = {
2 changes: 1 addition & 1 deletion packages/store-sync/src/zustand/createStorageAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Tables } from "@latticexyz/store";
import { Tables } from "@latticexyz/store/internal";
import { StorageAdapter } from "../common";
import { RawRecord, TableRecord } from "./common";
import { ZustandStore } from "./createStore";
2 changes: 1 addition & 1 deletion packages/store-sync/src/zustand/createStore.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SchemaToPrimitives, Table, Tables } from "@latticexyz/store";
import { SchemaToPrimitives, Table, Tables } from "@latticexyz/store/internal";
import { StoreApi, UseBoundStore, create } from "zustand";
import { RawRecord, TableRecord } from "./common";
import { Hex } from "viem";
5 changes: 3 additions & 2 deletions packages/store-sync/src/zustand/syncToZustand.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { ResolvedStoreConfig, Tables, resolveConfig } from "@latticexyz/store";
import { ResolvedStoreConfig, Tables, resolveConfig } from "@latticexyz/store/internal";
import { SyncOptions, SyncResult, storeTables, worldTables } from "../common";
import { createStoreSync } from "../createStoreSync";
import { ZustandStore } from "./createStore";
import { createStore } from "./createStore";
import { createStorageAdapter } from "./createStorageAdapter";
import { Address } from "viem";
import { SyncStep } from "../SyncStep";
import { Store as StoreConfig, storeToV1 } from "@latticexyz/store/config/v2";
import { Store as StoreConfig } from "@latticexyz/store";
import { storeToV1 } from "@latticexyz/store/config/v2";

type AllTables<config extends StoreConfig, extraTables extends Tables | undefined> = ResolvedStoreConfig<
storeToV1<config>
2 changes: 1 addition & 1 deletion packages/store-sync/test/mockGame.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { execa } from "execa";
import { anvilRpcUrl } from "./common";
import configV2 from "mock-game-contracts/mud.config";
import { resolveConfig } from "@latticexyz/store";
import { resolveConfig } from "@latticexyz/store/internal";
import { Hex, isHex } from "viem";
import worldAbi from "mock-game-contracts/out/IWorld.sol/IWorld.abi.json";
import { storeToV1 } from "@latticexyz/store/config/v2";
2 changes: 1 addition & 1 deletion packages/store-sync/test/utils.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import { foundry } from "viem/chains";
import initSqlJs from "sql.js";
import mudConfig from "../../../e2e/packages/contracts/mud.config";
import { createWorld } from "@latticexyz/recs";
import { resolveConfig } from "@latticexyz/store";
import { resolveConfig } from "@latticexyz/store/internal";
import { RecsStorageAdapter, recsStorage } from "../src/recs";
import { sqliteStorage } from "../src/sqlite";
import { ZustandStore, createStorageAdapter, createStore } from "../src/zustand";
16 changes: 10 additions & 6 deletions packages/store/package.json
Original file line number Diff line number Diff line change
@@ -10,18 +10,22 @@
"license": "MIT",
"type": "module",
"exports": {
".": "./dist/ts/index.js",
".": "./dist/index.js",
"./internal": "./dist/internal.js",
"./mud.config": "./dist/mud.config.js",
"./codegen": "./dist/ts/codegen/index.js",
"./config": "./dist/ts/config/index.js",
"./config/v2": "./dist/ts/config/v2/index.js",
"./register": "./dist/ts/register/index.js",
"./codegen": "./dist/codegen.js",
"./config": "./dist/config.js",
"./config/v2": "./dist/config/v2.js",
"./register": "./dist/register.js",
"./out/*": "./out/*"
},
"typesVersions": {
"*": {
"index": [
"./ts/index.ts"
"./ts/exports/index.ts"
],
"internal": [
"./ts/exports/internal.ts"
],
"codegen": [
"./ts/codegen/index.ts"
20 changes: 20 additions & 0 deletions packages/store/ts/exports/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* External exports.
*
* Be sure we're ready to commit to these being supported and changes made backward compatible!
*/

export {
helloStoreEvent,
storeSetRecordEvent,
storeSpliceStaticDataEvent,
storeSpliceDynamicDataEvent,
storeDeleteRecordEvent,
storeEvents,
} from "../storeEvents";

export { storeEventsAbi } from "../storeEventsAbi";
export type { StoreEventsAbi, StoreEventsAbiItem } from "../storeEventsAbi";

export { defineStore } from "../config/v2/store";
export type { Store } from "../config/v2/output";
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Importing library has no side-effects, unlike register
// (library neither creates nor extends MUDCoreContext when imported)
export * from "./config";
export * from "../config";

export * from "./common";
export * from "./storeEvents";
export * from "./storeEventsAbi";
export * from "../common";
2 changes: 1 addition & 1 deletion packages/store/ts/register/mudConfig.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mudCoreConfig, MUDCoreUserConfig } from "@latticexyz/config/library";
import { ExtractUserTypes, StringForUnion } from "@latticexyz/common/type-utils";
import { MUDUserConfig } from "..";
import { ExpandMUDUserConfig } from "./typeExtensions";
import { MUDUserConfig } from "../config/storeConfig";

/** mudCoreConfig wrapper to use generics in some options for better type inference */
export function mudConfig<
17 changes: 9 additions & 8 deletions packages/store/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { defineConfig } from "tsup";

export default defineConfig({
entry: [
"mud.config.ts",
"ts/index.ts",
"ts/codegen/index.ts",
"ts/config/index.ts",
"ts/config/v2/index.ts",
"ts/register/index.ts",
],
entry: {
"mud.config": "mud.config.ts",
index: "ts/exports/index.ts",
internal: "ts/exports/internal.ts",
codegen: "ts/codegen/index.ts",
config: "ts/config/index.ts",
"config/v2": "ts/config/v2/index.ts",
register: "ts/register/index.ts",
},
target: "esnext",
format: ["esm"],
dts: true,
2 changes: 1 addition & 1 deletion packages/world-modules/ts/scripts/tablegen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from "path";
import { loadConfig } from "@latticexyz/config/node";
import { getRemappings, getSrcDirectory } from "@latticexyz/common/foundry";
import { Store as StoreConfig } from "@latticexyz/store/config/v2";
import { Store as StoreConfig } from "@latticexyz/store";
import { tablegen } from "@latticexyz/store/codegen";

const config = (await loadConfig()) as StoreConfig;
14 changes: 9 additions & 5 deletions packages/world/package.json
Original file line number Diff line number Diff line change
@@ -10,17 +10,21 @@
"license": "MIT",
"type": "module",
"exports": {
".": "./dist/ts/index.js",
".": "./dist/index.js",
"./internal": "./dist/internal.js",
"./mud.config": "./dist/mud.config.js",
"./config/v2": "./dist/ts/config/v2/index.js",
"./register": "./dist/ts/register/index.js",
"./node": "./dist/ts/node/index.js",
"./config/v2": "./dist/config/v2.js",
"./register": "./dist/register.js",
"./node": "./dist/node.js",
"./out/*": "./out/*"
},
"typesVersions": {
"*": {
"index": [
"./ts/index.ts"
"./ts/exports/index.ts"
],
"internal": [
"./ts/exports/internal.ts"
],
"config/v2": [
"./ts/config/v2/index.ts"
2 changes: 1 addition & 1 deletion packages/world/ts/config/resolveWorldConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UnrecognizedSystemErrorFactory } from "@latticexyz/config/library";
import { StoreConfig } from "@latticexyz/store";
import { StoreConfig } from "@latticexyz/store/internal";
import { SystemConfig, WorldConfig } from "./types";

export type ResolvedSystemConfig = ReturnType<typeof resolveSystemConfig>;
3 changes: 2 additions & 1 deletion packages/world/ts/config/v2/compat.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { conform, mutable } from "@arktype/util";
import { Module, World, Systems } from "./output";
import { storeToV1, Store } from "@latticexyz/store/config/v2";
import { Store } from "@latticexyz/store";
import { storeToV1 } from "@latticexyz/store/config/v2";

type modulesToV1<modules extends readonly Module[]> = mutable<{
[key in keyof modules]: Required<modules[key]>;
2 changes: 1 addition & 1 deletion packages/world/ts/config/v2/output.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Store } from "@latticexyz/store/config/v2";
import { Store } from "@latticexyz/store";
import { DynamicResolution, ValueWithType } from "./dynamicResolution";

export type Module = {
2 changes: 1 addition & 1 deletion packages/world/ts/config/v2/world.ts
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ import {
} from "@latticexyz/store/config/v2";
import { SystemsInput, WorldInput } from "./input";
import { CONFIG_DEFAULTS } from "./defaults";
import { Tables } from "@latticexyz/store";
import { Tables } from "@latticexyz/store/internal";
import { resolveSystems } from "./systems";
import { resolveNamespacedTables, validateNamespaces } from "./namespaces";
import { resolveCodegen } from "./codegen";
10 changes: 10 additions & 0 deletions packages/world/ts/exports/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* External exports.
*
* Be sure we're ready to commit to these being supported and changes made backward compatible!
*/

export { helloWorldEvent, worldDeployedEvent } from "../worldEvents";

export { defineWorld } from "../config/v2/world";
export type { World } from "../config/v2/output";
9 changes: 9 additions & 0 deletions packages/world/ts/exports/internal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export * from "../config/defaults";
export * from "../config/resolveWorldConfig";
export * from "../config/types";
export * from "../config/worldConfig";

export * from "../encodeSystemCall";
export * from "../encodeSystemCallFrom";
export * from "../encodeSystemCalls";
export * from "../encodeSystemCallsFrom";
10 changes: 0 additions & 10 deletions packages/world/ts/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/world/ts/scripts/tablegen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from "path";
import { loadConfig } from "@latticexyz/config/node";
import { getRemappings, getSrcDirectory } from "@latticexyz/common/foundry";
import { Store as StoreConfig } from "@latticexyz/store/config/v2";
import { Store as StoreConfig } from "@latticexyz/store";
import { tablegen } from "@latticexyz/store/codegen";

const config = (await loadConfig()) as StoreConfig;
9 changes: 8 additions & 1 deletion packages/world/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { defineConfig } from "tsup";

export default defineConfig({
entry: ["mud.config.ts", "ts/index.ts", "ts/register/index.ts", "ts/config/v2/index.ts", "ts/node/index.ts"],
entry: {
"mud.config": "mud.config.ts",
index: "ts/exports/index.ts",
internal: "ts/exports/internal.ts",
register: "ts/register/index.ts",
"config/v2": "ts/config/v2/index.ts",
node: "ts/node/index.ts",
},
target: "esnext",
format: ["esm"],
dts: true,
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

0 comments on commit f24fac2

Please sign in to comment.