-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into holic/indexer-gzip
- Loading branch information
Showing
36 changed files
with
755 additions
and
422 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"@latticexyz/dev-tools": patch | ||
"@latticexyz/store-indexer": minor | ||
"@latticexyz/store-sync": minor | ||
--- | ||
|
||
Store sync logic is now consolidated into a `createStoreSync` function exported from `@latticexyz/store-sync`. This simplifies each storage sync strategy to just a simple wrapper around the storage adapter. You can now sync to RECS with `syncToRecs` or SQLite with `syncToSqlite` and PostgreSQL support coming soon. | ||
|
||
There are no breaking changes if you were just using `syncToRecs` from `@latticexyz/store-sync` or running the `sqlite-indexer` binary from `@latticexyz/store-indexer`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@latticexyz/dev-tools": patch | ||
"@latticexyz/store-sync": patch | ||
--- | ||
|
||
Improves support for internal/client-only RECS components |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
import { assertExhaustive } from "@latticexyz/common/utils"; | ||
import { StoreEventsAbiItem } from "@latticexyz/store"; | ||
import { StoreConfig } from "@latticexyz/store"; | ||
import { StorageOperation } from "@latticexyz/store-sync"; | ||
|
||
type Props = { | ||
eventName: StoreEventsAbiItem["name"]; | ||
type: StorageOperation<StoreConfig>["type"]; | ||
}; | ||
|
||
export function EventIcon({ eventName }: Props) { | ||
switch (eventName) { | ||
case "StoreSetRecord": | ||
export function EventIcon({ type }: Props) { | ||
switch (type) { | ||
case "SetRecord": | ||
return <span className="text-green-500 font-bold">=</span>; | ||
case "StoreSetField": | ||
case "SetField": | ||
return <span className="text-cyan-500 font-bold">+</span>; | ||
case "StoreDeleteRecord": | ||
case "DeleteRecord": | ||
return <span className="text-red-500 font-bold">-</span>; | ||
case "StoreEphemeralRecord": | ||
return <span className="text-violet-400 font-bold">~</span>; | ||
// case "EphemeralRecord": | ||
// return <span className="text-violet-400 font-bold">~</span>; | ||
default: | ||
return assertExhaustive(eventName, `Unexpected event name: ${eventName}`); | ||
return assertExhaustive(type, `Unexpected storage operation type: ${type}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { useEntityQuery } from "@latticexyz/react"; | ||
import { Component, Has, Schema, getComponentValueStrict } from "@latticexyz/recs"; | ||
import { StoreComponentMetadata, decodeEntity } from "@latticexyz/store-sync/recs"; | ||
|
||
// TODO: use react-table or similar for better perf with lots of logs | ||
|
||
type Props = { | ||
component: Component<Schema, StoreComponentMetadata>; | ||
}; | ||
|
||
export function StoreComponentDataTable({ component }: Props) { | ||
// TODO: this breaks when navigating because its state still has entity IDs from prev page | ||
const entities = useEntityQuery([Has(component)]); | ||
|
||
return ( | ||
<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(component.metadata.keySchema).map((name) => ( | ||
<th key={name} className="px-1 pt-1.5 font-normal"> | ||
{name} | ||
</th> | ||
))} | ||
{Object.keys(component.metadata.valueSchema).map((name) => ( | ||
<th key={name} className="px-1 pt-1.5 font-normal"> | ||
{name} | ||
</th> | ||
))} | ||
</tr> | ||
</thead> | ||
<tbody className="font-mono text-xs"> | ||
{entities.map((entity) => { | ||
const key = decodeEntity(component.metadata.keySchema, entity); | ||
const value = getComponentValueStrict(component, entity); | ||
return ( | ||
<tr key={entity}> | ||
{Object.keys(component.metadata.keySchema).map((name) => ( | ||
<td key={name} className="px-1 whitespace-nowrap overflow-hidden text-ellipsis"> | ||
{String(key[name])} | ||
</td> | ||
))} | ||
{Object.keys(component.metadata.valueSchema).map((name) => { | ||
const fieldValue = value[name]; | ||
return ( | ||
<td key={name} className="px-1 whitespace-nowrap overflow-hidden text-ellipsis"> | ||
{Array.isArray(fieldValue) ? fieldValue.map(String).join(", ") : String(fieldValue)} | ||
</td> | ||
); | ||
})} | ||
</tr> | ||
); | ||
})} | ||
</tbody> | ||
</table> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Component } from "@latticexyz/recs"; | ||
|
||
export function getComponentName(component: Component): string { | ||
return String(component.metadata?.componentName ?? component.id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.