diff --git a/.changeset/khaki-wolves-perform.md b/.changeset/khaki-wolves-perform.md new file mode 100644 index 0000000000..f580f34c24 --- /dev/null +++ b/.changeset/khaki-wolves-perform.md @@ -0,0 +1,20 @@ +--- +"@latticexyz/store-sync": patch +--- + +Refactored `syncToRecs` and `syncToZustand` to use tables from config namespaces output. This is a precursor for supporting multiple namespaces. + +Note for library authors: If you were using `createStorageAdapter` from `@latticexyz/store-sync/recs`, this helper no longer appends MUD's built-in tables from Store and World packages. This behavior was moved into `syncToRecs` for consistency with `syncToZustand` and makes `createStorageAdapter` less opinionated. + +You can achieve the previous behavior with: + +```diff + import { createStorageAdapter } from "@latticexyz/store-sync/recs"; ++import { mudTables } from "@latticexyz/store-sync"; + + createStorageAdapter({ +- tables, ++ tables: { ...tables, ...mudTables }, + ... + }); +``` diff --git a/package.json b/package.json index 4235b8fbe1..0191d6afa9 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "package.json": "pnpm sort-package-json" }, "devDependencies": { - "@ark/attest": "0.9.2", + "@arktype/attest": "0.7.5", "@changesets/cli": "^2.26.1", "@types/node": "^18.15.11", "@typescript-eslint/eslint-plugin": "7.1.1", diff --git a/packages/store-sync/package.json b/packages/store-sync/package.json index 17a41ceb44..3247a5fb34 100644 --- a/packages/store-sync/package.json +++ b/packages/store-sync/package.json @@ -62,6 +62,7 @@ "test:ci": "vitest --run" }, "dependencies": { + "@arktype/util": "0.1.0", "@latticexyz/block-logs-stream": "workspace:*", "@latticexyz/common": "workspace:*", "@latticexyz/config": "workspace:*", diff --git a/packages/store-sync/src/common.test.ts b/packages/store-sync/src/common.test.ts new file mode 100644 index 0000000000..efee4e1e2f --- /dev/null +++ b/packages/store-sync/src/common.test.ts @@ -0,0 +1,12 @@ +import { describe, it } from "vitest"; +import { attest } from "@arktype/attest"; +import { isDisjoint } from "@arktype/util"; +import storeConfig from "@latticexyz/store/mud.config"; +import worldConfig from "@latticexyz/world/mud.config"; +import { configToTables } from "./configToTables"; + +describe("mudTables", () => { + it("has no overlapping table labels", () => { + attest, keyof configToTables>>(); + }); +}); diff --git a/packages/store-sync/src/common.ts b/packages/store-sync/src/common.ts index 4ecfe26fd9..740935e2c9 100644 --- a/packages/store-sync/src/common.ts +++ b/packages/store-sync/src/common.ts @@ -12,16 +12,15 @@ import storeConfig from "@latticexyz/store/mud.config"; import worldConfig from "@latticexyz/world/mud.config"; import { Store as StoreConfig } from "@latticexyz/store"; import { Table as ConfigTable, Schema } from "@latticexyz/config"; +import { configToTables } from "./configToTables"; -export const storeTables = storeConfig.tables; -export type storeTables = typeof storeTables; +export const mudTables = { + ...configToTables(storeConfig), + ...configToTables(worldConfig), +} as const; +export type mudTables = typeof mudTables; -export const worldTables = worldConfig.tables; -export type worldTables = typeof worldTables; - -export const internalTableIds = [...Object.values(storeTables), ...Object.values(worldTables)].map( - (table) => table.tableId, -); +export const internalTableIds = Object.values(mudTables).map((table) => table.tableId); export type ChainId = number; export type WorldId = `${ChainId}:${Address}`; @@ -137,7 +136,7 @@ export type StorageAdapterBlock = { blockNumber: BlockLogs["blockNumber"]; logs: export type StorageAdapter = (block: StorageAdapterBlock) => Promise; export const schemasTable = { - ...storeTables.store__Tables, - keySchema: getSchemaTypes(getKeySchema(storeTables.store__Tables)), - valueSchema: getSchemaTypes(getValueSchema(storeTables.store__Tables)), + ...mudTables.Tables, + keySchema: getSchemaTypes(getKeySchema(mudTables.Tables)), + valueSchema: getSchemaTypes(getValueSchema(mudTables.Tables)), }; diff --git a/packages/store-sync/src/configToTables.test.ts b/packages/store-sync/src/configToTables.test.ts new file mode 100644 index 0000000000..5e393bb507 --- /dev/null +++ b/packages/store-sync/src/configToTables.test.ts @@ -0,0 +1,44 @@ +import { describe, it } from "vitest"; +import { configToTables } from "./configToTables"; +import { defineWorld } from "@latticexyz/world"; +import { resourceToHex } from "@latticexyz/common"; +import { attest } from "@arktype/attest"; + +describe("configToTables", () => { + it("flattens tables from single namespace", async () => { + const config = defineWorld({ + namespace: "app", + tables: { + ExceedsResourceNameSizeLimit: "bytes32", + Table2: "address", + }, + }); + + const tables = configToTables(config); + + attest<"ExceedsResourceNameSizeLimit" | "Table2", keyof typeof tables>(); + + attest(tables.ExceedsResourceNameSizeLimit.tableId).equals( + resourceToHex({ + type: "table", + namespace: "app", + name: "ExceedsResourceN", + }), + ); + attest(tables.ExceedsResourceNameSizeLimit.label).equals("ExceedsResourceNameSizeLimit"); + attest(tables.ExceedsResourceNameSizeLimit.name).equals("ExceedsResourceN"); + + attest(tables.Table2.tableId).equals( + resourceToHex({ + type: "table", + namespace: "app", + name: "Table2", + }), + ); + attest(tables.Table2.label).equals("Table2"); + attest(tables.Table2.name).equals("Table2"); + }); + + // TODO: add test with multiple namespaces + // TODO: add test where the label is the same for two tables in different namespaces to make sure TS + runtime agree on which takes precedence +}); diff --git a/packages/store-sync/src/configToTables.ts b/packages/store-sync/src/configToTables.ts new file mode 100644 index 0000000000..aa08ee327d --- /dev/null +++ b/packages/store-sync/src/configToTables.ts @@ -0,0 +1,25 @@ +import { show } from "@arktype/util"; +import { Store } from "@latticexyz/store"; + +type flattenedTableKeys = config extends { readonly namespaces: infer namespaces } + ? { + [namespaceLabel in keyof namespaces]: namespaces[namespaceLabel] extends { readonly tables: infer tables } + ? `${namespaceLabel & string}__${keyof tables & string}` + : never; + }[keyof namespaces] + : never; + +// TODO: figure out how TS handles overlapping table labels so we can make runtime match + +export type configToTables = { + readonly [key in flattenedTableKeys as key extends `${string}__${infer tableLabel}` + ? tableLabel + : never]: key extends `${infer namespaceLabel}__${infer tableLabel}` + ? config["namespaces"][namespaceLabel]["tables"][tableLabel] + : never; +}; + +export function configToTables(config: config): show> { + const tables = Object.values(config.namespaces).flatMap((namespace) => Object.values(namespace.tables)); + return Object.fromEntries(tables.map((table) => [table.label, table])) as never; +} diff --git a/packages/store-sync/src/index.ts b/packages/store-sync/src/index.ts index 7efbf9258d..b69f95f5ce 100644 --- a/packages/store-sync/src/index.ts +++ b/packages/store-sync/src/index.ts @@ -1,4 +1,5 @@ export * from "./common"; +export * from "./configToTables"; export * from "./createStoreSync"; export * from "./SyncStep"; export * from "./isTableRegistrationLog"; diff --git a/packages/store-sync/src/postgres-decoded/syncToPostgres.ts b/packages/store-sync/src/postgres-decoded/syncToPostgres.ts index a413faa593..6f42469ed9 100644 --- a/packages/store-sync/src/postgres-decoded/syncToPostgres.ts +++ b/packages/store-sync/src/postgres-decoded/syncToPostgres.ts @@ -4,7 +4,7 @@ import { SyncOptions, SyncResult } from "../common"; import { createStorageAdapter } from "./createStorageAdapter"; import { createStoreSync } from "../createStoreSync"; -type SyncToPostgresOptions = SyncOptions & { +export type SyncToPostgresOptions = SyncOptions & { /** * [Postgres database object from Drizzle][0]. * @@ -15,7 +15,7 @@ type SyncToPostgresOptions = SyncOptio startSync?: boolean; }; -type SyncToPostgresResult = SyncResult & { +export type SyncToPostgresResult = SyncResult & { stopSync: () => void; }; diff --git a/packages/store-sync/src/postgres/syncToPostgres.ts b/packages/store-sync/src/postgres/syncToPostgres.ts index a413faa593..6f42469ed9 100644 --- a/packages/store-sync/src/postgres/syncToPostgres.ts +++ b/packages/store-sync/src/postgres/syncToPostgres.ts @@ -4,7 +4,7 @@ import { SyncOptions, SyncResult } from "../common"; import { createStorageAdapter } from "./createStorageAdapter"; import { createStoreSync } from "../createStoreSync"; -type SyncToPostgresOptions = SyncOptions & { +export type SyncToPostgresOptions = SyncOptions & { /** * [Postgres database object from Drizzle][0]. * @@ -15,7 +15,7 @@ type SyncToPostgresOptions = SyncOptio startSync?: boolean; }; -type SyncToPostgresResult = SyncResult & { +export type SyncToPostgresResult = SyncResult & { stopSync: () => void; }; diff --git a/packages/store-sync/src/recs/createStorageAdapter.ts b/packages/store-sync/src/recs/createStorageAdapter.ts index 4213af8651..a029ce9b80 100644 --- a/packages/store-sync/src/recs/createStorageAdapter.ts +++ b/packages/store-sync/src/recs/createStorageAdapter.ts @@ -1,4 +1,4 @@ -import { Table } from "@latticexyz/config"; +import { Tables } from "@latticexyz/config"; import { debug } from "./debug"; import { World as RecsWorld, getComponentValue, hasComponent, removeComponent, setComponent } from "@latticexyz/recs"; import { defineInternalComponents } from "./defineInternalComponents"; @@ -11,28 +11,21 @@ import { logToTable } from "../logToTable"; import { hexKeyTupleToEntity } from "./hexKeyTupleToEntity"; import { StorageAdapter, StorageAdapterBlock } from "../common"; import { singletonEntity } from "./singletonEntity"; -import storeConfig from "@latticexyz/store/mud.config"; -import worldConfig from "@latticexyz/world/mud.config"; import { tablesToComponents } from "./tablesToComponents"; +import { merge } from "@arktype/util"; -const storeTables = storeConfig.tables; -const worldTables = worldConfig.tables; - -export type CreateStorageAdapterOptions> = { +export type CreateStorageAdapterOptions = { world: RecsWorld; tables: tables; shouldSkipUpdateStream?: () => boolean; }; -export type CreateStorageAdapterResult> = { +export type CreateStorageAdapterResult = { storageAdapter: StorageAdapter; - components: tablesToComponents & - tablesToComponents & - tablesToComponents & - ReturnType; + components: merge, ReturnType>; }; -export function createStorageAdapter>({ +export function createStorageAdapter({ world, tables, shouldSkipUpdateStream, @@ -41,8 +34,6 @@ export function createStorageAdapter>({ const components = { ...tablesToComponents(world, tables), - ...tablesToComponents(world, storeTables), - ...tablesToComponents(world, worldTables), ...defineInternalComponents(world), }; diff --git a/packages/store-sync/src/recs/syncToRecs.ts b/packages/store-sync/src/recs/syncToRecs.ts index e8f63f7d6d..891d3309f0 100644 --- a/packages/store-sync/src/recs/syncToRecs.ts +++ b/packages/store-sync/src/recs/syncToRecs.ts @@ -1,35 +1,38 @@ -import { Table } from "@latticexyz/config"; +import { Tables } from "@latticexyz/config"; import { Store as StoreConfig } from "@latticexyz/store"; import { Component as RecsComponent, World as RecsWorld, getComponentValue, setComponent } from "@latticexyz/recs"; -import { SyncOptions, SyncResult } from "../common"; +import { SyncOptions, SyncResult, mudTables } from "../common"; import { CreateStorageAdapterResult, createStorageAdapter } from "./createStorageAdapter"; import { createStoreSync } from "../createStoreSync"; import { singletonEntity } from "./singletonEntity"; import { SyncStep } from "../SyncStep"; +import { configToTables } from "../configToTables"; +import { merge } from "@arktype/util"; -type SyncToRecsOptions> = SyncOptions & { +export type SyncToRecsOptions = Omit & { world: RecsWorld; config: config; tables?: extraTables; startSync?: boolean; }; -type SyncToRecsResult> = SyncResult & { - components: CreateStorageAdapterResult["components"]; +export type SyncToRecsResult = SyncResult & { + components: CreateStorageAdapterResult, extraTables>, mudTables>>["components"]; stopSync: () => void; }; -export async function syncToRecs>({ +export async function syncToRecs({ world, config, - tables: extraTables, + tables: extraTables = {} as extraTables, startSync = true, ...syncOptions }: SyncToRecsOptions): Promise> { const tables = { - ...config.tables, + ...configToTables(config), ...extraTables, - } as config["tables"] & extraTables; + ...mudTables, + }; const { storageAdapter, components } = createStorageAdapter({ world, @@ -79,5 +82,5 @@ export async function syncToRecs> = { +export type tablesToComponents = { [label in keyof tables as tables[label]["label"]]: tableToComponent; }; -export function tablesToComponents>( +export function tablesToComponents( world: World, tables: tables, -): tablesToComponents { +): show> { return Object.fromEntries( Object.entries(tables).map(([, table]) => [table.label, tableToComponent(world, table)]), ) as never; diff --git a/packages/store-sync/src/sqlite/syncToSqlite.ts b/packages/store-sync/src/sqlite/syncToSqlite.ts index 5c32249664..406e5eb98c 100644 --- a/packages/store-sync/src/sqlite/syncToSqlite.ts +++ b/packages/store-sync/src/sqlite/syncToSqlite.ts @@ -4,7 +4,7 @@ import { SyncOptions, SyncResult } from "../common"; import { sqliteStorage } from "./sqliteStorage"; import { createStoreSync } from "../createStoreSync"; -type SyncToSqliteOptions = SyncOptions & { +export type SyncToSqliteOptions = SyncOptions & { /** * [SQLite database object from Drizzle][0]. * @@ -15,7 +15,7 @@ type SyncToSqliteOptions = SyncOptions startSync?: boolean; }; -type SyncToSqliteResult = SyncResult & { +export type SyncToSqliteResult = SyncResult & { stopSync: () => void; }; diff --git a/packages/store-sync/src/zustand/getAllTables.ts b/packages/store-sync/src/zustand/getAllTables.ts deleted file mode 100644 index d050127f3b..0000000000 --- a/packages/store-sync/src/zustand/getAllTables.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { Store as StoreConfig } from "@latticexyz/store"; -import { Tables } from "@latticexyz/config"; -import { tablesByLabel } from "./tablesByLabel"; -import { mergeRight } from "./mergeRight"; -import storeConfig from "@latticexyz/store/mud.config"; -import worldConfig from "@latticexyz/world/mud.config"; - -const storeTables = storeConfig.tables; -type storeTables = typeof storeTables; - -const worldTables = worldConfig.tables; -type worldTables = typeof worldTables; - -export type getAllTables = tablesByLabel< - mergeRight>> ->; - -export function getAllTables( - config: config, - extraTables: extraTables, -): getAllTables { - return tablesByLabel({ - ...config.tables, - ...extraTables, - ...storeTables, - ...worldTables, - }) as never; -} diff --git a/packages/store-sync/src/zustand/mergeRight.ts b/packages/store-sync/src/zustand/mergeRight.ts deleted file mode 100644 index b45ef5e54a..0000000000 --- a/packages/store-sync/src/zustand/mergeRight.ts +++ /dev/null @@ -1,7 +0,0 @@ -export type mergeRight = { - readonly [key in keyof left | keyof right]: key extends keyof right - ? right[key] - : key extends keyof left - ? left[key] - : never; -}; diff --git a/packages/store-sync/src/zustand/syncToZustand.ts b/packages/store-sync/src/zustand/syncToZustand.ts index 61e75fd2ed..33793d2d0b 100644 --- a/packages/store-sync/src/zustand/syncToZustand.ts +++ b/packages/store-sync/src/zustand/syncToZustand.ts @@ -1,4 +1,4 @@ -import { SyncOptions, SyncResult } from "../common"; +import { SyncOptions, SyncResult, mudTables } from "../common"; import { createStoreSync } from "../createStoreSync"; import { ZustandStore } from "./createStore"; import { createStore } from "./createStore"; @@ -7,9 +7,10 @@ import { Address } from "viem"; import { SyncStep } from "../SyncStep"; import { Store as StoreConfig } from "@latticexyz/store"; import { Tables } from "@latticexyz/config"; -import { getAllTables } from "./getAllTables"; +import { merge } from "@arktype/util"; +import { configToTables } from "../configToTables"; -type SyncToZustandOptions = Omit< +export type SyncToZustandOptions = Omit< SyncOptions, "address" | "config" > & { @@ -17,13 +18,13 @@ type SyncToZustandOptions>; + store?: ZustandStore, extraTables>, mudTables>>; startSync?: boolean; }; -type SyncToZustandResult = SyncResult & { - tables: getAllTables; - useStore: ZustandStore>; +export type SyncToZustandResult = SyncResult & { + tables: merge, extraTables>, mudTables>; + useStore: ZustandStore, extraTables>, mudTables>>; stopSync: () => void; }; @@ -34,7 +35,11 @@ export async function syncToZustand): Promise> { - const tables = getAllTables(config, extraTables); + const tables: merge, extraTables>, mudTables> = { + ...configToTables(config), + ...extraTables, + ...mudTables, + }; const useStore = store ?? createStore({ tables }); const storageAdapter = createStorageAdapter({ store: useStore }); diff --git a/packages/store-sync/src/zustand/tablesByLabel.test.ts b/packages/store-sync/src/zustand/tablesByLabel.test.ts deleted file mode 100644 index 8082b9992c..0000000000 --- a/packages/store-sync/src/zustand/tablesByLabel.test.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { describe, expect, it } from "vitest"; -import { tablesByLabel } from "./tablesByLabel"; -import { defineWorld } from "@latticexyz/world"; -import { resourceToHex } from "@latticexyz/common"; - -describe("tablesByLabel", () => { - it("maps table label to component name", async () => { - const config = defineWorld({ - namespace: "app", - tables: { - ExceedsResourceNameSizeLimit: "bytes32", - }, - }); - - const tables = tablesByLabel(config.tables); - expect(tables.ExceedsResourceNameSizeLimit.tableId).toBe( - resourceToHex({ - type: "table", - namespace: "app", - name: "ExceedsResourceN", - }), - ); - expect(tables.ExceedsResourceNameSizeLimit.label).toBe("ExceedsResourceNameSizeLimit"); - expect(tables.ExceedsResourceNameSizeLimit.name).toBe("ExceedsResourceN"); - }); -}); diff --git a/packages/store-sync/src/zustand/tablesByLabel.ts b/packages/store-sync/src/zustand/tablesByLabel.ts deleted file mode 100644 index d247ef3223..0000000000 --- a/packages/store-sync/src/zustand/tablesByLabel.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Tables } from "@latticexyz/config"; - -export type tablesByLabel = { - readonly [key in string & keyof tables as tables[key]["label"]]: tables[key]; -}; - -export function tablesByLabel(tables: tables): tablesByLabel { - return Object.fromEntries(Object.entries(tables).map(([, table]) => [table.label, table])) as never; -} diff --git a/packages/store-sync/vitest.config.ts b/packages/store-sync/vitest.config.ts index ebc97d5e06..0913de5c2d 100644 --- a/packages/store-sync/vitest.config.ts +++ b/packages/store-sync/vitest.config.ts @@ -2,7 +2,7 @@ import { defineConfig } from "vitest/config"; export default defineConfig({ test: { - globalSetup: ["test/globalSetup.ts"], + globalSetup: ["vitestSetup.ts", "test/globalSetup.ts"], setupFiles: ["test/setup.ts"], // Temporarily set a low teardown timeout because anvil hangs otherwise // Could move this timeout to anvil setup after https://github.com/wevm/anvil.js/pull/46 diff --git a/packages/store-sync/vitestSetup.ts b/packages/store-sync/vitestSetup.ts new file mode 100644 index 0000000000..13353cdfd6 --- /dev/null +++ b/packages/store-sync/vitestSetup.ts @@ -0,0 +1 @@ +export { setup, cleanup as teardown } from "@arktype/attest"; diff --git a/packages/store/ts/config/v2/input.ts b/packages/store/ts/config/v2/input.ts index 7a721c9503..058b07bba1 100644 --- a/packages/store/ts/config/v2/input.ts +++ b/packages/store/ts/config/v2/input.ts @@ -88,5 +88,5 @@ export type TablesWithShorthandsInput = { }; export type StoreWithShorthandsInput = show< - Omit & { readonly tables: TablesWithShorthandsInput } + Omit & { readonly tables?: TablesWithShorthandsInput } >; diff --git a/packages/store/ts/config/v2/store.test.ts b/packages/store/ts/config/v2/store.test.ts index 44c0f1037a..55eff2a974 100644 --- a/packages/store/ts/config/v2/store.test.ts +++ b/packages/store/ts/config/v2/store.test.ts @@ -516,6 +516,11 @@ describe("defineStore", () => { attest>(); }); + it("should accept an empty input", () => { + const config = defineStore({}); + attest>(); + }); + it("should use the global namespace instead for tables", () => { const config = defineStore({ namespace: "namespace", diff --git a/packages/store/ts/config/v2/storeWithShorthands.test.ts b/packages/store/ts/config/v2/storeWithShorthands.test.ts index ba266970c3..963e4e4c52 100644 --- a/packages/store/ts/config/v2/storeWithShorthands.test.ts +++ b/packages/store/ts/config/v2/storeWithShorthands.test.ts @@ -56,7 +56,7 @@ describe("defineStoreWithShorthands", () => { }); it("should satisfy the output type", () => { - const config = defineStore({ + const config = defineStoreWithShorthands({ tables: { Name: { schema: { id: "address" }, key: ["id"] } }, userTypes: { CustomType: { type: "address", filePath: "path/to/file" } }, }); @@ -64,6 +64,11 @@ describe("defineStoreWithShorthands", () => { attest>(); }); + it("should accept an empty input", () => { + const config = defineStoreWithShorthands({}); + attest>(); + }); + it("should accept a user type as input and expand it", () => { const config = defineStoreWithShorthands({ tables: { Name: "CustomType" }, diff --git a/packages/store/ts/config/v2/storeWithShorthands.ts b/packages/store/ts/config/v2/storeWithShorthands.ts index c5bfeacaea..74413c6127 100644 --- a/packages/store/ts/config/v2/storeWithShorthands.ts +++ b/packages/store/ts/config/v2/storeWithShorthands.ts @@ -32,11 +32,15 @@ export function resolveStoreWithShorthands { const scope = extendedScope(store); + const tables = store.tables + ? mapObject(store.tables, (table) => { + return isTableShorthandInput(table) ? resolveTableShorthand(table, scope) : table; + }) + : null; + const fullConfig = { ...store, - tables: mapObject(store.tables, (table) => { - return isTableShorthandInput(table) ? resolveTableShorthand(table, scope) : table; - }), + ...(tables ? { tables } : null), }; validateStore(fullConfig); diff --git a/packages/world/ts/config/v2/worldWithShorthands.ts b/packages/world/ts/config/v2/worldWithShorthands.ts index f8f4339660..18c85a15bb 100644 --- a/packages/world/ts/config/v2/worldWithShorthands.ts +++ b/packages/world/ts/config/v2/worldWithShorthands.ts @@ -41,13 +41,18 @@ export function resolveWorldWithShorthands { const scope = extendedScope(world); - const tables = mapObject(world.tables ?? {}, (table) => { - return isTableShorthandInput(table) ? resolveTableShorthand(table, scope) : table; - }); + const tables = world.tables + ? mapObject(world.tables, (table) => { + return isTableShorthandInput(table) ? resolveTableShorthand(table, scope) : table; + }) + : null; - const fullConfig = { ...world, tables }; - validateWorld(fullConfig); + const fullConfig = { + ...world, + ...(tables ? { tables } : null), + }; + validateWorld(fullConfig); return resolveWorld(fullConfig) as never; } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e33aaabaab..4391fc9bb5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,9 +8,9 @@ importers: .: devDependencies: - '@ark/attest': - specifier: 0.9.2 - version: 0.9.2(typescript@5.4.2) + '@arktype/attest': + specifier: 0.7.5 + version: 0.7.5(typescript@5.4.2) '@changesets/cli': specifier: ^2.26.1 version: 2.26.1 @@ -880,6 +880,9 @@ importers: packages/store-sync: dependencies: + '@arktype/util': + specifier: 0.1.0 + version: 0.1.0 '@latticexyz/block-logs-stream': specifier: workspace:* version: link:../block-logs-stream @@ -1196,21 +1199,6 @@ packages: resolution: {integrity: sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==} engines: {node: '>=6.0.0'} - '@ark/attest@0.9.2': - resolution: {integrity: sha512-AgwTHTmRMKiEWFeXIHtNb87KISPwACn+kUrAxlqyRx+0/opXA1qnEn/hKCyB61zWPfcur4dB0GUnx+ILDCl5Dg==} - hasBin: true - peerDependencies: - typescript: '*' - - '@ark/fs@0.1.0': - resolution: {integrity: sha512-A7zoIqcO8dPKbzYruYuCro1J4Ai/20rwlIJv2ExbKOBl/XowczKnNV8bh+6azOkkieeZJdrnSXSfNklVHf7zoA==} - - '@ark/schema@0.2.0': - resolution: {integrity: sha512-IkNWCSHdjaoemMXpps4uFHEAQzwJPbTAS8K2vcQpk90sa+eNBuPSVyB/81/Qyl1VYW0iX3ceGC5NL/OznQv1jg==} - - '@ark/util@0.1.0': - resolution: {integrity: sha512-qCLYICQoCy3kEKDVwirQp8qvxhY7NJd8BhhoHaj1l3wCFAk9NUbcDsxAkPStZEMdPI/d7NcbGJe8SWZuRG2twQ==} - '@arktype/attest@0.7.5': resolution: {integrity: sha512-ZOF9uqLbvoVO6RHhlByJEBBj5qhWLpaCK/wWa5guD1OQR1/a7JZ9jCrDAcaASt6tYBA3dGhDerXhc7FcDWlRQw==} hasBin: true @@ -1232,6 +1220,9 @@ packages: '@arktype/util@0.0.41': resolution: {integrity: sha512-0YURzJ42v+lhlP1t5Dj90YezETRTCdFU0oM4xMVpYsmPx/DHJzr9n7AX1QPAlYWH4wY7hYY3gwai3O+8VntPgw==} + '@arktype/util@0.1.0': + resolution: {integrity: sha512-t5jCNbspCF/XizGfmM5fn+86IMtQgCB2Px3Y1E8ckm5AjTECyI7Aj5pV6e9iL8qXF9FdKA53FBLRzAZUqYBnCw==} + '@aws-crypto/ie11-detection@3.0.0': resolution: {integrity: sha512-341lBBkiY1DfDNKai/wXM3aujNBkXR7tq1URPQDL9wi3AUbI80NR74uF1TXHMm7po1AcnFk8iu2S2IeU/+/A+Q==} @@ -2741,11 +2732,6 @@ packages: '@typescript/vfs@1.5.0': resolution: {integrity: sha512-AJS307bPgbsZZ9ggCT3wwpg3VbTKMFNHfaY/uF0ahSkYYrPF2dSSKDNIDIQAHm9qJqbLvCsSJH7yN4Vs/CsMMg==} - '@typescript/vfs@1.5.3': - resolution: {integrity: sha512-OSZ/o3wwD5VPZVdGGsXWk7sRGRtwrGnqA4zwmb33FTs7Wxmad0QTkQCbaNyqWA8hL09TCwAthdp8yjFA5G1lvw==} - peerDependencies: - typescript: '*' - '@ungap/structured-clone@1.2.0': resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} @@ -2957,9 +2943,6 @@ packages: arktype@1.0.29-alpha: resolution: {integrity: sha512-glMLgVhIQRSkR3tymiS+POAcWVJH09sfrgic0jHnyFL8BlhHAJZX2BzdImU9zYr1y9NBqy+U93ZNrRTHXsKRDw==} - arktype@2.0.0-beta.0: - resolution: {integrity: sha512-fE3ssMiXjr/bLqFPzlDhRlXngdyHQreu7p7i8+dtcY1CA+f8WrVUcue6JxywhnqEJXPG4HOcIwQcC+q4VfeUMQ==} - arktype@2.0.0-dev.11: resolution: {integrity: sha512-k+WVQoHsHsTyTiVQkO201mxLQxyXHmy3buJW8TXLOkr4X2yOUCp0K1SBscuG9OEJoc8MjpvoIharjPHEkFI7kg==} @@ -6939,25 +6922,6 @@ snapshots: '@jridgewell/gen-mapping': 0.3.3 '@jridgewell/trace-mapping': 0.3.18 - '@ark/attest@0.9.2(typescript@5.4.2)': - dependencies: - '@ark/fs': 0.1.0 - '@ark/util': 0.1.0 - '@typescript/analyze-trace': 0.10.1 - '@typescript/vfs': 1.5.3(typescript@5.4.2) - arktype: 2.0.0-beta.0 - typescript: 5.4.2 - transitivePeerDependencies: - - supports-color - - '@ark/fs@0.1.0': {} - - '@ark/schema@0.2.0': - dependencies: - '@ark/util': 0.1.0 - - '@ark/util@0.1.0': {} - '@arktype/attest@0.7.5(typescript@5.4.2)': dependencies: '@arktype/fs': 0.0.19 @@ -6981,6 +6945,8 @@ snapshots: '@arktype/util@0.0.41': {} + '@arktype/util@0.1.0': {} + '@aws-crypto/ie11-detection@3.0.0': dependencies: tslib: 1.14.1 @@ -8985,13 +8951,6 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript/vfs@1.5.3(typescript@5.4.2)': - dependencies: - debug: 4.3.4 - typescript: 5.4.2 - transitivePeerDependencies: - - supports-color - '@ungap/structured-clone@1.2.0': {} '@viem/anvil@0.0.7(debug@4.3.4)': @@ -9186,11 +9145,6 @@ snapshots: arktype@1.0.29-alpha: {} - arktype@2.0.0-beta.0: - dependencies: - '@ark/schema': 0.2.0 - '@ark/util': 0.1.0 - arktype@2.0.0-dev.11: dependencies: '@arktype/schema': 0.1.2 diff --git a/test/ts-benchmarks/bench.ts b/test/ts-benchmarks/bench.ts index 2537213f55..637c5ee6dc 100644 --- a/test/ts-benchmarks/bench.ts +++ b/test/ts-benchmarks/bench.ts @@ -1,4 +1,4 @@ -import { bench } from "@ark/attest"; +import { bench } from "@arktype/attest"; import { syncToRecs } from "@latticexyz/store-sync/recs"; import { syncToZustand } from "@latticexyz/store-sync/zustand"; import { Hex, type PublicClient } from "viem"; @@ -28,7 +28,7 @@ bench("syncToRecs", async () => { }); return t; -}).types([20704, "instantiations"]); +}).types([21231, "instantiations"]); bench("syncToZustand", async () => { const config = defineWorld({ @@ -52,4 +52,4 @@ bench("syncToZustand", async () => { }); return t; -}).types([20728, "instantiations"]); +}).types([21214, "instantiations"]); diff --git a/test/ts-benchmarks/package.json b/test/ts-benchmarks/package.json index 0a03af156c..3b07e8d6e8 100644 --- a/test/ts-benchmarks/package.json +++ b/test/ts-benchmarks/package.json @@ -4,7 +4,9 @@ "private": true, "license": "MIT", "scripts": { - "bench": "tsx ./bench" + "bench": "tsx ./bench", + "test": "pnpm run bench", + "test:ci": "pnpm run test" }, "devDependencies": { "@latticexyz/recs": "workspace:*",