Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into account-kit
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Jul 11, 2024
2 parents 347c7a2 + 9e05278 commit 957ab7d
Show file tree
Hide file tree
Showing 81 changed files with 452 additions and 3,242 deletions.
5 changes: 5 additions & 0 deletions .changeset/flat-swans-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/store-sync": patch
---

Refactored `syncToZustand` to use new Store config under the hood, removing compatibility layers and improving performance.
8 changes: 8 additions & 0 deletions .changeset/good-rice-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@latticexyz/config": patch
"@latticexyz/query": patch
"@latticexyz/store": patch
"@latticexyz/world": patch
---

Bumped `@arktype/util` and moved `evaluate`/`satisfy` usages to its `show`/`satisfy` helpers.
5 changes: 5 additions & 0 deletions .changeset/ninety-mirrors-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/common": patch
---

Removed `evaluate` and `satisfy` type utils in favor of `show` and `satisfy` from `@arktype/util`.
5 changes: 5 additions & 0 deletions .changeset/orange-beans-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/dev-tools": patch
---

Updated Zustand components after changes to `syncToZustand`.
5 changes: 5 additions & 0 deletions .changeset/real-pigs-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/store-sync": patch
---

Refactored `syncToRecs` to use new Store config under the hood, removing compatibility layers and improving performance.
2 changes: 1 addition & 1 deletion .github/actions/setup-prerequisites/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ runs:
using: composite
steps:
- name: Setup pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4

- name: Setup node
uses: actions/setup-node@v3
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/remove-npm-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Remove npm tag

on:
workflow_dispatch:
inputs:
tag:
description: "Tag name in npm"
type: string
required: true

jobs:
remove-npm-tag:
Expand All @@ -14,11 +19,15 @@ jobs:
submodules: recursive
fetch-depth: 0

- name: Setup
uses: ./.github/actions/setup

- name: Set deployment token
run: npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Remove npm dist tag
run: pnpm dist-tag-rm
env: TAG=${{ github.ref_name }}
run: pnpm run dist-tag-rm
env:
TAG: ${{ github.event.inputs.tag }}
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"url": "https://github.com/latticexyz/mud.git"
},
"scripts": {
"all-codegen": "for dir in packages/store packages/world packages/world-modules packages/cli test/mock-game-contracts e2e/packages/contracts examples/*/packages/contracts templates/*/packages/contracts; do (cd \"$dir\" && pwd && pnpm build); done",
"all-build": "for dir in packages/store packages/world packages/world-modules packages/cli test/mock-game-contracts e2e/packages/contracts examples/*/packages/contracts templates/*/packages/contracts; do (cd \"$dir\" && pwd && pnpm build); done",
"all-install": "for dir in . docs e2e examples/* templates/*; do (cd \"$dir\" && pwd && pnpm install); done",
"bench": "pnpm run --recursive bench",
"build": "turbo run build",
Expand Down Expand Up @@ -37,8 +37,6 @@
"package.json": "pnpm sort-package-json"
},
"devDependencies": {
"@arktype/attest": "0.7.5",
"@arktype/util": "0.0.43",
"@changesets/cli": "^2.26.1",
"@types/node": "^18.15.11",
"@typescript-eslint/eslint-plugin": "7.1.1",
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/scripts/generate-test-tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { tablegen } from "@latticexyz/store/codegen";
import { defineStore } from "@latticexyz/store";
import { getRemappings } from "@latticexyz/common/foundry";
import { fileURLToPath } from "node:url";
import path from "node:path";

const configPath = fileURLToPath(import.meta.url);

Expand Down Expand Up @@ -97,4 +98,4 @@ const config = defineStore({

const remappings = await getRemappings();

await tablegen({ configPath, config, remappings });
await tablegen({ rootDir: path.dirname(configPath), config, remappings });
10 changes: 5 additions & 5 deletions packages/cli/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ type BuildOptions = {
foundryProfile?: string;
srcDir: string;
/**
* Path to `mud.config.ts`. We use this as the "project root" to resolve other relative paths.
* MUD project root directory where all other relative paths are resolved from.
*
* Defaults to finding the nearest `mud.config.ts`, looking in `process.cwd()` and moving up the directory tree.
* Defaults to the directory of the nearest `mud.config.ts`, looking in `process.cwd()` and moving up the directory tree.
*/
configPath: string;
rootDir: string;
config: WorldConfig;
};

export async function build({
configPath,
rootDir,
config,
srcDir,
foundryProfile = process.env.FOUNDRY_PROFILE,
Expand All @@ -28,7 +28,7 @@ export async function build({
const remappings = await getRemappings(foundryProfile);

await Promise.all([
tablegen({ configPath, config, remappings }),
tablegen({ rootDir, config, remappings }),
worldgen(config, getExistingContracts(srcDir), outPath),
]);

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/build.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { CommandModule } from "yargs";
import { loadConfig, resolveConfigPath } from "@latticexyz/config/node";
import { World as WorldConfig } from "@latticexyz/world";

import { getSrcDirectory } from "@latticexyz/common/foundry";
import { build } from "../build";
import path from "node:path";

type Options = {
configPath?: string;
Expand All @@ -27,7 +27,7 @@ const commandModule: CommandModule<Options, Options> = {
const config = (await loadConfig(configPath)) as WorldConfig;
const srcDir = await getSrcDirectory();

await build({ configPath, config, srcDir, foundryProfile: opts.profile });
await build({ rootDir: path.dirname(configPath), config, srcDir, foundryProfile: opts.profile });

process.exit(0);
},
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/commands/tablegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { loadConfig, resolveConfigPath } from "@latticexyz/config/node";
import { Store as StoreConfig } from "@latticexyz/store";
import { tablegen } from "@latticexyz/store/codegen";
import { getRemappings } from "@latticexyz/common/foundry";
import path from "node:path";

type Options = {
configPath?: string;
Expand All @@ -24,7 +25,7 @@ const commandModule: CommandModule<Options, Options> = {
const config = (await loadConfig(configPath)) as StoreConfig;
const remappings = await getRemappings();

await tablegen({ configPath, config, remappings });
await tablegen({ rootDir: path.dirname(configPath), config, remappings });

process.exit(0);
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/runDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export async function runDeploy(opts: DeployOptions): Promise<WorldDeploy> {

// Run build
if (!opts.skipBuild) {
await build({ configPath, config: configV2, srcDir, foundryProfile: profile });
await build({ rootDir: path.dirname(configPath), config: configV2, srcDir, foundryProfile: profile });
}

const resolvedConfig = resolveConfig({ config, forgeSourceDir: srcDir, forgeOutDir: outDir });
Expand Down
2 changes: 0 additions & 2 deletions packages/common/src/type-utils/evaluate.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/common/src/type-utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export * from "./abi";
export * from "./common";
export * from "./evaluate";
export * from "./satisfy";
1 change: 0 additions & 1 deletion packages/common/src/type-utils/satisfy.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"test:ci": "pnpm run test"
},
"dependencies": {
"@arktype/util": "0.0.40",
"@latticexyz/common": "workspace:*",
"@latticexyz/schema-type": "workspace:*",
"esbuild": "^0.17.15",
Expand Down
6 changes: 5 additions & 1 deletion packages/config/src/common.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Hex } from "viem";
import { DynamicAbiType, StaticAbiType } from "@latticexyz/schema-type/internal";
import { ResourceType } from "@latticexyz/common";
import { satisfy } from "@latticexyz/common/type-utils";
import { satisfy } from "@arktype/util";

/**
* Common output types of a MUD config. We use these types as inputs for libraries.
Expand Down Expand Up @@ -31,3 +31,7 @@ export type Table = {
readonly schema: Schema;
readonly key: readonly string[];
};

export type Tables = {
readonly [label: string]: Table;
};
2 changes: 1 addition & 1 deletion packages/config/src/deprecated/node/loadConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function loadConfig(configPath?: string): Promise<unknown> {
}

/** @deprecated */
export async function resolveConfigPath(configPath: string | undefined, toFileURL?: boolean) {
export async function resolveConfigPath(configPath?: string, toFileURL?: boolean) {
if (configPath === undefined) {
configPath = await getUserConfigPath();
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/config/src/exports/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* Be sure we're ready to commit to these being supported and changes made backward compatible!
*/

export type { AbiType, StaticAbiType, DynamicAbiType, Schema, Table } from "../common";
export type { AbiType, StaticAbiType, DynamicAbiType, Schema, Table, Tables } from "../common";
18 changes: 4 additions & 14 deletions packages/dev-tools/src/zustand/TableDataTable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Table } from "@latticexyz/store/internal";
import { useRecords } from "./useRecords";
import { FieldValue } from "./FieldValue";
import { Table } from "@latticexyz/store-sync/zustand";

// TODO: use react-table or similar for better perf with lots of logs

Expand All @@ -15,12 +15,7 @@ export function TableDataTable({ table }: Props) {
<table className="w-full -mx-1">
<thead className="sticky top-0 z-10 bg-slate-800 text-left">
<tr className="text-amber-200/80 font-mono">
{Object.keys(table.keySchema).map((name) => (
<th key={name} className="px-1.5 pt-1.5 font-normal">
{name}
</th>
))}
{Object.keys(table.valueSchema).map((name) => (
{Object.keys(table.schema).map((name) => (
<th key={name} className="px-1.5 pt-1.5 font-normal">
{name}
</th>
Expand All @@ -31,14 +26,9 @@ export function TableDataTable({ table }: Props) {
{records.map((record) => {
return (
<tr key={record.id}>
{Object.keys(table.keySchema).map((name) => (
<td key={name} className="px-1.5 whitespace-nowrap overflow-hidden text-ellipsis">
<FieldValue value={record.key[name]} />
</td>
))}
{Object.keys(table.valueSchema).map((name) => (
{Object.keys(table.schema).map((name) => (
<td key={name} className="px-1.5 whitespace-nowrap overflow-hidden text-ellipsis">
<FieldValue value={record.value[name]} />
<FieldValue value={record.fields[name]} />
</td>
))}
</tr>
Expand Down
3 changes: 1 addition & 2 deletions packages/dev-tools/src/zustand/useRecords.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Table } from "@latticexyz/store/internal";
import { useDevToolsContext } from "../DevToolsContext";
import { useEffect, useState } from "react";
import { TableRecord } from "@latticexyz/store-sync/zustand";
import { Table, TableRecord } from "@latticexyz/store-sync/zustand";

export function useRecords<table extends Table>(table: table): TableRecord<table>[] {
const { useStore } = useDevToolsContext();
Expand Down
2 changes: 1 addition & 1 deletion packages/dev-tools/src/zustand/useTables.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Table } from "@latticexyz/store/internal";
import { useDevToolsContext } from "../DevToolsContext";
import { useEffect, useState } from "react";
import { Table } from "@latticexyz/store-sync/zustand";

export function useTables(): Table[] {
const { useStore } = useDevToolsContext();
Expand Down
1 change: 1 addition & 0 deletions packages/protocol-parser/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export type KeySchema<userTypes extends UserTypes | undefined = undefined> = Rec
string,
userTypes extends UserTypes ? StaticAbiType | keyof userTypes : StaticAbiType
>;

export type ValueSchema<userTypes extends UserTypes | undefined = undefined> = Record<
string,
userTypes extends UserTypes ? SchemaAbiType | keyof userTypes : SchemaAbiType
Expand Down
1 change: 1 addition & 0 deletions packages/query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"test:ci": "pnpm run test"
},
"dependencies": {
"@arktype/util": "0.0.40",
"@latticexyz/common": "workspace:*",
"@latticexyz/config": "workspace:*",
"@latticexyz/schema-type": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/query/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Hex } from "viem";
import { satisfy } from "@arktype/util";
import { StaticPrimitiveType, DynamicPrimitiveType, SchemaAbiType } from "@latticexyz/schema-type/internal";
import { satisfy } from "@latticexyz/common/type-utils";
import { SchemaToPrimitives } from "@latticexyz/store/internal";
import { Table } from "@latticexyz/config";

Expand Down
55 changes: 0 additions & 55 deletions packages/store-sync/src/query-cache/common.ts

This file was deleted.

Loading

0 comments on commit 957ab7d

Please sign in to comment.