@latticexyz/store 3.0.0-main-e85dc5349 → 3.0.0-main-8f6fa588d

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.
@@ -1,2 +1,2 @@
1
- import{K as e}from"./chunk-YSCNU2IH.js";var o=e({codegen:{storeImportPath:"../../"},namespace:"store",userTypes:{ResourceId:{filePath:"./src/ResourceId.sol",type:"bytes32"},FieldLayout:{filePath:"./src/FieldLayout.sol",type:"bytes32"},Schema:{filePath:"./src/Schema.sol",type:"bytes32"}},tables:{StoreHooks:{schema:{tableId:"ResourceId",hooks:"bytes21[]"},key:["tableId"]},Tables:{schema:{tableId:"ResourceId",fieldLayout:"FieldLayout",keySchema:"Schema",valueSchema:"Schema",abiEncodedKeyNames:"bytes",abiEncodedFieldNames:"bytes"},key:["tableId"]},ResourceIds:{schema:{resourceId:"ResourceId",exists:"bool"},key:["resourceId"]},Hooks:{schema:{resourceId:"ResourceId",hooks:"bytes21[]"},key:["resourceId"],codegen:{tableIdArgument:!0}}}});export{o as default};
1
+ import{K as e}from"./chunk-ZL5JTF5W.js";var o=e({codegen:{storeImportPath:"../../"},namespace:"store",userTypes:{ResourceId:{filePath:"./src/ResourceId.sol",type:"bytes32"},FieldLayout:{filePath:"./src/FieldLayout.sol",type:"bytes32"},Schema:{filePath:"./src/Schema.sol",type:"bytes32"}},tables:{StoreHooks:{schema:{tableId:"ResourceId",hooks:"bytes21[]"},key:["tableId"]},Tables:{schema:{tableId:"ResourceId",fieldLayout:"FieldLayout",keySchema:"Schema",valueSchema:"Schema",abiEncodedKeyNames:"bytes",abiEncodedFieldNames:"bytes"},key:["tableId"]},ResourceIds:{schema:{resourceId:"ResourceId",exists:"bool"},key:["resourceId"]},Hooks:{schema:{resourceId:"ResourceId",hooks:"bytes21[]"},key:["resourceId"],codegen:{tableIdArgument:!0}}}});export{o as default};
2
2
  //# sourceMappingURL=mud.config.js.map
@@ -36,7 +36,7 @@ type TableDeployInput = Partial<TableDeploy>;
36
36
  type TableInput = {
37
37
  /**
38
38
  * Human-readable table label. Used as config keys, table library names, and filenames.
39
- * Labels are not length constrained like table names, but special characters should be avoided to be compatible with the filesystem, Solidity compiler, etc.
39
+ * Labels are not length constrained like resource names, but special characters should be avoided to be compatible with the filesystem, Solidity compiler, etc.
40
40
  */
41
41
  readonly label: string;
42
42
  /**
@@ -1,25 +1,8 @@
1
- import { merge, conform, show, requiredKeyOf, ErrorMessage, narrow } from '@arktype/util';
2
- import { a as Scope, A as AbiTypeScope, c as SchemaInput, g as getStaticAbiTypeKeys, h as TableInput, o as TableCodegen, i as TablesInput, U as UserTypes, e as extendScope, E as EnumsInput, j as StoreInput, k as TableShorthandInput, d as ScopedSchemaInput, l as TablesWithShorthandsInput, m as StoreWithShorthandsInput } from './output-672c1950.js';
1
+ import { conform, show, requiredKeyOf, ErrorMessage, narrow } from '@arktype/util';
2
+ import { g as get, m as mergeIfUndefined, p as parseNumber, r as resolveNamespacedTables } from './generics-627f4c31.js';
3
+ import { a as Scope, A as AbiTypeScope, c as SchemaInput, g as getStaticAbiTypeKeys, h as TableInput, o as TableCodegen, i as TablesInput, U as UserTypes, e as extendScope, E as EnumsInput, j as StoreInput, k as TableShorthandInput, d as ScopedSchemaInput, l as TablesWithShorthandsInput, m as StoreWithShorthandsInput } from './output-d041ff5d.js';
3
4
  import { Hex } from 'viem';
4
5
  import { FixedArrayAbiType, fixedArrayToArray } from '@latticexyz/schema-type/internal';
5
- import { r as resolveNamespacedTables } from './namespacedTables-bf676cf3.js';
6
-
7
- type get<input, key> = key extends keyof input ? input[key] : undefined;
8
- declare function get<input, key extends PropertyKey>(input: input, key: key): get<input, key>;
9
- type getPath<input, path extends readonly PropertyKey[]> = path extends readonly [
10
- infer head,
11
- ...infer tail extends PropertyKey[]
12
- ] ? head extends keyof input ? getPath<input[head], tail> : undefined : input;
13
- declare function getPath<input, path extends readonly PropertyKey[]>(input: input, path: path): getPath<input, path>;
14
- declare function hasOwnKey<obj, const key extends PropertyKey>(object: obj, key: key): object is {
15
- [k in key]: k extends keyof obj ? obj[k] : unknown;
16
- } & obj;
17
- declare function isObject<input>(input: input): input is input & object;
18
- type mergeIfUndefined<base, merged> = merge<base, {
19
- [key in keyof merged]: key extends keyof base ? undefined extends base[key] ? merged[key] : base[key] : merged[key];
20
- }>;
21
- declare function mergeIfUndefined<base extends object, merged extends object>(base: base, merged: merged): mergeIfUndefined<base, merged>;
22
- type parseNumber<T> = T extends `${infer N extends number}` ? N : never;
23
6
 
24
7
  declare const CODEGEN_DEFAULTS: {
25
8
  readonly storeImportPath: "@latticexyz/store/src/";
@@ -148,7 +131,7 @@ type validateStore<input> = {
148
131
  [key in keyof input]: key extends "tables" ? validateTables<input[key], extendedScope<input>> : key extends "userTypes" ? UserTypes : key extends "enums" ? narrow<input[key]> : key extends keyof StoreInput ? StoreInput[key] : ErrorMessage<`\`${key & string}\` is not a valid Store config option.`>;
149
132
  };
150
133
  declare function validateStore(input: unknown): asserts input is StoreInput;
151
- type resolveStore<input, namespace = "namespace" extends keyof input ? input["namespace"] : CONFIG_DEFAULTS["namespace"]> = {
134
+ type resolveStore<input, namespace = "namespace" extends keyof input ? input["namespace"] extends string ? input["namespace"] : CONFIG_DEFAULTS["namespace"] : CONFIG_DEFAULTS["namespace"]> = {
152
135
  readonly namespace: namespace;
153
136
  readonly sourceDirectory: "sourceDirectory" extends keyof input ? input["sourceDirectory"] : CONFIG_DEFAULTS["sourceDirectory"];
154
137
  readonly tables: "tables" extends keyof input ? resolveNamespacedTables<{
@@ -216,4 +199,4 @@ type resolveStoreWithShorthands<store> = resolveStore<{
216
199
  declare function resolveStoreWithShorthands<const store extends StoreWithShorthandsInput>(store: store): resolveStoreWithShorthands<store>;
217
200
  declare function defineStoreWithShorthands<const store>(store: validateStoreWithShorthands<store>): resolveStoreWithShorthands<store>;
218
201
 
219
- export { resolveTableCodegen as A, resolveTable as B, defineTable as C, validateTables as D, resolveTables as E, extendedScope as F, validateStore as G, resolveStore as H, defineStore as I, CODEGEN_DEFAULTS as J, TABLE_DEPLOY_DEFAULTS as K, TABLE_DEFAULTS as L, CONFIG_DEFAULTS as M, NoStaticKeyFieldError as N, resolveCodegen as O, scopeWithEnums as P, resolveEnums as Q, mapEnums as R, extractInternalType as S, TABLE_CODEGEN_DEFAULTS as T, isUserTypes as U, ValidKeys as V, scopeWithUserTypes as W, validateUserTypes as X, getPath as a, defineSchema as b, isSchemaInput as c, defineStoreWithShorthands as d, isTableShorthandInput as e, validateTableWithShorthand as f, get as g, hasOwnKey as h, isObject as i, validateTableShorthand as j, resolveTableShorthand as k, defineTableShorthand as l, mergeIfUndefined as m, resolveTableWithShorthand as n, resolveTablesWithShorthands as o, parseNumber as p, validateTablesWithShorthands as q, resolveSchema as r, validateStoreWithShorthands as s, resolveStoreWithShorthands as t, isValidPrimaryKey as u, validateSchema as v, validateKeys as w, ValidateTableOptions as x, requiredTableKey as y, validateTable as z };
202
+ export { validateStore as A, resolveStore as B, defineStore as C, CODEGEN_DEFAULTS as D, TABLE_DEPLOY_DEFAULTS as E, TABLE_DEFAULTS as F, CONFIG_DEFAULTS as G, resolveCodegen as H, scopeWithEnums as I, resolveEnums as J, mapEnums as K, extractInternalType as L, isUserTypes as M, NoStaticKeyFieldError as N, scopeWithUserTypes as O, validateUserTypes as P, TABLE_CODEGEN_DEFAULTS as T, ValidKeys as V, defineSchema as a, isTableShorthandInput as b, validateTableWithShorthand as c, defineStoreWithShorthands as d, validateTableShorthand as e, resolveTableShorthand as f, defineTableShorthand as g, resolveTableWithShorthand as h, isSchemaInput as i, resolveTablesWithShorthands as j, validateTablesWithShorthands as k, validateStoreWithShorthands as l, resolveStoreWithShorthands as m, isValidPrimaryKey as n, validateKeys as o, ValidateTableOptions as p, requiredTableKey as q, resolveSchema as r, validateTable as s, resolveTableCodegen as t, resolveTable as u, validateSchema as v, defineTable as w, validateTables as x, resolveTables as y, extendedScope as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latticexyz/store",
3
- "version": "3.0.0-main-e85dc5349",
3
+ "version": "3.0.0-main-8f6fa588d",
4
4
  "description": "Store",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,9 +14,7 @@
14
14
  "./internal": "./dist/internal.js",
15
15
  "./mud.config": "./dist/mud.config.js",
16
16
  "./codegen": "./dist/codegen.js",
17
- "./config": "./dist/config.js",
18
17
  "./config/v2": "./dist/config/v2.js",
19
- "./register": "./dist/register.js",
20
18
  "./out/*": "./out/*"
21
19
  },
22
20
  "typesVersions": {
@@ -33,14 +31,8 @@
33
31
  "codegen": [
34
32
  "./dist/codegen.d.ts"
35
33
  ],
36
- "config": [
37
- "./dist/config.d.ts"
38
- ],
39
34
  "config/v2": [
40
35
  "./dist/config/v2.d.ts"
41
- ],
42
- "register": [
43
- "./dist/register.d.ts"
44
36
  ]
45
37
  }
46
38
  },
@@ -54,11 +46,10 @@
54
46
  "abitype": "1.0.0",
55
47
  "arktype": "1.0.29-alpha",
56
48
  "viem": "2.9.20",
57
- "zod": "^3.22.2",
58
- "@latticexyz/common": "3.0.0-main-e85dc5349",
59
- "@latticexyz/config": "3.0.0-main-e85dc5349",
60
- "@latticexyz/protocol-parser": "3.0.0-main-e85dc5349",
61
- "@latticexyz/schema-type": "3.0.0-main-e85dc5349"
49
+ "@latticexyz/common": "3.0.0-main-8f6fa588d",
50
+ "@latticexyz/config": "3.0.0-main-8f6fa588d",
51
+ "@latticexyz/protocol-parser": "3.0.0-main-8f6fa588d",
52
+ "@latticexyz/schema-type": "3.0.0-main-8f6fa588d"
62
53
  },
63
54
  "devDependencies": {
64
55
  "@arktype/attest": "0.7.5",
@@ -71,8 +62,8 @@
71
62
  "tsup": "^6.7.0",
72
63
  "tsx": "^3.12.6",
73
64
  "vitest": "0.34.6",
74
- "@latticexyz/abi-ts": "3.0.0-main-e85dc5349",
75
- "@latticexyz/gas-report": "3.0.0-main-e85dc5349"
65
+ "@latticexyz/abi-ts": "3.0.0-main-8f6fa588d",
66
+ "@latticexyz/gas-report": "3.0.0-main-8f6fa588d"
76
67
  },
77
68
  "scripts": {
78
69
  "build": "pnpm run build:tightcoder && pnpm run build:mud && pnpm run build:abi && pnpm run build:abi-ts && pnpm run build:js",
@@ -1,2 +0,0 @@
1
- var l={namespace:"",enums:{},userTypes:{}},c={directory:"tables",keySchema:{key:"bytes32"},tableIdArgument:!1,storeArgument:!1,offchainOnly:!1};import{AbiTypes as E,StaticAbiTypes as v}from"@latticexyz/schema-type/deprecated";import{z as n,ZodIssueCode as i}from"zod";import{getDuplicates as y,parseStaticArray as S,STORE_NAME_MAX_LENGTH as z,zObjectName as T,zUserEnum as R,zValueName as U,zNamespace as k,zName as D}from"@latticexyz/config/library";import{isSchemaAbiType as O,schemaAbiTypes as j}from"@latticexyz/schema-type/internal";var L=T,I=U,_=U,B=T,K=T,g=n.string(),q=n.string(),$=n.record(I,q).default(c.keySchema),b=n.record(_,g).refine(e=>Object.keys(e).length>0,"Table schema may not be empty"),M=g.transform(e=>b.parse({value:e})),P=b.or(M);function pe(e,t){let s={};for(let[r,a]of Object.entries(e))if(O(a))s[r]=a;else if(t[a]!==void 0)s[r]=t[a].internalType;else{let p=S(a);if(!p)throw new Error(`Unexpected type: ${a}`);s[r]=`${p.elementType}[]`}return s}var h=n.object({directory:n.string().default(c.directory),name:D.optional(),tableIdArgument:n.boolean().default(c.tableIdArgument),storeArgument:n.boolean().default(c.storeArgument),dataStruct:n.boolean().optional(),keySchema:$,valueSchema:P,offchainOnly:n.boolean().default(c.offchainOnly)}).transform(e=>(Object.keys(e.valueSchema).length===1?e.dataStruct??=!1:e.dataStruct??=!0,e)),w=g.transform(e=>h.parse({valueSchema:{value:e}})),G=h.or(w),V=n.record(L,G).transform(e=>{for(let t of Object.keys(e)){let s=e[t];s.name=t.slice(0,z),e[t]=s}return e}),H=n.object({enums:n.record(B,R).default(l.enums)}),X=n.object({filePath:n.string(),internalType:n.enum(j)}),Z=n.object({userTypes:n.record(K,X).default(l.userTypes)}),x=n.object({namespace:k.default(l.namespace),tables:V}).merge(H).merge(Z),le=x.superRefine(C),ye=x.catchall(n.any()).superRefine(C);function C(e,t){for(let o of Object.values(e.tables)){let m=Object.keys(o.keySchema),N=Object.keys(o.valueSchema),f=y([...m,...N]);f.length>0&&t.addIssue({code:i.custom,message:`Field and key names within one table must be unique: ${f.join(", ")}`})}let s=Object.keys(e.tables),r=[...Object.keys(e.enums),...Object.keys(e.userTypes)],a=r,p=[...s,...a],d=y(p);d.length>0&&t.addIssue({code:i.custom,message:`Table library names, enum names, user type names must be globally unique: ${d.join(", ")}`});let A=Object.values(e.tables).map(({name:o})=>o),u=y(A);u.length>0&&t.addIssue({code:i.custom,message:`Table names must be unique: ${u.join(", ")}`});for(let o of Object.values(e.tables)){for(let m of Object.values(o.keySchema))F(r,m,t);for(let m of Object.values(o.valueSchema))J(a,r,m,t)}}function J(e,t,s,r){if(!E.includes(s)&&!e.includes(s)){let a=S(s);a?Q(t,a.elementType,a.staticLength,r):r.addIssue({code:i.custom,message:`${s} is not a valid abi type, and is not defined in userTypes`})}}function F(e,t,s){!v.includes(t)&&!e.includes(t)&&s.addIssue({code:i.custom,message:`${t} is not a static type`})}function Q(e,t,s,r){F(e,t,r),s===0?r.addIssue({code:i.custom,message:"Static array length must not be 0"}):s>=2**16&&r.addIssue({code:i.custom,message:"Static array length must be less than 2**16"})}export{l as a,c as b,P as c,pe as d,G as e,V as f,H as g,Z as h,le as i,ye as j};
2
- //# sourceMappingURL=chunk-RRYXNY5P.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../ts/config/defaults.ts","../ts/config/storeConfig.ts"],"sourcesContent":["export const DEFAULTS = {\n namespace: \"\",\n enums: {},\n userTypes: {},\n} as const;\n\nexport type DEFAULTS = typeof DEFAULTS;\n\nexport const TABLE_DEFAULTS = {\n directory: \"tables\",\n keySchema: { key: \"bytes32\" },\n tableIdArgument: false,\n storeArgument: false,\n offchainOnly: false,\n} as const;\n\nexport type TABLE_DEFAULTS = typeof TABLE_DEFAULTS;\n","import { AbiType, AbiTypes, StaticAbiType, StaticAbiTypes, StaticArray } from \"@latticexyz/schema-type/deprecated\";\nimport { RefinementCtx, z, ZodIssueCode } from \"zod\";\nimport type {\n AsDependent,\n ExtractUserTypes,\n OrDefaults,\n RequireKeys,\n StringForUnion,\n} from \"@latticexyz/common/type-utils\";\nimport {\n // validation utils\n getDuplicates,\n parseStaticArray,\n STORE_NAME_MAX_LENGTH,\n // config\n MUDCoreUserConfig,\n // schemas\n zObjectName,\n zUserEnum,\n zValueName,\n zNamespace,\n zName,\n} from \"@latticexyz/config/library\";\nimport { DEFAULTS, TABLE_DEFAULTS } from \"./defaults\";\nimport { UserType } from \"@latticexyz/common/codegen\";\nimport { SchemaAbiType, isSchemaAbiType, schemaAbiTypes } from \"@latticexyz/schema-type/internal\";\n\nconst zTableName = zObjectName;\nconst zKeyName = zValueName;\nconst zColumnName = zValueName;\nconst zUserEnumName = zObjectName;\nconst zUserTypeName = zObjectName;\n\n// Fields can use AbiType or one of user-defined wrapper types\n// (user types are refined later, based on the appropriate config options)\nconst zFieldData = z.string();\n\nexport type FieldData<UserTypes extends StringForUnion> = AbiType | StaticArray | UserTypes;\n\n// Primary keys allow only static types\n// (user types are refined later, based on the appropriate config options)\nconst zKeyElementSchema = z.string();\nconst zKeySchema = z.record(zKeyName, zKeyElementSchema).default(TABLE_DEFAULTS.keySchema);\n\ntype KeySchema<StaticUserTypes extends StringForUnion> = StaticAbiType | StaticUserTypes;\n\n/************************************************************************\n *\n * TABLE SCHEMA\n *\n ************************************************************************/\n\nexport type FullSchemaConfig<UserTypes extends StringForUnion = StringForUnion> = Record<string, FieldData<UserTypes>>;\nexport type ShorthandSchemaConfig<UserTypes extends StringForUnion = StringForUnion> = FieldData<UserTypes>;\nexport type SchemaConfig<UserTypes extends StringForUnion = StringForUnion> =\n | FullSchemaConfig<UserTypes>\n | ShorthandSchemaConfig<UserTypes>;\n\nexport type ExpandSchemaConfig<TSchemaConfig extends SchemaConfig<string>> =\n TSchemaConfig extends ShorthandSchemaConfig<string> ? { value: TSchemaConfig } : TSchemaConfig;\n\nconst zFullSchemaConfig = z\n .record(zColumnName, zFieldData)\n .refine((arg) => Object.keys(arg).length > 0, \"Table schema may not be empty\");\n\nconst zShorthandSchemaConfig = zFieldData.transform((fieldData) => {\n return zFullSchemaConfig.parse({\n value: fieldData,\n });\n});\n\nexport const zSchemaConfig = zFullSchemaConfig.or(zShorthandSchemaConfig);\n\ntype ResolvedSchema<\n TSchema extends Record<string, string>,\n TUserTypes extends Record<string, Pick<UserType, \"internalType\">>,\n> = {\n [key in keyof TSchema]: TSchema[key] extends keyof TUserTypes\n ? TUserTypes[TSchema[key]][\"internalType\"]\n : TSchema[key];\n};\n\n// TODO: add strong types to UserTypes config and use them here\n// (see https://github.com/latticexyz/mud/pull/1588)\nexport function resolveUserTypes<\n TSchema extends Record<string, string>,\n TUserTypes extends Record<string, Pick<UserType, \"internalType\">>,\n>(schema: TSchema, userTypes: TUserTypes): ResolvedSchema<TSchema, TUserTypes> {\n const resolvedSchema: Record<string, SchemaAbiType> = {};\n for (const [key, value] of Object.entries(schema)) {\n if (isSchemaAbiType(value)) {\n resolvedSchema[key] = value;\n } else if (userTypes[value] !== undefined) {\n resolvedSchema[key] = userTypes[value].internalType as SchemaAbiType;\n } else {\n const staticArray = parseStaticArray(value);\n if (!staticArray) throw new Error(`Unexpected type: ${value}`);\n resolvedSchema[key] = `${staticArray.elementType as StaticAbiType}[]`;\n }\n }\n return resolvedSchema as ResolvedSchema<TSchema, TUserTypes>;\n}\n\n/************************************************************************\n *\n * TABLE\n *\n ************************************************************************/\n\nexport interface TableConfig<\n UserTypes extends StringForUnion = StringForUnion,\n StaticUserTypes extends StringForUnion = StringForUnion,\n> {\n /** Output directory path for the file. Default is \"tables\" */\n directory?: string;\n /** Make methods accept `tableId` argument instead of it being a hardcoded constant. Default is false */\n tableIdArgument?: boolean;\n /** Include methods that accept a manual `IStore` argument. Default is true. */\n storeArgument?: boolean;\n /** Include a data struct and methods for it. Default is false for 1-column tables; true for multi-column tables. */\n dataStruct?: boolean;\n /** Offchain tables don't write to onchain storage, but only emit events for offchain clients. Default is false. */\n offchainOnly?: boolean;\n /**\n * Table's key names mapped to their types.\n * Default is `{ key: \"bytes32\" }`\n * Key names' first letter should be lowercase.\n */\n keySchema?: Record<string, KeySchema<StaticUserTypes>>;\n /**\n * Table's field names mapped to their types.\n * Field names' first letter should be lowercase.\n */\n valueSchema: SchemaConfig<UserTypes>;\n}\n\nexport type FullTableConfig<\n UserTypes extends StringForUnion = StringForUnion,\n StaticUserTypes extends StringForUnion = StringForUnion,\n> = Required<TableConfig<UserTypes, StaticUserTypes>> & {\n valueSchema: FullSchemaConfig<UserTypes>;\n};\n\nexport interface ExpandTableConfig<T extends TableConfig<string, string>, TableName extends string>\n extends OrDefaults<\n T,\n {\n directory: string;\n name: TableName;\n tableIdArgument: typeof TABLE_DEFAULTS.tableIdArgument;\n storeArgument: typeof TABLE_DEFAULTS.storeArgument;\n // dataStruct isn't expanded, because its value is conditional on the number of value schema fields\n dataStruct: boolean;\n keySchema: typeof TABLE_DEFAULTS.keySchema;\n offchainOnly: typeof TABLE_DEFAULTS.offchainOnly;\n }\n > {\n valueSchema: ExpandSchemaConfig<T[\"valueSchema\"]>;\n}\n\nconst zFullTableConfig = z\n .object({\n directory: z.string().default(TABLE_DEFAULTS.directory),\n name: zName.optional(),\n tableIdArgument: z.boolean().default(TABLE_DEFAULTS.tableIdArgument),\n storeArgument: z.boolean().default(TABLE_DEFAULTS.storeArgument),\n dataStruct: z.boolean().optional(),\n keySchema: zKeySchema,\n valueSchema: zSchemaConfig,\n offchainOnly: z.boolean().default(TABLE_DEFAULTS.offchainOnly),\n })\n .transform((arg) => {\n // default dataStruct value depends on value schema's length\n if (Object.keys(arg.valueSchema).length === 1) {\n arg.dataStruct ??= false;\n } else {\n arg.dataStruct ??= true;\n }\n return arg as RequireKeys<typeof arg, \"dataStruct\">;\n });\n\nconst zShorthandTableConfig = zFieldData.transform((fieldData) => {\n return zFullTableConfig.parse({\n valueSchema: {\n value: fieldData,\n },\n });\n});\n\nexport const zTableConfig = zFullTableConfig.or(zShorthandTableConfig);\n\n/************************************************************************\n *\n * TABLES\n *\n ************************************************************************/\n\nexport type TablesConfig<\n UserTypes extends StringForUnion = StringForUnion,\n StaticUserTypes extends StringForUnion = StringForUnion,\n> = Record<string, TableConfig<UserTypes, StaticUserTypes> | FieldData<UserTypes>>;\n\nexport const zTablesConfig = z.record(zTableName, zTableConfig).transform((tables) => {\n // default name depends on tableName\n for (const tableName of Object.keys(tables)) {\n const table = tables[tableName];\n table.name = tableName.slice(0, STORE_NAME_MAX_LENGTH);\n\n tables[tableName] = table;\n }\n return tables as Record<string, RequireKeys<(typeof tables)[string], \"name\">>;\n});\n\nexport type FullTablesConfig<\n UserTypes extends StringForUnion = StringForUnion,\n StaticUserTypes extends StringForUnion = StringForUnion,\n> = Record<string, FullTableConfig<UserTypes, StaticUserTypes>>;\n\nexport type ExpandTablesConfig<T extends TablesConfig<string, string>> = {\n [TableName in keyof T]: T[TableName] extends FieldData<string>\n ? ExpandTableConfig<{ valueSchema: { value: T[TableName] } }, TableName extends string ? TableName : never>\n : T[TableName] extends TableConfig<string, string>\n ? ExpandTableConfig<T[TableName], TableName extends string ? TableName : never>\n : // Weakly typed values get a weakly typed expansion.\n // This shouldn't normally happen within `mudConfig`, but can be manually triggered via `ExpandMUDUserConfig`\n ExpandTableConfig<TableConfig<string, string>, TableName extends string ? TableName : string>;\n};\n\n/************************************************************************\n *\n * ENUMS\n *\n ************************************************************************/\n\nexport type EnumsConfig<EnumNames extends StringForUnion> = never extends EnumNames\n ? {\n /**\n * Enum names mapped to lists of their member names\n *\n * (enums are inferred to be absent)\n */\n enums?: Record<EnumNames, string[]>;\n }\n : StringForUnion extends EnumNames\n ? {\n /**\n * Enum names mapped to lists of their member names\n *\n * (enums aren't inferred - use `mudConfig` or `storeConfig` helper, and `as const` for variables)\n */\n enums?: Record<EnumNames, string[]>;\n }\n : {\n /**\n * Enum names mapped to lists of their member names\n *\n * Enums defined here can be used as types in table schemas/keys\n */\n enums: Record<EnumNames, string[]>;\n };\n\nexport type FullEnumsConfig<EnumNames extends StringForUnion> = {\n enums: Record<EnumNames, string[]>;\n};\n\nexport const zEnumsConfig = z.object({\n enums: z.record(zUserEnumName, zUserEnum).default(DEFAULTS.enums),\n});\n\n/************************************************************************\n *\n * USER TYPES\n *\n ************************************************************************/\n\nexport type UserTypesConfig<UserTypeNames extends StringForUnion = StringForUnion> = never extends UserTypeNames\n ? {\n /**\n * User types mapped to file paths from which to import them.\n * Paths are treated as relative to root.\n * Paths that don't start with a \".\" have foundry remappings applied to them first.\n *\n * (user types are inferred to be absent)\n */\n userTypes?: Record<UserTypeNames, UserType>;\n }\n : StringForUnion extends UserTypeNames\n ? {\n /**\n * User types mapped to file paths from which to import them.\n * Paths are treated as relative to root.\n * Paths that don't start with a \".\" have foundry remappings applied to them first.\n *\n * (user types aren't inferred - use `mudConfig` or `storeConfig` helper, and `as const` for variables)\n */\n userTypes?: Record<UserTypeNames, UserType>;\n }\n : {\n /**\n * User types mapped to file paths from which to import them.\n * Paths are treated as relative to root.\n * Paths that don't start with a \".\" have foundry remappings applied to them first.\n *\n * User types defined here can be used as types in table schemas/keys\n */\n userTypes: Record<UserTypeNames, UserType>;\n };\n\nconst zUserTypeConfig = z.object({\n filePath: z.string(),\n internalType: z.enum(schemaAbiTypes),\n});\n\nexport const zUserTypesConfig = z.object({\n userTypes: z.record(zUserTypeName, zUserTypeConfig).default(DEFAULTS.userTypes),\n});\n\n/************************************************************************\n *\n * FINAL\n *\n ************************************************************************/\n\n// zod doesn't preserve doc comments\n/** MUDCoreUserConfig wrapper to use generics in some options for better type inference */\nexport type MUDUserConfig<\n T extends MUDCoreUserConfig = MUDCoreUserConfig,\n EnumNames extends StringForUnion = StringForUnion,\n UserTypeNames extends StringForUnion = StringForUnion,\n StaticUserTypes extends ExtractUserTypes<EnumNames | UserTypeNames> = ExtractUserTypes<EnumNames | UserTypeNames>,\n> = T &\n EnumsConfig<EnumNames> &\n UserTypesConfig<UserTypeNames> & {\n /**\n * Configuration for each table.\n *\n * The key is the table name (capitalized).\n *\n * The value:\n * - abi or user type for a single-value table.\n * - FullTableConfig object for multi-value tables (or for customizable options).\n */\n tables: TablesConfig<AsDependent<StaticUserTypes>, AsDependent<StaticUserTypes>>;\n /** The namespace for table ids. Default is \"\" (ROOT) */\n namespace?: string;\n };\n\nconst StoreConfigUnrefined = z\n .object({\n namespace: zNamespace.default(DEFAULTS.namespace),\n tables: zTablesConfig,\n })\n .merge(zEnumsConfig)\n .merge(zUserTypesConfig);\n\n// finally validate global conditions\nexport const zStoreConfig = StoreConfigUnrefined.superRefine(validateStoreConfig);\n\nexport type StoreUserConfig = z.input<typeof zStoreConfig>;\nexport type StoreConfig = z.output<typeof zStoreConfig>;\n\n// Catchall preserves other plugins' options\nexport const zPluginStoreConfig = StoreConfigUnrefined.catchall(z.any()).superRefine(validateStoreConfig);\n\n/************************************************************************\n *\n * HELPERS\n *\n ************************************************************************/\n\n// Validate conditions that check multiple different config options simultaneously\nfunction validateStoreConfig(config: z.output<typeof StoreConfigUnrefined>, ctx: RefinementCtx) {\n // Local table variables must be unique within the table\n for (const table of Object.values(config.tables)) {\n const keySchemaNames = Object.keys(table.keySchema);\n const fieldNames = Object.keys(table.valueSchema);\n const duplicateVariableNames = getDuplicates([...keySchemaNames, ...fieldNames]);\n if (duplicateVariableNames.length > 0) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Field and key names within one table must be unique: ${duplicateVariableNames.join(\", \")}`,\n });\n }\n }\n // Global names must be unique\n const tableLibraryNames = Object.keys(config.tables);\n const staticUserTypeNames = [...Object.keys(config.enums), ...Object.keys(config.userTypes)];\n const userTypeNames = staticUserTypeNames;\n const globalNames = [...tableLibraryNames, ...userTypeNames];\n const duplicateGlobalNames = getDuplicates(globalNames);\n if (duplicateGlobalNames.length > 0) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Table library names, enum names, user type names must be globally unique: ${duplicateGlobalNames.join(\n \", \",\n )}`,\n });\n }\n // Table names used for tableId must be unique\n const tableNames = Object.values(config.tables).map(({ name }) => name);\n const duplicateTableNames = getDuplicates(tableNames);\n if (duplicateTableNames.length > 0) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Table names must be unique: ${duplicateTableNames.join(\", \")}`,\n });\n }\n // User types must exist\n for (const table of Object.values(config.tables)) {\n for (const keySchemaType of Object.values(table.keySchema)) {\n validateStaticAbiOrUserType(staticUserTypeNames, keySchemaType, ctx);\n }\n for (const fieldType of Object.values(table.valueSchema)) {\n validateAbiOrUserType(userTypeNames, staticUserTypeNames, fieldType, ctx);\n }\n }\n}\n\nfunction validateAbiOrUserType(\n userTypeNames: string[],\n staticUserTypeNames: string[],\n type: string,\n ctx: RefinementCtx,\n) {\n if (!(AbiTypes as string[]).includes(type) && !userTypeNames.includes(type)) {\n const staticArray = parseStaticArray(type);\n if (staticArray) {\n validateStaticArray(staticUserTypeNames, staticArray.elementType, staticArray.staticLength, ctx);\n } else {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `${type} is not a valid abi type, and is not defined in userTypes`,\n });\n }\n }\n}\n\nfunction validateStaticAbiOrUserType(staticUserTypeNames: string[], type: string, ctx: RefinementCtx) {\n if (!(StaticAbiTypes as string[]).includes(type) && !staticUserTypeNames.includes(type)) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `${type} is not a static type`,\n });\n }\n}\n\nfunction validateStaticArray(\n staticUserTypeNames: string[],\n elementType: string,\n staticLength: number,\n ctx: RefinementCtx,\n) {\n validateStaticAbiOrUserType(staticUserTypeNames, elementType, ctx);\n\n if (staticLength === 0) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Static array length must not be 0`,\n });\n } else if (staticLength >= 2 ** 16) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Static array length must be less than 2**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B,OAAO,OAAO3B,EAAM,SAAS,EACvD4B,EAA4BR,EAAqBO,EAAed,CAAG,EAErE,QAAWgB,KAAa,OAAO,OAAO7B,EAAM,WAAW,EACrD8B,EAAsBT,EAAeD,EAAqBS,EAAWhB,CAAG,EAG9E,CAEA,SAASiB,EACPT,EACAD,EACAW,EACAlB,EACA,CACA,GAAI,CAAEmB,EAAsB,SAASD,CAAI,GAAK,CAACV,EAAc,SAASU,CAAI,EAAG,CAC3E,IAAMxC,EAAcC,EAAiBuC,CAAI,EACrCxC,EACF0C,EAAoBb,EAAqB7B,EAAY,YAAaA,EAAY,aAAcsB,CAAG,EAE/FA,EAAI,SAAS,CACX,KAAMK,EAAa,OACnB,QAAS,GAAGa,4DACd,CAAC,EAGP,CAEA,SAASH,EAA4BR,EAA+BW,EAAclB,EAAoB,CAChG,CAAEqB,EAA4B,SAASH,CAAI,GAAK,CAACX,EAAoB,SAASW,CAAI,GACpFlB,EAAI,SAAS,CACX,KAAMK,EAAa,OACnB,QAAS,GAAGa,wBACd,CAAC,CAEL,CAEA,SAASE,EACPb,EACAe,EACAC,EACAvB,EACA,CACAe,EAA4BR,EAAqBe,EAAatB,CAAG,EAE7DuB,IAAiB,EACnBvB,EAAI,SAAS,CACX,KAAMK,EAAa,OACnB,QAAS,mCACX,CAAC,EACQkB,GAAgB,GAAK,IAC9BvB,EAAI,SAAS,CACX,KAAMK,EAAa,OACnB,QAAS,6CACX,CAAC,CAEL","names":["DEFAULTS","TABLE_DEFAULTS","AbiTypes","StaticAbiTypes","z","ZodIssueCode","getDuplicates","parseStaticArray","STORE_NAME_MAX_LENGTH","zObjectName","zUserEnum","zValueName","zNamespace","zName","isSchemaAbiType","schemaAbiTypes","zTableName","zObjectName","zKeyName","zValueName","zColumnName","zUserEnumName","zUserTypeName","zFieldData","z","zKeyElementSchema","zKeySchema","TABLE_DEFAULTS","zFullSchemaConfig","arg","zShorthandSchemaConfig","fieldData","zSchemaConfig","resolveUserTypes","schema","userTypes","resolvedSchema","key","value","staticArray","parseStaticArray","zFullTableConfig","zName","zShorthandTableConfig","zTableConfig","zTablesConfig","tables","tableName","table","STORE_NAME_MAX_LENGTH","zEnumsConfig","zUserEnum","DEFAULTS","zUserTypeConfig","zUserTypesConfig","StoreConfigUnrefined","zNamespace","zStoreConfig","validateStoreConfig","zPluginStoreConfig","config","ctx","keySchemaNames","fieldNames","duplicateVariableNames","getDuplicates","ZodIssueCode","tableLibraryNames","staticUserTypeNames","userTypeNames","globalNames","duplicateGlobalNames","tableNames","name","duplicateTableNames","keySchemaType","validateStaticAbiOrUserType","fieldType","validateAbiOrUserType","type","AbiTypes","validateStaticArray","StaticAbiTypes","elementType","staticLength"]}
@@ -1,2 +0,0 @@
1
- function p(e,t){return typeof e=="object"&&e!=null&&n(e,t)?e[t]:void 0}function F(e,t){return t.length?F(p(e,t[0]),t.slice(1)):e}function n(e,t){return typeof e=="object"&&e!==null&&e.hasOwnProperty(t)}function a(e){return e!=null&&typeof e=="object"}function c(e,t){let s=[...new Set([...Object.keys(e),...Object.keys(t)])];return Object.fromEntries(s.map(o=>[o,e[o]??t[o]]))}var u={storeImportPath:"@latticexyz/store/src/",userTypesFilename:"common.sol",outputDirectory:"codegen",namespaceDirectories:!1,indexFilename:"index.sol"},m={outputDirectory:"tables",tableIdArgument:!1,storeArgument:!1},g={disabled:!1},f={namespace:"",type:"table"},b={sourceDirectory:"src",namespace:""};import{schemaAbiTypes as j}from"@latticexyz/schema-type/internal";var te={types:{}},r={types:Object.fromEntries(j.map(e=>[e,e]))};function l(e,t){return{types:{...e.types,...t}}}import{fixedArrayToArray as N,isFixedArrayAbiType as x}from"@latticexyz/schema-type/internal";function T(e,t=r){if(!a(e))throw new Error(`Expected schema, received ${JSON.stringify(e)}`);for(let s of Object.values(e))if(!x(s)&&!n(t.types,s))throw new Error(`"${String(s)}" is not a valid type in this scope.`)}function S(e,t=r){return Object.fromEntries(Object.entries(e).map(([s,o])=>[s,{type:x(o)?N(o):t.types[o],internalType:o}]))}function ie(e,t=r){return T(e,t),S(e,t)}function ce(e,t=r){return typeof e=="object"&&e!=null&&Object.values(e).every(s=>x(s)||n(t.types,s))}import{isStaticAbiType as h}from"@latticexyz/schema-type/internal";import{resourceToHex as K}from"@latticexyz/common";function $(e,t=r){return Object.entries(e).filter(([,s])=>n(t.types,s)&&h(t.types[s])).map(([s])=>s)}function B(e,t,s=r){return Array.isArray(e)&&e.every(o=>n(t,o)&&n(s.types,t[o])&&h(s.types[t[o]]))}function k(e,t=r,s={inStoreContext:!1}){if(typeof e!="object"||e==null)throw new Error(`Expected full table config, got \`${JSON.stringify(e)}\``);if(!n(e,"schema"))throw new Error("Missing schema input");if(T(e.schema,t),!n(e,"key")||!B(e.key,e.schema,t))throw new Error(`Invalid key. Expected \`(${$(e.schema,t).map(o=>`"${String(o)}"`).join(" | ")})[]\`, received \`${n(e,"key")&&Array.isArray(e.key)?`[${e.key.map(o=>`"${o}"`).join(", ")}]`:String(p(e,"key"))}\``);if(n(e,"namespace")&&typeof e.namespace=="string"&&e.namespace.length>14)throw new Error(`Table \`namespace\` must fit into a \`bytes14\`, but "${e.namespace}" is too long.`);if(n(e,"name")&&typeof e.name=="string"&&e.name.length>16)throw new Error(`Table \`name\` must fit into a \`bytes16\`, but "${e.name}" is too long.`);if(s.inStoreContext&&(n(e,"label")||n(e,"namespace")))throw new Error("Overrides of `label` and `namespace` are not allowed for tables in a store config.")}function G(e){let t=e.codegen;return{outputDirectory:p(t,"outputDirectory")??m.outputDirectory,tableIdArgument:p(t,"tableIdArgument")??m.tableIdArgument,storeArgument:p(t,"storeArgument")??m.storeArgument,dataStruct:p(t,"dataStruct")??Object.keys(e.schema).length-e.key.length>1}}function E(e,t=r){let s=e.label,o=e.type??f.type,i=e.namespace??f.namespace,y=e.name??s.slice(0,16),d=K({type:o,namespace:i,name:y});return{label:s,type:o,namespace:i,name:y,tableId:d,schema:S(e.schema,t),key:e.key,codegen:G(e),deploy:c(e.deploy??{},g)}}function Se(e,t=r){return k(e,t),E(e,t)}function A(e,t){if(a(e)){for(let s of Object.values(e))k(s,t,{inStoreContext:!0});return}throw new Error(`Expected store config, received ${JSON.stringify(e)}`)}function v(e,t){if(!a(e))throw new Error(`Expected tables config, received ${JSON.stringify(e)}`);return Object.fromEntries(Object.entries(e).map(([s,o])=>[s,E(c(o,{label:s}),t)]))}import{mapObject as P}from"@latticexyz/common/utils";import{isSchemaAbiType as M}from"@latticexyz/schema-type/internal";function V(e){return P(e,t=>t.type)}function W(e){return a(e)&&Object.values(e).every(t=>M(t.type))}function I(e,t=r){return W(e)?l(t,V(e)):t}function D(e){if(!a(e))throw new Error(`Expected userTypes, received ${JSON.stringify(e)}`);for(let{type:t}of Object.values(e))if(!n(r.types,t))throw new Error(`"${String(t)}" is not a valid ABI type.`)}import{flatMorph as O}from"@arktype/util";function J(e){return typeof e=="object"&&e!=null&&Object.values(e).every(t=>Array.isArray(t)&&t.every(s=>typeof s=="string"))}function w(e,t=r){if(J(e)){let s=Object.fromEntries(Object.keys(e).map(o=>[o,"uint8"]));return l(t,s)}return t}function Y(e){return e}function U(e){return O(e,(t,s)=>[t,O(s,(o,i)=>[i,o])])}function L(e){return a(e)?c(e,u):u}import{flatMorph as q}from"@arktype/util";function _(e,t){return q(e,(s,o)=>[t===""?s:`${t}__${s}`,o])}import{flatMorph as H}from"@arktype/util";function C(e){return w(p(e,"enums"),I(p(e,"userTypes")))}function R(e){let t=C(e);n(e,"tables")&&A(e.tables,t),n(e,"userTypes")&&D(e.userTypes)}function z(e){let t=C(e),s=e.namespace??b.namespace,o=L(e.codegen),i=v(H(e.tables??{},(y,d)=>[y,{...d,label:y,namespace:s,codegen:{...d.codegen,outputDirectory:d.codegen?.outputDirectory??(o.namespaceDirectories&&s!==""?`${s}/tables`:"tables")}}]),t);return{namespace:s,sourceDirectory:e.sourceDirectory??b.sourceDirectory,tables:_(i,s),userTypes:e.userTypes??{},enums:e.enums??{},enumValues:U(e.enums??{}),codegen:o}}function Re(e){return R(e),z(e)}export{p as a,F as b,n as c,a as d,c as e,u as f,m as g,g as h,f as i,b as j,te as k,r as l,l as m,T as n,S as o,ie as p,ce as q,B as r,k as s,G as t,E as u,Se as v,A as w,v as x,V as y,W as z,I as A,D as B,w as C,Y as D,U as E,L as F,_ as G,C as H,R as I,z as J,Re as K};
2
- //# sourceMappingURL=chunk-YSCNU2IH.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../ts/config/v2/generics.ts","../ts/config/v2/defaults.ts","../ts/config/v2/scope.ts","../ts/config/v2/schema.ts","../ts/config/v2/table.ts","../ts/config/v2/tables.ts","../ts/config/v2/userTypes.ts","../ts/config/v2/enums.ts","../ts/config/v2/codegen.ts","../ts/config/v2/namespacedTables.ts","../ts/config/v2/store.ts"],"sourcesContent":["import { merge } from \"@arktype/util\";\n\nexport type get<input, key> = key extends keyof input ? input[key] : undefined;\n\nexport function get<input, key extends PropertyKey>(input: input, key: key): get<input, key> {\n return (typeof input === \"object\" && input != null && hasOwnKey(input, key) ? input[key] : undefined) as never;\n}\n\nexport type getPath<input, path extends readonly PropertyKey[]> = path extends readonly [\n infer head,\n ...infer tail extends PropertyKey[],\n]\n ? head extends keyof input\n ? getPath<input[head], tail>\n : undefined\n : input;\n\nexport function getPath<input, path extends readonly PropertyKey[]>(input: input, path: path): getPath<input, path> {\n return path.length ? (getPath(get(input, path[0]), path.slice(1)) as never) : (input as never);\n}\n\nexport function hasOwnKey<obj, const key extends PropertyKey>(\n object: obj,\n key: key,\n): object is { [k in key]: k extends keyof obj ? obj[k] : unknown } & obj {\n // eslint-disable-next-line no-prototype-builtins\n return typeof object === \"object\" && object !== null && object.hasOwnProperty(key);\n}\n\nexport function isObject<input>(input: input): input is input & object {\n return input != null && typeof input === \"object\";\n}\n\nexport type mergeIfUndefined<base, merged> = merge<\n base,\n {\n [key in keyof merged]: key extends keyof base\n ? undefined extends base[key]\n ? merged[key]\n : base[key]\n : merged[key];\n }\n>;\n\nexport function mergeIfUndefined<base extends object, merged extends object>(\n base: base,\n merged: merged,\n): mergeIfUndefined<base, merged> {\n const allKeys = [...new Set([...Object.keys(base), ...Object.keys(merged)])];\n return Object.fromEntries(\n allKeys.map((key) => [key, base[key as keyof base] ?? merged[key as keyof merged]]),\n ) as never;\n}\n\nexport type parseNumber<T> = T extends `${infer N extends number}` ? N : never;\n","import { CodegenInput, StoreInput, TableCodegenInput, TableDeployInput, TableInput } from \"./input\";\n\nexport const CODEGEN_DEFAULTS = {\n storeImportPath: \"@latticexyz/store/src/\",\n userTypesFilename: \"common.sol\",\n outputDirectory: \"codegen\",\n // TODO: default to true if using top-level `namespaces` key (once its migrated to store)\n namespaceDirectories: false,\n indexFilename: \"index.sol\",\n} as const satisfies CodegenInput;\n\nexport type CODEGEN_DEFAULTS = typeof CODEGEN_DEFAULTS;\n\nexport const TABLE_CODEGEN_DEFAULTS = {\n outputDirectory: \"tables\" as string,\n tableIdArgument: false,\n storeArgument: false,\n} as const satisfies TableCodegenInput;\n\nexport type TABLE_CODEGEN_DEFAULTS = typeof TABLE_CODEGEN_DEFAULTS;\n\nexport const TABLE_DEPLOY_DEFAULTS = {\n disabled: false,\n} as const satisfies TableDeployInput;\n\nexport type TABLE_DEPLOY_DEFAULTS = typeof TABLE_DEPLOY_DEFAULTS;\n\nexport const TABLE_DEFAULTS = {\n namespace: \"\",\n type: \"table\",\n} as const satisfies Pick<TableInput, \"namespace\" | \"type\">;\n\nexport type TABLE_DEFAULTS = typeof TABLE_DEFAULTS;\n\nexport const CONFIG_DEFAULTS = {\n sourceDirectory: \"src\",\n namespace: \"\",\n} as const satisfies StoreInput;\n\nexport type CONFIG_DEFAULTS = typeof CONFIG_DEFAULTS;\n","import { Dict, show } from \"@arktype/util\";\nimport { SchemaInput } from \"./input\";\nimport { StaticAbiType, schemaAbiTypes } from \"@latticexyz/schema-type/internal\";\nimport { AbiType } from \"./output\";\n\nexport const Scope = { types: {} } as const satisfies ScopeOptions;\nexport type Scope = typeof Scope;\n\nexport type AbiTypeScope = ScopeOptions<{ [t in AbiType]: t }>;\nexport const AbiTypeScope = {\n types: Object.fromEntries(schemaAbiTypes.map((abiType) => [abiType, abiType])),\n} as AbiTypeScope;\n\nexport type ScopeOptions<types extends Dict<string, AbiType> = Dict<string, AbiType>> = {\n types: types;\n};\n\nexport type getStaticAbiTypeKeys<\n schema extends SchemaInput,\n scope extends Scope = AbiTypeScope,\n> = SchemaInput extends schema\n ? string\n : {\n [key in keyof schema]: scope[\"types\"] extends { [_ in schema[key]]: StaticAbiType } ? key : never;\n }[keyof schema];\n\nexport type extendScope<scope extends ScopeOptions, additionalTypes extends Dict<string, AbiType>> = show<\n ScopeOptions<show<scope[\"types\"] & additionalTypes>>\n>;\n\nexport function extendScope<scope extends ScopeOptions, additionalTypes extends Dict<string, AbiType>>(\n scope: scope,\n additionalTypes: additionalTypes,\n): extendScope<scope, additionalTypes> {\n return {\n types: {\n ...scope.types,\n ...additionalTypes,\n },\n };\n}\n","import { conform, show } from \"@arktype/util\";\nimport { AbiTypeScope, Scope } from \"./scope\";\nimport { hasOwnKey, isObject } from \"./generics\";\nimport { SchemaInput } from \"./input\";\nimport { FixedArrayAbiType, fixedArrayToArray, isFixedArrayAbiType } from \"@latticexyz/schema-type/internal\";\n\nexport type validateSchema<schema, scope extends Scope = AbiTypeScope> = schema extends string\n ? SchemaInput\n : {\n [key in keyof schema]: schema[key] extends FixedArrayAbiType\n ? schema[key]\n : conform<schema[key], keyof scope[\"types\"]>;\n };\n\nexport function validateSchema<scope extends Scope = AbiTypeScope>(\n schema: unknown,\n scope: scope = AbiTypeScope as never,\n): asserts schema is SchemaInput {\n if (!isObject(schema)) {\n throw new Error(`Expected schema, received ${JSON.stringify(schema)}`);\n }\n\n for (const internalType of Object.values(schema)) {\n if (isFixedArrayAbiType(internalType)) continue;\n if (hasOwnKey(scope.types, internalType)) continue;\n throw new Error(`\"${String(internalType)}\" is not a valid type in this scope.`);\n }\n}\n\nexport type resolveSchema<schema, scope extends Scope> = show<{\n readonly [key in keyof schema]: {\n /** the Solidity primitive ABI type */\n readonly type: schema[key] extends FixedArrayAbiType\n ? fixedArrayToArray<schema[key]>\n : scope[\"types\"][schema[key] & keyof scope[\"types\"]];\n /** the user defined type or Solidity primitive ABI type */\n readonly internalType: schema[key];\n };\n}>;\n\nexport function resolveSchema<schema extends SchemaInput, scope extends Scope = AbiTypeScope>(\n schema: schema,\n scope: scope = AbiTypeScope as unknown as scope,\n): resolveSchema<schema, scope> {\n return Object.fromEntries(\n Object.entries(schema).map(([key, internalType]) => [\n key,\n {\n type: isFixedArrayAbiType(internalType) ? fixedArrayToArray(internalType) : scope.types[internalType as never],\n internalType,\n },\n ]),\n ) as never;\n}\n\nexport function defineSchema<schema, scope extends AbiTypeScope = AbiTypeScope>(\n schema: validateSchema<schema, scope>,\n scope: scope = AbiTypeScope as scope,\n): resolveSchema<schema, scope> {\n validateSchema(schema, scope);\n return resolveSchema(schema, scope) as never;\n}\n\nexport function isSchemaInput<scope extends Scope = AbiTypeScope>(\n input: unknown,\n scope: scope = AbiTypeScope as never,\n): input is SchemaInput {\n return (\n typeof input === \"object\" &&\n input != null &&\n Object.values(input).every((fieldType) => isFixedArrayAbiType(fieldType) || hasOwnKey(scope.types, fieldType))\n );\n}\n","import { ErrorMessage, conform, show, narrow, requiredKeyOf } from \"@arktype/util\";\nimport { isStaticAbiType } from \"@latticexyz/schema-type/internal\";\nimport { Hex } from \"viem\";\nimport { get, hasOwnKey, mergeIfUndefined } from \"./generics\";\nimport { resolveSchema, validateSchema } from \"./schema\";\nimport { AbiTypeScope, Scope, getStaticAbiTypeKeys } from \"./scope\";\nimport { TableCodegen } from \"./output\";\nimport { TABLE_CODEGEN_DEFAULTS, TABLE_DEFAULTS, TABLE_DEPLOY_DEFAULTS } from \"./defaults\";\nimport { resourceToHex } from \"@latticexyz/common\";\nimport { SchemaInput, TableInput } from \"./input\";\n\nexport type ValidKeys<schema extends SchemaInput, scope extends Scope> = readonly [\n getStaticAbiTypeKeys<schema, scope>,\n ...getStaticAbiTypeKeys<schema, scope>[],\n];\n\nfunction getValidKeys<schema extends SchemaInput, scope extends Scope = AbiTypeScope>(\n schema: schema,\n scope: scope = AbiTypeScope as unknown as scope,\n): ValidKeys<schema, scope> {\n return Object.entries(schema)\n .filter(([, internalType]) => hasOwnKey(scope.types, internalType) && isStaticAbiType(scope.types[internalType]))\n .map(([key]) => key) as never;\n}\n\nexport function isValidPrimaryKey<schema extends SchemaInput, scope extends Scope>(\n key: unknown,\n schema: schema,\n scope: scope = AbiTypeScope as unknown as scope,\n): key is ValidKeys<schema, scope> {\n return (\n Array.isArray(key) &&\n key.every(\n (key) =>\n hasOwnKey(schema, key) && hasOwnKey(scope.types, schema[key]) && isStaticAbiType(scope.types[schema[key]]),\n )\n );\n}\n\nexport type validateKeys<validKeys extends PropertyKey, keys> = keys extends readonly string[]\n ? {\n readonly [i in keyof keys]: keys[i] extends validKeys ? keys[i] : validKeys;\n }\n : readonly string[];\n\nexport type ValidateTableOptions = { inStoreContext: boolean };\n\nexport type requiredTableKey<inStoreContext extends boolean> = Exclude<\n requiredKeyOf<TableInput>,\n inStoreContext extends true ? \"label\" | \"namespace\" : \"\"\n>;\n\nexport type validateTable<\n input,\n scope extends Scope = AbiTypeScope,\n options extends ValidateTableOptions = { inStoreContext: false },\n> = {\n [key in keyof input | requiredTableKey<options[\"inStoreContext\"]>]: key extends \"key\"\n ? validateKeys<getStaticAbiTypeKeys<conform<get<input, \"schema\">, SchemaInput>, scope>, get<input, key>>\n : key extends \"schema\"\n ? validateSchema<get<input, key>, scope>\n : key extends \"label\" | \"namespace\"\n ? options[\"inStoreContext\"] extends true\n ? ErrorMessage<\"Overrides of `label` and `namespace` are not allowed for tables in a store config\">\n : key extends keyof input\n ? narrow<input[key]>\n : never\n : key extends keyof TableInput\n ? TableInput[key]\n : ErrorMessage<`Key \\`${key & string}\\` does not exist in TableInput`>;\n};\n\nexport function validateTable<input, scope extends Scope = AbiTypeScope>(\n input: input,\n scope: scope = AbiTypeScope as unknown as scope,\n options: ValidateTableOptions = { inStoreContext: false },\n): asserts input is TableInput & input {\n if (typeof input !== \"object\" || input == null) {\n throw new Error(`Expected full table config, got \\`${JSON.stringify(input)}\\``);\n }\n\n if (!hasOwnKey(input, \"schema\")) {\n throw new Error(\"Missing schema input\");\n }\n validateSchema(input.schema, scope);\n\n if (!hasOwnKey(input, \"key\") || !isValidPrimaryKey(input[\"key\"], input[\"schema\"], scope)) {\n throw new Error(\n `Invalid key. Expected \\`(${getValidKeys(input[\"schema\"], scope)\n .map((item) => `\"${String(item)}\"`)\n .join(\" | \")})[]\\`, received \\`${\n hasOwnKey(input, \"key\") && Array.isArray(input.key)\n ? `[${input.key.map((item) => `\"${item}\"`).join(\", \")}]`\n : String(get(input, \"key\"))\n }\\``,\n );\n }\n\n if (hasOwnKey(input, \"namespace\") && typeof input.namespace === \"string\" && input.namespace.length > 14) {\n throw new Error(`Table \\`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(`Table \\`name\\` must fit into a \\`bytes16\\`, but \"${input.name}\" is too long.`);\n }\n\n if (options.inStoreContext && (hasOwnKey(input, \"label\") || hasOwnKey(input, \"namespace\"))) {\n throw new Error(\"Overrides of `label` and `namespace` are not allowed for tables in a store config.\");\n }\n}\n\nexport type resolveTableCodegen<input extends TableInput> = show<{\n [key in keyof TableCodegen]-?: key extends keyof input[\"codegen\"]\n ? undefined extends input[\"codegen\"][key]\n ? key extends \"dataStruct\"\n ? boolean\n : key extends keyof TABLE_CODEGEN_DEFAULTS\n ? TABLE_CODEGEN_DEFAULTS[key]\n : never\n : input[\"codegen\"][key]\n : // dataStruct isn't narrowed, because its value is conditional on the number of value schema fields\n key extends \"dataStruct\"\n ? boolean\n : key extends keyof TABLE_CODEGEN_DEFAULTS\n ? TABLE_CODEGEN_DEFAULTS[key]\n : never;\n}>;\n\nexport function resolveTableCodegen<input extends TableInput>(input: input): resolveTableCodegen<input> {\n const options = input.codegen;\n return {\n outputDirectory: get(options, \"outputDirectory\") ?? TABLE_CODEGEN_DEFAULTS.outputDirectory,\n tableIdArgument: get(options, \"tableIdArgument\") ?? TABLE_CODEGEN_DEFAULTS.tableIdArgument,\n storeArgument: get(options, \"storeArgument\") ?? TABLE_CODEGEN_DEFAULTS.storeArgument,\n // dataStruct is true if there are at least 2 value fields\n dataStruct: get(options, \"dataStruct\") ?? Object.keys(input.schema).length - input.key.length > 1,\n } satisfies TableCodegen as never;\n}\n\nexport type resolveTable<input, scope extends Scope = Scope> = input extends TableInput\n ? {\n readonly label: input[\"label\"];\n readonly type: undefined extends input[\"type\"] ? typeof TABLE_DEFAULTS.type : input[\"type\"];\n readonly namespace: undefined extends input[\"namespace\"] ? typeof TABLE_DEFAULTS.namespace : input[\"namespace\"];\n readonly name: string;\n readonly tableId: Hex;\n readonly schema: resolveSchema<input[\"schema\"], scope>;\n readonly key: Readonly<input[\"key\"]>;\n readonly codegen: resolveTableCodegen<input>;\n readonly deploy: mergeIfUndefined<\n undefined extends input[\"deploy\"] ? {} : input[\"deploy\"],\n TABLE_DEPLOY_DEFAULTS\n >;\n }\n : never;\n\nexport function resolveTable<input extends TableInput, scope extends Scope = AbiTypeScope>(\n input: input,\n scope: scope = AbiTypeScope as unknown as scope,\n): resolveTable<input, scope> {\n const label = input.label;\n const type = input.type ?? TABLE_DEFAULTS.type;\n const namespace = input.namespace ?? TABLE_DEFAULTS.namespace;\n const name = input.name ?? label.slice(0, 16);\n const tableId = resourceToHex({ type, namespace, name });\n\n return {\n label,\n type,\n namespace,\n name,\n tableId,\n schema: resolveSchema(input.schema, scope),\n key: input.key,\n codegen: resolveTableCodegen(input),\n deploy: mergeIfUndefined(input.deploy ?? {}, TABLE_DEPLOY_DEFAULTS),\n } as never;\n}\n\nexport function defineTable<input, scope extends Scope = AbiTypeScope>(\n input: validateTable<input, scope>,\n scope: scope = AbiTypeScope as unknown as scope,\n): resolveTable<input, scope> {\n validateTable(input, scope);\n return resolveTable(input, scope) as never;\n}\n","import { ErrorMessage, show } from \"@arktype/util\";\nimport { isObject, mergeIfUndefined } from \"./generics\";\nimport { TablesInput } from \"./input\";\nimport { Scope, AbiTypeScope } from \"./scope\";\nimport { validateTable, resolveTable } from \"./table\";\n\nexport type validateTables<tables, scope extends Scope = AbiTypeScope> = {\n [label in keyof tables]: tables[label] extends object\n ? validateTable<tables[label], scope, { inStoreContext: true }>\n : ErrorMessage<`Expected full table config.`>;\n};\n\nexport function validateTables<scope extends Scope = AbiTypeScope>(\n input: unknown,\n scope: scope,\n): asserts input is TablesInput {\n if (isObject(input)) {\n for (const table of Object.values(input)) {\n validateTable(table, scope, { inStoreContext: true });\n }\n return;\n }\n throw new Error(`Expected store config, received ${JSON.stringify(input)}`);\n}\n\nexport type resolveTables<tables, scope extends Scope = AbiTypeScope> = show<{\n readonly [label in keyof tables]: resolveTable<mergeIfUndefined<tables[label], { label: label }>, scope>;\n}>;\n\nexport function resolveTables<tables extends TablesInput, scope extends Scope = AbiTypeScope>(\n tables: tables,\n scope: scope,\n): resolveTables<tables, scope> {\n if (!isObject(tables)) {\n throw new Error(`Expected tables config, received ${JSON.stringify(tables)}`);\n }\n\n return Object.fromEntries(\n Object.entries(tables).map(([label, table]) => {\n return [label, resolveTable(mergeIfUndefined(table, { label }), scope)];\n }),\n ) as never;\n}\n","import { mapObject } from \"@latticexyz/common/utils\";\nimport { UserTypes } from \"./output\";\nimport { isSchemaAbiType } from \"@latticexyz/schema-type/internal\";\nimport { AbiTypeScope, extendScope } from \"./scope\";\nimport { hasOwnKey, isObject } from \"./generics\";\n\nexport type extractInternalType<userTypes extends UserTypes> = { [key in keyof userTypes]: userTypes[key][\"type\"] };\n\nexport function extractInternalType<userTypes extends UserTypes>(userTypes: userTypes): extractInternalType<userTypes> {\n return mapObject(userTypes, (userType) => userType.type);\n}\n\nexport function isUserTypes(userTypes: unknown): userTypes is UserTypes {\n return isObject(userTypes) && Object.values(userTypes).every((userType) => isSchemaAbiType(userType.type));\n}\n\nexport type scopeWithUserTypes<userTypes, scope extends AbiTypeScope = AbiTypeScope> = UserTypes extends userTypes\n ? scope\n : userTypes extends UserTypes\n ? extendScope<scope, extractInternalType<userTypes>>\n : scope;\n\nexport function scopeWithUserTypes<userTypes, scope extends AbiTypeScope = AbiTypeScope>(\n userTypes: userTypes,\n scope: scope = AbiTypeScope as scope,\n): scopeWithUserTypes<userTypes, scope> {\n return (isUserTypes(userTypes) ? extendScope(scope, extractInternalType(userTypes)) : scope) as never;\n}\n\nexport function validateUserTypes(userTypes: unknown): asserts userTypes is UserTypes {\n if (!isObject(userTypes)) {\n throw new Error(`Expected userTypes, received ${JSON.stringify(userTypes)}`);\n }\n\n for (const { type } of Object.values(userTypes)) {\n if (!hasOwnKey(AbiTypeScope.types, type)) {\n throw new Error(`\"${String(type)}\" is not a valid ABI type.`);\n }\n }\n}\n","import { flatMorph } from \"@arktype/util\";\nimport { EnumsInput } from \"./input\";\nimport { AbiTypeScope, extendScope } from \"./scope\";\nimport { parseNumber } from \"./generics\";\n\nfunction isEnums(enums: unknown): enums is EnumsInput {\n return (\n typeof enums === \"object\" &&\n enums != null &&\n Object.values(enums).every((item) => Array.isArray(item) && item.every((element) => typeof element === \"string\"))\n );\n}\n\nexport type scopeWithEnums<enums, scope extends AbiTypeScope = AbiTypeScope> = EnumsInput extends enums\n ? scope\n : enums extends EnumsInput\n ? extendScope<scope, { [key in keyof enums]: \"uint8\" }>\n : scope;\n\nexport function scopeWithEnums<enums, scope extends AbiTypeScope = AbiTypeScope>(\n enums: enums,\n scope: scope = AbiTypeScope as scope,\n): scopeWithEnums<enums, scope> {\n if (isEnums(enums)) {\n const enumScope = Object.fromEntries(Object.keys(enums).map((key) => [key, \"uint8\" as const]));\n return extendScope(scope, enumScope) as never;\n }\n return scope as never;\n}\n\nexport type resolveEnums<enums> = {\n readonly [key in keyof enums]: Readonly<enums[key]>;\n};\n\nexport function resolveEnums<enums extends EnumsInput>(enums: enums): resolveEnums<enums> {\n return enums;\n}\n\nexport type mapEnums<enums> = {\n readonly [key in keyof enums]: {\n readonly [element in keyof enums[key] as enums[key][element] & string]: parseNumber<element>;\n };\n};\n\nexport function mapEnums<enums extends EnumsInput>(enums: enums): resolveEnums<enums> {\n return flatMorph(enums as EnumsInput, (enumName, enumElements) => [\n enumName,\n flatMorph(enumElements, (enumIndex, enumElement) => [enumElement, enumIndex]),\n ]) as never;\n}\n","import { CODEGEN_DEFAULTS } from \"./defaults\";\nimport { isObject, mergeIfUndefined } from \"./generics\";\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 (\n isObject(codegen) ? mergeIfUndefined(codegen, CODEGEN_DEFAULTS) : CODEGEN_DEFAULTS\n ) as resolveCodegen<codegen>;\n}\n","import { flatMorph } from \"@arktype/util\";\nimport { Tables } from \"./output\";\n\n/**\n * @internal Only kept for backwards compatibility\n */\nexport type resolveNamespacedTables<tables, namespace> = {\n readonly [label in keyof tables as namespace extends \"\"\n ? label\n : `${namespace & string}__${label & string}`]: tables[label];\n};\n\n/**\n * @internal Only kept for backwards compatibility\n */\nexport function resolveNamespacedTables<tables, namespace>(\n tables: tables,\n namespace: namespace,\n): resolveNamespacedTables<tables, namespace> {\n return flatMorph(tables as Tables, (label, table) => [\n namespace === \"\" ? label : `${namespace}__${label}`,\n table,\n ]) as never;\n}\n","import { ErrorMessage, show, flatMorph, narrow } from \"@arktype/util\";\nimport { get, hasOwnKey, mergeIfUndefined } from \"./generics\";\nimport { UserTypes } from \"./output\";\nimport { CONFIG_DEFAULTS } from \"./defaults\";\nimport { StoreInput } from \"./input\";\nimport { resolveTables, validateTables } from \"./tables\";\nimport { scopeWithUserTypes, validateUserTypes } from \"./userTypes\";\nimport { mapEnums, resolveEnums, scopeWithEnums } from \"./enums\";\nimport { resolveCodegen } from \"./codegen\";\nimport { resolveNamespacedTables } from \"./namespacedTables\";\nimport { resolveTable } from \"./table\";\n\nexport type extendedScope<input> = scopeWithEnums<get<input, \"enums\">, scopeWithUserTypes<get<input, \"userTypes\">>>;\n\nexport function extendedScope<input>(input: input): extendedScope<input> {\n return scopeWithEnums(get(input, \"enums\"), scopeWithUserTypes(get(input, \"userTypes\")));\n}\n\nexport type validateStore<input> = {\n [key in keyof input]: key extends \"tables\"\n ? validateTables<input[key], extendedScope<input>>\n : key extends \"userTypes\"\n ? UserTypes\n : key extends \"enums\"\n ? narrow<input[key]>\n : key extends keyof StoreInput\n ? StoreInput[key]\n : ErrorMessage<`\\`${key & string}\\` is not a valid Store config option.`>;\n};\n\nexport function validateStore(input: unknown): asserts input is StoreInput {\n const scope = extendedScope(input);\n if (hasOwnKey(input, \"tables\")) {\n validateTables(input.tables, scope);\n }\n\n if (hasOwnKey(input, \"userTypes\")) {\n validateUserTypes(input.userTypes);\n }\n}\n\nexport type resolveStore<\n input,\n namespace = \"namespace\" extends keyof input ? input[\"namespace\"] : CONFIG_DEFAULTS[\"namespace\"],\n> = {\n readonly namespace: namespace;\n readonly sourceDirectory: \"sourceDirectory\" extends keyof input\n ? input[\"sourceDirectory\"]\n : CONFIG_DEFAULTS[\"sourceDirectory\"];\n readonly tables: \"tables\" extends keyof input\n ? resolveNamespacedTables<\n {\n readonly [label in keyof input[\"tables\"]]: resolveTable<\n mergeIfUndefined<input[\"tables\"][label], { label: label; namespace: namespace }>,\n extendedScope<input>\n >;\n },\n namespace\n >\n : {};\n readonly userTypes: \"userTypes\" extends keyof input ? input[\"userTypes\"] : {};\n readonly enums: \"enums\" extends keyof input ? show<resolveEnums<input[\"enums\"]>> : {};\n readonly enumValues: \"enums\" extends keyof input ? show<mapEnums<input[\"enums\"]>> : {};\n readonly codegen: \"codegen\" extends keyof input ? resolveCodegen<input[\"codegen\"]> : resolveCodegen<{}>;\n};\n\nexport function resolveStore<const input extends StoreInput>(input: input): resolveStore<input> {\n const scope = extendedScope(input);\n const namespace = input.namespace ?? CONFIG_DEFAULTS[\"namespace\"];\n const codegen = resolveCodegen(input.codegen);\n\n const tables = resolveTables(\n flatMorph(input.tables ?? {}, (label, table) => {\n return [\n label,\n {\n ...table,\n label,\n namespace,\n codegen: {\n ...table.codegen,\n outputDirectory:\n table.codegen?.outputDirectory ??\n (codegen.namespaceDirectories && namespace !== \"\" ? `${namespace}/tables` : \"tables\"),\n },\n },\n ];\n }),\n scope,\n );\n\n return {\n namespace,\n sourceDirectory: input.sourceDirectory ?? CONFIG_DEFAULTS[\"sourceDirectory\"],\n tables: resolveNamespacedTables(tables, namespace),\n userTypes: input.userTypes ?? {},\n enums: resolveEnums(input.enums ?? {}),\n enumValues: mapEnums(input.enums ?? {}),\n codegen,\n } as never;\n}\n\nexport function defineStore<const input>(input: validateStore<input>): show<resolveStore<input>> {\n validateStore(input);\n return resolveStore(input) as never;\n}\n"],"mappings":"AAIO,SAASA,EAAoCC,EAAcC,EAA2B,CAC3F,OAAQ,OAAOD,GAAU,UAAYA,GAAS,MAAQE,EAAUF,EAAOC,CAAG,EAAID,EAAMC,CAAG,EAAI,MAC7F,CAWO,SAASE,EAAoDH,EAAcI,EAAkC,CAClH,OAAOA,EAAK,OAAUD,EAAQJ,EAAIC,EAAOI,EAAK,CAAC,CAAC,EAAGA,EAAK,MAAM,CAAC,CAAC,EAAeJ,CACjF,CAEO,SAASE,EACdG,EACAJ,EACwE,CAExE,OAAO,OAAOI,GAAW,UAAYA,IAAW,MAAQA,EAAO,eAAeJ,CAAG,CACnF,CAEO,SAASK,EAAgBN,EAAuC,CACrE,OAAOA,GAAS,MAAQ,OAAOA,GAAU,QAC3C,CAaO,SAASO,EACdC,EACAC,EACgC,CAChC,IAAMC,EAAU,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,OAAO,KAAKF,CAAI,EAAG,GAAG,OAAO,KAAKC,CAAM,CAAC,CAAC,CAAC,EAC3E,OAAO,OAAO,YACZC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ACF,CAAC,CACH,CCvBA,OAA6B,aAAAC,MAAyB,gBAc/C,SAASC,EAAqBC,EAAoC,CACvE,OAAOC,EAAeC,EAAIF,EAAO,OAAO,EAAGG,EAAmBD,EAAIF,EAAO,WAAW,CAAC,CAAC,CACxF,CAcO,SAASI,EAAcJ,EAA6C,CACzE,IAAMK,EAAQN,EAAcC,CAAK,EAC7BM,EAAUN,EAAO,QAAQ,GAC3BO,EAAeP,EAAM,OAAQK,CAAK,EAGhCC,EAAUN,EAAO,WAAW,GAC9BQ,EAAkBR,EAAM,SAAS,CAErC,CA2BO,SAASS,EAA6CT,EAAmC,CAC9F,IAAMK,EAAQN,EAAcC,CAAK,EAC3BU,EAAYV,EAAM,WAAaW,EAAgB,UAC/CC,EAAUC,EAAeb,EAAM,OAAO,EAEtCc,EAASC,EACbC,EAAUhB,EAAM,QAAU,CAAC,EAAG,CAACiB,EAAOC,IAC7B,CACLD,EACA,CACE,GAAGC,EACH,MAAAD,EACA,UAAAP,EACA,QAAS,CACP,GAAGQ,EAAM,QACT,gBACEA,EAAM,SAAS,kBACdN,EAAQ,sBAAwBF,IAAc,GAAK,GAAGA,WAAqB,SAChF,CACF,CACF,CACD,EACDL,CACF,EAEA,MAAO,CACL,UAAAK,EACA,gBAAiBV,EAAM,iBAAmBW,EAAgB,gBAC1D,OAAQQ,EAAwBL,EAAQJ,CAAS,EACjD,UAAWV,EAAM,WAAa,CAAC,EAC/B,MAAoBA,EAAM,OAAS,CAAC,EACpC,WAAYoB,EAASpB,EAAM,OAAS,CAAC,CAAC,EACtC,QAAAY,CACF,CACF,CAEO,SAASS,GAAyBrB,EAAwD,CAC/F,OAAAI,EAAcJ,CAAK,EACZS,EAAaT,CAAK,CAC3B","names":["get","input","key","hasOwnKey","getPath","path","object","isObject","mergeIfUndefined","base","merged","allKeys","CODEGEN_DEFAULTS","TABLE_CODEGEN_DEFAULTS","TABLE_DEPLOY_DEFAULTS","TABLE_DEFAULTS","CONFIG_DEFAULTS","schemaAbiTypes","Scope","AbiTypeScope","abiType","extendScope","scope","additionalTypes","fixedArrayToArray","isFixedArrayAbiType","validateSchema","schema","scope","AbiTypeScope","isObject","internalType","hasOwnKey","resolveSchema","key","defineSchema","isSchemaInput","input","fieldType","isStaticAbiType","resourceToHex","getValidKeys","schema","scope","AbiTypeScope","internalType","hasOwnKey","isStaticAbiType","key","isValidPrimaryKey","validateTable","input","options","validateSchema","item","get","resolveTableCodegen","TABLE_CODEGEN_DEFAULTS","resolveTable","label","type","TABLE_DEFAULTS","namespace","name","tableId","resolveSchema","mergeIfUndefined","TABLE_DEPLOY_DEFAULTS","defineTable","validateTables","input","scope","isObject","table","validateTable","resolveTables","tables","label","resolveTable","mergeIfUndefined","mapObject","isSchemaAbiType","extractInternalType","userTypes","mapObject","userType","isUserTypes","isObject","isSchemaAbiType","scopeWithUserTypes","scope","AbiTypeScope","extendScope","validateUserTypes","type","hasOwnKey","flatMorph","isEnums","enums","item","element","scopeWithEnums","scope","AbiTypeScope","enumScope","key","extendScope","resolveEnums","mapEnums","flatMorph","enumName","enumElements","enumIndex","enumElement","resolveCodegen","codegen","isObject","mergeIfUndefined","CODEGEN_DEFAULTS","flatMorph","resolveNamespacedTables","tables","namespace","label","table","flatMorph","extendedScope","input","scopeWithEnums","get","scopeWithUserTypes","validateStore","scope","hasOwnKey","validateTables","validateUserTypes","resolveStore","namespace","CONFIG_DEFAULTS","codegen","resolveCodegen","tables","resolveTables","flatMorph","label","table","resolveNamespacedTables","mapEnums","defineStore"]}
package/dist/config.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export { D as DEFAULTS, l as EnumsConfig, E as ExpandSchemaConfig, f as ExpandTableConfig, k as ExpandTablesConfig, F as FieldData, m as FullEnumsConfig, a as FullSchemaConfig, e as FullTableConfig, j as FullTablesConfig, M as MUDUserConfig, c as SchemaConfig, b as ShorthandSchemaConfig, S as StoreConfig, q as StoreUserConfig, T as TABLE_DEFAULTS, d as TableConfig, h as TablesConfig, U as UserTypesConfig, r as resolveUserTypes, n as zEnumsConfig, s as zPluginStoreConfig, z as zSchemaConfig, p as zStoreConfig, g as zTableConfig, i as zTablesConfig, o as zUserTypesConfig } from './storeConfig-55cad8c2.js';
2
- import '@latticexyz/schema-type/deprecated';
3
- import 'zod';
4
- import '@latticexyz/common/type-utils';
5
- import '@latticexyz/config/library';
6
- import '@latticexyz/common/codegen';
package/dist/config.js DELETED
@@ -1,2 +0,0 @@
1
- import{a,b,c,d,e,f,g,h,i,j}from"./chunk-RRYXNY5P.js";export{a as DEFAULTS,b as TABLE_DEFAULTS,d as resolveUserTypes,g as zEnumsConfig,j as zPluginStoreConfig,c as zSchemaConfig,i as zStoreConfig,e as zTableConfig,f as zTablesConfig,h as zUserTypesConfig};
2
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,12 +0,0 @@
1
- /**
2
- * @internal Only kept for backwards compatibility
3
- */
4
- type resolveNamespacedTables<tables, namespace> = {
5
- readonly [label in keyof tables as namespace extends "" ? label : `${namespace & string}__${label & string}`]: tables[label];
6
- };
7
- /**
8
- * @internal Only kept for backwards compatibility
9
- */
10
- declare function resolveNamespacedTables<tables, namespace>(tables: tables, namespace: namespace): resolveNamespacedTables<tables, namespace>;
11
-
12
- export { resolveNamespacedTables as r };
@@ -1,22 +0,0 @@
1
- export { mudCoreConfig } from '@latticexyz/config/register';
2
- import { OrDefaults, StringForUnion, ExtractUserTypes } from '@latticexyz/common/type-utils';
3
- import { MUDCoreUserConfig } from '@latticexyz/config/library';
4
- import { q as StoreUserConfig, S as StoreConfig, D as DEFAULTS, k as ExpandTablesConfig, M as MUDUserConfig } from './storeConfig-55cad8c2.js';
5
- import '@latticexyz/schema-type/deprecated';
6
- import 'zod';
7
- import '@latticexyz/common/codegen';
8
-
9
- declare module "@latticexyz/config/library" {
10
- interface MUDCoreUserConfig extends StoreUserConfig {
11
- }
12
- interface MUDCoreConfig extends StoreConfig {
13
- }
14
- }
15
- interface ExpandMUDUserConfig<T extends MUDCoreUserConfig> extends OrDefaults<T, DEFAULTS> {
16
- tables: ExpandTablesConfig<T["tables"]>;
17
- }
18
-
19
- /** mudCoreConfig wrapper to use generics in some options for better type inference */
20
- declare function mudConfig<T extends MUDCoreUserConfig, EnumNames extends StringForUnion = never, UserTypeNames extends StringForUnion = never, StaticUserTypes extends ExtractUserTypes<EnumNames | UserTypeNames> = ExtractUserTypes<EnumNames | UserTypeNames>>(config: MUDUserConfig<T, EnumNames, UserTypeNames, StaticUserTypes>): ExpandMUDUserConfig<T>;
21
-
22
- export { ExpandMUDUserConfig, mudConfig };
package/dist/register.js DELETED
@@ -1,2 +0,0 @@
1
- import{j as o}from"./chunk-RRYXNY5P.js";import"@latticexyz/config/register";import{mudCoreConfig as y}from"@latticexyz/config/register";import{extendMUDCoreConfig as n,fromZodErrorCustom as t}from"@latticexyz/config/library";import{ZodError as s}from"zod";n(r=>{try{return o.parse(r)}catch(e){throw e instanceof s?t(e,"StoreConfig Validation Error"):e}});import{mudCoreConfig as i}from"@latticexyz/config/library";function m(r){return i(r)}export{m as mudConfig,y as mudCoreConfig};
2
- //# sourceMappingURL=register.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../ts/register/index.ts","../ts/register/configExtensions.ts","../ts/register/mudConfig.ts"],"sourcesContent":["// Importing this file has side-effects for MUD config,\n// and the order of imports is important in relation to other plugins\n// (store should usually be the first plugin)\n\n// For convenience register and reexport config, to reduce the number of needed imports for users\nimport \"@latticexyz/config/register\";\nexport { mudCoreConfig } from \"@latticexyz/config/register\";\n// Extend core config and types\nimport \"./configExtensions\";\nimport \"./typeExtensions\";\n\nexport { mudConfig } from \"./mudConfig\";\nexport type { ExpandMUDUserConfig } from \"./typeExtensions\";\n","import { extendMUDCoreConfig, fromZodErrorCustom } from \"@latticexyz/config/library\";\nimport { ZodError } from \"zod\";\nimport { zPluginStoreConfig } from \"../config\";\n\nextendMUDCoreConfig((config) => {\n // This function gets called within mudConfig.\n // The call order of config extenders depends on the order of their imports.\n // Any config validation and transformation should be placed here.\n try {\n return zPluginStoreConfig.parse(config);\n } catch (error) {\n if (error instanceof ZodError) {\n throw fromZodErrorCustom(error, \"StoreConfig Validation Error\");\n } else {\n throw error;\n }\n }\n});\n","import { mudCoreConfig, MUDCoreUserConfig } from \"@latticexyz/config/library\";\nimport { ExtractUserTypes, StringForUnion } from \"@latticexyz/common/type-utils\";\nimport { ExpandMUDUserConfig } from \"./typeExtensions\";\nimport { MUDUserConfig } from \"../config/storeConfig\";\n\n/** mudCoreConfig wrapper to use generics in some options for better type inference */\nexport function mudConfig<\n T extends MUDCoreUserConfig,\n // (`never` is overridden by inference, so only the defined enums can be used by default)\n EnumNames extends StringForUnion = never,\n UserTypeNames extends StringForUnion = never,\n StaticUserTypes extends ExtractUserTypes<EnumNames | UserTypeNames> = ExtractUserTypes<EnumNames | UserTypeNames>,\n>(config: MUDUserConfig<T, EnumNames, UserTypeNames, StaticUserTypes>): ExpandMUDUserConfig<T> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return mudCoreConfig(config) as any;\n}\n"],"mappings":"wCAKA,MAAO,8BACP,OAAS,iBAAAA,MAAqB,8BCN9B,OAAS,uBAAAC,EAAqB,sBAAAC,MAA0B,6BACxD,OAAS,YAAAC,MAAgB,MAGzBC,EAAqBC,GAAW,CAI9B,GAAI,CACF,OAAOC,EAAmB,MAAMD,CAAM,CACxC,OAASE,EAAP,CACA,MAAIA,aAAiBC,EACbC,EAAmBF,EAAO,8BAA8B,EAExDA,CAEV,CACF,CAAC,ECjBD,OAAS,iBAAAG,MAAwC,6BAM1C,SAASC,EAMdC,EAA6F,CAE7F,OAAOF,EAAcE,CAAM,CAC7B","names":["mudCoreConfig","extendMUDCoreConfig","fromZodErrorCustom","ZodError","extendMUDCoreConfig","config","zPluginStoreConfig","error","ZodError","fromZodErrorCustom","mudCoreConfig","mudConfig","config"]}