@latticexyz/config 2.0.0-next.17 → 2.0.0-next.18
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.
- package/dist/{chunk-NOTUCTDJ.js → chunk-JORWOKR3.js} +1 -1
- package/dist/chunk-JORWOKR3.js.map +1 -0
- package/dist/{chunk-YRED5UZY.js → chunk-MG7VRERG.js} +2 -2
- package/dist/chunk-MG7VRERG.js.map +1 -0
- package/dist/{library/index.d.ts → deprecated/library.d.ts} +65 -12
- package/dist/{library/index.js → deprecated/library.js} +2 -2
- package/dist/{node/index.d.ts → deprecated/node.d.ts} +2 -0
- package/dist/{node/index.js → deprecated/node.js} +2 -2
- package/dist/deprecated/node.js.map +1 -0
- package/dist/{register/index.d.ts → deprecated/register.d.ts} +1 -1
- package/dist/deprecated/register.js +2 -0
- package/dist/deprecated/register.js.map +1 -0
- package/dist/{dynamicResolution-d10c23a8.d.ts → dynamicResolution-ac143cd8.d.ts} +12 -2
- package/dist/index.d.ts +29 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/internal.d.ts +2 -0
- package/dist/internal.js +1 -0
- package/dist/internal.js.map +1 -0
- package/package.json +18 -11
- package/src/common.ts +33 -0
- package/src/{library → deprecated/library}/commonSchemas.ts +29 -9
- package/src/{library → deprecated/library}/context.ts +7 -0
- package/src/{library → deprecated/library}/core.ts +11 -2
- package/src/{library → deprecated/library}/dynamicResolution.ts +3 -1
- package/src/{library → deprecated/library}/errors.ts +8 -1
- package/src/{library → deprecated/library}/validation.ts +20 -2
- package/src/{node → deprecated/node}/loadConfig.ts +5 -0
- package/src/exports/index.ts +7 -0
- package/src/exports/internal.ts +0 -0
- package/dist/chunk-NOTUCTDJ.js.map +0 -1
- package/dist/chunk-YRED5UZY.js.map +0 -1
- package/dist/node/index.js.map +0 -1
- package/dist/register/index.js +0 -2
- package/dist/register/index.js.map +0 -1
- /package/dist/{library/index.js.map → deprecated/library.js.map} +0 -0
- /package/src/{library → deprecated/library}/index.ts +0 -0
- /package/src/{node → deprecated/node}/index.ts +0 -0
- /package/src/{register → deprecated/register}/index.ts +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
var a=Object.defineProperty;var d=(r,e,o)=>e in r?a(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o;var p=(r,e,o)=>(d(r,typeof e!="symbol"?e+"":e,o),o);import{z as m,ZodIssueCode as c}from"zod";import{fromZodError as i}from"zod-validation-error";var t=class extends Error{name="MUDContextAlreadyCreatedError";message="MUD context was already created"},s=class extends Error{name="MUDContextNotCreatedError";message="MUD context has not been created"};function f(r,e){return i(r,{prefix:e,prefixSeparator:`
|
|
2
2
|
- `,issueSeparator:`
|
|
3
3
|
- `})}var n=class extends Error{name="NotInsideProjectError";message="You are not inside a MUD project"};function Z(r,e){return new m.ZodError([{code:c.custom,path:r,message:`Unrecognized system: "${e}"`}])}export{p as a,t as b,s as c,f as d,n as e,Z as f};
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
4
|
+
//# sourceMappingURL=chunk-JORWOKR3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/deprecated/library/errors.ts"],"sourcesContent":["import { z, ZodError, ZodIssueCode } from \"zod\";\nimport { fromZodError } from \"zod-validation-error\";\n\n/** @deprecated */\nexport class MUDContextAlreadyCreatedError extends Error {\n name = \"MUDContextAlreadyCreatedError\";\n message = \"MUD context was already created\";\n}\n\n/** @deprecated */\nexport class MUDContextNotCreatedError extends Error {\n name = \"MUDContextNotCreatedError\";\n message = \"MUD context has not been created\";\n}\n\n/**\n * Wrapper with preset styles, only requires a `prefix`\n * @deprecated\n */\nexport function fromZodErrorCustom(error: ZodError, prefix: string) {\n return fromZodError(error, {\n prefix: prefix,\n prefixSeparator: \"\\n- \",\n issueSeparator: \"\\n- \",\n });\n}\n\n/** @deprecated */\nexport class NotInsideProjectError extends Error {\n name = \"NotInsideProjectError\";\n message = \"You are not inside a MUD project\";\n}\n\n/** @deprecated */\nexport function UnrecognizedSystemErrorFactory(path: string[], systemName: string) {\n return new z.ZodError([{ code: ZodIssueCode.custom, path: path, message: `Unrecognized system: \"${systemName}\"` }]);\n}\n"],"mappings":"wKAAA,OAAS,KAAAA,EAAa,gBAAAC,MAAoB,MAC1C,OAAS,gBAAAC,MAAoB,uBAGtB,IAAMC,EAAN,cAA4C,KAAM,CACvD,KAAO,gCACP,QAAU,iCACZ,EAGaC,EAAN,cAAwC,KAAM,CACnD,KAAO,4BACP,QAAU,kCACZ,EAMO,SAASC,EAAmBC,EAAiBC,EAAgB,CAClE,OAAOL,EAAaI,EAAO,CACzB,OAAQC,EACR,gBAAiB;AAAA,IACjB,eAAgB;AAAA,GAClB,CAAC,CACH,CAGO,IAAMC,EAAN,cAAoC,KAAM,CAC/C,KAAO,wBACP,QAAU,kCACZ,EAGO,SAASC,EAA+BC,EAAgBC,EAAoB,CACjF,OAAO,IAAIX,EAAE,SAAS,CAAC,CAAE,KAAMC,EAAa,OAAQ,KAAMS,EAAM,QAAS,yBAAyBC,IAAc,CAAC,CAAC,CACpH","names":["z","ZodIssueCode","fromZodError","MUDContextAlreadyCreatedError","MUDContextNotCreatedError","fromZodErrorCustom","error","prefix","NotInsideProjectError","UnrecognizedSystemErrorFactory","path","systemName"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as m,b as f,c as p}from"./chunk-
|
|
1
|
+
import{a as m,b as f,c as p}from"./chunk-JORWOKR3.js";import{z as r}from"zod";import{ZodIssueCode as s}from"zod";import{isAddress as U}from"viem";var z=16,g=14;function d(e,t){/^\w+$/.test(e)||t.addIssue({code:s.custom,message:"Name must contain only alphanumeric & underscore characters"})}function x(e,t){d(e,t),/^[A-Z]/.test(e)||t.addIssue({code:s.custom,message:"Name must start with a capital letter"})}function C(e,t){d(e,t),/^[a-z]/.test(e)||t.addIssue({code:s.custom,message:"Name must start with a lowercase letter"})}function h(e,t){e.length===0&&t.addIssue({code:s.custom,message:"Enum must not be empty"}),e.length>=256&&t.addIssue({code:s.custom,message:"Length of enum must be < 256"});let o=M(e);o.length>0&&t.addIssue({code:s.custom,message:`Enum must not have duplicate names for: ${o.join(", ")}`})}function c(e,t){return(o,n)=>{if(o===""){e&&n.addIssue({code:s.custom,message:"Route must not be empty"});return}o[0]!=="/"&&n.addIssue({code:s.custom,message:'Route must start with "/"'}),o[o.length-1]==="/"&&n.addIssue({code:s.custom,message:'Route must not end with "/"'});let a=o.split("/");t&&a.length>2&&n.addIssue({code:s.custom,message:'Route must only have one level (e.g. "/foo")'});for(let u=1;u<a.length;u++)a[u]===""&&n.addIssue({code:s.custom,message:'Route must not contain empty route fragments (e.g. "//")'}),/^\w+$/.test(a[u])||n.addIssue({code:s.custom,message:"Route must contain only alphanumeric & underscore characters"})}}var R=c(!0,!1),y=c(!1,!1),b=c(!0,!0);function D(e,t){U(e)||t.addIssue({code:s.custom,message:"Address must be a valid Ethereum address"})}function M(e){let t=new Set,o=new Set;for(let n of e)t.has(n)&&o.add(n),t.add(n);return[...o]}function E(e,t){e.length>g&&t.addIssue({code:s.custom,message:`Namespace must be <= ${g} characters`}),/^\w*$/.test(e)||t.addIssue({code:s.custom,message:"Selector must contain only alphanumeric & underscore characters"})}function S(e){let t=e.match(/^(\w+)\[(\d+)\]$/);return t?{elementType:t[1],staticLength:Number.parseInt(t[2])}:null}var v=r.string().superRefine(x),B=r.string().superRefine(C),G=r.string().superRefine(d),O=r.string().superRefine(E),V=r.array(v).superRefine(h),j=r.string().superRefine(R),k=r.string().superRefine(b),H=r.string().superRefine(y),P=r.string().superRefine(D);var l=class{static isCreated(){return this._global.__mudCoreContext!==void 0}static createContext(){if(this.isCreated())throw new f;let t=this._global,o=new l;return t.__mudCoreContext=o,o}static getContext(){let o=this._global.__mudCoreContext;if(o===void 0)throw new p;return o}configExtenders=[]},i=l;m(i,"_global",typeof global>"u"?window.global??{}:global);function q(e){let t=e,o=i.getContext();for(let n of o.configExtenders)t=n(t);return t}function K(e){i.getContext().configExtenders.push(e)}import{MUDError as I}from"@latticexyz/common/errors";var N=(o=>(o[o.TABLE_ID=0]="TABLE_ID",o[o.SYSTEM_ADDRESS=1]="SYSTEM_ADDRESS",o))(N||{});function te(e){return{type:0,input:e}}function w(e){return typeof e=="object"&&e!==null&&"type"in e&&"input"in e}function oe(e,t){if(!w(e))return e;let o;if(e.type===0){let n=t.tableIds?.[e.input];o=n&&{value:n,type:"bytes32"}}if(o===void 0)throw new I(`Could not resolve dynamic resolution:
|
|
2
2
|
${JSON.stringify(e,null,2)}`);return o}export{z as a,g as b,d as c,x as d,C as e,h as f,R as g,y as h,b as i,D as j,M as k,E as l,S as m,v as n,B as o,G as p,O as q,V as r,j as s,k as t,H as u,P as v,i as w,q as x,K as y,N as z,te as A,w as B,oe as C};
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
//# sourceMappingURL=chunk-MG7VRERG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/deprecated/library/commonSchemas.ts","../src/deprecated/library/validation.ts","../src/deprecated/library/context.ts","../src/deprecated/library/core.ts","../src/deprecated/library/dynamicResolution.ts"],"sourcesContent":["import { z } from \"zod\";\nimport {\n validateBaseRoute,\n validateCapitalizedName,\n validateEthereumAddress,\n validateEnum,\n validateName,\n validateRoute,\n validateSingleLevelRoute,\n validateUncapitalizedName,\n validateNamespace,\n} from \"./validation\";\n\n/**\n * Capitalized names of objects, like tables and systems\n * @deprecated\n */\nexport const zObjectName = z.string().superRefine(validateCapitalizedName);\n/**\n * Uncapitalized names of values, like keys and columns\n * @deprecated\n */\nexport const zValueName = z.string().superRefine(validateUncapitalizedName);\n/** Name that can start with any case\n * @deprecated\n */\nexport const zName = z.string().superRefine(validateName);\n/** A namespace\n * @deprecated\n */\nexport const zNamespace = z.string().superRefine(validateNamespace);\n\n/** List of unique enum member names and 0 < length < 256\n * @deprecated\n */\nexport const zUserEnum = z.array(zObjectName).superRefine(validateEnum);\n\n/** Ordinary routes\n * @deprecated\n */\nexport const zOrdinaryRoute = z.string().superRefine(validateRoute);\n/** Routes with exactly 1 non-empty level\n * @deprecated\n */\nexport const zSingleLevelRoute = z.string().superRefine(validateSingleLevelRoute);\n/** Base routes (can be an empty string)\n * @deprecated\n */\nexport const zBaseRoute = z.string().superRefine(validateBaseRoute);\n\n/** A valid Ethereum address\n * @deprecated\n */\nexport const zEthereumAddress = z.string().superRefine(validateEthereumAddress);\n","import { ZodIssueCode, RefinementCtx } from \"zod\";\nimport { isAddress } from \"viem\";\n\n/** @deprecated */\nexport const STORE_NAME_MAX_LENGTH = 16;\n/** @deprecated */\nexport const STORE_NAMESPACE_MAX_LENGTH = 14;\n\n/** @deprecated */\nexport function validateName(name: string, ctx: RefinementCtx) {\n if (!/^\\w+$/.test(name)) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Name must contain only alphanumeric & underscore characters`,\n });\n }\n}\n\n/** @deprecated */\nexport function validateCapitalizedName(name: string, ctx: RefinementCtx) {\n validateName(name, ctx);\n\n if (!/^[A-Z]/.test(name)) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Name must start with a capital letter`,\n });\n }\n}\n\n/** @deprecated */\nexport function validateUncapitalizedName(name: string, ctx: RefinementCtx) {\n validateName(name, ctx);\n\n if (!/^[a-z]/.test(name)) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Name must start with a lowercase letter`,\n });\n }\n}\n\n/**\n * validates only the enum array, not the names of enum members\n * @deprecated\n */\nexport function validateEnum(members: string[], ctx: RefinementCtx) {\n if (members.length === 0) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Enum must not be empty`,\n });\n }\n if (members.length >= 256) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Length of enum must be < 256`,\n });\n }\n\n const duplicates = getDuplicates(members);\n if (duplicates.length > 0) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Enum must not have duplicate names for: ${duplicates.join(\", \")}`,\n });\n }\n}\n\n/** @deprecated */\nfunction _factoryForValidateRoute(requireNonEmpty: boolean, requireSingleLevel: boolean) {\n return (route: string, ctx: RefinementCtx) => {\n if (route === \"\") {\n if (requireNonEmpty) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Route must not be empty`,\n });\n }\n // we can skip further validation for empty routes\n return;\n }\n\n if (route[0] !== \"/\") {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Route must start with \"/\"`,\n });\n }\n\n if (route[route.length - 1] === \"/\") {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Route must not end with \"/\"`,\n });\n }\n\n const parts = route.split(\"/\");\n if (requireSingleLevel && parts.length > 2) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Route must only have one level (e.g. \"/foo\")`,\n });\n }\n\n // start at 1 to skip the first empty part\n for (let i = 1; i < parts.length; i++) {\n if (parts[i] === \"\") {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Route must not contain empty route fragments (e.g. \"//\")`,\n });\n }\n\n if (!/^\\w+$/.test(parts[i])) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Route must contain only alphanumeric & underscore characters`,\n });\n }\n }\n };\n}\n\n/** @deprecated */\nexport const validateRoute = _factoryForValidateRoute(true, false);\n\n/** @deprecated */\nexport const validateBaseRoute = _factoryForValidateRoute(false, false);\n\n/** @deprecated */\nexport const validateSingleLevelRoute = _factoryForValidateRoute(true, true);\n\n/** @deprecated */\nexport function validateEthereumAddress(address: string, ctx: RefinementCtx) {\n if (!isAddress(address)) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Address must be a valid Ethereum address`,\n });\n }\n}\n\n/** @deprecated */\nexport function getDuplicates<T>(array: T[]) {\n const checked = new Set<T>();\n const duplicates = new Set<T>();\n for (const element of array) {\n if (checked.has(element)) {\n duplicates.add(element);\n }\n checked.add(element);\n }\n return [...duplicates];\n}\n\n/** @deprecated */\nexport function validateNamespace(name: string, ctx: RefinementCtx) {\n if (name.length > STORE_NAMESPACE_MAX_LENGTH) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Namespace must be <= ${STORE_NAMESPACE_MAX_LENGTH} characters`,\n });\n }\n if (!/^\\w*$/.test(name)) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Selector must contain only alphanumeric & underscore characters`,\n });\n }\n}\n\n/**\n * Returns null if the type does not look like a static array, otherwise element and length data\n * @deprecated\n */\nexport function parseStaticArray(abiType: string) {\n const matches = abiType.match(/^(\\w+)\\[(\\d+)\\]$/);\n if (!matches) return null;\n return {\n elementType: matches[1],\n staticLength: Number.parseInt(matches[2]),\n };\n}\n","import { MUDConfigExtender } from \"./core\";\nimport { MUDContextAlreadyCreatedError, MUDContextNotCreatedError } from \"./errors\";\n\n/** @deprecated */\nexport type GlobalWithMUDCoreContext = typeof global & {\n __mudCoreContext: MUDCoreContext;\n};\n\n/** @deprecated */\nexport class MUDCoreContext {\n /** @deprecated */\n static _global = typeof global === \"undefined\" ? window.global ?? {} : global;\n\n /** @deprecated */\n public static isCreated(): boolean {\n const globalWithMUDCoreContext = this._global as GlobalWithMUDCoreContext;\n return globalWithMUDCoreContext.__mudCoreContext !== undefined;\n }\n\n /** @deprecated */\n public static createContext(): MUDCoreContext {\n if (this.isCreated()) {\n throw new MUDContextAlreadyCreatedError();\n }\n const globalWithMUDCoreContext = this._global as GlobalWithMUDCoreContext;\n const context = new MUDCoreContext();\n globalWithMUDCoreContext.__mudCoreContext = context;\n return context;\n }\n\n /** @deprecated */\n public static getContext(): MUDCoreContext {\n const globalWithMUDCoreContext = this._global as GlobalWithMUDCoreContext;\n const context = globalWithMUDCoreContext.__mudCoreContext;\n if (context === undefined) {\n throw new MUDContextNotCreatedError();\n }\n return context;\n }\n\n /** @deprecated */\n public readonly configExtenders: MUDConfigExtender[] = [];\n}\n","import { MUDCoreContext } from \"./context\";\n\n/** @deprecated */\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface MUDCoreUserConfig {}\n\n/** @deprecated */\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface MUDCoreConfig {}\n\n/** @deprecated */\nexport type MUDConfigExtender = (config: MUDCoreConfig) => Record<string, unknown>;\n\n/**\n * Resolver that sequentially passes the config through all the plugins\n * @deprecated\n */\nexport function mudCoreConfig(config: MUDCoreUserConfig): MUDCoreConfig {\n // config types can change with plugins, `any` helps avoid errors when typechecking dependencies\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let configAsAny = config as any;\n const context = MUDCoreContext.getContext();\n for (const extender of context.configExtenders) {\n configAsAny = extender(configAsAny);\n }\n return configAsAny;\n}\n\n/**\n * Utility for plugin developers to extend the core config\n * @deprecated\n */\nexport function extendMUDCoreConfig(extender: MUDConfigExtender) {\n const context = MUDCoreContext.getContext();\n context.configExtenders.push(extender);\n}\n","import { MUDError } from \"@latticexyz/common/errors\";\n\nexport enum DynamicResolutionType {\n TABLE_ID,\n SYSTEM_ADDRESS,\n}\n\nexport type DynamicResolution = {\n type: DynamicResolutionType;\n input: string;\n};\n\nexport type ValueWithType = {\n value: string | number | Uint8Array;\n type: string;\n};\n\n/**\n * Dynamically resolve a table name to a table id at deploy time\n */\nexport function resolveTableId(tableName: string) {\n return {\n type: DynamicResolutionType.TABLE_ID,\n input: tableName,\n };\n}\n\n/** Type guard for DynamicResolution */\nexport function isDynamicResolution(value: unknown): value is DynamicResolution {\n return typeof value === \"object\" && value !== null && \"type\" in value && \"input\" in value;\n}\n\n/**\n * Turn a DynamicResolution object into a ValueWithType based on the provided context\n * @deprecated\n */\nexport function resolveWithContext(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n unresolved: any,\n context: { systemAddresses?: Record<string, Promise<string>>; tableIds?: Record<string, Uint8Array> },\n): ValueWithType {\n if (!isDynamicResolution(unresolved)) return unresolved;\n let resolved: ValueWithType | undefined = undefined;\n\n if (unresolved.type === DynamicResolutionType.TABLE_ID) {\n const tableId = context.tableIds?.[unresolved.input];\n resolved = tableId && { value: tableId, type: \"bytes32\" };\n }\n\n if (resolved === undefined) {\n throw new MUDError(`Could not resolve dynamic resolution: \\n${JSON.stringify(unresolved, null, 2)}`);\n }\n\n return resolved;\n}\n"],"mappings":"sDAAA,OAAS,KAAAA,MAAS,MCAlB,OAAS,gBAAAC,MAAmC,MAC5C,OAAS,aAAAC,MAAiB,OAGnB,IAAMC,EAAwB,GAExBC,EAA6B,GAGnC,SAASC,EAAaC,EAAcC,EAAoB,CACxD,QAAQ,KAAKD,CAAI,GACpBC,EAAI,SAAS,CACX,KAAMN,EAAa,OACnB,QAAS,6DACX,CAAC,CAEL,CAGO,SAASO,EAAwBF,EAAcC,EAAoB,CACxEF,EAAaC,EAAMC,CAAG,EAEjB,SAAS,KAAKD,CAAI,GACrBC,EAAI,SAAS,CACX,KAAMN,EAAa,OACnB,QAAS,uCACX,CAAC,CAEL,CAGO,SAASQ,EAA0BH,EAAcC,EAAoB,CAC1EF,EAAaC,EAAMC,CAAG,EAEjB,SAAS,KAAKD,CAAI,GACrBC,EAAI,SAAS,CACX,KAAMN,EAAa,OACnB,QAAS,yCACX,CAAC,CAEL,CAMO,SAASS,EAAaC,EAAmBJ,EAAoB,CAC9DI,EAAQ,SAAW,GACrBJ,EAAI,SAAS,CACX,KAAMN,EAAa,OACnB,QAAS,wBACX,CAAC,EAECU,EAAQ,QAAU,KACpBJ,EAAI,SAAS,CACX,KAAMN,EAAa,OACnB,QAAS,8BACX,CAAC,EAGH,IAAMW,EAAaC,EAAcF,CAAO,EACpCC,EAAW,OAAS,GACtBL,EAAI,SAAS,CACX,KAAMN,EAAa,OACnB,QAAS,2CAA2CW,EAAW,KAAK,IAAI,GAC1E,CAAC,CAEL,CAGA,SAASE,EAAyBC,EAA0BC,EAA6B,CACvF,MAAO,CAACC,EAAeV,IAAuB,CAC5C,GAAIU,IAAU,GAAI,CACZF,GACFR,EAAI,SAAS,CACX,KAAMN,EAAa,OACnB,QAAS,yBACX,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AcG,EAASH,CAAW,EAEpC,OAAOA,CACT,CAMO,SAASI,EAAoBD,EAA6B,CAC/CD,EAAe,WAAW,EAClC,gBAAgB,KAAKC,CAAQ,CACvC,CCnCA,OAAS,YAAAE,MAAgB,4BAElB,IAAKC,OACVA,IAAA,uBACAA,IAAA,mCAFUA,OAAA,IAkBL,SAASC,GAAeC,EAAmB,CAChD,MAAO,CACL,KAAM,EACN,MAAOA,CACT,CACF,CAGO,SAASC,EAAoBC,EAA4C,CAC9E,OAAO,OAAOA,GAAU,UAAYA,IAAU,MAAQ,SAAUA,GAAS,UAAWA,CACtF,CAMO,SAASC,GAEdC,EACAC,EACe,CACf,GAAI,CAACJ,EAAoBG,CAAU,EAAG,OAAOA,EAC7C,IAAIE,EAEJ,GAAIF,EAAW,OAAS,EAAgC,CACtD,IAAMG,EAAUF,EAAQ,WAAWD,EAAW,KAAK,EACnDE,EAAWC,GAAW,CAAE,MAAOA,EAAS,KAAM,SAAU,EAG1D,GAAID,IAAa,OACf,MAAM,IAAIT,EAAS;AAAA,EAA2C,KAAK,UAAUO,EAAY,KAAM,CAAC,GAAG,EAGrG,OAAOE,CACT","names":["z","ZodIssueCode","isAddress","STORE_NAME_MAX_LENGTH","STORE_NAMESPACE_MAX_LENGTH","validateName","name","ctx","validateCapitalizedName","validateUncapitalizedName","validateEnum","members","duplicates","getDuplicates","_factoryForValidateRoute","requireNonEmpty","requireSingleLevel","route","parts","i","validateRoute","validateBaseRoute","validateSingleLevelRoute","validateEthereumAddress","address","array","checked","element","validateNamespace","parseStaticArray","abiType","matches","zObjectName","z","validateCapitalizedName","zValueName","validateUncapitalizedName","zName","validateName","zNamespace","validateNamespace","zUserEnum","validateEnum","zOrdinaryRoute","validateRoute","zSingleLevelRoute","validateSingleLevelRoute","zBaseRoute","validateBaseRoute","zEthereumAddress","validateEthereumAddress","_MUDCoreContext","MUDContextAlreadyCreatedError","globalWithMUDCoreContext","context","MUDContextNotCreatedError","MUDCoreContext","__publicField","mudCoreConfig","config","configAsAny","context","MUDCoreContext","extender","extendMUDCoreConfig","MUDError","DynamicResolutionType","resolveTableId","tableName","isDynamicResolution","value","resolveWithContext","unresolved","context","resolved","tableId"]}
|
|
@@ -1,66 +1,119 @@
|
|
|
1
1
|
import { z, ZodError, RefinementCtx } from 'zod';
|
|
2
|
-
import { M as MUDConfigExtender } from '../dynamicResolution-
|
|
3
|
-
export { c as DynamicResolution, D as DynamicResolutionType, b as MUDCoreConfig, a as MUDCoreUserConfig, V as ValueWithType, e as extendMUDCoreConfig, i as isDynamicResolution, m as mudCoreConfig, r as resolveTableId, d as resolveWithContext } from '../dynamicResolution-
|
|
2
|
+
import { M as MUDConfigExtender } from '../dynamicResolution-ac143cd8.js';
|
|
3
|
+
export { c as DynamicResolution, D as DynamicResolutionType, b as MUDCoreConfig, a as MUDCoreUserConfig, V as ValueWithType, e as extendMUDCoreConfig, i as isDynamicResolution, m as mudCoreConfig, r as resolveTableId, d as resolveWithContext } from '../dynamicResolution-ac143cd8.js';
|
|
4
4
|
import * as zod_validation_error from 'zod-validation-error';
|
|
5
5
|
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Capitalized names of objects, like tables and systems
|
|
8
|
+
* @deprecated
|
|
9
|
+
*/
|
|
7
10
|
declare const zObjectName: z.ZodEffects<z.ZodString, string, string>;
|
|
8
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Uncapitalized names of values, like keys and columns
|
|
13
|
+
* @deprecated
|
|
14
|
+
*/
|
|
9
15
|
declare const zValueName: z.ZodEffects<z.ZodString, string, string>;
|
|
10
|
-
/** Name that can start with any case
|
|
16
|
+
/** Name that can start with any case
|
|
17
|
+
* @deprecated
|
|
18
|
+
*/
|
|
11
19
|
declare const zName: z.ZodEffects<z.ZodString, string, string>;
|
|
12
|
-
/** A namespace
|
|
20
|
+
/** A namespace
|
|
21
|
+
* @deprecated
|
|
22
|
+
*/
|
|
13
23
|
declare const zNamespace: z.ZodEffects<z.ZodString, string, string>;
|
|
14
|
-
/** List of unique enum member names and 0 < length < 256
|
|
24
|
+
/** List of unique enum member names and 0 < length < 256
|
|
25
|
+
* @deprecated
|
|
26
|
+
*/
|
|
15
27
|
declare const zUserEnum: z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">, string[], string[]>;
|
|
16
|
-
/** Ordinary routes
|
|
28
|
+
/** Ordinary routes
|
|
29
|
+
* @deprecated
|
|
30
|
+
*/
|
|
17
31
|
declare const zOrdinaryRoute: z.ZodEffects<z.ZodString, string, string>;
|
|
18
|
-
/** Routes with exactly 1 non-empty level
|
|
32
|
+
/** Routes with exactly 1 non-empty level
|
|
33
|
+
* @deprecated
|
|
34
|
+
*/
|
|
19
35
|
declare const zSingleLevelRoute: z.ZodEffects<z.ZodString, string, string>;
|
|
20
|
-
/** Base routes (can be an empty string)
|
|
36
|
+
/** Base routes (can be an empty string)
|
|
37
|
+
* @deprecated
|
|
38
|
+
*/
|
|
21
39
|
declare const zBaseRoute: z.ZodEffects<z.ZodString, string, string>;
|
|
22
|
-
/** A valid Ethereum address
|
|
40
|
+
/** A valid Ethereum address
|
|
41
|
+
* @deprecated
|
|
42
|
+
*/
|
|
23
43
|
declare const zEthereumAddress: z.ZodEffects<z.ZodString, string, string>;
|
|
24
44
|
|
|
45
|
+
/** @deprecated */
|
|
25
46
|
type GlobalWithMUDCoreContext = typeof global & {
|
|
26
47
|
__mudCoreContext: MUDCoreContext;
|
|
27
48
|
};
|
|
49
|
+
/** @deprecated */
|
|
28
50
|
declare class MUDCoreContext {
|
|
51
|
+
/** @deprecated */
|
|
29
52
|
static _global: typeof globalThis;
|
|
53
|
+
/** @deprecated */
|
|
30
54
|
static isCreated(): boolean;
|
|
55
|
+
/** @deprecated */
|
|
31
56
|
static createContext(): MUDCoreContext;
|
|
57
|
+
/** @deprecated */
|
|
32
58
|
static getContext(): MUDCoreContext;
|
|
59
|
+
/** @deprecated */
|
|
33
60
|
readonly configExtenders: MUDConfigExtender[];
|
|
34
61
|
}
|
|
35
62
|
|
|
63
|
+
/** @deprecated */
|
|
36
64
|
declare class MUDContextAlreadyCreatedError extends Error {
|
|
37
65
|
name: string;
|
|
38
66
|
message: string;
|
|
39
67
|
}
|
|
68
|
+
/** @deprecated */
|
|
40
69
|
declare class MUDContextNotCreatedError extends Error {
|
|
41
70
|
name: string;
|
|
42
71
|
message: string;
|
|
43
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Wrapper with preset styles, only requires a `prefix`
|
|
75
|
+
* @deprecated
|
|
76
|
+
*/
|
|
44
77
|
declare function fromZodErrorCustom(error: ZodError, prefix: string): zod_validation_error.ValidationError;
|
|
78
|
+
/** @deprecated */
|
|
45
79
|
declare class NotInsideProjectError extends Error {
|
|
46
80
|
name: string;
|
|
47
81
|
message: string;
|
|
48
82
|
}
|
|
83
|
+
/** @deprecated */
|
|
49
84
|
declare function UnrecognizedSystemErrorFactory(path: string[], systemName: string): z.ZodError<any>;
|
|
50
85
|
|
|
86
|
+
/** @deprecated */
|
|
51
87
|
declare const STORE_NAME_MAX_LENGTH = 16;
|
|
88
|
+
/** @deprecated */
|
|
52
89
|
declare const STORE_NAMESPACE_MAX_LENGTH = 14;
|
|
90
|
+
/** @deprecated */
|
|
53
91
|
declare function validateName(name: string, ctx: RefinementCtx): void;
|
|
92
|
+
/** @deprecated */
|
|
54
93
|
declare function validateCapitalizedName(name: string, ctx: RefinementCtx): void;
|
|
94
|
+
/** @deprecated */
|
|
55
95
|
declare function validateUncapitalizedName(name: string, ctx: RefinementCtx): void;
|
|
96
|
+
/**
|
|
97
|
+
* validates only the enum array, not the names of enum members
|
|
98
|
+
* @deprecated
|
|
99
|
+
*/
|
|
56
100
|
declare function validateEnum(members: string[], ctx: RefinementCtx): void;
|
|
101
|
+
/** @deprecated */
|
|
57
102
|
declare const validateRoute: (route: string, ctx: RefinementCtx) => void;
|
|
103
|
+
/** @deprecated */
|
|
58
104
|
declare const validateBaseRoute: (route: string, ctx: RefinementCtx) => void;
|
|
105
|
+
/** @deprecated */
|
|
59
106
|
declare const validateSingleLevelRoute: (route: string, ctx: RefinementCtx) => void;
|
|
107
|
+
/** @deprecated */
|
|
60
108
|
declare function validateEthereumAddress(address: string, ctx: RefinementCtx): void;
|
|
109
|
+
/** @deprecated */
|
|
61
110
|
declare function getDuplicates<T>(array: T[]): T[];
|
|
111
|
+
/** @deprecated */
|
|
62
112
|
declare function validateNamespace(name: string, ctx: RefinementCtx): void;
|
|
63
|
-
/**
|
|
113
|
+
/**
|
|
114
|
+
* Returns null if the type does not look like a static array, otherwise element and length data
|
|
115
|
+
* @deprecated
|
|
116
|
+
*/
|
|
64
117
|
declare function parseStaticArray(abiType: string): {
|
|
65
118
|
elementType: string;
|
|
66
119
|
staticLength: number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as F,B as G,C as H,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w as B,x as C,y as D,z as E}from"../chunk-
|
|
2
|
-
//# sourceMappingURL=
|
|
1
|
+
import{A as F,B as G,C as H,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w as B,x as C,y as D,z as E}from"../chunk-MG7VRERG.js";import{b as w,c as x,d as y,e as z,f as A}from"../chunk-JORWOKR3.js";export{E as DynamicResolutionType,w as MUDContextAlreadyCreatedError,x as MUDContextNotCreatedError,B as MUDCoreContext,z as NotInsideProjectError,b as STORE_NAMESPACE_MAX_LENGTH,a as STORE_NAME_MAX_LENGTH,A as UnrecognizedSystemErrorFactory,D as extendMUDCoreConfig,y as fromZodErrorCustom,k as getDuplicates,G as isDynamicResolution,C as mudCoreConfig,m as parseStaticArray,F as resolveTableId,H as resolveWithContext,h as validateBaseRoute,d as validateCapitalizedName,f as validateEnum,j as validateEthereumAddress,c as validateName,l as validateNamespace,g as validateRoute,i as validateSingleLevelRoute,e as validateUncapitalizedName,u as zBaseRoute,v as zEthereumAddress,p as zName,q as zNamespace,n as zObjectName,s as zOrdinaryRoute,t as zSingleLevelRoute,r as zUserEnum,o as zValueName};
|
|
2
|
+
//# sourceMappingURL=library.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{e as t}from"../chunk-
|
|
2
|
-
//# sourceMappingURL=
|
|
1
|
+
import{e as t}from"../chunk-JORWOKR3.js";import{findUp as m}from"find-up";import o from"path";import s from"esbuild";import{rmSync as u}from"fs";import{pathToFileURL as f}from"url";import a from"os";var d=["mud.config.js","mud.config.mjs","mud.config.ts","mud.config.mts"],e="mud.config.temp.mjs";async function x(r){r=await n(r);try{return await s.build({entryPoints:[r],format:"esm",outfile:e,platform:"node",bundle:!0,packages:"external"}),r=await n(e,!0),(await import(r+`?update=${Date.now()}`)).default}finally{u(e,{force:!0})}}async function n(r,i){return r===void 0?r=await p():o.isAbsolute(r)||(r=o.join(process.cwd(),r),r=o.normalize(r)),i&&a.platform()==="win32"?f(r).href:r}async function p(){let r=await m(d);if(r===void 0)throw new t;return r}export{x as loadConfig,n as resolveConfigPath};
|
|
2
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/deprecated/node/loadConfig.ts"],"sourcesContent":["import { findUp } from \"find-up\";\nimport path from \"path\";\nimport { NotInsideProjectError } from \"../library/errors\";\nimport esbuild from \"esbuild\";\nimport { rmSync } from \"fs\";\nimport { pathToFileURL } from \"url\";\nimport os from \"os\";\n\n// TODO: explore using https://www.npmjs.com/package/ts-import instead\n\n// In order of preference files are checked\n/** @deprecated */\nconst configFiles = [\"mud.config.js\", \"mud.config.mjs\", \"mud.config.ts\", \"mud.config.mts\"];\n/** @deprecated */\nconst TEMP_CONFIG = \"mud.config.temp.mjs\";\n\n/** @deprecated */\nexport async function loadConfig(configPath?: string): Promise<unknown> {\n configPath = await resolveConfigPath(configPath);\n try {\n await esbuild.build({\n entryPoints: [configPath],\n format: \"esm\",\n outfile: TEMP_CONFIG,\n // https://esbuild.github.io/getting-started/#bundling-for-node\n platform: \"node\",\n // bundle local imports (otherwise it may error, js can't import ts)\n bundle: true,\n // avoid bundling external imports (it's unnecessary and esbuild can't handle all node features)\n packages: \"external\",\n });\n configPath = await resolveConfigPath(TEMP_CONFIG, true);\n // Node.js caches dynamic imports, so without appending a cache breaking\n // param like `?update={Date.now()}` this import always returns the same config\n // if called multiple times in a single process, like the `dev-contracts` cli\n return (await import(configPath + `?update=${Date.now()}`)).default;\n } finally {\n rmSync(TEMP_CONFIG, { force: true });\n }\n}\n\n/** @deprecated */\nexport async function resolveConfigPath(configPath: string | undefined, toFileURL?: boolean) {\n if (configPath === undefined) {\n configPath = await getUserConfigPath();\n } else {\n if (!path.isAbsolute(configPath)) {\n configPath = path.join(process.cwd(), configPath);\n configPath = path.normalize(configPath);\n }\n }\n\n // Add `file:///` for Windows support\n // (see https://github.com/nodejs/node/issues/31710)\n return toFileURL && os.platform() === \"win32\" ? pathToFileURL(configPath).href : configPath;\n}\n\n/** @deprecated */\nasync function getUserConfigPath() {\n const tsConfigPath = await findUp(configFiles);\n if (tsConfigPath === undefined) {\n throw new NotInsideProjectError();\n }\n return tsConfigPath;\n}\n"],"mappings":"yCAAA,OAAS,UAAAA,MAAc,UACvB,OAAOC,MAAU,OAEjB,OAAOC,MAAa,UACpB,OAAS,UAAAC,MAAc,KACvB,OAAS,iBAAAC,MAAqB,MAC9B,OAAOC,MAAQ,KAMf,IAAMC,EAAc,CAAC,gBAAiB,iBAAkB,gBAAiB,gBAAgB,EAEnFC,EAAc,sBAGpB,eAAsBC,EAAWC,EAAuC,CACtEA,EAAa,MAAMC,EAAkBD,CAAU,EAC/C,GAAI,CACF,aAAMP,EAAQ,MAAM,CAClB,YAAa,CAACO,CAAU,EACxB,OAAQ,MACR,QAASF,EAET,SAAU,OAEV,OAAQ,GAER,SAAU,UACZ,CAAC,EACDE,EAAa,MAAMC,EAAkBH,EAAa,EAAI,GAI9C,MAAM,OAAOE,EAAa,WAAW,KAAK,IAAI,MAAM,OAC9D,QAAE,CACAN,EAAOI,EAAa,CAAE,MAAO,EAAK,CAAC,CACrC,CACF,CAGA,eAAsBG,EAAkBD,EAAgCE,EAAqB,CAC3F,OAAIF,IAAe,OACjBA,EAAa,MAAMG,EAAkB,EAEhCC,EAAK,WAAWJ,CAAU,IAC7BA,EAAaI,EAAK,KAAK,QAAQ,IAAI,EAAGJ,CAAU,EAChDA,EAAaI,EAAK,UAAUJ,CAAU,GAMnCE,GAAaN,EAAG,SAAS,IAAM,QAAUD,EAAcK,CAAU,EAAE,KAAOA,CACnF,CAGA,eAAeG,GAAoB,CACjC,IAAME,EAAe,MAAMC,EAAOT,CAAW,EAC7C,GAAIQ,IAAiB,OACnB,MAAM,IAAIE,EAEZ,OAAOF,CACT","names":["findUp","path","esbuild","rmSync","pathToFileURL","os","configFiles","TEMP_CONFIG","loadConfig","configPath","resolveConfigPath","toFileURL","getUserConfigPath","path","tsConfigPath","findUp","NotInsideProjectError"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { m as mudCoreConfig, r as resolveTableId } from '../dynamicResolution-
|
|
1
|
+
export { m as mudCoreConfig, r as resolveTableId } from '../dynamicResolution-ac143cd8.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/deprecated/register/index.ts"],"sourcesContent":["import { mudCoreConfig, resolveTableId } from \"../library\";\nimport { MUDCoreContext } from \"../library/context\";\n\nexport { mudCoreConfig, resolveTableId };\n\n// Importing this file has side-effects, and it should always be imported before MUD plugins.\n// Use this import for defining a MUD config.\n// Use the library endpoint instead when writing MUD-based libraries or plugins.\nif (!MUDCoreContext.isCreated()) {\n MUDCoreContext.createContext();\n}\n"],"mappings":"oFAQKA,EAAe,UAAU,GAC5BA,EAAe,cAAc","names":["MUDCoreContext"]}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
+
/** @deprecated */
|
|
1
2
|
interface MUDCoreUserConfig {
|
|
2
3
|
}
|
|
4
|
+
/** @deprecated */
|
|
3
5
|
interface MUDCoreConfig {
|
|
4
6
|
}
|
|
7
|
+
/** @deprecated */
|
|
5
8
|
type MUDConfigExtender = (config: MUDCoreConfig) => Record<string, unknown>;
|
|
6
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Resolver that sequentially passes the config through all the plugins
|
|
11
|
+
* @deprecated
|
|
12
|
+
*/
|
|
7
13
|
declare function mudCoreConfig(config: MUDCoreUserConfig): MUDCoreConfig;
|
|
8
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Utility for plugin developers to extend the core config
|
|
16
|
+
* @deprecated
|
|
17
|
+
*/
|
|
9
18
|
declare function extendMUDCoreConfig(extender: MUDConfigExtender): void;
|
|
10
19
|
|
|
11
20
|
declare enum DynamicResolutionType {
|
|
@@ -31,6 +40,7 @@ declare function resolveTableId(tableName: string): {
|
|
|
31
40
|
declare function isDynamicResolution(value: unknown): value is DynamicResolution;
|
|
32
41
|
/**
|
|
33
42
|
* Turn a DynamicResolution object into a ValueWithType based on the provided context
|
|
43
|
+
* @deprecated
|
|
34
44
|
*/
|
|
35
45
|
declare function resolveWithContext(unresolved: any, context: {
|
|
36
46
|
systemAddresses?: Record<string, Promise<string>>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Hex } from 'viem';
|
|
2
|
+
import { StaticAbiType, DynamicAbiType } from '@latticexyz/schema-type/internal';
|
|
3
|
+
export { DynamicAbiType, StaticAbiType } from '@latticexyz/schema-type/internal';
|
|
4
|
+
import { ResourceType } from '@latticexyz/common';
|
|
5
|
+
import { satisfy } from '@latticexyz/common/type-utils';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Common output types of a MUD config. We use these types as inputs for libraries.
|
|
9
|
+
*/
|
|
10
|
+
type AbiType = StaticAbiType | DynamicAbiType;
|
|
11
|
+
|
|
12
|
+
type Schema = {
|
|
13
|
+
readonly [fieldName: string]: {
|
|
14
|
+
/** the Solidity primitive ABI type */
|
|
15
|
+
readonly type: AbiType;
|
|
16
|
+
/** the user defined type or Solidity primitive ABI type */
|
|
17
|
+
readonly internalType: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
type Table = {
|
|
21
|
+
readonly type: satisfy<ResourceType, "table" | "offchainTable">;
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly namespace: string;
|
|
24
|
+
readonly tableId: Hex;
|
|
25
|
+
readonly schema: Schema;
|
|
26
|
+
readonly key: readonly string[];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { AbiType, Schema, Table };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/internal.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@latticexyz/config",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.18",
|
|
4
4
|
"description": "Config for Store and World",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,36 +10,43 @@
|
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"type": "module",
|
|
12
12
|
"exports": {
|
|
13
|
-
".": "./dist/
|
|
14
|
-
"./
|
|
15
|
-
"./
|
|
13
|
+
".": "./dist/index.js",
|
|
14
|
+
"./internal": "./dist/internal.js",
|
|
15
|
+
"./library": "./dist/deprecated/library.js",
|
|
16
|
+
"./register": "./dist/deprecated/register.js",
|
|
17
|
+
"./node": "./dist/deprecated/node.js"
|
|
16
18
|
},
|
|
17
19
|
"typesVersions": {
|
|
18
20
|
"*": {
|
|
19
21
|
"index": [
|
|
20
|
-
"./src/
|
|
22
|
+
"./src/exports/index.ts"
|
|
23
|
+
],
|
|
24
|
+
"internal": [
|
|
25
|
+
"./src/exports/internal.ts"
|
|
26
|
+
],
|
|
27
|
+
"library": [
|
|
28
|
+
"./src/deprecated/library/index.ts"
|
|
21
29
|
],
|
|
22
30
|
"register": [
|
|
23
|
-
"./src/register/index.ts"
|
|
31
|
+
"./src/deprecated/register/index.ts"
|
|
24
32
|
],
|
|
25
33
|
"node": [
|
|
26
|
-
"./src/node/index.ts"
|
|
34
|
+
"./src/deprecated/node/index.ts"
|
|
27
35
|
]
|
|
28
36
|
}
|
|
29
37
|
},
|
|
30
38
|
"dependencies": {
|
|
31
39
|
"esbuild": "^0.17.15",
|
|
32
40
|
"find-up": "^6.3.0",
|
|
33
|
-
"viem": "
|
|
41
|
+
"viem": "2.7.12",
|
|
34
42
|
"zod": "^3.21.4",
|
|
35
43
|
"zod-validation-error": "^1.3.0",
|
|
36
|
-
"@latticexyz/common": "2.0.0-next.
|
|
37
|
-
"@latticexyz/schema-type": "2.0.0-next.
|
|
44
|
+
"@latticexyz/common": "2.0.0-next.18",
|
|
45
|
+
"@latticexyz/schema-type": "2.0.0-next.18"
|
|
38
46
|
},
|
|
39
47
|
"devDependencies": {
|
|
40
48
|
"tsup": "^6.7.0"
|
|
41
49
|
},
|
|
42
|
-
"gitHead": "914a1e0ae4a573d685841ca2ea921435057deb8f",
|
|
43
50
|
"scripts": {
|
|
44
51
|
"build": "pnpm run build:js",
|
|
45
52
|
"build:js": "tsup",
|
package/src/common.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Hex } from "viem";
|
|
2
|
+
import { DynamicAbiType, StaticAbiType } from "@latticexyz/schema-type/internal";
|
|
3
|
+
import { ResourceType } from "@latticexyz/common";
|
|
4
|
+
import { satisfy } from "@latticexyz/common/type-utils";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Common output types of a MUD config. We use these types as inputs for libraries.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// Although we could import `SchemaAbiType` from `@latticexyz/schema-type` here, we "redefine" this here
|
|
11
|
+
// so that our downstream type errors give back `AbiType` instead of the union of all possible ABI types.
|
|
12
|
+
//
|
|
13
|
+
// This is a bit of a TS compiler hack and we should figure out a better long-term approach.
|
|
14
|
+
export type AbiType = StaticAbiType | DynamicAbiType;
|
|
15
|
+
export type { StaticAbiType, DynamicAbiType };
|
|
16
|
+
|
|
17
|
+
export type Schema = {
|
|
18
|
+
readonly [fieldName: string]: {
|
|
19
|
+
/** the Solidity primitive ABI type */
|
|
20
|
+
readonly type: AbiType;
|
|
21
|
+
/** the user defined type or Solidity primitive ABI type */
|
|
22
|
+
readonly internalType: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type Table = {
|
|
27
|
+
readonly type: satisfy<ResourceType, "table" | "offchainTable">;
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly namespace: string;
|
|
30
|
+
readonly tableId: Hex;
|
|
31
|
+
readonly schema: Schema;
|
|
32
|
+
readonly key: readonly string[];
|
|
33
|
+
};
|
|
@@ -11,24 +11,44 @@ import {
|
|
|
11
11
|
validateNamespace,
|
|
12
12
|
} from "./validation";
|
|
13
13
|
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Capitalized names of objects, like tables and systems
|
|
16
|
+
* @deprecated
|
|
17
|
+
*/
|
|
15
18
|
export const zObjectName = z.string().superRefine(validateCapitalizedName);
|
|
16
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Uncapitalized names of values, like keys and columns
|
|
21
|
+
* @deprecated
|
|
22
|
+
*/
|
|
17
23
|
export const zValueName = z.string().superRefine(validateUncapitalizedName);
|
|
18
|
-
/** Name that can start with any case
|
|
24
|
+
/** Name that can start with any case
|
|
25
|
+
* @deprecated
|
|
26
|
+
*/
|
|
19
27
|
export const zName = z.string().superRefine(validateName);
|
|
20
|
-
/** A namespace
|
|
28
|
+
/** A namespace
|
|
29
|
+
* @deprecated
|
|
30
|
+
*/
|
|
21
31
|
export const zNamespace = z.string().superRefine(validateNamespace);
|
|
22
32
|
|
|
23
|
-
/** List of unique enum member names and 0 < length < 256
|
|
33
|
+
/** List of unique enum member names and 0 < length < 256
|
|
34
|
+
* @deprecated
|
|
35
|
+
*/
|
|
24
36
|
export const zUserEnum = z.array(zObjectName).superRefine(validateEnum);
|
|
25
37
|
|
|
26
|
-
/** Ordinary routes
|
|
38
|
+
/** Ordinary routes
|
|
39
|
+
* @deprecated
|
|
40
|
+
*/
|
|
27
41
|
export const zOrdinaryRoute = z.string().superRefine(validateRoute);
|
|
28
|
-
/** Routes with exactly 1 non-empty level
|
|
42
|
+
/** Routes with exactly 1 non-empty level
|
|
43
|
+
* @deprecated
|
|
44
|
+
*/
|
|
29
45
|
export const zSingleLevelRoute = z.string().superRefine(validateSingleLevelRoute);
|
|
30
|
-
/** Base routes (can be an empty string)
|
|
46
|
+
/** Base routes (can be an empty string)
|
|
47
|
+
* @deprecated
|
|
48
|
+
*/
|
|
31
49
|
export const zBaseRoute = z.string().superRefine(validateBaseRoute);
|
|
32
50
|
|
|
33
|
-
/** A valid Ethereum address
|
|
51
|
+
/** A valid Ethereum address
|
|
52
|
+
* @deprecated
|
|
53
|
+
*/
|
|
34
54
|
export const zEthereumAddress = z.string().superRefine(validateEthereumAddress);
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { MUDConfigExtender } from "./core";
|
|
2
2
|
import { MUDContextAlreadyCreatedError, MUDContextNotCreatedError } from "./errors";
|
|
3
3
|
|
|
4
|
+
/** @deprecated */
|
|
4
5
|
export type GlobalWithMUDCoreContext = typeof global & {
|
|
5
6
|
__mudCoreContext: MUDCoreContext;
|
|
6
7
|
};
|
|
7
8
|
|
|
9
|
+
/** @deprecated */
|
|
8
10
|
export class MUDCoreContext {
|
|
11
|
+
/** @deprecated */
|
|
9
12
|
static _global = typeof global === "undefined" ? window.global ?? {} : global;
|
|
10
13
|
|
|
14
|
+
/** @deprecated */
|
|
11
15
|
public static isCreated(): boolean {
|
|
12
16
|
const globalWithMUDCoreContext = this._global as GlobalWithMUDCoreContext;
|
|
13
17
|
return globalWithMUDCoreContext.__mudCoreContext !== undefined;
|
|
14
18
|
}
|
|
15
19
|
|
|
20
|
+
/** @deprecated */
|
|
16
21
|
public static createContext(): MUDCoreContext {
|
|
17
22
|
if (this.isCreated()) {
|
|
18
23
|
throw new MUDContextAlreadyCreatedError();
|
|
@@ -23,6 +28,7 @@ export class MUDCoreContext {
|
|
|
23
28
|
return context;
|
|
24
29
|
}
|
|
25
30
|
|
|
31
|
+
/** @deprecated */
|
|
26
32
|
public static getContext(): MUDCoreContext {
|
|
27
33
|
const globalWithMUDCoreContext = this._global as GlobalWithMUDCoreContext;
|
|
28
34
|
const context = globalWithMUDCoreContext.__mudCoreContext;
|
|
@@ -32,5 +38,6 @@ export class MUDCoreContext {
|
|
|
32
38
|
return context;
|
|
33
39
|
}
|
|
34
40
|
|
|
41
|
+
/** @deprecated */
|
|
35
42
|
public readonly configExtenders: MUDConfigExtender[] = [];
|
|
36
43
|
}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { MUDCoreContext } from "./context";
|
|
2
2
|
|
|
3
|
+
/** @deprecated */
|
|
3
4
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
4
5
|
export interface MUDCoreUserConfig {}
|
|
5
6
|
|
|
7
|
+
/** @deprecated */
|
|
6
8
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
7
9
|
export interface MUDCoreConfig {}
|
|
8
10
|
|
|
11
|
+
/** @deprecated */
|
|
9
12
|
export type MUDConfigExtender = (config: MUDCoreConfig) => Record<string, unknown>;
|
|
10
13
|
|
|
11
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Resolver that sequentially passes the config through all the plugins
|
|
16
|
+
* @deprecated
|
|
17
|
+
*/
|
|
12
18
|
export function mudCoreConfig(config: MUDCoreUserConfig): MUDCoreConfig {
|
|
13
19
|
// config types can change with plugins, `any` helps avoid errors when typechecking dependencies
|
|
14
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -20,7 +26,10 @@ export function mudCoreConfig(config: MUDCoreUserConfig): MUDCoreConfig {
|
|
|
20
26
|
return configAsAny;
|
|
21
27
|
}
|
|
22
28
|
|
|
23
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Utility for plugin developers to extend the core config
|
|
31
|
+
* @deprecated
|
|
32
|
+
*/
|
|
24
33
|
export function extendMUDCoreConfig(extender: MUDConfigExtender) {
|
|
25
34
|
const context = MUDCoreContext.getContext();
|
|
26
35
|
context.configExtenders.push(extender);
|
|
@@ -32,10 +32,12 @@ export function isDynamicResolution(value: unknown): value is DynamicResolution
|
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Turn a DynamicResolution object into a ValueWithType based on the provided context
|
|
35
|
+
* @deprecated
|
|
35
36
|
*/
|
|
36
37
|
export function resolveWithContext(
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
39
|
unresolved: any,
|
|
38
|
-
context: { systemAddresses?: Record<string, Promise<string>>; tableIds?: Record<string, Uint8Array> }
|
|
40
|
+
context: { systemAddresses?: Record<string, Promise<string>>; tableIds?: Record<string, Uint8Array> },
|
|
39
41
|
): ValueWithType {
|
|
40
42
|
if (!isDynamicResolution(unresolved)) return unresolved;
|
|
41
43
|
let resolved: ValueWithType | undefined = undefined;
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { z, ZodError, ZodIssueCode } from "zod";
|
|
2
2
|
import { fromZodError } from "zod-validation-error";
|
|
3
3
|
|
|
4
|
+
/** @deprecated */
|
|
4
5
|
export class MUDContextAlreadyCreatedError extends Error {
|
|
5
6
|
name = "MUDContextAlreadyCreatedError";
|
|
6
7
|
message = "MUD context was already created";
|
|
7
8
|
}
|
|
8
9
|
|
|
10
|
+
/** @deprecated */
|
|
9
11
|
export class MUDContextNotCreatedError extends Error {
|
|
10
12
|
name = "MUDContextNotCreatedError";
|
|
11
13
|
message = "MUD context has not been created";
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Wrapper with preset styles, only requires a `prefix`
|
|
18
|
+
* @deprecated
|
|
19
|
+
*/
|
|
15
20
|
export function fromZodErrorCustom(error: ZodError, prefix: string) {
|
|
16
21
|
return fromZodError(error, {
|
|
17
22
|
prefix: prefix,
|
|
@@ -20,11 +25,13 @@ export function fromZodErrorCustom(error: ZodError, prefix: string) {
|
|
|
20
25
|
});
|
|
21
26
|
}
|
|
22
27
|
|
|
28
|
+
/** @deprecated */
|
|
23
29
|
export class NotInsideProjectError extends Error {
|
|
24
30
|
name = "NotInsideProjectError";
|
|
25
31
|
message = "You are not inside a MUD project";
|
|
26
32
|
}
|
|
27
33
|
|
|
34
|
+
/** @deprecated */
|
|
28
35
|
export function UnrecognizedSystemErrorFactory(path: string[], systemName: string) {
|
|
29
36
|
return new z.ZodError([{ code: ZodIssueCode.custom, path: path, message: `Unrecognized system: "${systemName}"` }]);
|
|
30
37
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { ZodIssueCode, RefinementCtx } from "zod";
|
|
2
2
|
import { isAddress } from "viem";
|
|
3
3
|
|
|
4
|
+
/** @deprecated */
|
|
4
5
|
export const STORE_NAME_MAX_LENGTH = 16;
|
|
6
|
+
/** @deprecated */
|
|
5
7
|
export const STORE_NAMESPACE_MAX_LENGTH = 14;
|
|
6
8
|
|
|
9
|
+
/** @deprecated */
|
|
7
10
|
export function validateName(name: string, ctx: RefinementCtx) {
|
|
8
11
|
if (!/^\w+$/.test(name)) {
|
|
9
12
|
ctx.addIssue({
|
|
@@ -13,6 +16,7 @@ export function validateName(name: string, ctx: RefinementCtx) {
|
|
|
13
16
|
}
|
|
14
17
|
}
|
|
15
18
|
|
|
19
|
+
/** @deprecated */
|
|
16
20
|
export function validateCapitalizedName(name: string, ctx: RefinementCtx) {
|
|
17
21
|
validateName(name, ctx);
|
|
18
22
|
|
|
@@ -24,6 +28,7 @@ export function validateCapitalizedName(name: string, ctx: RefinementCtx) {
|
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
|
|
31
|
+
/** @deprecated */
|
|
27
32
|
export function validateUncapitalizedName(name: string, ctx: RefinementCtx) {
|
|
28
33
|
validateName(name, ctx);
|
|
29
34
|
|
|
@@ -35,7 +40,10 @@ export function validateUncapitalizedName(name: string, ctx: RefinementCtx) {
|
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
|
|
38
|
-
|
|
43
|
+
/**
|
|
44
|
+
* validates only the enum array, not the names of enum members
|
|
45
|
+
* @deprecated
|
|
46
|
+
*/
|
|
39
47
|
export function validateEnum(members: string[], ctx: RefinementCtx) {
|
|
40
48
|
if (members.length === 0) {
|
|
41
49
|
ctx.addIssue({
|
|
@@ -59,6 +67,7 @@ export function validateEnum(members: string[], ctx: RefinementCtx) {
|
|
|
59
67
|
}
|
|
60
68
|
}
|
|
61
69
|
|
|
70
|
+
/** @deprecated */
|
|
62
71
|
function _factoryForValidateRoute(requireNonEmpty: boolean, requireSingleLevel: boolean) {
|
|
63
72
|
return (route: string, ctx: RefinementCtx) => {
|
|
64
73
|
if (route === "") {
|
|
@@ -113,12 +122,16 @@ function _factoryForValidateRoute(requireNonEmpty: boolean, requireSingleLevel:
|
|
|
113
122
|
};
|
|
114
123
|
}
|
|
115
124
|
|
|
125
|
+
/** @deprecated */
|
|
116
126
|
export const validateRoute = _factoryForValidateRoute(true, false);
|
|
117
127
|
|
|
128
|
+
/** @deprecated */
|
|
118
129
|
export const validateBaseRoute = _factoryForValidateRoute(false, false);
|
|
119
130
|
|
|
131
|
+
/** @deprecated */
|
|
120
132
|
export const validateSingleLevelRoute = _factoryForValidateRoute(true, true);
|
|
121
133
|
|
|
134
|
+
/** @deprecated */
|
|
122
135
|
export function validateEthereumAddress(address: string, ctx: RefinementCtx) {
|
|
123
136
|
if (!isAddress(address)) {
|
|
124
137
|
ctx.addIssue({
|
|
@@ -128,6 +141,7 @@ export function validateEthereumAddress(address: string, ctx: RefinementCtx) {
|
|
|
128
141
|
}
|
|
129
142
|
}
|
|
130
143
|
|
|
144
|
+
/** @deprecated */
|
|
131
145
|
export function getDuplicates<T>(array: T[]) {
|
|
132
146
|
const checked = new Set<T>();
|
|
133
147
|
const duplicates = new Set<T>();
|
|
@@ -140,6 +154,7 @@ export function getDuplicates<T>(array: T[]) {
|
|
|
140
154
|
return [...duplicates];
|
|
141
155
|
}
|
|
142
156
|
|
|
157
|
+
/** @deprecated */
|
|
143
158
|
export function validateNamespace(name: string, ctx: RefinementCtx) {
|
|
144
159
|
if (name.length > STORE_NAMESPACE_MAX_LENGTH) {
|
|
145
160
|
ctx.addIssue({
|
|
@@ -155,7 +170,10 @@ export function validateNamespace(name: string, ctx: RefinementCtx) {
|
|
|
155
170
|
}
|
|
156
171
|
}
|
|
157
172
|
|
|
158
|
-
/**
|
|
173
|
+
/**
|
|
174
|
+
* Returns null if the type does not look like a static array, otherwise element and length data
|
|
175
|
+
* @deprecated
|
|
176
|
+
*/
|
|
159
177
|
export function parseStaticArray(abiType: string) {
|
|
160
178
|
const matches = abiType.match(/^(\w+)\[(\d+)\]$/);
|
|
161
179
|
if (!matches) return null;
|
|
@@ -9,9 +9,12 @@ import os from "os";
|
|
|
9
9
|
// TODO: explore using https://www.npmjs.com/package/ts-import instead
|
|
10
10
|
|
|
11
11
|
// In order of preference files are checked
|
|
12
|
+
/** @deprecated */
|
|
12
13
|
const configFiles = ["mud.config.js", "mud.config.mjs", "mud.config.ts", "mud.config.mts"];
|
|
14
|
+
/** @deprecated */
|
|
13
15
|
const TEMP_CONFIG = "mud.config.temp.mjs";
|
|
14
16
|
|
|
17
|
+
/** @deprecated */
|
|
15
18
|
export async function loadConfig(configPath?: string): Promise<unknown> {
|
|
16
19
|
configPath = await resolveConfigPath(configPath);
|
|
17
20
|
try {
|
|
@@ -36,6 +39,7 @@ export async function loadConfig(configPath?: string): Promise<unknown> {
|
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
41
|
|
|
42
|
+
/** @deprecated */
|
|
39
43
|
export async function resolveConfigPath(configPath: string | undefined, toFileURL?: boolean) {
|
|
40
44
|
if (configPath === undefined) {
|
|
41
45
|
configPath = await getUserConfigPath();
|
|
@@ -51,6 +55,7 @@ export async function resolveConfigPath(configPath: string | undefined, toFileUR
|
|
|
51
55
|
return toFileURL && os.platform() === "win32" ? pathToFileURL(configPath).href : configPath;
|
|
52
56
|
}
|
|
53
57
|
|
|
58
|
+
/** @deprecated */
|
|
54
59
|
async function getUserConfigPath() {
|
|
55
60
|
const tsConfigPath = await findUp(configFiles);
|
|
56
61
|
if (tsConfigPath === undefined) {
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/library/errors.ts"],"sourcesContent":["import { z, ZodError, ZodIssueCode } from \"zod\";\nimport { fromZodError } from \"zod-validation-error\";\n\nexport class MUDContextAlreadyCreatedError extends Error {\n name = \"MUDContextAlreadyCreatedError\";\n message = \"MUD context was already created\";\n}\n\nexport class MUDContextNotCreatedError extends Error {\n name = \"MUDContextNotCreatedError\";\n message = \"MUD context has not been created\";\n}\n\n// Wrapper with preset styles, only requires a `prefix`\nexport function fromZodErrorCustom(error: ZodError, prefix: string) {\n return fromZodError(error, {\n prefix: prefix,\n prefixSeparator: \"\\n- \",\n issueSeparator: \"\\n- \",\n });\n}\n\nexport class NotInsideProjectError extends Error {\n name = \"NotInsideProjectError\";\n message = \"You are not inside a MUD project\";\n}\n\nexport function UnrecognizedSystemErrorFactory(path: string[], systemName: string) {\n return new z.ZodError([{ code: ZodIssueCode.custom, path: path, message: `Unrecognized system: \"${systemName}\"` }]);\n}\n"],"mappings":"wKAAA,OAAS,KAAAA,EAAa,gBAAAC,MAAoB,MAC1C,OAAS,gBAAAC,MAAoB,uBAEtB,IAAMC,EAAN,cAA4C,KAAM,CACvD,KAAO,gCACP,QAAU,iCACZ,EAEaC,EAAN,cAAwC,KAAM,CACnD,KAAO,4BACP,QAAU,kCACZ,EAGO,SAASC,EAAmBC,EAAiBC,EAAgB,CAClE,OAAOL,EAAaI,EAAO,CACzB,OAAQC,EACR,gBAAiB;AAAA,IACjB,eAAgB;AAAA,GAClB,CAAC,CACH,CAEO,IAAMC,EAAN,cAAoC,KAAM,CAC/C,KAAO,wBACP,QAAU,kCACZ,EAEO,SAASC,EAA+BC,EAAgBC,EAAoB,CACjF,OAAO,IAAIX,EAAE,SAAS,CAAC,CAAE,KAAMC,EAAa,OAAQ,KAAMS,EAAM,QAAS,yBAAyBC,IAAc,CAAC,CAAC,CACpH","names":["z","ZodIssueCode","fromZodError","MUDContextAlreadyCreatedError","MUDContextNotCreatedError","fromZodErrorCustom","error","prefix","NotInsideProjectError","UnrecognizedSystemErrorFactory","path","systemName"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/library/commonSchemas.ts","../src/library/validation.ts","../src/library/context.ts","../src/library/core.ts","../src/library/dynamicResolution.ts"],"sourcesContent":["import { z } from \"zod\";\nimport {\n validateBaseRoute,\n validateCapitalizedName,\n validateEthereumAddress,\n validateEnum,\n validateName,\n validateRoute,\n validateSingleLevelRoute,\n validateUncapitalizedName,\n validateNamespace,\n} from \"./validation\";\n\n/** Capitalized names of objects, like tables and systems */\nexport const zObjectName = z.string().superRefine(validateCapitalizedName);\n/** Uncapitalized names of values, like keys and columns */\nexport const zValueName = z.string().superRefine(validateUncapitalizedName);\n/** Name that can start with any case */\nexport const zName = z.string().superRefine(validateName);\n/** A namespace */\nexport const zNamespace = z.string().superRefine(validateNamespace);\n\n/** List of unique enum member names and 0 < length < 256 */\nexport const zUserEnum = z.array(zObjectName).superRefine(validateEnum);\n\n/** Ordinary routes */\nexport const zOrdinaryRoute = z.string().superRefine(validateRoute);\n/** Routes with exactly 1 non-empty level */\nexport const zSingleLevelRoute = z.string().superRefine(validateSingleLevelRoute);\n/** Base routes (can be an empty string) */\nexport const zBaseRoute = z.string().superRefine(validateBaseRoute);\n\n/** A valid Ethereum address */\nexport const zEthereumAddress = z.string().superRefine(validateEthereumAddress);\n","import { ZodIssueCode, RefinementCtx } from \"zod\";\nimport { isAddress } from \"viem\";\n\nexport const STORE_NAME_MAX_LENGTH = 16;\nexport const STORE_NAMESPACE_MAX_LENGTH = 14;\n\nexport function validateName(name: string, ctx: RefinementCtx) {\n if (!/^\\w+$/.test(name)) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Name must contain only alphanumeric & underscore characters`,\n });\n }\n}\n\nexport function validateCapitalizedName(name: string, ctx: RefinementCtx) {\n validateName(name, ctx);\n\n if (!/^[A-Z]/.test(name)) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Name must start with a capital letter`,\n });\n }\n}\n\nexport function validateUncapitalizedName(name: string, ctx: RefinementCtx) {\n validateName(name, ctx);\n\n if (!/^[a-z]/.test(name)) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Name must start with a lowercase letter`,\n });\n }\n}\n\n// validates only the enum array, not the names of enum members\nexport function validateEnum(members: string[], ctx: RefinementCtx) {\n if (members.length === 0) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Enum must not be empty`,\n });\n }\n if (members.length >= 256) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Length of enum must be < 256`,\n });\n }\n\n const duplicates = getDuplicates(members);\n if (duplicates.length > 0) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Enum must not have duplicate names for: ${duplicates.join(\", \")}`,\n });\n }\n}\n\nfunction _factoryForValidateRoute(requireNonEmpty: boolean, requireSingleLevel: boolean) {\n return (route: string, ctx: RefinementCtx) => {\n if (route === \"\") {\n if (requireNonEmpty) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Route must not be empty`,\n });\n }\n // we can skip further validation for empty routes\n return;\n }\n\n if (route[0] !== \"/\") {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Route must start with \"/\"`,\n });\n }\n\n if (route[route.length - 1] === \"/\") {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Route must not end with \"/\"`,\n });\n }\n\n const parts = route.split(\"/\");\n if (requireSingleLevel && parts.length > 2) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Route must only have one level (e.g. \"/foo\")`,\n });\n }\n\n // start at 1 to skip the first empty part\n for (let i = 1; i < parts.length; i++) {\n if (parts[i] === \"\") {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Route must not contain empty route fragments (e.g. \"//\")`,\n });\n }\n\n if (!/^\\w+$/.test(parts[i])) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Route must contain only alphanumeric & underscore characters`,\n });\n }\n }\n };\n}\n\nexport const validateRoute = _factoryForValidateRoute(true, false);\n\nexport const validateBaseRoute = _factoryForValidateRoute(false, false);\n\nexport const validateSingleLevelRoute = _factoryForValidateRoute(true, true);\n\nexport function validateEthereumAddress(address: string, ctx: RefinementCtx) {\n if (!isAddress(address)) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Address must be a valid Ethereum address`,\n });\n }\n}\n\nexport function getDuplicates<T>(array: T[]) {\n const checked = new Set<T>();\n const duplicates = new Set<T>();\n for (const element of array) {\n if (checked.has(element)) {\n duplicates.add(element);\n }\n checked.add(element);\n }\n return [...duplicates];\n}\n\nexport function validateNamespace(name: string, ctx: RefinementCtx) {\n if (name.length > STORE_NAMESPACE_MAX_LENGTH) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Namespace must be <= ${STORE_NAMESPACE_MAX_LENGTH} characters`,\n });\n }\n if (!/^\\w*$/.test(name)) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Selector must contain only alphanumeric & underscore characters`,\n });\n }\n}\n\n/** Returns null if the type does not look like a static array, otherwise element and length data */\nexport function parseStaticArray(abiType: string) {\n const matches = abiType.match(/^(\\w+)\\[(\\d+)\\]$/);\n if (!matches) return null;\n return {\n elementType: matches[1],\n staticLength: Number.parseInt(matches[2]),\n };\n}\n","import { MUDConfigExtender } from \"./core\";\nimport { MUDContextAlreadyCreatedError, MUDContextNotCreatedError } from \"./errors\";\n\nexport type GlobalWithMUDCoreContext = typeof global & {\n __mudCoreContext: MUDCoreContext;\n};\n\nexport class MUDCoreContext {\n static _global = typeof global === \"undefined\" ? window.global ?? {} : global;\n\n public static isCreated(): boolean {\n const globalWithMUDCoreContext = this._global as GlobalWithMUDCoreContext;\n return globalWithMUDCoreContext.__mudCoreContext !== undefined;\n }\n\n public static createContext(): MUDCoreContext {\n if (this.isCreated()) {\n throw new MUDContextAlreadyCreatedError();\n }\n const globalWithMUDCoreContext = this._global as GlobalWithMUDCoreContext;\n const context = new MUDCoreContext();\n globalWithMUDCoreContext.__mudCoreContext = context;\n return context;\n }\n\n public static getContext(): MUDCoreContext {\n const globalWithMUDCoreContext = this._global as GlobalWithMUDCoreContext;\n const context = globalWithMUDCoreContext.__mudCoreContext;\n if (context === undefined) {\n throw new MUDContextNotCreatedError();\n }\n return context;\n }\n\n public readonly configExtenders: MUDConfigExtender[] = [];\n}\n","import { MUDCoreContext } from \"./context\";\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface MUDCoreUserConfig {}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface MUDCoreConfig {}\n\nexport type MUDConfigExtender = (config: MUDCoreConfig) => Record<string, unknown>;\n\n/** Resolver that sequentially passes the config through all the plugins */\nexport function mudCoreConfig(config: MUDCoreUserConfig): MUDCoreConfig {\n // config types can change with plugins, `any` helps avoid errors when typechecking dependencies\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let configAsAny = config as any;\n const context = MUDCoreContext.getContext();\n for (const extender of context.configExtenders) {\n configAsAny = extender(configAsAny);\n }\n return configAsAny;\n}\n\n/** Utility for plugin developers to extend the core config */\nexport function extendMUDCoreConfig(extender: MUDConfigExtender) {\n const context = MUDCoreContext.getContext();\n context.configExtenders.push(extender);\n}\n","import { MUDError } from \"@latticexyz/common/errors\";\n\nexport enum DynamicResolutionType {\n TABLE_ID,\n SYSTEM_ADDRESS,\n}\n\nexport type DynamicResolution = {\n type: DynamicResolutionType;\n input: string;\n};\n\nexport type ValueWithType = {\n value: string | number | Uint8Array;\n type: string;\n};\n\n/**\n * Dynamically resolve a table name to a table id at deploy time\n */\nexport function resolveTableId(tableName: string) {\n return {\n type: DynamicResolutionType.TABLE_ID,\n input: tableName,\n };\n}\n\n/** Type guard for DynamicResolution */\nexport function isDynamicResolution(value: unknown): value is DynamicResolution {\n return typeof value === \"object\" && value !== null && \"type\" in value && \"input\" in value;\n}\n\n/**\n * Turn a DynamicResolution object into a ValueWithType based on the provided context\n */\nexport function resolveWithContext(\n unresolved: any,\n context: { systemAddresses?: Record<string, Promise<string>>; tableIds?: Record<string, Uint8Array> }\n): ValueWithType {\n if (!isDynamicResolution(unresolved)) return unresolved;\n let resolved: ValueWithType | undefined = undefined;\n\n if (unresolved.type === DynamicResolutionType.TABLE_ID) {\n const tableId = context.tableIds?.[unresolved.input];\n resolved = tableId && { value: tableId, type: \"bytes32\" };\n }\n\n if (resolved === undefined) {\n throw new MUDError(`Could not resolve dynamic resolution: \\n${JSON.stringify(unresolved, null, 2)}`);\n }\n\n return resolved;\n}\n"],"mappings":"sDAAA,OAAS,KAAAA,MAAS,MCAlB,OAAS,gBAAAC,MAAmC,MAC5C,OAAS,aAAAC,MAAiB,OAEnB,IAAMC,EAAwB,GACxBC,EAA6B,GAEnC,SAASC,EAAaC,EAAcC,EAAoB,CACxD,QAAQ,KAAKD,CAAI,GACpBC,EAAI,SAAS,CACX,KAAMN,EAAa,OACnB,QAAS,6DACX,CAAC,CAEL,CAEO,SAASO,EAAwBF,EAAcC,EAAoB,CACxEF,EAAaC,EAAMC,CAAG,EAEjB,SAAS,KAAKD,CAAI,GACrBC,EAAI,SAAS,CACX,KAAMN,EAAa,OACn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,EACnDE,EAAWC,GAAW,CAAE,MAAOA,EAAS,KAAM,SAAU,EAG1D,GAAID,IAAa,OACf,MAAM,IAAIT,EAAS;AAAA,EAA2C,KAAK,UAAUO,EAAY,KAAM,CAAC,GAAG,EAGrG,OAAOE,CACT","names":["z","ZodIssueCode","isAddress","STORE_NAME_MAX_LENGTH","STORE_NAMESPACE_MAX_LENGTH","validateName","name","ctx","validateCapitalizedName","validateUncapitalizedName","validateEnum","members","duplicates","getDuplicates","_factoryForValidateRoute","requireNonEmpty","requireSingleLevel","route","parts","i","validateRoute","validateBaseRoute","validateSingleLevelRoute","validateEthereumAddress","address","array","checked","element","validateNamespace","parseStaticArray","abiType","matches","zObjectName","z","validateCapitalizedName","zValueName","validateUncapitalizedName","zName","validateName","zNamespace","validateNamespace","zUserEnum","validateEnum","zOrdinaryRoute","validateRoute","zSingleLevelRoute","validateSingleLevelRoute","zBaseRoute","validateBaseRoute","zEthereumAddress","validateEthereumAddress","_MUDCoreContext","MUDContextAlreadyCreatedError","globalWithMUDCoreContext","context","MUDContextNotCreatedError","MUDCoreContext","__publicField","mudCoreConfig","config","configAsAny","context","MUDCoreContext","extender","extendMUDCoreConfig","MUDError","DynamicResolutionType","resolveTableId","tableName","isDynamicResolution","value","resolveWithContext","unresolved","context","resolved","tableId"]}
|
package/dist/node/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/node/loadConfig.ts"],"sourcesContent":["import { findUp } from \"find-up\";\nimport path from \"path\";\nimport { NotInsideProjectError } from \"../library/errors\";\nimport esbuild from \"esbuild\";\nimport { rmSync } from \"fs\";\nimport { pathToFileURL } from \"url\";\nimport os from \"os\";\n\n// TODO: explore using https://www.npmjs.com/package/ts-import instead\n\n// In order of preference files are checked\nconst configFiles = [\"mud.config.js\", \"mud.config.mjs\", \"mud.config.ts\", \"mud.config.mts\"];\nconst TEMP_CONFIG = \"mud.config.temp.mjs\";\n\nexport async function loadConfig(configPath?: string): Promise<unknown> {\n configPath = await resolveConfigPath(configPath);\n try {\n await esbuild.build({\n entryPoints: [configPath],\n format: \"esm\",\n outfile: TEMP_CONFIG,\n // https://esbuild.github.io/getting-started/#bundling-for-node\n platform: \"node\",\n // bundle local imports (otherwise it may error, js can't import ts)\n bundle: true,\n // avoid bundling external imports (it's unnecessary and esbuild can't handle all node features)\n packages: \"external\",\n });\n configPath = await resolveConfigPath(TEMP_CONFIG, true);\n // Node.js caches dynamic imports, so without appending a cache breaking\n // param like `?update={Date.now()}` this import always returns the same config\n // if called multiple times in a single process, like the `dev-contracts` cli\n return (await import(configPath + `?update=${Date.now()}`)).default;\n } finally {\n rmSync(TEMP_CONFIG, { force: true });\n }\n}\n\nexport async function resolveConfigPath(configPath: string | undefined, toFileURL?: boolean) {\n if (configPath === undefined) {\n configPath = await getUserConfigPath();\n } else {\n if (!path.isAbsolute(configPath)) {\n configPath = path.join(process.cwd(), configPath);\n configPath = path.normalize(configPath);\n }\n }\n\n // Add `file:///` for Windows support\n // (see https://github.com/nodejs/node/issues/31710)\n return toFileURL && os.platform() === \"win32\" ? pathToFileURL(configPath).href : configPath;\n}\n\nasync function getUserConfigPath() {\n const tsConfigPath = await findUp(configFiles);\n if (tsConfigPath === undefined) {\n throw new NotInsideProjectError();\n }\n return tsConfigPath;\n}\n"],"mappings":"yCAAA,OAAS,UAAAA,MAAc,UACvB,OAAOC,MAAU,OAEjB,OAAOC,MAAa,UACpB,OAAS,UAAAC,MAAc,KACvB,OAAS,iBAAAC,MAAqB,MAC9B,OAAOC,MAAQ,KAKf,IAAMC,EAAc,CAAC,gBAAiB,iBAAkB,gBAAiB,gBAAgB,EACnFC,EAAc,sBAEpB,eAAsBC,EAAWC,EAAuC,CACtEA,EAAa,MAAMC,EAAkBD,CAAU,EAC/C,GAAI,CACF,aAAMP,EAAQ,MAAM,CAClB,YAAa,CAACO,CAAU,EACxB,OAAQ,MACR,QAASF,EAET,SAAU,OAEV,OAAQ,GAER,SAAU,UACZ,CAAC,EACDE,EAAa,MAAMC,EAAkBH,EAAa,EAAI,GAI9C,MAAM,OAAOE,EAAa,WAAW,KAAK,IAAI,MAAM,OAC9D,QAAE,CACAN,EAAOI,EAAa,CAAE,MAAO,EAAK,CAAC,CACrC,CACF,CAEA,eAAsBG,EAAkBD,EAAgCE,EAAqB,CAC3F,OAAIF,IAAe,OACjBA,EAAa,MAAMG,EAAkB,EAEhCC,EAAK,WAAWJ,CAAU,IAC7BA,EAAaI,EAAK,KAAK,QAAQ,IAAI,EAAGJ,CAAU,EAChDA,EAAaI,EAAK,UAAUJ,CAAU,GAMnCE,GAAaN,EAAG,SAAS,IAAM,QAAUD,EAAcK,CAAU,EAAE,KAAOA,CACnF,CAEA,eAAeG,GAAoB,CACjC,IAAME,EAAe,MAAMC,EAAOT,CAAW,EAC7C,GAAIQ,IAAiB,OACnB,MAAM,IAAIE,EAEZ,OAAOF,CACT","names":["findUp","path","esbuild","rmSync","pathToFileURL","os","configFiles","TEMP_CONFIG","loadConfig","configPath","resolveConfigPath","toFileURL","getUserConfigPath","path","tsConfigPath","findUp","NotInsideProjectError"]}
|
package/dist/register/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/register/index.ts"],"sourcesContent":["import { mudCoreConfig, resolveTableId } from \"../library\";\nimport { MUDCoreContext } from \"../library/context\";\n\nexport { mudCoreConfig, resolveTableId };\n\n// Importing this file has side-effects, and it should always be imported before MUD plugins.\n// Use this import for defining a MUD config.\n// Use the library endpoint instead when writing MUD-based libraries or plugins.\nif (!MUDCoreContext.isCreated()) {\n MUDCoreContext.createContext();\n}\n"],"mappings":"oFAQKA,EAAe,UAAU,GAC5BA,EAAe,cAAc","names":["MUDCoreContext"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|