@latticexyz/world 2.0.0-alpha.1.151 → 2.0.0-alpha.1.153

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ import"../../../chunk-OWSPJIEF.js";import{f as a}from"../../../chunk-JOQBBVRS.js";import{extendMUDCoreConfig as l,resolveTableId as f}from"@latticexyz/config";import{zPluginStoreConfig as m}from"@latticexyz/store/config";import{z as o}from"zod";var i=o.object({snapSync:o.boolean()}).catchall(o.any());l(n=>{let r={...n};if(i.parse(n).snapSync){let s=a.parse(n),p=m.parse(n),c=Object.entries(p.tables).filter(([e,t])=>!t.ephemeral).map(([e,t])=>e).map(e=>({name:"KeysInTableModule",root:!0,args:[f(e)]}));r.modules=[...s.modules,{name:"SnapSyncModule",root:!0,args:[]},...c]}return r});import"@latticexyz/store/register";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../ts/plugins/snapsync/configExtensions.ts","../../../../ts/plugins/snapsync/plugin.ts","../../../../ts/plugins/snapsync/typeExtensions.ts"],"sourcesContent":["import { extendMUDCoreConfig, resolveTableId } from \"@latticexyz/config\";\nimport { zPluginStoreConfig } from \"@latticexyz/store/config\";\nimport { zSnapSyncPluginConfig } from \"./plugin\";\nimport { zPluginWorldConfig } from \"../../library\";\n\nextendMUDCoreConfig((config) => {\n const modifiedConfig = { ...config } as Record<string, unknown>;\n const snapSyncConfig = zSnapSyncPluginConfig.parse(config);\n\n if (snapSyncConfig.snapSync) {\n const worldConfig = zPluginWorldConfig.parse(config);\n const storeConfig = zPluginStoreConfig.parse(config);\n const tableNames = Object.entries(storeConfig.tables)\n .filter(([_, t]) => !t.ephemeral)\n .map(([name, _]) => name);\n const newModules = tableNames.map((tableName) => {\n return {\n name: \"KeysInTableModule\",\n root: true,\n args: [resolveTableId(tableName)],\n };\n });\n\n modifiedConfig.modules = [\n ...worldConfig.modules,\n {\n name: \"SnapSyncModule\",\n root: true,\n args: [],\n },\n ...newModules,\n ];\n }\n\n return modifiedConfig;\n});\n","import { z } from \"zod\";\n\nexport const zSnapSyncPluginConfig = z\n .object({\n snapSync: z.boolean(),\n })\n .catchall(z.any());\n","import \"@latticexyz/store/register\";\n\ninterface SnapSyncConfig {\n snapSync: boolean;\n}\n\ndeclare module \"@latticexyz/config\" {\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n export interface MUDCoreUserConfig extends SnapSyncConfig {}\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n export interface MUDCoreConfig extends SnapSyncConfig {}\n}\n"],"mappings":"kFAAA,OAAS,uBAAAA,EAAqB,kBAAAC,MAAsB,qBACpD,OAAS,sBAAAC,MAA0B,2BCDnC,OAAS,KAAAC,MAAS,MAEX,IAAMC,EAAwBD,EAClC,OAAO,CACN,SAAUA,EAAE,QAAQ,CACtB,CAAC,EACA,SAASA,EAAE,IAAI,CAAC,EDDnBE,EAAqBC,GAAW,CAC9B,IAAMC,EAAiB,CAAE,GAAGD,CAAO,EAGnC,GAFuBE,EAAsB,MAAMF,CAAM,EAEtC,SAAU,CAC3B,IAAMG,EAAcC,EAAmB,MAAMJ,CAAM,EAC7CK,EAAcC,EAAmB,MAAMN,CAAM,EAI7CO,EAHa,OAAO,QAAQF,EAAY,MAAM,EACjD,OAAO,CAAC,CAACG,EAAG,CAAC,IAAM,CAAC,EAAE,SAAS,EAC/B,IAAI,CAAC,CAACC,EAAMD,CAAC,IAAMC,CAAI,EACI,IAAKC,IAC1B,CACL,KAAM,oBACN,KAAM,GACN,KAAM,CAACC,EAAeD,CAAS,CAAC,CAClC,EACD,EAEDT,EAAe,QAAU,CACvB,GAAGE,EAAY,QACf,CACE,KAAM,iBACN,KAAM,GACN,KAAM,CAAC,CACT,EACA,GAAGI,CACL,EAGF,OAAON,CACT,CAAC,EEnCD,MAAO","names":["extendMUDCoreConfig","resolveTableId","zPluginStoreConfig","z","zSnapSyncPluginConfig","extendMUDCoreConfig","config","modifiedConfig","zSnapSyncPluginConfig","worldConfig","zPluginWorldConfig","storeConfig","zPluginStoreConfig","newModules","_","name","tableName","resolveTableId"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latticexyz/world",
3
- "version": "2.0.0-alpha.1.151+daaee0a8",
3
+ "version": "2.0.0-alpha.1.153+17446d7b",
4
4
  "description": "World framework",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,7 +15,8 @@
15
15
  "./node": "./dist/ts/node/index.js",
16
16
  "./mud.config.js": "./dist/mud.config.js",
17
17
  "./abi/*": "./abi/*",
18
- "./types/*": "./types/*"
18
+ "./types/*": "./types/*",
19
+ "./snapsync": "./dist/ts/plugins/snapsync/index.js"
19
20
  },
20
21
  "typesVersions": {
21
22
  "*": {
@@ -27,6 +28,9 @@
27
28
  ],
28
29
  "node": [
29
30
  "./ts/node/index.ts"
31
+ ],
32
+ "snapsync": [
33
+ "./ts/plugins/snapsync/index.ts"
30
34
  ]
31
35
  }
32
36
  },
@@ -49,10 +53,10 @@
49
53
  "dependencies": {
50
54
  "@ethersproject/abi": "^5.7.0",
51
55
  "@ethersproject/providers": "^5.7.2",
52
- "@latticexyz/common": "2.0.0-alpha.1.151+daaee0a8",
53
- "@latticexyz/config": "2.0.0-alpha.1.151+daaee0a8",
54
- "@latticexyz/schema-type": "2.0.0-alpha.1.151+daaee0a8",
55
- "@latticexyz/store": "2.0.0-alpha.1.151+daaee0a8",
56
+ "@latticexyz/common": "2.0.0-alpha.1.153+17446d7b",
57
+ "@latticexyz/config": "2.0.0-alpha.1.153+17446d7b",
58
+ "@latticexyz/schema-type": "2.0.0-alpha.1.153+17446d7b",
59
+ "@latticexyz/store": "2.0.0-alpha.1.153+17446d7b",
56
60
  "ethers": "^5.7.2",
57
61
  "zod": "^3.21.4"
58
62
  },
@@ -77,5 +81,5 @@
77
81
  "typescript": "^4.9.5",
78
82
  "vitest": "0.30.1"
79
83
  },
80
- "gitHead": "daaee0a81b32bd3cbbe822546be3ab3de6023807"
84
+ "gitHead": "17446d7b0ebac4ce4c9982cdb0e9fd4c43bf54b7"
81
85
  }
@@ -0,0 +1,36 @@
1
+ import { extendMUDCoreConfig, resolveTableId } from "@latticexyz/config";
2
+ import { zPluginStoreConfig } from "@latticexyz/store/config";
3
+ import { zSnapSyncPluginConfig } from "./plugin";
4
+ import { zPluginWorldConfig } from "../../library";
5
+
6
+ extendMUDCoreConfig((config) => {
7
+ const modifiedConfig = { ...config } as Record<string, unknown>;
8
+ const snapSyncConfig = zSnapSyncPluginConfig.parse(config);
9
+
10
+ if (snapSyncConfig.snapSync) {
11
+ const worldConfig = zPluginWorldConfig.parse(config);
12
+ const storeConfig = zPluginStoreConfig.parse(config);
13
+ const tableNames = Object.entries(storeConfig.tables)
14
+ .filter(([_, t]) => !t.ephemeral)
15
+ .map(([name, _]) => name);
16
+ const newModules = tableNames.map((tableName) => {
17
+ return {
18
+ name: "KeysInTableModule",
19
+ root: true,
20
+ args: [resolveTableId(tableName)],
21
+ };
22
+ });
23
+
24
+ modifiedConfig.modules = [
25
+ ...worldConfig.modules,
26
+ {
27
+ name: "SnapSyncModule",
28
+ root: true,
29
+ args: [],
30
+ },
31
+ ...newModules,
32
+ ];
33
+ }
34
+
35
+ return modifiedConfig;
36
+ });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Importing this file automatically adds the required MUD modules to make
3
+ * snap sync work.
4
+ */
5
+
6
+ import "./configExtensions";
7
+ import "./typeExtensions";
@@ -0,0 +1,7 @@
1
+ import { z } from "zod";
2
+
3
+ export const zSnapSyncPluginConfig = z
4
+ .object({
5
+ snapSync: z.boolean(),
6
+ })
7
+ .catchall(z.any());
@@ -0,0 +1,12 @@
1
+ import "@latticexyz/store/register";
2
+
3
+ interface SnapSyncConfig {
4
+ snapSync: boolean;
5
+ }
6
+
7
+ declare module "@latticexyz/config" {
8
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
9
+ export interface MUDCoreUserConfig extends SnapSyncConfig {}
10
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
11
+ export interface MUDCoreConfig extends SnapSyncConfig {}
12
+ }