@latticexyz/config 2.0.0-next.8 → 2.0.0-next.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ import{a as m,b as f,c as p}from"./chunk-AXXYPYMM.js";import{z as r}from"zod";import{utils as U}from"ethers";import{ZodIssueCode as s}from"zod";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.isAddress(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
+ ${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-3J7LHGP4.js.map
@@ -0,0 +1 @@
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 { utils } from \"ethers\";\nimport { ZodIssueCode, RefinementCtx } from \"zod\";\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 (!utils.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 res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Q,CACvC,CC1BA,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,CAKO,SAASC,GACdC,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","utils","ZodIssueCode","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,2 +1,2 @@
1
- import{A as F,B as G,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v as A,w as B,x as C,y as D,z as E}from"../chunk-4G6ZGMDP.js";import{b as v,c as w,d as x,e as y,f as z}from"../chunk-AXXYPYMM.js";export{D as DynamicResolutionType,v as MUDContextAlreadyCreatedError,w as MUDContextNotCreatedError,A as MUDCoreContext,y as NotInsideProjectError,a as STORE_SELECTOR_MAX_LENGTH,z as UnrecognizedSystemErrorFactory,C as extendMUDCoreConfig,x as fromZodErrorCustom,j as getDuplicates,F as isDynamicResolution,B as mudCoreConfig,l as parseStaticArray,E as resolveTableId,G as resolveWithContext,g as validateBaseRoute,c as validateCapitalizedName,e as validateEnum,i as validateEthereumAddress,b as validateName,f as validateRoute,k as validateSelector,h as validateSingleLevelRoute,d as validateUncapitalizedName,o as zAnyCaseName,s as zBaseRoute,t as zEthereumAddress,m as zObjectName,q as zOrdinaryRoute,u as zSelector,r as zSingleLevelRoute,p as zUserEnum,n as zValueName};
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-3J7LHGP4.js";import{b as w,c as x,d as y,e as z,f as A}from"../chunk-AXXYPYMM.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
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import{v as e,w as o,z as r}from"../chunk-4G6ZGMDP.js";import"../chunk-AXXYPYMM.js";e.isCreated()||e.createContext();export{o as mudCoreConfig,r as resolveTableId};
1
+ import{A as r,w as e,x as o}from"../chunk-3J7LHGP4.js";import"../chunk-AXXYPYMM.js";e.isCreated()||e.createContext();export{o as mudCoreConfig,r as resolveTableId};
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latticexyz/config",
3
- "version": "2.0.0-next.8",
3
+ "version": "2.0.0-next.9",
4
4
  "description": "Config for Store and World",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,8 +34,8 @@
34
34
  "find-up": "^6.3.0",
35
35
  "zod": "^3.21.4",
36
36
  "zod-validation-error": "^1.3.0",
37
- "@latticexyz/common": "2.0.0-next.8",
38
- "@latticexyz/schema-type": "2.0.0-next.8"
37
+ "@latticexyz/common": "2.0.0-next.9",
38
+ "@latticexyz/schema-type": "2.0.0-next.9"
39
39
  },
40
40
  "devDependencies": {
41
41
  "tsup": "^6.7.0"
@@ -8,7 +8,7 @@ import {
8
8
  validateRoute,
9
9
  validateSingleLevelRoute,
10
10
  validateUncapitalizedName,
11
- validateSelector,
11
+ validateNamespace,
12
12
  } from "./validation";
13
13
 
14
14
  /** Capitalized names of objects, like tables and systems */
@@ -16,7 +16,10 @@ export const zObjectName = z.string().superRefine(validateCapitalizedName);
16
16
  /** Uncapitalized names of values, like keys and columns */
17
17
  export const zValueName = z.string().superRefine(validateUncapitalizedName);
18
18
  /** Name that can start with any case */
19
- export const zAnyCaseName = z.string().superRefine(validateName);
19
+ export const zName = z.string().superRefine(validateName);
20
+ /** A namespace */
21
+ export const zNamespace = z.string().superRefine(validateNamespace);
22
+
20
23
  /** List of unique enum member names and 0 < length < 256 */
21
24
  export const zUserEnum = z.array(zObjectName).superRefine(validateEnum);
22
25
 
@@ -29,6 +32,3 @@ export const zBaseRoute = z.string().superRefine(validateBaseRoute);
29
32
 
30
33
  /** A valid Ethereum address */
31
34
  export const zEthereumAddress = z.string().superRefine(validateEthereumAddress);
32
-
33
- /** A selector for namespace/file/resource */
34
- export const zSelector = z.string().superRefine(validateSelector);
@@ -33,10 +33,10 @@ export function isDynamicResolution(value: unknown): value is DynamicResolution
33
33
  /**
34
34
  * Turn a DynamicResolution object into a ValueWithType based on the provided context
35
35
  */
36
- export async function resolveWithContext(
36
+ export function resolveWithContext(
37
37
  unresolved: any,
38
38
  context: { systemAddresses?: Record<string, Promise<string>>; tableIds?: Record<string, Uint8Array> }
39
- ): Promise<ValueWithType> {
39
+ ): ValueWithType {
40
40
  if (!isDynamicResolution(unresolved)) return unresolved;
41
41
  let resolved: ValueWithType | undefined = undefined;
42
42
 
@@ -1,7 +1,8 @@
1
1
  import { utils } from "ethers";
2
2
  import { ZodIssueCode, RefinementCtx } from "zod";
3
3
 
4
- export const STORE_SELECTOR_MAX_LENGTH = 16;
4
+ export const STORE_NAME_MAX_LENGTH = 16;
5
+ export const STORE_NAMESPACE_MAX_LENGTH = 14;
5
6
 
6
7
  export function validateName(name: string, ctx: RefinementCtx) {
7
8
  if (!/^\w+$/.test(name)) {
@@ -139,11 +140,11 @@ export function getDuplicates<T>(array: T[]) {
139
140
  return [...duplicates];
140
141
  }
141
142
 
142
- export function validateSelector(name: string, ctx: RefinementCtx) {
143
- if (name.length > STORE_SELECTOR_MAX_LENGTH) {
143
+ export function validateNamespace(name: string, ctx: RefinementCtx) {
144
+ if (name.length > STORE_NAMESPACE_MAX_LENGTH) {
144
145
  ctx.addIssue({
145
146
  code: ZodIssueCode.custom,
146
- message: `Selector must be <= ${STORE_SELECTOR_MAX_LENGTH} characters`,
147
+ message: `Namespace must be <= ${STORE_NAMESPACE_MAX_LENGTH} characters`,
147
148
  });
148
149
  }
149
150
  if (!/^\w*$/.test(name)) {
@@ -1,3 +0,0 @@
1
- import{a as m,b as f,c as p}from"./chunk-AXXYPYMM.js";import{z as s}from"zod";import{utils as E}from"ethers";import{ZodIssueCode as r}from"zod";var g=16;function d(e,t){/^\w+$/.test(e)||t.addIssue({code:r.custom,message:"Name must contain only alphanumeric & underscore characters"})}function x(e,t){d(e,t),/^[A-Z]/.test(e)||t.addIssue({code:r.custom,message:"Name must start with a capital letter"})}function C(e,t){d(e,t),/^[a-z]/.test(e)||t.addIssue({code:r.custom,message:"Name must start with a lowercase letter"})}function h(e,t){e.length===0&&t.addIssue({code:r.custom,message:"Enum must not be empty"}),e.length>=256&&t.addIssue({code:r.custom,message:"Length of enum must be < 256"});let o=M(e);o.length>0&&t.addIssue({code:r.custom,message:`Enum must not have duplicate names for: ${o.join(", ")}`})}function c(e,t){return(o,n)=>{if(o===""){e&&n.addIssue({code:r.custom,message:"Route must not be empty"});return}o[0]!=="/"&&n.addIssue({code:r.custom,message:'Route must start with "/"'}),o[o.length-1]==="/"&&n.addIssue({code:r.custom,message:'Route must not end with "/"'});let a=o.split("/");t&&a.length>2&&n.addIssue({code:r.custom,message:'Route must only have one level (e.g. "/foo")'});for(let u=1;u<a.length;u++)a[u]===""&&n.addIssue({code:r.custom,message:'Route must not contain empty route fragments (e.g. "//")'}),/^\w+$/.test(a[u])||n.addIssue({code:r.custom,message:"Route must contain only alphanumeric & underscore characters"})}}var y=c(!0,!1),R=c(!1,!1),b=c(!0,!0);function D(e,t){E.isAddress(e)||t.addIssue({code:r.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 U(e,t){e.length>g&&t.addIssue({code:r.custom,message:`Selector must be <= ${g} characters`}),/^\w*$/.test(e)||t.addIssue({code:r.custom,message:"Selector must contain only alphanumeric & underscore characters"})}function z(e){let t=e.match(/^(\w+)\[(\d+)\]$/);return t?{elementType:t[1],staticLength:Number.parseInt(t[2])}:null}var v=s.string().superRefine(x),$=s.string().superRefine(C),B=s.string().superRefine(d),G=s.array(v).superRefine(h),O=s.string().superRefine(y),V=s.string().superRefine(b),j=s.string().superRefine(R),k=s.string().superRefine(D),P=s.string().superRefine(U);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 Y(e){let t=e,o=i.getContext();for(let n of o.configExtenders)t=n(t);return t}function q(e){i.getContext().configExtenders.push(e)}import{MUDError as I}from"@latticexyz/common/errors";var w=(o=>(o[o.TABLE_ID=0]="TABLE_ID",o[o.SYSTEM_ADDRESS=1]="SYSTEM_ADDRESS",o))(w||{});function ee(e){return{type:0,input:e}}function A(e){return typeof e=="object"&&e!==null&&"type"in e&&"input"in e}async function te(e,t){if(!A(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
- ${JSON.stringify(e,null,2)}`);return o}export{g as a,d as b,x as c,C as d,h as e,y as f,R as g,b as h,D as i,M as j,U as k,z as l,v as m,$ as n,B as o,G as p,O as q,V as r,j as s,k as t,P as u,i as v,Y as w,q as x,w as y,ee as z,A,te as B};
3
- //# sourceMappingURL=chunk-4G6ZGMDP.js.map
@@ -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 validateSelector,\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 zAnyCaseName = z.string().superRefine(validateName);\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\n/** A selector for namespace/file/resource */\nexport const zSelector = z.string().superRefine(validateSelector);\n","import { utils } from \"ethers\";\nimport { ZodIssueCode, RefinementCtx } from \"zod\";\n\nexport const STORE_SELECTOR_MAX_LENGTH = 16;\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 (!utils.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 validateSelector(name: string, ctx: RefinementCtx) {\n if (name.length > STORE_SELECTOR_MAX_LENGTH) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Selector must be <= ${STORE_SELECTOR_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 async function resolveWithContext(\n unresolved: any,\n context: { systemAddresses?: Record<string, Promise<string>>; tableIds?: Record<string, Uint8Array> }\n): Promise<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,SAAAC,MAAa,SACtB,OAAS,gBAAA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,MAAO,CACL,KAAM,EACN,MAAOA,CACT,CACF,CAGO,SAASC,EAAoBC,EAA4C,CAC9E,OAAO,OAAOA,GAAU,UAAYA,IAAU,MAAQ,SAAUA,GAAS,UAAWA,CACtF,CAKA,eAAsBC,GACpBC,EACAC,EACwB,CACxB,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","utils","ZodIssueCode","STORE_SELECTOR_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","validateSelector","parseStaticArray","abiType","matches","zObjectName","z","validateCapitalizedName","zValueName","validateUncapitalizedName","zAnyCaseName","validateName","zUserEnum","validateEnum","zOrdinaryRoute","validateRoute","zSingleLevelRoute","validateSingleLevelRoute","zBaseRoute","validateBaseRoute","zEthereumAddress","validateEthereumAddress","zSelector","validateSelector","_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"]}