@latticexyz/world 2.2.18-f0433092876e2ac9b5b12cd0ecae9c120a2d0368 → 2.2.19-900ac35deebfa260bafb1697d15e95eef855cd69

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.
Files changed (75) hide show
  1. package/dist/IBaseWorld.abi-L4NKVDJN.js +2015 -0
  2. package/dist/{IBaseWorld.abi-SGUPOG6A.js.map → IBaseWorld.abi-L4NKVDJN.js.map} +1 -1
  3. package/dist/System.abi-ENBBMWQJ.js +67 -0
  4. package/dist/{System.abi-D2D3OAI5.js.map → System.abi-ENBBMWQJ.js.map} +1 -1
  5. package/dist/chunk-2W4TKC47.js +114 -0
  6. package/dist/{chunk-DIHBEOC2.js.map → chunk-2W4TKC47.js.map} +1 -1
  7. package/dist/chunk-5WRI5ZAA.js +31 -0
  8. package/dist/chunk-SGZK356L.js +132 -0
  9. package/dist/{chunk-AJUHOWGE.js.map → chunk-SGZK356L.js.map} +1 -1
  10. package/dist/chunk-XSBK355I.js +142 -0
  11. package/dist/{chunk-CGF3NYHC.js.map → chunk-XSBK355I.js.map} +1 -1
  12. package/dist/index.js +14 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/internal.js +301 -3
  15. package/dist/internal.js.map +1 -1
  16. package/dist/mud.config.js +11 -1
  17. package/dist/node.js +7276 -102
  18. package/dist/node.js.map +1 -1
  19. package/out/AccessControl.t.sol/AccessControlTest.json +1 -1
  20. package/out/AccessManagementSystem.sol/AccessManagementSystem.json +1 -1
  21. package/out/BalanceTransferSystem.sol/BalanceTransferSystem.json +1 -1
  22. package/out/BatchCall.t.sol/BatchCallTest.json +1 -1
  23. package/out/BatchCall.t.sol/TestSystem.json +1 -1
  24. package/out/BatchCallSystem.sol/BatchCallSystem.json +1 -1
  25. package/out/Delegation.sol/Delegation.json +1 -1
  26. package/out/DelegationControl.sol/DelegationControl.json +1 -1
  27. package/out/DelegationControlMock.sol/DelegationControlMock.json +1 -1
  28. package/out/Factories.t.sol/FactoriesTest.json +1 -1
  29. package/out/IBaseWorld.sol/IBaseWorld.json +1 -1
  30. package/out/IWorldRegistrationSystem.sol/IWorldRegistrationSystem.json +1 -1
  31. package/out/InitModule.sol/InitModule.json +1 -1
  32. package/out/InitModule.t.sol/InitModuleTest.json +1 -1
  33. package/out/InitModule.t.sol/WorldMock.json +1 -1
  34. package/out/InitSystems.t.sol/LimitedCallContextTest.json +1 -1
  35. package/out/Module.sol/Module.json +1 -1
  36. package/out/ModuleInstallationSystem.sol/ModuleInstallationSystem.json +1 -1
  37. package/out/RegistrationSystem.sol/RegistrationSystem.json +1 -1
  38. package/out/StoreRegistrationSystem.sol/StoreRegistrationSystem.json +1 -1
  39. package/out/System.sol/System.json +1 -1
  40. package/out/System.t.sol/SystemTest.json +1 -1
  41. package/out/System.t.sol/TestSystem.json +1 -1
  42. package/out/SystemCall.sol/SystemCall.json +1 -1
  43. package/out/Utils.t.sol/UtilsTest.json +1 -1
  44. package/out/Utils.t.sol/UtilsTestSystem.json +1 -1
  45. package/out/World.sol/World.json +1 -1
  46. package/out/World.t.sol/EchoSystemHook.json +1 -1
  47. package/out/World.t.sol/IWorldTestSystem.json +1 -1
  48. package/out/World.t.sol/PayableFallbackSystem.json +1 -1
  49. package/out/World.t.sol/RevertSystemHook.json +1 -1
  50. package/out/World.t.sol/WorldTest.json +1 -1
  51. package/out/World.t.sol/WorldTestSystem.json +1 -1
  52. package/out/WorldBalance.t.sol/WorldBalanceTest.json +1 -1
  53. package/out/WorldBalance.t.sol/WorldBalanceTestSystem.json +1 -1
  54. package/out/WorldContext.sol/WorldContextConsumer.json +1 -1
  55. package/out/WorldContext.sol/WorldContextConsumerLib.json +1 -1
  56. package/out/WorldContext.sol/WorldContextProviderLib.json +1 -1
  57. package/out/WorldContext.t.sol/TestContextConsumer.json +1 -1
  58. package/out/WorldContext.t.sol/WorldContextTest.json +1 -1
  59. package/out/WorldDynamicUpdate.t.sol/UpdateInDynamicFieldTest.json +1 -1
  60. package/out/WorldFactory.sol/WorldFactory.json +1 -1
  61. package/out/WorldProxy.sol/WorldProxy.json +1 -1
  62. package/out/WorldProxy.t.sol/WorldProxyTest.json +1 -1
  63. package/out/WorldProxyFactory.sol/WorldProxyFactory.json +1 -1
  64. package/out/WorldProxyFactory.t.sol/WorldProxyFactoryTest.json +1 -1
  65. package/out/WorldRegistrationSystem.sol/WorldRegistrationSystem.json +1 -1
  66. package/out/build-info/{5b08d15c729dccf7cb96a41c445f5026.json → 27bef2dac23cc424daa40171c98ac387.json} +1 -1
  67. package/package.json +9 -9
  68. package/src/WorldContext.sol +1 -1
  69. package/dist/IBaseWorld.abi-SGUPOG6A.js +0 -2
  70. package/dist/System.abi-D2D3OAI5.js +0 -2
  71. package/dist/chunk-AJUHOWGE.js +0 -2
  72. package/dist/chunk-CGF3NYHC.js +0 -2
  73. package/dist/chunk-DIHBEOC2.js +0 -2
  74. package/dist/chunk-FW4363Y4.js +0 -2
  75. /package/dist/{chunk-FW4363Y4.js.map → chunk-5WRI5ZAA.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../ts/config/v2/namespaces.ts","../ts/config/v2/codegen.ts","../ts/config/v2/deploy.ts","../ts/config/v2/world.ts"],"sourcesContent":["import { show, flatMorph } from \"@ark/util\";\nimport { NamespacesInput } from \"./input\";\nimport { validateNamespace, resolveNamespace } from \"./namespace\";\nimport { groupBy } from \"@latticexyz/common/utils\";\nimport { AbiTypeScope, Scope, isObject, mergeIfUndefined } from \"@latticexyz/store/internal\";\n\n// Copied from store/ts/config/v2/namespaces.ts but using world namespace validate/resolve methods\n// TODO: figure out how to dedupe these?\n\nexport type validateNamespaces<namespaces, scope extends Scope = AbiTypeScope> = {\n [label in keyof namespaces]: validateNamespace<namespaces[label], scope>;\n};\n\nexport function validateNamespaces<scope extends Scope = AbiTypeScope>(\n namespaces: unknown,\n scope: scope,\n): asserts namespaces is NamespacesInput {\n if (!isObject(namespaces)) {\n throw new Error(`Expected namespaces, received ${JSON.stringify(namespaces)}`);\n }\n for (const namespace of Object.values(namespaces)) {\n validateNamespace(namespace, scope);\n }\n}\n\nexport type resolveNamespaces<namespaces, scope extends Scope = AbiTypeScope> = {\n readonly [label in keyof namespaces]: resolveNamespace<mergeIfUndefined<namespaces[label], { label: label }>, scope>;\n};\n\nexport function resolveNamespaces<input extends NamespacesInput, scope extends Scope = AbiTypeScope>(\n input: input,\n scope: scope,\n): resolveNamespaces<input, scope> {\n if (!isObject(input)) {\n throw new Error(`Expected namespaces config, received ${JSON.stringify(input)}`);\n }\n\n const namespaces = flatMorph(input as NamespacesInput, (label, namespace) => [\n label,\n resolveNamespace(mergeIfUndefined(namespace, { label }), scope),\n ]);\n\n // This should probably be in `validate`, but `namespace` gets set during the resolve step above, so it's easier to validate here.\n const duplicates = Array.from(groupBy(Object.values(namespaces), (namespace) => namespace.namespace).entries())\n .filter(([, entries]) => entries.length > 1)\n .map(([namespace]) => namespace);\n if (duplicates.length > 0) {\n throw new Error(`Found namespaces defined more than once in config: ${duplicates.join(\", \")}`);\n }\n\n return namespaces as never;\n}\n\nexport function defineNamespaces<input, scope extends Scope = AbiTypeScope>(\n input: validateNamespaces<input, scope>,\n scope: scope = AbiTypeScope as never,\n): show<resolveNamespaces<input, scope>> {\n validateNamespaces(input, scope);\n return resolveNamespaces(input, scope) as never;\n}\n","import { isObject, mergeIfUndefined } from \"@latticexyz/store/internal\";\nimport { CODEGEN_DEFAULTS } from \"./defaults\";\n\nexport type resolveCodegen<codegen> = codegen extends {}\n ? mergeIfUndefined<codegen, CODEGEN_DEFAULTS>\n : CODEGEN_DEFAULTS;\n\nexport function resolveCodegen<codegen>(codegen: codegen): resolveCodegen<codegen> {\n return (isObject(codegen) ? mergeIfUndefined(codegen, CODEGEN_DEFAULTS) : CODEGEN_DEFAULTS) as never;\n}\n","import { mergeIfUndefined, isObject } from \"@latticexyz/store/internal\";\nimport { DEPLOY_DEFAULTS } from \"./defaults\";\n\nexport type resolveDeploy<deploy> = deploy extends {} ? mergeIfUndefined<deploy, DEPLOY_DEFAULTS> : DEPLOY_DEFAULTS;\n\nexport function resolveDeploy<deploy>(deploy: deploy): resolveDeploy<deploy> {\n return (isObject(deploy) ? mergeIfUndefined(deploy, DEPLOY_DEFAULTS) : DEPLOY_DEFAULTS) as never;\n}\n","import { ErrorMessage, conform, show, type withJsDoc } from \"@ark/util\";\nimport {\n extendedScope,\n get,\n mergeIfUndefined,\n resolveStore,\n hasOwnKey,\n validateStore,\n flattenNamespacedTables,\n CONFIG_DEFAULTS as STORE_CONFIG_DEFAULTS,\n} from \"@latticexyz/store/internal\";\nimport { SystemsInput, WorldInput } from \"./input\";\nimport { CONFIG_DEFAULTS, MODULE_DEFAULTS } from \"./defaults\";\nimport { resolveSystems, validateSystems } from \"./systems\";\nimport { resolveNamespaces, validateNamespaces } from \"./namespaces\";\nimport { resolveCodegen } from \"./codegen\";\nimport { resolveDeploy } from \"./deploy\";\nimport type { World } from \"./output.js\";\nimport { StoreInput } from \"@latticexyz/store\";\n\nexport type validateWorld<input> = {\n readonly [key in keyof input]: key extends \"namespaces\"\n ? input extends { namespace?: unknown; tables?: unknown; systems?: unknown }\n ? ErrorMessage<\"Cannot use `namespaces` with `namespace`, `tables`, or `systems` keys.\">\n : validateNamespaces<input[key], extendedScope<input>>\n : key extends \"systems\"\n ? validateSystems<input[key]>\n : key extends \"codegen\"\n ? conform<input[key], WorldInput[key] & StoreInput[key]>\n : key extends keyof StoreInput\n ? validateStore<input>[key]\n : key extends keyof WorldInput\n ? conform<input[key], WorldInput[key]>\n : ErrorMessage<`\\`${key & string}\\` is not a valid World config option.`>;\n};\n\nexport function validateWorld(input: unknown): asserts input is WorldInput {\n const scope = extendedScope(input);\n\n if (hasOwnKey(input, \"namespaces\")) {\n if (hasOwnKey(input, \"namespace\") || hasOwnKey(input, \"tables\") || hasOwnKey(input, \"systems\")) {\n throw new Error(\"Cannot use `namespaces` with `namespace`, `tables`, or `systems` keys.\");\n }\n validateNamespaces(input.namespaces, scope);\n }\n if (hasOwnKey(input, \"systems\")) {\n validateSystems(input.systems);\n }\n\n validateStore(input);\n}\n\nexport type resolveNamespaceMode<input> = \"namespaces\" extends keyof input\n ? {\n readonly multipleNamespaces: true;\n readonly namespace: null;\n readonly namespaces: show<resolveNamespaces<input[\"namespaces\"], extendedScope<input>>>;\n }\n : {\n readonly multipleNamespaces: false;\n readonly namespace: string;\n readonly namespaces: show<\n resolveNamespaces<\n {\n // TODO: improve this so we don't have to duplicate store behavior\n readonly [label in \"namespace\" extends keyof input\n ? input[\"namespace\"] extends string\n ? input[\"namespace\"]\n : STORE_CONFIG_DEFAULTS[\"namespace\"]\n : STORE_CONFIG_DEFAULTS[\"namespace\"]]: input;\n },\n extendedScope<input>\n >\n >;\n };\n\ntype resolveModules<input> = { [key in keyof input]: mergeIfUndefined<input[key], MODULE_DEFAULTS> };\n\nexport type resolveWorld<input> = resolveNamespaceMode<input> &\n Omit<resolveStore<input>, \"multipleNamespaces\" | \"namespace\" | \"namespaces\" | \"tables\"> & {\n readonly tables: flattenNamespacedTables<resolveNamespaceMode<input>>;\n // TODO: flatten systems from namespaces\n readonly systems: \"systems\" extends keyof input\n ? input[\"systems\"] extends SystemsInput\n ? resolveNamespaceMode<input>[\"namespace\"] extends string\n ? show<resolveSystems<input[\"systems\"], resolveNamespaceMode<input>[\"namespace\"]>>\n : {}\n : {}\n : {};\n readonly excludeSystems: \"excludeSystems\" extends keyof input\n ? input[\"excludeSystems\"]\n : CONFIG_DEFAULTS[\"excludeSystems\"];\n readonly modules: \"modules\" extends keyof input ? resolveModules<input[\"modules\"]> : CONFIG_DEFAULTS[\"modules\"];\n readonly codegen: show<resolveCodegen<\"codegen\" extends keyof input ? input[\"codegen\"] : {}>>;\n readonly deploy: show<resolveDeploy<\"deploy\" extends keyof input ? input[\"deploy\"] : {}>>;\n };\n\nexport function resolveWorld<const input extends WorldInput>(input: input): resolveWorld<input> {\n const scope = extendedScope(input);\n const store = resolveStore(input);\n\n const namespaces = input.namespaces\n ? resolveNamespaces(input.namespaces, scope)\n : resolveNamespaces({ [store.namespace!]: input }, scope);\n\n const tables = flattenNamespacedTables({ namespaces });\n const modules = (input.modules ?? CONFIG_DEFAULTS.modules).map((mod) => mergeIfUndefined(mod, MODULE_DEFAULTS));\n\n return mergeIfUndefined(\n {\n ...store,\n namespaces,\n tables,\n // TODO: flatten systems from namespaces\n systems:\n !store.multipleNamespaces && input.systems\n ? resolveSystems(input.systems, store.namespace, store.namespace)\n : CONFIG_DEFAULTS.systems,\n excludeSystems: get(input, \"excludeSystems\"),\n codegen: mergeIfUndefined(store.codegen, resolveCodegen(input.codegen)),\n deploy: resolveDeploy(input.deploy),\n modules,\n },\n CONFIG_DEFAULTS,\n ) as never;\n}\n\nexport function defineWorld<const input>(input: validateWorld<input>): withJsDoc<resolveWorld<input>, World> {\n validateWorld(input);\n return resolveWorld(input) as never;\n}\n"],"mappings":"yFAAA,OAAe,aAAAA,MAAiB,YAGhC,OAAS,WAAAC,MAAe,2BACxB,OAAS,gBAAAC,EAAqB,YAAAC,EAAU,oBAAAC,MAAwB,6BASzD,SAASC,EACdC,EACAC,EACuC,CACvC,GAAI,CAACJ,EAASG,CAAU,EACtB,MAAM,IAAI,MAAM,iCAAiC,KAAK,UAAUA,CAAU,CAAC,EAAE,EAE/E,QAAWE,KAAa,OAAO,OAAOF,CAAU,EAC9CG,EAAkBD,EAAWD,CAAK,CAEtC,CAMO,SAASG,EACdC,EACAJ,EACiC,CACjC,GAAI,CAACJ,EAASQ,CAAK,EACjB,MAAM,IAAI,MAAM,wCAAwC,KAAK,UAAUA,CAAK,CAAC,EAAE,EAGjF,IAAML,EAAaM,EAAUD,EAA0B,CAACE,EAAOL,IAAc,CAC3EK,EACAC,EAAiBV,EAAiBI,EAAW,CAAE,MAAAK,CAAM,CAAC,EAAGN,CAAK,CAChE,CAAC,EAGKQ,EAAa,MAAM,KAAKd,EAAQ,OAAO,OAAOK,CAAU,EAAIE,GAAcA,EAAU,SAAS,E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ACzCU,EAAkB,CAAE,CAACH,EAAM,SAAU,EAAGR,CAAM,EAAGC,CAAK,EAEpDW,EAASC,EAAwB,CAAE,WAAAH,CAAW,CAAC,EAC/CI,GAAWd,EAAM,SAAWe,EAAgB,SAAS,IAAKC,GAAQC,EAAiBD,EAAKE,CAAe,CAAC,EAE9G,OAAOD,EACL,CACE,GAAGT,EACH,WAAAE,EACA,OAAAE,EAEA,QACE,CAACJ,EAAM,oBAAsBR,EAAM,QAC/BmB,EAAenB,EAAM,QAASQ,EAAM,UAAWA,EAAM,SAAS,EAC9DO,EAAgB,QACtB,eAAgBK,EAAIpB,EAAO,gBAAgB,EAC3C,QAASiB,EAAiBT,EAAM,QAASa,EAAerB,EAAM,OAAO,CAAC,EACtE,OAAQsB,EAActB,EAAM,MAAM,EAClC,QAAAc,CACF,EACAC,CACF,CACF,CAEO,SAASQ,GAAyBvB,EAAoE,CAC3G,OAAAD,EAAcC,CAAK,EACZO,EAAaP,CAAK,CAC3B","names":["flatMorph","groupBy","AbiTypeScope","isObject","mergeIfUndefined","validateNamespaces","namespaces","scope","namespace","validateNamespace","resolveNamespaces","input","flatMorph","label","resolveNamespace","duplicates","entries","defineNamespaces","isObject","mergeIfUndefined","resolveCodegen","codegen","isObject","mergeIfUndefined","CODEGEN_DEFAULTS","mergeIfUndefined","isObject","resolveDeploy","deploy","isObject","mergeIfUndefined","DEPLOY_DEFAULTS","extendedScope","get","mergeIfUndefined","resolveStore","hasOwnKey","validateStore","flattenNamespacedTables","validateWorld","input","scope","extendedScope","hasOwnKey","validateNamespaces","validateSystems","validateStore","resolveWorld","store","resolveStore","namespaces","resolveNamespaces","tables","flattenNamespacedTables","modules","CONFIG_DEFAULTS","mod","mergeIfUndefined","MODULE_DEFAULTS","resolveSystems","get","resolveCodegen","resolveDeploy","defineWorld"]}
1
+ {"version":3,"sources":["../ts/config/v2/namespaces.ts","../ts/config/v2/codegen.ts","../ts/config/v2/deploy.ts","../ts/config/v2/world.ts"],"sourcesContent":["import { show, flatMorph } from \"@ark/util\";\nimport { NamespacesInput } from \"./input\";\nimport { validateNamespace, resolveNamespace } from \"./namespace\";\nimport { groupBy } from \"@latticexyz/common/utils\";\nimport { AbiTypeScope, Scope, isObject, mergeIfUndefined } from \"@latticexyz/store/internal\";\n\n// Copied from store/ts/config/v2/namespaces.ts but using world namespace validate/resolve methods\n// TODO: figure out how to dedupe these?\n\nexport type validateNamespaces<namespaces, scope extends Scope = AbiTypeScope> = {\n [label in keyof namespaces]: validateNamespace<namespaces[label], scope>;\n};\n\nexport function validateNamespaces<scope extends Scope = AbiTypeScope>(\n namespaces: unknown,\n scope: scope,\n): asserts namespaces is NamespacesInput {\n if (!isObject(namespaces)) {\n throw new Error(`Expected namespaces, received ${JSON.stringify(namespaces)}`);\n }\n for (const namespace of Object.values(namespaces)) {\n validateNamespace(namespace, scope);\n }\n}\n\nexport type resolveNamespaces<namespaces, scope extends Scope = AbiTypeScope> = {\n readonly [label in keyof namespaces]: resolveNamespace<mergeIfUndefined<namespaces[label], { label: label }>, scope>;\n};\n\nexport function resolveNamespaces<input extends NamespacesInput, scope extends Scope = AbiTypeScope>(\n input: input,\n scope: scope,\n): resolveNamespaces<input, scope> {\n if (!isObject(input)) {\n throw new Error(`Expected namespaces config, received ${JSON.stringify(input)}`);\n }\n\n const namespaces = flatMorph(input as NamespacesInput, (label, namespace) => [\n label,\n resolveNamespace(mergeIfUndefined(namespace, { label }), scope),\n ]);\n\n // This should probably be in `validate`, but `namespace` gets set during the resolve step above, so it's easier to validate here.\n const duplicates = Array.from(groupBy(Object.values(namespaces), (namespace) => namespace.namespace).entries())\n .filter(([, entries]) => entries.length > 1)\n .map(([namespace]) => namespace);\n if (duplicates.length > 0) {\n throw new Error(`Found namespaces defined more than once in config: ${duplicates.join(\", \")}`);\n }\n\n return namespaces as never;\n}\n\nexport function defineNamespaces<input, scope extends Scope = AbiTypeScope>(\n input: validateNamespaces<input, scope>,\n scope: scope = AbiTypeScope as never,\n): show<resolveNamespaces<input, scope>> {\n validateNamespaces(input, scope);\n return resolveNamespaces(input, scope) as never;\n}\n","import { isObject, mergeIfUndefined } from \"@latticexyz/store/internal\";\nimport { CODEGEN_DEFAULTS } from \"./defaults\";\n\nexport type resolveCodegen<codegen> = codegen extends {}\n ? mergeIfUndefined<codegen, CODEGEN_DEFAULTS>\n : CODEGEN_DEFAULTS;\n\nexport function resolveCodegen<codegen>(codegen: codegen): resolveCodegen<codegen> {\n return (isObject(codegen) ? mergeIfUndefined(codegen, CODEGEN_DEFAULTS) : CODEGEN_DEFAULTS) as never;\n}\n","import { mergeIfUndefined, isObject } from \"@latticexyz/store/internal\";\nimport { DEPLOY_DEFAULTS } from \"./defaults\";\n\nexport type resolveDeploy<deploy> = deploy extends {} ? mergeIfUndefined<deploy, DEPLOY_DEFAULTS> : DEPLOY_DEFAULTS;\n\nexport function resolveDeploy<deploy>(deploy: deploy): resolveDeploy<deploy> {\n return (isObject(deploy) ? mergeIfUndefined(deploy, DEPLOY_DEFAULTS) : DEPLOY_DEFAULTS) as never;\n}\n","import { ErrorMessage, conform, show, type withJsDoc } from \"@ark/util\";\nimport {\n extendedScope,\n get,\n mergeIfUndefined,\n resolveStore,\n hasOwnKey,\n validateStore,\n flattenNamespacedTables,\n CONFIG_DEFAULTS as STORE_CONFIG_DEFAULTS,\n} from \"@latticexyz/store/internal\";\nimport { SystemsInput, WorldInput } from \"./input\";\nimport { CONFIG_DEFAULTS, MODULE_DEFAULTS } from \"./defaults\";\nimport { resolveSystems, validateSystems } from \"./systems\";\nimport { resolveNamespaces, validateNamespaces } from \"./namespaces\";\nimport { resolveCodegen } from \"./codegen\";\nimport { resolveDeploy } from \"./deploy\";\nimport type { World } from \"./output.js\";\nimport { StoreInput } from \"@latticexyz/store\";\n\nexport type validateWorld<input> = {\n readonly [key in keyof input]: key extends \"namespaces\"\n ? input extends { namespace?: unknown; tables?: unknown; systems?: unknown }\n ? ErrorMessage<\"Cannot use `namespaces` with `namespace`, `tables`, or `systems` keys.\">\n : validateNamespaces<input[key], extendedScope<input>>\n : key extends \"systems\"\n ? validateSystems<input[key]>\n : key extends \"codegen\"\n ? conform<input[key], WorldInput[key] & StoreInput[key]>\n : key extends keyof StoreInput\n ? validateStore<input>[key]\n : key extends keyof WorldInput\n ? conform<input[key], WorldInput[key]>\n : ErrorMessage<`\\`${key & string}\\` is not a valid World config option.`>;\n};\n\nexport function validateWorld(input: unknown): asserts input is WorldInput {\n const scope = extendedScope(input);\n\n if (hasOwnKey(input, \"namespaces\")) {\n if (hasOwnKey(input, \"namespace\") || hasOwnKey(input, \"tables\") || hasOwnKey(input, \"systems\")) {\n throw new Error(\"Cannot use `namespaces` with `namespace`, `tables`, or `systems` keys.\");\n }\n validateNamespaces(input.namespaces, scope);\n }\n if (hasOwnKey(input, \"systems\")) {\n validateSystems(input.systems);\n }\n\n validateStore(input);\n}\n\nexport type resolveNamespaceMode<input> = \"namespaces\" extends keyof input\n ? {\n readonly multipleNamespaces: true;\n readonly namespace: null;\n readonly namespaces: show<resolveNamespaces<input[\"namespaces\"], extendedScope<input>>>;\n }\n : {\n readonly multipleNamespaces: false;\n readonly namespace: string;\n readonly namespaces: show<\n resolveNamespaces<\n {\n // TODO: improve this so we don't have to duplicate store behavior\n readonly [label in \"namespace\" extends keyof input\n ? input[\"namespace\"] extends string\n ? input[\"namespace\"]\n : STORE_CONFIG_DEFAULTS[\"namespace\"]\n : STORE_CONFIG_DEFAULTS[\"namespace\"]]: input;\n },\n extendedScope<input>\n >\n >;\n };\n\ntype resolveModules<input> = { [key in keyof input]: mergeIfUndefined<input[key], MODULE_DEFAULTS> };\n\nexport type resolveWorld<input> = resolveNamespaceMode<input> &\n Omit<resolveStore<input>, \"multipleNamespaces\" | \"namespace\" | \"namespaces\" | \"tables\"> & {\n readonly tables: flattenNamespacedTables<resolveNamespaceMode<input>>;\n // TODO: flatten systems from namespaces\n readonly systems: \"systems\" extends keyof input\n ? input[\"systems\"] extends SystemsInput\n ? resolveNamespaceMode<input>[\"namespace\"] extends string\n ? show<resolveSystems<input[\"systems\"], resolveNamespaceMode<input>[\"namespace\"]>>\n : {}\n : {}\n : {};\n readonly excludeSystems: \"excludeSystems\" extends keyof input\n ? input[\"excludeSystems\"]\n : CONFIG_DEFAULTS[\"excludeSystems\"];\n readonly modules: \"modules\" extends keyof input ? resolveModules<input[\"modules\"]> : CONFIG_DEFAULTS[\"modules\"];\n readonly codegen: show<resolveCodegen<\"codegen\" extends keyof input ? input[\"codegen\"] : {}>>;\n readonly deploy: show<resolveDeploy<\"deploy\" extends keyof input ? input[\"deploy\"] : {}>>;\n };\n\nexport function resolveWorld<const input extends WorldInput>(input: input): resolveWorld<input> {\n const scope = extendedScope(input);\n const store = resolveStore(input);\n\n const namespaces = input.namespaces\n ? resolveNamespaces(input.namespaces, scope)\n : resolveNamespaces({ [store.namespace!]: input }, scope);\n\n const tables = flattenNamespacedTables({ namespaces });\n const modules = (input.modules ?? CONFIG_DEFAULTS.modules).map((mod) => mergeIfUndefined(mod, MODULE_DEFAULTS));\n\n return mergeIfUndefined(\n {\n ...store,\n namespaces,\n tables,\n // TODO: flatten systems from namespaces\n systems:\n !store.multipleNamespaces && input.systems\n ? resolveSystems(input.systems, store.namespace, store.namespace)\n : CONFIG_DEFAULTS.systems,\n excludeSystems: get(input, \"excludeSystems\"),\n codegen: mergeIfUndefined(store.codegen, resolveCodegen(input.codegen)),\n deploy: resolveDeploy(input.deploy),\n modules,\n },\n CONFIG_DEFAULTS,\n ) as never;\n}\n\nexport function defineWorld<const input>(input: validateWorld<input>): withJsDoc<resolveWorld<input>, World> {\n validateWorld(input);\n return resolveWorld(input) as never;\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAe,iBAAiB;AAGhC,SAAS,eAAe;AACxB,SAAS,cAAqB,UAAU,wBAAwB;AASzD,SAAS,mBACd,YACA,OACuC;AACvC,MAAI,CAAC,SAAS,UAAU,GAAG;AACzB,UAAM,IAAI,MAAM,iCAAiC,KAAK,UAAU,UAAU,CAAC,E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eIfUndefined"]}
@@ -0,0 +1,31 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ export {
28
+ __commonJS,
29
+ __toESM
30
+ };
31
+ //# sourceMappingURL=chunk-5WRI5ZAA.js.map
@@ -0,0 +1,132 @@
1
+ import {
2
+ defineWorld
3
+ } from "./chunk-2W4TKC47.js";
4
+
5
+ // mud.config.ts
6
+ var configInput = {
7
+ namespace: "world",
8
+ // NOTE: this namespace is only used for tables, the core system is deployed in the root namespace.
9
+ codegen: {
10
+ worldImportPath: "./src",
11
+ worldgenDirectory: "interfaces",
12
+ worldInterfaceName: "IBaseWorld"
13
+ },
14
+ userTypes: {
15
+ ResourceId: { filePath: "@latticexyz/store/src/ResourceId.sol", type: "bytes32" }
16
+ },
17
+ tables: {
18
+ NamespaceOwner: {
19
+ schema: {
20
+ namespaceId: "ResourceId",
21
+ owner: "address"
22
+ },
23
+ key: ["namespaceId"]
24
+ },
25
+ ResourceAccess: {
26
+ schema: {
27
+ resourceId: "ResourceId",
28
+ caller: "address",
29
+ access: "bool"
30
+ },
31
+ key: ["resourceId", "caller"]
32
+ },
33
+ InstalledModules: {
34
+ schema: {
35
+ moduleAddress: "address",
36
+ argumentsHash: "bytes32",
37
+ // Hash of the params passed to the `install` function
38
+ isInstalled: "bool"
39
+ },
40
+ key: ["moduleAddress", "argumentsHash"]
41
+ },
42
+ UserDelegationControl: {
43
+ schema: {
44
+ delegator: "address",
45
+ delegatee: "address",
46
+ delegationControlId: "ResourceId"
47
+ },
48
+ key: ["delegator", "delegatee"]
49
+ },
50
+ NamespaceDelegationControl: {
51
+ schema: {
52
+ namespaceId: "ResourceId",
53
+ delegationControlId: "ResourceId"
54
+ },
55
+ key: ["namespaceId"]
56
+ },
57
+ Balances: {
58
+ schema: {
59
+ namespaceId: "ResourceId",
60
+ balance: "uint256"
61
+ },
62
+ key: ["namespaceId"]
63
+ },
64
+ Systems: {
65
+ schema: {
66
+ systemId: "ResourceId",
67
+ system: "address",
68
+ publicAccess: "bool"
69
+ },
70
+ key: ["systemId"],
71
+ codegen: {
72
+ dataStruct: false
73
+ }
74
+ },
75
+ SystemRegistry: {
76
+ schema: {
77
+ system: "address",
78
+ systemId: "ResourceId"
79
+ },
80
+ key: ["system"]
81
+ },
82
+ SystemHooks: {
83
+ schema: {
84
+ systemId: "ResourceId",
85
+ value: "bytes21[]"
86
+ },
87
+ key: ["systemId"]
88
+ },
89
+ FunctionSelectors: {
90
+ schema: {
91
+ worldFunctionSelector: "bytes4",
92
+ systemId: "ResourceId",
93
+ systemFunctionSelector: "bytes4"
94
+ },
95
+ key: ["worldFunctionSelector"],
96
+ codegen: {
97
+ dataStruct: false
98
+ }
99
+ },
100
+ FunctionSignatures: {
101
+ type: "offchainTable",
102
+ schema: {
103
+ functionSelector: "bytes4",
104
+ functionSignature: "string"
105
+ },
106
+ key: ["functionSelector"]
107
+ },
108
+ InitModuleAddress: {
109
+ schema: {
110
+ value: "address"
111
+ },
112
+ key: []
113
+ }
114
+ },
115
+ excludeSystems: [
116
+ // Worldgen currently does not support systems inheriting logic
117
+ // from other contracts, so all parts of RegistrationSystem are named
118
+ // System too to be included in the IBaseWorld interface.
119
+ // However, IStoreRegistrationSystem overlaps with IStore if
120
+ // included in IBaseWorld, so it needs to be excluded from worldgen.
121
+ // TODO: add support for inheritance to worldgen
122
+ // (see: https://github.com/latticexyz/mud/issues/631)
123
+ "StoreRegistrationSystem"
124
+ ]
125
+ };
126
+ var mud_config_default = defineWorld(configInput);
127
+
128
+ export {
129
+ configInput,
130
+ mud_config_default
131
+ };
132
+ //# sourceMappingURL=chunk-SGZK356L.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../mud.config.ts"],"sourcesContent":["import { defineWorld } from \"./ts/config/v2/world\";\n\n/**\n * @internal\n */\nexport const configInput = {\n namespace: \"world\", // NOTE: this namespace is only used for tables, the core system is deployed in the root namespace.\n codegen: {\n worldImportPath: \"./src\",\n worldgenDirectory: \"interfaces\",\n worldInterfaceName: \"IBaseWorld\",\n },\n userTypes: {\n ResourceId: { filePath: \"@latticexyz/store/src/ResourceId.sol\", type: \"bytes32\" },\n },\n tables: {\n NamespaceOwner: {\n schema: {\n namespaceId: \"ResourceId\",\n owner: \"address\",\n },\n key: [\"namespaceId\"],\n },\n ResourceAccess: {\n schema: {\n resourceId: \"ResourceId\",\n caller: \"address\",\n access: \"bool\",\n },\n key: [\"resourceId\", \"caller\"],\n },\n InstalledModules: {\n schema: {\n moduleAddress: \"address\",\n argumentsHash: \"bytes32\", // Hash of the params passed to the `install` function\n isInstalled: \"bool\",\n },\n key: [\"moduleAddress\", \"argumentsHash\"],\n },\n UserDelegationControl: {\n schema: {\n delegator: \"address\",\n delegatee: \"address\",\n delegationControlId: \"ResourceId\",\n },\n key: [\"delegator\", \"delegatee\"],\n },\n NamespaceDelegationControl: {\n schema: {\n namespaceId: \"ResourceId\",\n delegationControlId: \"ResourceId\",\n },\n key: [\"namespaceId\"],\n },\n Balances: {\n schema: {\n namespaceId: \"ResourceId\",\n balance: \"uint256\",\n },\n key: [\"namespaceId\"],\n },\n Systems: {\n schema: {\n systemId: \"ResourceId\",\n system: \"address\",\n publicAccess: \"bool\",\n },\n key: [\"systemId\"],\n codegen: {\n dataStruct: false,\n },\n },\n SystemRegistry: {\n schema: {\n system: \"address\",\n systemId: \"ResourceId\",\n },\n key: [\"system\"],\n },\n SystemHooks: {\n schema: {\n systemId: \"ResourceId\",\n value: \"bytes21[]\",\n },\n key: [\"systemId\"],\n },\n FunctionSelectors: {\n schema: {\n worldFunctionSelector: \"bytes4\",\n systemId: \"ResourceId\",\n systemFunctionSelector: \"bytes4\",\n },\n key: [\"worldFunctionSelector\"],\n codegen: {\n dataStruct: false,\n },\n },\n FunctionSignatures: {\n type: \"offchainTable\",\n schema: {\n functionSelector: \"bytes4\",\n functionSignature: \"string\",\n },\n key: [\"functionSelector\"],\n },\n InitModuleAddress: {\n schema: {\n value: \"address\",\n },\n key: [],\n },\n },\n excludeSystems: [\n // Worldgen currently does not support systems inheriting logic\n // from other contracts, so all parts of RegistrationSystem are named\n // System too to be included in the IBaseWorld interface.\n // However, IStoreRegistrationSystem overlaps with IStore if\n // included in IBaseWorld, so it needs to be excluded from worldgen.\n // TODO: add support for inheritance to worldgen\n // (see: https://github.com/latticexyz/mud/issues/631)\n \"StoreRegistrationSystem\",\n ],\n} as const;\n\nexport default defineWorld(configInput);\n"],"mappings":"wCAKO,IAAMA,EAAc,CACzB,UAAW,QACX,QAAS,CACP,gBAAiB,QACjB,kBAAmB,aACnB,mBAAoB,YACtB,EACA,UAAW,CACT,WAAY,CAAE,SAAU,uCAAwC,KAAM,SAAU,CAClF,EACA,OAAQ,CACN,eAAgB,CACd,OAAQ,CACN,YAAa,aACb,MAAO,SACT,EACA,IAAK,CAAC,aAAa,CACrB,EACA,eAAgB,CACd,OAAQ,CACN,WAAY,aACZ,OAAQ,UACR,OAAQ,MACV,EACA,IAAK,CAAC,aAAc,QAAQ,CAC9B,EACA,iBAAkB,CAChB,OAAQ,CACN,cAAe,UACf,cAAe,UACf,YAAa,MACf,EACA,IAAK,CAAC,gBAAiB,eAAe,CACxC,EACA,sBAAuB,CACrB,OAAQ,CACN,UAAW,UACX,UAAW,UACX,oBAAqB,YACvB,EACA,IAAK,CAAC,YAAa,WAAW,CAChC,EACA,2BAA4B,CAC1B,OAAQ,CACN,YAAa,aACb,oBAAqB,YACvB,EACA,IAAK,CAAC,aAAa,CACrB,EACA,SAAU,CACR,OAAQ,CACN,YAAa,aACb,QAAS,SACX,EACA,IAAK,CAAC,aAAa,CACrB,EACA,QAAS,CACP,OAAQ,CACN,SAAU,aACV,OAAQ,UACR,aAAc,MAChB,EACA,IAAK,CAAC,UAAU,EAChB,QAAS,CACP,WAAY,EACd,CACF,EACA,eAAgB,CACd,OAAQ,CACN,OAAQ,UACR,SAAU,YACZ,EACA,IAAK,CAAC,QAAQ,CAChB,EACA,YAAa,CACX,OAAQ,CACN,SAAU,aACV,MAAO,WACT,EACA,IAAK,CAAC,UAAU,CAClB,EACA,kBAAmB,CACjB,OAAQ,CACN,sBAAuB,SACvB,SAAU,aACV,uBAAwB,QAC1B,EACA,IAAK,CAAC,uBAAuB,EAC7B,QAAS,CACP,WAAY,EACd,CACF,EACA,mBAAoB,CAClB,KAAM,gBACN,OAAQ,CACN,iBAAkB,SAClB,kBAAmB,QACrB,EACA,IAAK,CAAC,kBAAkB,CAC1B,EACA,kBAAmB,CACjB,OAAQ,CACN,MAAO,SACT,EACA,IAAK,CAAC,CACR,CACF,EACA,eAAgB,CAQd,yBACF,CACF,EAEOC,EAAQC,EAAYF,CAAW","names":["configInput","mud_config_default","defineWorld"]}
1
+ {"version":3,"sources":["../mud.config.ts"],"sourcesContent":["import { defineWorld } from \"./ts/config/v2/world\";\n\n/**\n * @internal\n */\nexport const configInput = {\n namespace: \"world\", // NOTE: this namespace is only used for tables, the core system is deployed in the root namespace.\n codegen: {\n worldImportPath: \"./src\",\n worldgenDirectory: \"interfaces\",\n worldInterfaceName: \"IBaseWorld\",\n },\n userTypes: {\n ResourceId: { filePath: \"@latticexyz/store/src/ResourceId.sol\", type: \"bytes32\" },\n },\n tables: {\n NamespaceOwner: {\n schema: {\n namespaceId: \"ResourceId\",\n owner: \"address\",\n },\n key: [\"namespaceId\"],\n },\n ResourceAccess: {\n schema: {\n resourceId: \"ResourceId\",\n caller: \"address\",\n access: \"bool\",\n },\n key: [\"resourceId\", \"caller\"],\n },\n InstalledModules: {\n schema: {\n moduleAddress: \"address\",\n argumentsHash: \"bytes32\", // Hash of the params passed to the `install` function\n isInstalled: \"bool\",\n },\n key: [\"moduleAddress\", \"argumentsHash\"],\n },\n UserDelegationControl: {\n schema: {\n delegator: \"address\",\n delegatee: \"address\",\n delegationControlId: \"ResourceId\",\n },\n key: [\"delegator\", \"delegatee\"],\n },\n NamespaceDelegationControl: {\n schema: {\n namespaceId: \"ResourceId\",\n delegationControlId: \"ResourceId\",\n },\n key: [\"namespaceId\"],\n },\n Balances: {\n schema: {\n namespaceId: \"ResourceId\",\n balance: \"uint256\",\n },\n key: [\"namespaceId\"],\n },\n Systems: {\n schema: {\n systemId: \"ResourceId\",\n system: \"address\",\n publicAccess: \"bool\",\n },\n key: [\"systemId\"],\n codegen: {\n dataStruct: false,\n },\n },\n SystemRegistry: {\n schema: {\n system: \"address\",\n systemId: \"ResourceId\",\n },\n key: [\"system\"],\n },\n SystemHooks: {\n schema: {\n systemId: \"ResourceId\",\n value: \"bytes21[]\",\n },\n key: [\"systemId\"],\n },\n FunctionSelectors: {\n schema: {\n worldFunctionSelector: \"bytes4\",\n systemId: \"ResourceId\",\n systemFunctionSelector: \"bytes4\",\n },\n key: [\"worldFunctionSelector\"],\n codegen: {\n dataStruct: false,\n },\n },\n FunctionSignatures: {\n type: \"offchainTable\",\n schema: {\n functionSelector: \"bytes4\",\n functionSignature: \"string\",\n },\n key: [\"functionSelector\"],\n },\n InitModuleAddress: {\n schema: {\n value: \"address\",\n },\n key: [],\n },\n },\n excludeSystems: [\n // Worldgen currently does not support systems inheriting logic\n // from other contracts, so all parts of RegistrationSystem are named\n // System too to be included in the IBaseWorld interface.\n // However, IStoreRegistrationSystem overlaps with IStore if\n // included in IBaseWorld, so it needs to be excluded from worldgen.\n // TODO: add support for inheritance to worldgen\n // (see: https://github.com/latticexyz/mud/issues/631)\n \"StoreRegistrationSystem\",\n ],\n} as const;\n\nexport default defineWorld(configInput);\n"],"mappings":";;;;;AAKO,IAAM,cAAc;AAAA,EACzB,WAAW;AAAA;AAAA,EACX,SAAS;AAAA,IACP,iBAAiB;AAAA,IACjB,mBAAmB;AAAA,IACnB,oBAAoB;AAAA,EACtB;AAAA,EACA,WAAW;AAAA,IACT,YAAY,EAAE,UAAU,wCAAwC,MAAM,UAAU;AAAA,EAClF;AAAA,EACA,QAAQ;AAAA,IACN,gBAAgB;AAAA,MACd,QAAQ;AAAA,QACN,aAAa;AAAA,QACb,OAAO;AAAA,MACT;AAAA,MACA,KAAK,CAAC,aAAa;AAAA,IACrB;AAAA,IACA,gBAAgB;AAAA,MACd,QAAQ;AAAA,QACN,YAAY;AAAA,QACZ,QAAQ;AAAA,QACR,QAAQ;AAAA,MACV;AAAA,MACA,KAAK,CAAC,cAAc,QAAQ;AAAA,IAC9B;AAAA,IACA,kBAAkB;AAAA,MAChB,QAAQ;AAAA,QACN,eAAe;AAAA,QACf,eAAe;AAAA;AAAA,QACf,aAAa;AAAA,MACf;AAAA,MACA,KAAK,CAAC,iBAAiB,eAAe;AAAA,IACxC;AAAA,IACA,uBAAuB;AAAA,MACrB,QAAQ;AAAA,QACN,WAAW;AAAA,QACX,WAAW;AAAA,QACX,qBAAqB;AAAA,MACvB;AAAA,MACA,KAAK,CAAC,aAAa,WAAW;AAAA,IAChC;AAAA,IACA,4BAA4B;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AY,WAAW;","names":[]}
@@ -0,0 +1,142 @@
1
+ // ts/config/v2/defaults.ts
2
+ var SYSTEM_DEPLOY_DEFAULTS = {
3
+ disabled: false,
4
+ registerWorldFunctions: true
5
+ };
6
+ var SYSTEM_DEFAULTS = {
7
+ namespaceLabel: "",
8
+ openAccess: true,
9
+ accessList: []
10
+ };
11
+ var MODULE_DEFAULTS = {
12
+ root: false,
13
+ args: [],
14
+ artifactPath: void 0
15
+ };
16
+ var CODEGEN_DEFAULTS = {
17
+ worldInterfaceName: "IWorld",
18
+ worldgenDirectory: "world",
19
+ systemLibrariesDirectory: "systems",
20
+ generateSystemLibraries: false,
21
+ worldImportPath: "@latticexyz/world/src"
22
+ };
23
+ var DEPLOY_DEFAULTS = {
24
+ postDeployScript: "PostDeploy",
25
+ deploysDirectory: "./deploys",
26
+ worldsFile: "./worlds.json",
27
+ upgradeableWorldImplementation: false
28
+ };
29
+ var CONFIG_DEFAULTS = {
30
+ systems: {},
31
+ tables: {},
32
+ excludeSystems: [],
33
+ modules: [],
34
+ codegen: CODEGEN_DEFAULTS,
35
+ deploy: DEPLOY_DEFAULTS
36
+ };
37
+
38
+ // ts/config/v2/system.ts
39
+ import { hasOwnKey, mergeIfUndefined } from "@latticexyz/store/internal";
40
+ import { resourceToHex } from "@latticexyz/common";
41
+ function validateSystem(input, options = {}) {
42
+ if (typeof input !== "object" || input == null) {
43
+ throw new Error(`Expected full system config, got \`${JSON.stringify(input)}\``);
44
+ }
45
+ if (options.inNamespace && (hasOwnKey(input, "label") || hasOwnKey(input, "namespaceLabel") || hasOwnKey(input, "namespace"))) {
46
+ throw new Error(
47
+ "Overrides of `label`, `namespaceLabel`, and `namespace` are not allowed for systems in this context."
48
+ );
49
+ }
50
+ if (hasOwnKey(input, "namespaceLabel") && typeof input.namespaceLabel === "string" && (!hasOwnKey(input, "namespace") || typeof input.namespace !== "string") && input.namespaceLabel.length > 14) {
51
+ throw new Error(
52
+ `System \`namespace\` defaults to \`namespaceLabel\`, but must fit into a \`bytes14\` and "${input.namespaceLabel}" is too long. Provide explicit \`namespace\` override.`
53
+ );
54
+ }
55
+ if (hasOwnKey(input, "namespace") && typeof input.namespace === "string" && input.namespace.length > 14) {
56
+ throw new Error(`System \`namespace\` must fit into a \`bytes14\`, but "${input.namespace}" is too long.`);
57
+ }
58
+ if (hasOwnKey(input, "name") && typeof input.name === "string" && input.name.length > 16) {
59
+ throw new Error(`System \`name\` must fit into a \`bytes16\`, but "${input.name}" is too long.`);
60
+ }
61
+ }
62
+ function resolveSystem(input) {
63
+ const namespaceLabel = input.namespaceLabel ?? SYSTEM_DEFAULTS.namespaceLabel;
64
+ const namespace = input.namespace ?? namespaceLabel;
65
+ const label = input.label;
66
+ const name = input.name ?? label.slice(0, 16);
67
+ const systemId = resourceToHex({ type: "system", namespace, name });
68
+ return mergeIfUndefined(
69
+ {
70
+ ...input,
71
+ label,
72
+ namespaceLabel,
73
+ namespace,
74
+ name,
75
+ systemId,
76
+ deploy: mergeIfUndefined(input.deploy ?? {}, SYSTEM_DEPLOY_DEFAULTS)
77
+ },
78
+ SYSTEM_DEFAULTS
79
+ );
80
+ }
81
+ function defineSystem(input) {
82
+ validateSystem(input);
83
+ return resolveSystem(input);
84
+ }
85
+
86
+ // ts/config/v2/systems.ts
87
+ import { isObject } from "@latticexyz/store/internal";
88
+ function validateSystems(input) {
89
+ if (isObject(input)) {
90
+ for (const system of Object.values(input)) {
91
+ validateSystem(system, { inNamespace: true });
92
+ }
93
+ return;
94
+ }
95
+ throw new Error(`Expected system config, received ${JSON.stringify(input)}`);
96
+ }
97
+ function resolveSystems(systems, namespaceLabel, namespace) {
98
+ return Object.fromEntries(
99
+ Object.entries(systems).map(([label, system]) => {
100
+ return [label, resolveSystem({ ...system, label, namespaceLabel, namespace })];
101
+ })
102
+ );
103
+ }
104
+
105
+ // ts/config/v2/namespace.ts
106
+ import {
107
+ hasOwnKey as hasOwnKey2,
108
+ validateNamespace as validateStoreNamespace,
109
+ resolveNamespace as resolveStoreNamespace,
110
+ AbiTypeScope
111
+ } from "@latticexyz/store/internal";
112
+ function validateNamespace(input, scope) {
113
+ if (hasOwnKey2(input, "systems")) {
114
+ validateSystems(input.systems);
115
+ }
116
+ validateStoreNamespace(input, scope);
117
+ }
118
+ function resolveNamespace(input, scope = AbiTypeScope) {
119
+ const namespace = resolveStoreNamespace(input, scope);
120
+ const systems = resolveSystems(input.systems ?? {}, namespace.label, namespace.namespace);
121
+ return {
122
+ ...namespace,
123
+ systems
124
+ };
125
+ }
126
+
127
+ export {
128
+ SYSTEM_DEPLOY_DEFAULTS,
129
+ SYSTEM_DEFAULTS,
130
+ MODULE_DEFAULTS,
131
+ CODEGEN_DEFAULTS,
132
+ DEPLOY_DEFAULTS,
133
+ CONFIG_DEFAULTS,
134
+ validateSystem,
135
+ resolveSystem,
136
+ defineSystem,
137
+ validateSystems,
138
+ resolveSystems,
139
+ validateNamespace,
140
+ resolveNamespace
141
+ };
142
+ //# sourceMappingURL=chunk-XSBK355I.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../ts/config/v2/defaults.ts","../ts/config/v2/system.ts","../ts/config/v2/systems.ts","../ts/config/v2/namespace.ts"],"sourcesContent":["import { CodegenInput, DeployInput, ModuleInput, SystemDeployInput, SystemInput, WorldInput } from \"./input\";\n\nexport const SYSTEM_DEPLOY_DEFAULTS = {\n disabled: false,\n registerWorldFunctions: true,\n} as const satisfies Required<SystemDeployInput>;\n\nexport type SYSTEM_DEPLOY_DEFAULTS = typeof SYSTEM_DEPLOY_DEFAULTS;\n\nexport const SYSTEM_DEFAULTS = {\n namespaceLabel: \"\",\n openAccess: true,\n accessList: [],\n} as const satisfies Omit<Required<SystemInput>, \"label\" | \"namespace\" | \"name\" | \"deploy\">;\n\nexport type SYSTEM_DEFAULTS = typeof SYSTEM_DEFAULTS;\n\nexport const MODULE_DEFAULTS = {\n root: false,\n args: [],\n artifactPath: undefined,\n} as const satisfies Pick<ModuleInput, \"root\" | \"args\" | \"artifactPath\">;\n\nexport type MODULE_DEFAULTS = typeof MODULE_DEFAULTS;\n\nexport const CODEGEN_DEFAULTS = {\n worldInterfaceName: \"IWorld\",\n worldgenDirectory: \"world\",\n systemLibrariesDirectory: \"systems\",\n generateSystemLibraries: false,\n worldImportPath: \"@latticexyz/world/src\",\n} as const satisfies CodegenInput;\n\nexport type CODEGEN_DEFAULTS = typeof CODEGEN_DEFAULTS;\n\nexport const DEPLOY_DEFAULTS = {\n postDeployScript: \"PostDeploy\",\n deploysDirectory: \"./deploys\",\n worldsFile: \"./worlds.json\",\n upgradeableWorldImplementation: false,\n} as const satisfies DeployInput;\n\nexport type DEPLOY_DEFAULTS = typeof DEPLOY_DEFAULTS;\n\nexport const CONFIG_DEFAULTS = {\n systems: {},\n tables: {},\n excludeSystems: [],\n modules: [],\n codegen: CODEGEN_DEFAULTS,\n deploy: DEPLOY_DEFAULTS,\n} as const satisfies WorldInput;\n\nexport type CONFIG_DEFAULTS = typeof CONFIG_DEFAULTS;\n","import { SYSTEM_DEFAULTS, SYSTEM_DEPLOY_DEFAULTS } from \"./defaults\";\nimport { SystemInput } from \"./input\";\nimport { hasOwnKey, mergeIfUndefined } from \"@latticexyz/store/internal\";\nimport { ErrorMessage, narrow, requiredKeyOf, show } from \"@ark/util\";\nimport { Hex } from \"viem\";\nimport { resourceToHex } from \"@latticexyz/common\";\n\nexport type ValidateSystemOptions = { readonly inNamespace?: true };\n\nexport type requiredSystemKey<inNamespace extends true | undefined> = Exclude<\n requiredKeyOf<SystemInput>,\n inNamespace extends true ? \"label\" | \"namespaceLabel\" | \"namespace\" : never\n>;\n\nexport type validateSystem<input, options extends ValidateSystemOptions = {}> = {\n [key in keyof input | requiredSystemKey<options[\"inNamespace\"]>]: key extends keyof SystemInput\n ? key extends \"label\" | \"namespaceLabel\" | \"namespace\"\n ? options[\"inNamespace\"] extends true\n ? ErrorMessage<\"Overrides of `label`, `namespaceLabel`, and `namespace` are not allowed for systems in this context.\">\n : key extends keyof input\n ? narrow<input[key]>\n : never\n : SystemInput[key]\n : ErrorMessage<`Key \\`${key & string}\\` does not exist in SystemInput`>;\n};\n\nexport function validateSystem<input>(\n input: input,\n options: ValidateSystemOptions = {},\n): asserts input is SystemInput & input {\n if (typeof input !== \"object\" || input == null) {\n throw new Error(`Expected full system config, got \\`${JSON.stringify(input)}\\``);\n }\n\n if (\n options.inNamespace &&\n (hasOwnKey(input, \"label\") || hasOwnKey(input, \"namespaceLabel\") || hasOwnKey(input, \"namespace\"))\n ) {\n throw new Error(\n \"Overrides of `label`, `namespaceLabel`, and `namespace` are not allowed for systems in this context.\",\n );\n }\n\n if (\n hasOwnKey(input, \"namespaceLabel\") &&\n typeof input.namespaceLabel === \"string\" &&\n (!hasOwnKey(input, \"namespace\") || typeof input.namespace !== \"string\") &&\n input.namespaceLabel.length > 14\n ) {\n throw new Error(\n `System \\`namespace\\` defaults to \\`namespaceLabel\\`, but must fit into a \\`bytes14\\` and \"${input.namespaceLabel}\" is too long. Provide explicit \\`namespace\\` override.`,\n );\n }\n\n if (hasOwnKey(input, \"namespace\") && typeof input.namespace === \"string\" && input.namespace.length > 14) {\n throw new Error(`System \\`namespace\\` must fit into a \\`bytes14\\`, but \"${input.namespace}\" is too long.`);\n }\n if (hasOwnKey(input, \"name\") && typeof input.name === \"string\" && input.name.length > 16) {\n throw new Error(`System \\`name\\` must fit into a \\`bytes16\\`, but \"${input.name}\" is too long.`);\n }\n}\n\nexport type resolveSystem<input> = input extends SystemInput\n ? {\n readonly label: input[\"label\"];\n readonly namespaceLabel: undefined extends input[\"namespaceLabel\"]\n ? typeof SYSTEM_DEFAULTS.namespaceLabel\n : input[\"namespaceLabel\"];\n readonly namespace: string;\n readonly name: string;\n readonly systemId: Hex;\n readonly openAccess: undefined extends input[\"openAccess\"] ? SYSTEM_DEFAULTS[\"openAccess\"] : input[\"openAccess\"];\n readonly accessList: undefined extends input[\"accessList\"] ? SYSTEM_DEFAULTS[\"accessList\"] : input[\"accessList\"];\n readonly deploy: show<\n mergeIfUndefined<undefined extends input[\"deploy\"] ? {} : input[\"deploy\"], SYSTEM_DEPLOY_DEFAULTS>\n >;\n }\n : never;\n\nexport function resolveSystem<input extends SystemInput>(input: input): resolveSystem<input> {\n const namespaceLabel = input.namespaceLabel ?? SYSTEM_DEFAULTS.namespaceLabel;\n // validate ensures this is length constrained\n const namespace = input.namespace ?? namespaceLabel;\n\n const label = input.label;\n const name = input.name ?? label.slice(0, 16);\n const systemId = resourceToHex({ type: \"system\", namespace, name });\n\n return mergeIfUndefined(\n {\n ...input,\n label,\n namespaceLabel,\n namespace,\n name,\n systemId,\n deploy: mergeIfUndefined(input.deploy ?? {}, SYSTEM_DEPLOY_DEFAULTS),\n },\n SYSTEM_DEFAULTS,\n ) as never;\n}\n\nexport function defineSystem<input>(input: validateSystem<input>): resolveSystem<input> {\n validateSystem(input);\n return resolveSystem(input) as never;\n}\n","import { ErrorMessage } from \"@ark/util\";\nimport { isObject } from \"@latticexyz/store/internal\";\nimport { SystemsInput } from \"./input\";\nimport { resolveSystem, validateSystem } from \"./system\";\n\n// TODO: add nuance between \"in namespace\" (namespace provided in context) and \"in systems\" (label provided in context)\n\nexport type validateSystems<input> = {\n [label in keyof input]: input[label] extends object\n ? validateSystem<input[label], { inNamespace: true }>\n : ErrorMessage<`Expected a system config for ${label & string}.`>;\n};\n\nexport function validateSystems(input: unknown): asserts input is SystemsInput {\n if (isObject(input)) {\n for (const system of Object.values(input)) {\n validateSystem(system, { inNamespace: true });\n }\n return;\n }\n throw new Error(`Expected system config, received ${JSON.stringify(input)}`);\n}\n\nexport type resolveSystems<systems extends SystemsInput, namespaceLabel extends string> = {\n [label in keyof systems]: resolveSystem<\n systems[label] & { label: label; namespaceLabel: namespaceLabel; namespace: string }\n >;\n};\n\nexport function resolveSystems<systems extends SystemsInput, namespaceLabel extends string>(\n systems: systems,\n namespaceLabel: namespaceLabel,\n namespace: string,\n): resolveSystems<systems, namespaceLabel> {\n return Object.fromEntries(\n Object.entries(systems).map(([label, system]) => {\n return [label, resolveSystem({ ...system, label, namespaceLabel, namespace })];\n }),\n ) as never;\n}\n","import { NamespaceInput, SystemsInput } from \"./input\";\nimport {\n hasOwnKey,\n validateNamespace as validateStoreNamespace,\n resolveNamespace as resolveStoreNamespace,\n Scope,\n AbiTypeScope,\n} from \"@latticexyz/store/internal\";\nimport { resolveSystems, validateSystems } from \"./systems\";\nimport { show } from \"@ark/util\";\n\nexport type validateNamespace<input, scope extends Scope = AbiTypeScope> = {\n [key in keyof input]: key extends \"systems\" ? validateSystems<input[key]> : validateStoreNamespace<input, scope>[key];\n};\n\nexport function validateNamespace<scope extends Scope = AbiTypeScope>(\n input: unknown,\n scope: scope,\n): asserts input is NamespaceInput {\n if (hasOwnKey(input, \"systems\")) {\n validateSystems(input.systems);\n }\n validateStoreNamespace(input, scope);\n}\n\nexport type resolveNamespace<input, scope extends Scope = AbiTypeScope> = input extends NamespaceInput\n ? show<\n resolveStoreNamespace<input, scope> & {\n readonly systems: input[\"systems\"] extends SystemsInput\n ? show<resolveSystems<input[\"systems\"], resolveStoreNamespace<input, scope>[\"label\"]>>\n : {};\n }\n >\n : never;\n\nexport function resolveNamespace<const input extends NamespaceInput, scope extends Scope = AbiTypeScope>(\n input: input,\n scope: scope = AbiTypeScope as never,\n): resolveNamespace<input, scope> {\n const namespace = resolveStoreNamespace(input, scope);\n const systems = resolveSystems(input.systems ?? {}, namespace.label, namespace.namespace);\n return {\n ...namespace,\n systems,\n } as never;\n}\n"],"mappings":"AAEO,IAAMA,EAAyB,CACpC,SAAU,GACV,uBAAwB,EAC1B,EAIaC,EAAkB,CAC7B,eAAgB,GAChB,WAAY,GACZ,WAAY,CAAC,CACf,EAIaC,EAAkB,CAC7B,KAAM,GACN,KAAM,CAAC,EACP,aAAc,MAChB,EAIaC,EAAmB,CAC9B,mBAAoB,SACpB,kBAAmB,QACnB,yBAA0B,UAC1B,wBAAyB,GACzB,gBAAiB,uBACnB,EAIaC,EAAkB,CAC7B,iBAAkB,aAClB,i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AULTS","CONFIG_DEFAULTS","hasOwnKey","mergeIfUndefined","resourceToHex","validateSystem","input","options","resolveSystem","namespaceLabel","SYSTEM_DEFAULTS","namespace","label","name","systemId","SYSTEM_DEPLOY_DEFAULTS","defineSystem","isObject","validateSystems","input","isObject","system","validateSystem","resolveSystems","systems","namespaceLabel","namespace","label","resolveSystem","hasOwnKey","validateStoreNamespace","resolveStoreNamespace","AbiTypeScope","validateNamespace","input","scope","hasOwnKey","validateSystems","validateStoreNamespace","resolveNamespace","AbiTypeScope","namespace","resolveStoreNamespace","systems","resolveSystems"]}
1
+ {"version":3,"sources":["../ts/config/v2/defaults.ts","../ts/config/v2/system.ts","../ts/config/v2/systems.ts","../ts/config/v2/namespace.ts"],"sourcesContent":["import { CodegenInput, DeployInput, ModuleInput, SystemDeployInput, SystemInput, WorldInput } from \"./input\";\n\nexport const SYSTEM_DEPLOY_DEFAULTS = {\n disabled: false,\n registerWorldFunctions: true,\n} as const satisfies Required<SystemDeployInput>;\n\nexport type SYSTEM_DEPLOY_DEFAULTS = typeof SYSTEM_DEPLOY_DEFAULTS;\n\nexport const SYSTEM_DEFAULTS = {\n namespaceLabel: \"\",\n openAccess: true,\n accessList: [],\n} as const satisfies Omit<Required<SystemInput>, \"label\" | \"namespace\" | \"name\" | \"deploy\">;\n\nexport type SYSTEM_DEFAULTS = typeof SYSTEM_DEFAULTS;\n\nexport const MODULE_DEFAULTS = {\n root: false,\n args: [],\n artifactPath: undefined,\n} as const satisfies Pick<ModuleInput, \"root\" | \"args\" | \"artifactPath\">;\n\nexport type MODULE_DEFAULTS = typeof MODULE_DEFAULTS;\n\nexport const CODEGEN_DEFAULTS = {\n worldInterfaceName: \"IWorld\",\n worldgenDirectory: \"world\",\n systemLibrariesDirectory: \"systems\",\n generateSystemLibraries: false,\n worldImportPath: \"@latticexyz/world/src\",\n} as const satisfies CodegenInput;\n\nexport type CODEGEN_DEFAULTS = typeof CODEGEN_DEFAULTS;\n\nexport const DEPLOY_DEFAULTS = {\n postDeployScript: \"PostDeploy\",\n deploysDirectory: \"./deploys\",\n worldsFile: \"./worlds.json\",\n upgradeableWorldImplementation: false,\n} as const satisfies DeployInput;\n\nexport type DEPLOY_DEFAULTS = typeof DEPLOY_DEFAULTS;\n\nexport const CONFIG_DEFAULTS = {\n systems: {},\n tables: {},\n excludeSystems: [],\n modules: [],\n codegen: CODEGEN_DEFAULTS,\n deploy: DEPLOY_DEFAULTS,\n} as const satisfies WorldInput;\n\nexport type CONFIG_DEFAULTS = typeof CONFIG_DEFAULTS;\n","import { SYSTEM_DEFAULTS, SYSTEM_DEPLOY_DEFAULTS } from \"./defaults\";\nimport { SystemInput } from \"./input\";\nimport { hasOwnKey, mergeIfUndefined } from \"@latticexyz/store/internal\";\nimport { ErrorMessage, narrow, requiredKeyOf, show } from \"@ark/util\";\nimport { Hex } from \"viem\";\nimport { resourceToHex } from \"@latticexyz/common\";\n\nexport type ValidateSystemOptions = { readonly inNamespace?: true };\n\nexport type requiredSystemKey<inNamespace extends true | undefined> = Exclude<\n requiredKeyOf<SystemInput>,\n inNamespace extends true ? \"label\" | \"namespaceLabel\" | \"namespace\" : never\n>;\n\nexport type validateSystem<input, options extends ValidateSystemOptions = {}> = {\n [key in keyof input | requiredSystemKey<options[\"inNamespace\"]>]: key extends keyof SystemInput\n ? key extends \"label\" | \"namespaceLabel\" | \"namespace\"\n ? options[\"inNamespace\"] extends true\n ? ErrorMessage<\"Overrides of `label`, `namespaceLabel`, and `namespace` are not allowed for systems in this context.\">\n : key extends keyof input\n ? narrow<input[key]>\n : never\n : SystemInput[key]\n : ErrorMessage<`Key \\`${key & string}\\` does not exist in SystemInput`>;\n};\n\nexport function validateSystem<input>(\n input: input,\n options: ValidateSystemOptions = {},\n): asserts input is SystemInput & input {\n if (typeof input !== \"object\" || input == null) {\n throw new Error(`Expected full system config, got \\`${JSON.stringify(input)}\\``);\n }\n\n if (\n options.inNamespace &&\n (hasOwnKey(input, \"label\") || hasOwnKey(input, \"namespaceLabel\") || hasOwnKey(input, \"namespace\"))\n ) {\n throw new Error(\n \"Overrides of `label`, `namespaceLabel`, and `namespace` are not allowed for systems in this context.\",\n );\n }\n\n if (\n hasOwnKey(input, \"namespaceLabel\") &&\n typeof input.namespaceLabel === \"string\" &&\n (!hasOwnKey(input, \"namespace\") || typeof input.namespace !== \"string\") &&\n input.namespaceLabel.length > 14\n ) {\n throw new Error(\n `System \\`namespace\\` defaults to \\`namespaceLabel\\`, but must fit into a \\`bytes14\\` and \"${input.namespaceLabel}\" is too long. Provide explicit \\`namespace\\` override.`,\n );\n }\n\n if (hasOwnKey(input, \"namespace\") && typeof input.namespace === \"string\" && input.namespace.length > 14) {\n throw new Error(`System \\`namespace\\` must fit into a \\`bytes14\\`, but \"${input.namespace}\" is too long.`);\n }\n if (hasOwnKey(input, \"name\") && typeof input.name === \"string\" && input.name.length > 16) {\n throw new Error(`System \\`name\\` must fit into a \\`bytes16\\`, but \"${input.name}\" is too long.`);\n }\n}\n\nexport type resolveSystem<input> = input extends SystemInput\n ? {\n readonly label: input[\"label\"];\n readonly namespaceLabel: undefined extends input[\"namespaceLabel\"]\n ? typeof SYSTEM_DEFAULTS.namespaceLabel\n : input[\"namespaceLabel\"];\n readonly namespace: string;\n readonly name: string;\n readonly systemId: Hex;\n readonly openAccess: undefined extends input[\"openAccess\"] ? SYSTEM_DEFAULTS[\"openAccess\"] : input[\"openAccess\"];\n readonly accessList: undefined extends input[\"accessList\"] ? SYSTEM_DEFAULTS[\"accessList\"] : input[\"accessList\"];\n readonly deploy: show<\n mergeIfUndefined<undefined extends input[\"deploy\"] ? {} : input[\"deploy\"], SYSTEM_DEPLOY_DEFAULTS>\n >;\n }\n : never;\n\nexport function resolveSystem<input extends SystemInput>(input: input): resolveSystem<input> {\n const namespaceLabel = input.namespaceLabel ?? SYSTEM_DEFAULTS.namespaceLabel;\n // validate ensures this is length constrained\n const namespace = input.namespace ?? namespaceLabel;\n\n const label = input.label;\n const name = input.name ?? label.slice(0, 16);\n const systemId = resourceToHex({ type: \"system\", namespace, name });\n\n return mergeIfUndefined(\n {\n ...input,\n label,\n namespaceLabel,\n namespace,\n name,\n systemId,\n deploy: mergeIfUndefined(input.deploy ?? {}, SYSTEM_DEPLOY_DEFAULTS),\n },\n SYSTEM_DEFAULTS,\n ) as never;\n}\n\nexport function defineSystem<input>(input: validateSystem<input>): resolveSystem<input> {\n validateSystem(input);\n return resolveSystem(input) as never;\n}\n","import { ErrorMessage } from \"@ark/util\";\nimport { isObject } from \"@latticexyz/store/internal\";\nimport { SystemsInput } from \"./input\";\nimport { resolveSystem, validateSystem } from \"./system\";\n\n// TODO: add nuance between \"in namespace\" (namespace provided in context) and \"in systems\" (label provided in context)\n\nexport type validateSystems<input> = {\n [label in keyof input]: input[label] extends object\n ? validateSystem<input[label], { inNamespace: true }>\n : ErrorMessage<`Expected a system config for ${label & string}.`>;\n};\n\nexport function validateSystems(input: unknown): asserts input is SystemsInput {\n if (isObject(input)) {\n for (const system of Object.values(input)) {\n validateSystem(system, { inNamespace: true });\n }\n return;\n }\n throw new Error(`Expected system config, received ${JSON.stringify(input)}`);\n}\n\nexport type resolveSystems<systems extends SystemsInput, namespaceLabel extends string> = {\n [label in keyof systems]: resolveSystem<\n systems[label] & { label: label; namespaceLabel: namespaceLabel; namespace: string }\n >;\n};\n\nexport function resolveSystems<systems extends SystemsInput, namespaceLabel extends string>(\n systems: systems,\n namespaceLabel: namespaceLabel,\n namespace: string,\n): resolveSystems<systems, namespaceLabel> {\n return Object.fromEntries(\n Object.entries(systems).map(([label, system]) => {\n return [label, resolveSystem({ ...system, label, namespaceLabel, namespace })];\n }),\n ) as never;\n}\n","import { NamespaceInput, SystemsInput } from \"./input\";\nimport {\n hasOwnKey,\n validateNamespace as validateStoreNamespace,\n resolveNamespace as resolveStoreNamespace,\n Scope,\n AbiTypeScope,\n} from \"@latticexyz/store/internal\";\nimport { resolveSystems, validateSystems } from \"./systems\";\nimport { show } from \"@ark/util\";\n\nexport type validateNamespace<input, scope extends Scope = AbiTypeScope> = {\n [key in keyof input]: key extends \"systems\" ? validateSystems<input[key]> : validateStoreNamespace<input, scope>[key];\n};\n\nexport function validateNamespace<scope extends Scope = AbiTypeScope>(\n input: unknown,\n scope: scope,\n): asserts input is NamespaceInput {\n if (hasOwnKey(input, \"systems\")) {\n validateSystems(input.systems);\n }\n validateStoreNamespace(input, scope);\n}\n\nexport type resolveNamespace<input, scope extends Scope = AbiTypeScope> = input extends NamespaceInput\n ? show<\n resolveStoreNamespace<input, scope> & {\n readonly systems: input[\"systems\"] extends SystemsInput\n ? show<resolveSystems<input[\"systems\"], resolveStoreNamespace<input, scope>[\"label\"]>>\n : {};\n }\n >\n : never;\n\nexport function resolveNamespace<const input extends NamespaceInput, scope extends Scope = AbiTypeScope>(\n input: input,\n scope: scope = AbiTypeScope as never,\n): resolveNamespace<input, scope> {\n const namespace = resolveStoreNamespace(input, scope);\n const systems = resolveSystems(input.systems ?? {}, namespace.label, namespace.namespace);\n return {\n ...namespace,\n systems,\n } as never;\n}\n"],"mappings":";AAEO,IAAM,yBAAyB;AAAA,EACpC,UAAU;AAAA,EACV,wBAAwB;AAC1B;AAIO,IAAM,kBAAkB;AAAA,EAC7B,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,YAAY,CAAC;AACf;AAIO,IAAM,kBAAkB;AAAA,EAC7B,MAAM;AAAA,EACN,MAAM,CAAC;AAAA,EACP,cAAc;AAChB;AAIO,IAAM,mBAAmB;AAAA,EAC9B,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,0BAA0B;AAAA,EAC1B,yBAAyB;AAAA,EACzB,iBAAiB;AACnB;AAIO,IAAM,kBAAkB;AAAA,EAC7B,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,YAAY;AAAA,EACZ,gCAAgC;AAClC;AAIO,IAAM,kBAAkB;AAAA,EAC7B,SAAS,CAAC;AAAA,EACV,QAAQ,CAAC;AAAA,EACT,gBAAgB,CAAC;AAAA,EACjB,SAA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k-DIHBEOC2.js";import"./chunk-CGF3NYHC.js";import"./chunk-FW4363Y4.js";var o="event WorldDeployed(address indexed newContract, uint256 salt)",t="event HelloWorld(bytes32 indexed worldVersion)";export{e as defineWorld,t as helloWorldEvent,o as worldDeployedEvent};
1
+ import {
2
+ defineWorld
3
+ } from "./chunk-2W4TKC47.js";
4
+ import "./chunk-XSBK355I.js";
5
+ import "./chunk-5WRI5ZAA.js";
6
+
7
+ // ts/worldEvents.ts
8
+ var worldDeployedEvent = "event WorldDeployed(address indexed newContract, uint256 salt)";
9
+ var helloWorldEvent = "event HelloWorld(bytes32 indexed worldVersion)";
10
+ export {
11
+ defineWorld,
12
+ helloWorldEvent,
13
+ worldDeployedEvent
14
+ };
2
15
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../ts/worldEvents.ts"],"sourcesContent":["// from WorldFactory\nexport const worldDeployedEvent = \"event WorldDeployed(address indexed newContract, uint256 salt)\";\n\n// from World\nexport const helloWorldEvent = \"event HelloWorld(bytes32 indexed worldVersion)\";\n"],"mappings":"gGACO,IAAMA,EAAqB,iEAGrBC,EAAkB","names":["worldDeployedEvent","helloWorldEvent"]}
1
+ {"version":3,"sources":["../ts/worldEvents.ts"],"sourcesContent":["// from WorldFactory\nexport const worldDeployedEvent = \"event WorldDeployed(address indexed newContract, uint256 salt)\";\n\n// from World\nexport const helloWorldEvent = \"event HelloWorld(bytes32 indexed worldVersion)\";\n"],"mappings":";;;;;;;AACO,IAAM,qBAAqB;AAG3B,IAAM,kBAAkB;","names":[]}