zeed 1.0.21 → 1.1.1
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/README.md +217 -234
- package/dist/{chunk-2Z75UI2C.js → chunk-3LSWLKUP.js} +2 -2
- package/dist/{chunk-Z3CCAUP7.js → chunk-4X7UJTXJ.js} +2 -2
- package/dist/chunk-5RJ6XORD.cjs +2 -0
- package/dist/chunk-5RJ6XORD.cjs.map +1 -0
- package/dist/{chunk-AVGEBKCV.js → chunk-5WAO44ET.js} +2 -2
- package/dist/{chunk-EXAC332B.cjs → chunk-DAD3M2IM.cjs} +2 -2
- package/dist/{chunk-EXAC332B.cjs.map → chunk-DAD3M2IM.cjs.map} +1 -1
- package/dist/{chunk-OWX5SXG3.js → chunk-FGAKPO3O.js} +2 -2
- package/dist/{chunk-4VAH6DEB.js → chunk-IBGLNGGT.js} +2 -2
- package/dist/{chunk-4K3FOY2Z.js → chunk-IQWBYSWG.js} +2 -2
- package/dist/chunk-JWON4PLZ.cjs +2 -0
- package/dist/{chunk-67WN7TPU.cjs.map → chunk-JWON4PLZ.cjs.map} +1 -1
- package/dist/{chunk-PCT5BR7B.cjs → chunk-K4IRAHZV.cjs} +2 -2
- package/dist/{chunk-PCT5BR7B.cjs.map → chunk-K4IRAHZV.cjs.map} +1 -1
- package/dist/{chunk-IMURZASN.js → chunk-KIKHNNKK.js} +2 -2
- package/dist/{chunk-KJKNVADW.cjs → chunk-L5OF6DSH.cjs} +2 -2
- package/dist/{chunk-KJKNVADW.cjs.map → chunk-L5OF6DSH.cjs.map} +1 -1
- package/dist/chunk-LAGM3ULD.js +1 -0
- package/dist/chunk-LLDVPAUS.js +2 -0
- package/dist/chunk-LLDVPAUS.js.map +1 -0
- package/dist/chunk-MIEXPALS.cjs +1 -0
- package/dist/chunk-MIEXPALS.cjs.map +1 -0
- package/dist/chunk-MQNZQKBT.js +1 -0
- package/dist/chunk-MQNZQKBT.js.map +1 -0
- package/dist/chunk-NPQ77LO4.cjs +1 -0
- package/dist/chunk-NPQ77LO4.cjs.map +1 -0
- package/dist/{chunk-IQQCKTKP.cjs → chunk-NVLJOTGF.cjs} +2 -2
- package/dist/{chunk-IQQCKTKP.cjs.map → chunk-NVLJOTGF.cjs.map} +1 -1
- package/dist/{chunk-GRMMMGD6.cjs → chunk-RMTW3TW2.cjs} +2 -2
- package/dist/{chunk-GRMMMGD6.cjs.map → chunk-RMTW3TW2.cjs.map} +1 -1
- package/dist/chunk-SHOLGUSO.cjs +2 -0
- package/dist/{chunk-2DDHD4HB.cjs.map → chunk-SHOLGUSO.cjs.map} +1 -1
- package/dist/{chunk-W4VPTJY3.js → chunk-UAU7GDLR.js} +2 -2
- package/dist/{chunk-YNFT35YQ.js → chunk-UFYY2K4G.js} +2 -2
- package/dist/{chunk-4GFUK2NK.cjs → chunk-VR7T3I5N.cjs} +2 -2
- package/dist/{chunk-4GFUK2NK.cjs.map → chunk-VR7T3I5N.cjs.map} +1 -1
- package/dist/chunk-ZEQQVU3K.cjs +2 -0
- package/dist/{chunk-6CVV5WAD.cjs.map → chunk-ZEQQVU3K.cjs.map} +1 -1
- package/dist/common/bin/index.cjs +1 -1
- package/dist/common/bin/index.js +1 -1
- package/dist/common/bin/lib0/buffer.cjs +1 -1
- package/dist/common/bin/lib0/buffer.js +1 -1
- package/dist/common/bin/lib0/decoding.cjs +1 -1
- package/dist/common/bin/lib0/decoding.js +1 -1
- package/dist/common/bin/lib0/encoding.cjs +1 -1
- package/dist/common/bin/lib0/encoding.js +1 -1
- package/dist/common/data/datauri.cjs +1 -1
- package/dist/common/data/datauri.js +1 -1
- package/dist/common/data/index.cjs +1 -1
- package/dist/common/data/index.js +1 -1
- package/dist/common/index.cjs +1 -1
- package/dist/common/index.cjs.map +1 -1
- package/dist/common/index.d.cts +1 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.js +1 -1
- package/dist/common/schema/export-json-schema.cjs +1 -1
- package/dist/common/schema/export-json-schema.js +1 -1
- package/dist/common/schema/export-swift.cjs +1 -1
- package/dist/common/schema/export-swift.js +1 -1
- package/dist/common/schema/index.cjs +1 -1
- package/dist/common/schema/index.cjs.map +1 -1
- package/dist/common/schema/index.d.cts +1 -0
- package/dist/common/schema/index.d.ts +1 -0
- package/dist/common/schema/index.js +1 -1
- package/dist/common/schema/parse-args.cjs +1 -1
- package/dist/common/schema/parse-args.js +1 -1
- package/dist/common/schema/parse-env.cjs +1 -1
- package/dist/common/schema/parse-env.js +1 -1
- package/dist/common/schema/parse-object.cjs +1 -1
- package/dist/common/schema/parse-object.js +1 -1
- package/dist/common/schema/schema-standard.cjs +2 -0
- package/dist/common/schema/schema-standard.cjs.map +1 -0
- package/dist/common/schema/schema-standard.d.cts +57 -0
- package/dist/common/schema/schema-standard.d.ts +57 -0
- package/dist/common/schema/schema-standard.js +2 -0
- package/dist/common/schema/schema-standard.js.map +1 -0
- package/dist/common/schema/schema.cjs +1 -1
- package/dist/common/schema/schema.d.cts +10 -0
- package/dist/common/schema/schema.d.ts +10 -0
- package/dist/common/schema/schema.js +1 -1
- package/dist/common/schema/serialize.cjs +1 -1
- package/dist/common/schema/serialize.js +1 -1
- package/dist/common/schema/z-collection.cjs +1 -1
- package/dist/common/schema/z-collection.js +1 -1
- package/dist/common/schema/z.cjs +1 -1
- package/dist/common/schema/z.js +1 -1
- package/dist/common/test.cjs +1 -1
- package/dist/common/test.js +1 -1
- package/dist/index.all.cjs +1 -1
- package/dist/index.all.cjs.map +1 -1
- package/dist/index.all.d.cts +1 -0
- package/dist/index.all.d.ts +1 -0
- package/dist/index.all.js +1 -1
- package/dist/index.browser.cjs +1 -1
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +1 -0
- package/dist/index.browser.d.ts +1 -0
- package/dist/index.browser.js +1 -1
- package/dist/index.node.cjs +1 -1
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.cts +1 -0
- package/dist/index.node.d.ts +1 -0
- package/dist/index.node.js +1 -1
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/log/index.cjs +1 -1
- package/dist/node/log/index.cjs.map +1 -1
- package/dist/node/log/index.js +1 -1
- package/dist/node/log/log-context-node.cjs +1 -1
- package/dist/node/log/log-context-node.cjs.map +1 -1
- package/dist/node/log/log-context-node.js +1 -1
- package/dist/node/log/log-file-rotation.cjs +1 -1
- package/dist/node/log/log-file-rotation.cjs.map +1 -1
- package/dist/node/log/log-file-rotation.js +1 -1
- package/dist/node/log/log-file.cjs +1 -1
- package/dist/node/log/log-file.cjs.map +1 -1
- package/dist/node/log/log-file.js +1 -1
- package/package.json +2 -2
- package/src/common/schema/README.md +96 -1
- package/src/common/schema/index.ts +1 -0
- package/src/common/schema/schema-standard.spec.ts +327 -0
- package/src/common/schema/schema-standard.ts +76 -0
- package/src/common/schema/schema.ts +225 -0
- package/dist/chunk-2DDHD4HB.cjs +0 -2
- package/dist/chunk-5VUEFXFJ.js +0 -1
- package/dist/chunk-67WN7TPU.cjs +0 -2
- package/dist/chunk-6CVV5WAD.cjs +0 -2
- package/dist/chunk-IPZOSTTO.cjs +0 -1
- package/dist/chunk-IPZOSTTO.cjs.map +0 -1
- package/dist/chunk-UC5TCP5S.cjs +0 -2
- package/dist/chunk-UC5TCP5S.cjs.map +0 -1
- package/dist/chunk-VFRJ7C3X.js +0 -2
- package/dist/chunk-VFRJ7C3X.js.map +0 -1
- /package/dist/{chunk-2Z75UI2C.js.map → chunk-3LSWLKUP.js.map} +0 -0
- /package/dist/{chunk-Z3CCAUP7.js.map → chunk-4X7UJTXJ.js.map} +0 -0
- /package/dist/{chunk-AVGEBKCV.js.map → chunk-5WAO44ET.js.map} +0 -0
- /package/dist/{chunk-OWX5SXG3.js.map → chunk-FGAKPO3O.js.map} +0 -0
- /package/dist/{chunk-4VAH6DEB.js.map → chunk-IBGLNGGT.js.map} +0 -0
- /package/dist/{chunk-4K3FOY2Z.js.map → chunk-IQWBYSWG.js.map} +0 -0
- /package/dist/{chunk-IMURZASN.js.map → chunk-KIKHNNKK.js.map} +0 -0
- /package/dist/{chunk-5VUEFXFJ.js.map → chunk-LAGM3ULD.js.map} +0 -0
- /package/dist/{chunk-W4VPTJY3.js.map → chunk-UAU7GDLR.js.map} +0 -0
- /package/dist/{chunk-YNFT35YQ.js.map → chunk-UFYY2K4G.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/zeed/zeed/dist/chunk-5RJ6XORD.cjs","../src/common/schema/schema.ts"],"names":["Type","_Type","__name","name","options","value","isFunction"],"mappings":"AAAA,yuBAAkF,wDAAyC,ICgB9GA,CAAAA,CAAN,MAAMC,CAAkB,CAhB/B,MAgB+B,CAAAC,iCAAAA,IAAA,CAAA,MAAA,CAAA,CACpB,WAgBT,CAAYC,CAAAA,CAAcC,CAAAA,CAA4B,CAAC,CAAA,CAAG,CACxD,IAAA,CAAK,IAAA,CAAOD,CAAAA,CACZ,MAAA,CAAO,MAAA,CAAO,IAAA,CAAMC,CAAO,CAC7B,CAMA,GAAI,WAAA,CAAA,CAAmB,CACrB,MAAO,CACL,OAAA,CAAS,CAAA,CACT,MAAA,CAAQ,MAAA,CACR,QAAA,CAAUF,iCAAAA,CAACG,EACF,IAAA,CAAK,QAAA,CAASA,CAAK,CAAA,CADlB,UAAA,CAAA,CAGV,KAAA,CAAO,CACL,KAAA,CAAO,KAAA,CAAA,CACP,MAAA,CAAQ,KAAA,CACV,CACF,CACF,CAKA,QAAA,CAASA,CAAAA,CAAiB,CAIxB,EAAA,CAAIA,CAAAA,EAAS,IAAA,CACX,OAAI,IAAA,CAAK,SAAA,CACA,CAAE,KAAA,CAAO,KAAA,CAAsB,CAAA,CAEpC,IAAA,CAAK,QAAA,GAAa,KAAA,CAAA,CAEb,CAAE,KAAA,CADYC,iCAAAA,IAAW,CAAK,QAAQ,CAAA,CAAI,IAAA,CAAK,QAAA,CAAS,IAAI,CAAA,CAAI,IAAA,CAAK,QAC/C,CAAA,CAExB,CACL,MAAA,CAAQ,CAAC,CACP,OAAA,CAAS,2BAAA,CACT,IAAA,CAAM,CAAC,CACT,CAAC,CACH,CAAA,CAIF,EAAA,CAAI,IAAA,CAAK,IAAA,GAAS,SAAA,EAAa,IAAA,CAAK,QAAA,GAAaD,CAAAA,CAC/C,MAAO,CACL,MAAA,CAAQ,CAAC,CACP,OAAA,CAAS,CAAA,uBAAA,EAA0B,IAAA,CAAK,QAAQ,CAAA,MAAA,EAASA,CAAK,CAAA,CAAA","file":"/home/runner/work/zeed/zeed/dist/chunk-5RJ6XORD.cjs","sourcesContent":[null,"// With many, many inspiration from https://github.com/badrap/valita MIT License as of 2024-09-10\n\nimport type { StandardSchemaV1 } from './schema-standard'\nimport { isArray, isBoolean, isFunction, isInteger, isNumber, isObject, isString } from '../data/is'\n\n/**\n * Metadata interface for type descriptions and additional properties\n */\nexport interface TypeMeta {\n desc?: string\n}\n\n/**\n * Core Type class for schema validation and type inference\n * Implements StandardSchemaV1 for cross-library compatibility\n */\nexport class Type<T = unknown> {\n readonly type: string\n\n _default?: any\n _optional?: boolean\n _meta?: TypeMeta\n _check?: (obj: any) => boolean\n _object?: any\n _type?: any\n _union?: any\n _enumValues?: any\n _args?: any\n _ret?: any\n _info?: any\n\n // [key: `_${string}`]: any // Allow only optional dynamic properties starting with an underscore\n\n constructor(name: string, options: Partial<Type<T>> = {}) {\n this.type = name\n Object.assign(this, options)\n }\n\n /**\n * Standard Schema V1 compliance property\n * Provides a standard interface for validation and type inference\n */\n get '~standard'(): any {\n return {\n version: 1,\n vendor: 'zeed',\n validate: (value: unknown): StandardSchemaV1.Result<T> => {\n return this.validate(value)\n },\n types: {\n input: undefined as any as T,\n output: undefined as any as T,\n },\n }\n }\n\n /**\n * Validation method for standard-schema compliance\n */\n validate(value: any): any {\n // const messages: Array<{ path: string, message: string, type: string, valid: boolean }> = []\n\n // Handle null/undefined cases\n if (value == null) {\n if (this._optional) {\n return { value: undefined as any as T }\n }\n if (this._default !== undefined) {\n const defaultValue = isFunction(this._default) ? this._default(this) : this._default\n return { value: defaultValue }\n }\n return {\n issues: [{\n message: `Required value is missing`,\n path: [],\n }],\n }\n }\n\n // Handle literal types\n if (this.type === 'literal' && this._default !== value) {\n return {\n issues: [{\n message: `Expected literal value ${this._default}, got ${value}`,\n path: [],\n }],\n }\n }\n\n // Handle string literals (enums)\n if (this._enumValues && Array.isArray(this._enumValues)) {\n if (!this._enumValues.includes(value)) {\n return {\n issues: [{\n message: `Expected one of [${this._enumValues.join(', ')}], got ${value}`,\n path: [],\n }],\n }\n }\n }\n\n // Handle union types\n if (this._union && Array.isArray(this._union)) {\n for (const option of this._union) {\n const result = (option as Type<any>).validate(value)\n if (!result.issues) {\n return result\n }\n }\n return {\n issues: [{\n message: `Value does not match any union variant`,\n path: [],\n }],\n }\n }\n\n // Handle array types\n if (this.type === 'array' || this.type === 'tuple') {\n if (!Array.isArray(value)) {\n return {\n issues: [{\n message: `Expected array, got ${typeof value}`,\n path: [],\n }],\n }\n }\n\n if (this.type === 'tuple' && this._type) {\n const items = this._type as Type<any>[]\n if (value.length !== items.length) {\n return {\n issues: [{\n message: `Expected tuple of length ${items.length}, got ${value.length}`,\n path: [],\n }],\n }\n }\n\n const issues: StandardSchemaV1.Issue[] = []\n for (let i = 0; i < items.length; i++) {\n const itemResult = items[i].validate(value[i])\n if (itemResult.issues) {\n for (const issue of itemResult.issues) {\n issues.push({\n message: issue.message,\n path: [i, ...(issue.path || [])],\n })\n }\n }\n }\n\n if (issues.length > 0) {\n return { issues }\n }\n }\n else if (this._type) {\n // Regular array with item type\n const itemType = this._type as Type<any>\n const issues: StandardSchemaV1.Issue[] = []\n\n for (let i = 0; i < value.length; i++) {\n const itemResult = itemType.validate(value[i])\n if (itemResult.issues) {\n for (const issue of itemResult.issues) {\n issues.push({\n message: issue.message,\n path: [i, ...(issue.path || [])],\n })\n }\n }\n }\n\n if (issues.length > 0) {\n return { issues }\n }\n }\n }\n\n // Handle object types\n if (this._object) {\n if (!isObject(value)) {\n return {\n issues: [{\n message: `Expected object, got ${typeof value}`,\n path: [],\n }],\n }\n }\n\n const issues: StandardSchemaV1.Issue[] = []\n const obj = value as Record<string, any>\n\n for (const key in this._object) {\n const propSchema = this._object[key] as Type<any>\n const propValue = obj[key]\n const propResult = propSchema.validate(propValue)\n\n if (propResult.issues) {\n for (const issue of propResult.issues) {\n issues.push({\n message: issue.message,\n path: [key, ...(issue.path || [])],\n })\n }\n }\n }\n\n if (issues.length > 0) {\n return { issues }\n }\n\n return { value: value as T, issues: undefined }\n }\n\n // Handle record types\n if (this.type === 'record' && this._type) {\n if (!isObject(value)) {\n return {\n issues: [{\n message: `Expected object, got ${typeof value}`,\n path: [],\n }],\n }\n }\n\n const valueType = this._type as Type<any>\n const issues: StandardSchemaV1.Issue[] = []\n const obj = value as Record<string, any>\n\n for (const key in obj) {\n const propResult = valueType.validate(obj[key])\n if (propResult.issues) {\n for (const issue of propResult.issues) {\n issues.push({\n message: issue.message,\n path: [key, ...(issue.path || [])],\n })\n }\n }\n }\n\n if (issues.length > 0) {\n return { issues }\n }\n }\n\n // Check primitive types\n if (this._check && !this._check(value)) {\n return {\n issues: [{\n message: `Expected ${this.type}, got ${typeof value}`,\n path: [],\n }],\n }\n }\n\n // Success - return the value\n return { value: value as T }\n }\n\n /**\n * Creates a copy of the type with new properties merged\n */\n private _cloneWithProps<U = T>(newProps: Partial<Type<any>> = {}): Type<U> {\n const cloned = new Type<U>(this.type)\n // Copy all existing properties\n const propertiesToCopy = ['_default', '_optional', '_meta', '_check', '_object', '_type', '_union', '_enumValues', '_args', '_ret', '_info']\n for (const prop of propertiesToCopy) {\n if ((this as any)[prop] !== undefined) {\n (cloned as any)[prop] = (this as any)[prop]\n }\n }\n // Apply new properties\n Object.assign(cloned, newProps)\n return cloned\n }\n\n /**\n * Helper to copy type properties when creating new type instances\n */\n private static _copyTypeProperties(source: Type<any>, target: Type<any>): void {\n const properties = ['_check', '_default', '_meta', '_object', '_type', '_enumValues']\n for (const prop of properties) {\n if ((source as any)[prop] !== undefined) {\n (target as any)[prop] = (source as any)[prop]\n }\n }\n }\n\n /**\n * Marks the type as optional, meaning it can be undefined\n * This is useful for properties that are not required.\n */\n optional(): Type<T | undefined> {\n return this._cloneWithProps<T | undefined>({ _optional: true })\n }\n\n /**\n * Sets a default value for the type, which will be used if the value is not provided\n * The default value can be a function that receives the schema as argument, or a static value.\n */\n default(value: T | ((schema?: this) => T)): Type<T> {\n return this._cloneWithProps<T>({ _default: value })\n }\n\n /**\n * Props / Metadata for the type, like description or other properties\n */\n meta(meta: TypeMeta): Type<T> {\n return this._cloneWithProps<T>({ _meta: meta })\n }\n\n /**\n * Sets the `desc` property for the type, which is a human-readable description\n */\n describe(msg: string): Type<T> {\n const meta = this._meta || {}\n meta.desc = msg\n return this._cloneWithProps<T>({ _meta: meta })\n }\n\n /**\n * Extends the type with an object, merging the properties\n */\n extend<O>(obj: O): Type<T & TypeObject<O>> {\n if (!this._object) {\n throw new Error('extend() can only be used on object schemas')\n }\n const newObj = { ...this._object, ...obj }\n return object(newObj) as any\n }\n\n /**\n * Picks certain keys from an object schema\n */\n pick<K extends keyof T>(keys: Record<K, true>): Type<Pick<T, K>> {\n if (!this._object) {\n throw new Error('pick() can only be used on object schemas')\n }\n const pickedObj: any = {}\n for (const key of Object.keys(keys)) {\n if (key in this._object) {\n pickedObj[key] = (this._object as any)[key]\n }\n }\n return object(pickedObj) as any\n }\n\n /**\n * Omits certain keys from an object schema\n */\n omit<K extends keyof T>(keys: Record<K, true>): Type<Omit<T, K>> {\n if (!this._object) {\n throw new Error('omit() can only be used on object schemas')\n }\n const omittedObj: any = { ...this._object }\n for (const key of Object.keys(keys)) {\n delete omittedObj[key]\n }\n return object(omittedObj) as any\n }\n\n /**\n * Helper method to modify object properties with a transformation function\n */\n private _transformObjectProperties(\n transform: (key: string, type: Type<any>, shouldTransform: boolean) => Type<any>,\n keys?: Record<string, true>,\n ): any {\n if (!this._object) {\n throw new Error('This operation can only be used on object schemas')\n }\n\n const transformedObj: any = {}\n const originalObj = this._object as any\n\n for (const [key, typeInstance] of Object.entries(originalObj)) {\n const shouldTransform = !keys || key in keys\n transformedObj[key] = transform(key, typeInstance as Type<any>, shouldTransform)\n }\n\n return object(transformedObj)\n }\n\n /**\n * Makes some or all properties of an object schema optional\n */\n partial(): Type<Partial<T>>\n partial<K extends keyof T>(keys: Record<K, true>): Type<Partial<Pick<T, K>> & Omit<T, K>>\n partial<K extends keyof T>(keys?: Record<K, true>): Type<Partial<T> | (Partial<Pick<T, K>> & Omit<T, K>)> {\n if (!this._object) {\n throw new Error('partial() can only be used on object schemas')\n }\n return this._transformObjectProperties((key, type, shouldTransform) => {\n if (!shouldTransform)\n return type\n return Type._cloneTypeWithOptional(type, true)\n }, keys)\n }\n\n /**\n * Makes some or all properties of an object schema required\n */\n required(): Type<Required<T>>\n required<K extends keyof T>(keys: Record<K, true>): Type<Required<Pick<T, K>> & Omit<T, K>>\n required<K extends keyof T>(keys?: Record<K, true>): Type<Required<T> | (Required<Pick<T, K>> & Omit<T, K>)> {\n if (!this._object) {\n throw new Error('required() can only be used on object schemas')\n }\n return this._transformObjectProperties((key, type, shouldTransform) => {\n if (!shouldTransform)\n return type\n return Type._cloneTypeWithOptional(type, false)\n }, keys)\n }\n\n /**\n * Helper method to clone a type with optional flag\n */\n private static _cloneTypeWithOptional(originalType: Type<any>, optional: boolean): Type<any> {\n const newType = new Type(originalType.type)\n Type._copyTypeProperties(originalType, newType)\n newType._optional = optional\n return newType\n }\n}\n\n/**\n * Type inference utility for extracting the TypeScript type from a schema Type\n */\nexport type Infer<T> = T extends Type<infer TT> ? TT : never\n\n// =============================================================================\n// Primitive Types\n// =============================================================================\n\n/**\n * Creates a string type validator\n */\nexport function string(): Type<string> {\n return new Type('string', {\n _check: isString,\n })\n}\n\n/**\n * Creates a number type validator\n */\nexport function number(): Type<number> {\n return new Type('number', {\n _check: isNumber,\n })\n}\n\n/**\n * Creates an integer type validator\n */\nexport function int(): Type<number> {\n return new Type('int', {\n _check: isInteger,\n })\n}\n\n/**\n * Creates a boolean type validator\n */\nexport function boolean(): Type<boolean> {\n return new Type('boolean', {\n _check: isBoolean,\n })\n}\n\n/**\n * Creates a none type validator (undefined | null)\n * Like undefined | null in TS and nil in Swift\n */\nexport function none(): Type<undefined> {\n return new Type('none', {\n _check: (v: any) => v == null,\n _optional: true,\n })\n}\n\n/**\n * Creates an any type validator that accepts any non-null value\n */\nexport function any<T = any>(): Type<T> {\n return new Type('any', {\n _check: (v: any) => v != null,\n })\n}\n\n// Aliases for number types\nexport const float = number\nexport const double = number\nexport const real = number\n\n// =============================================================================\n// Object Types\n// =============================================================================\n\n/**\n * Utility type to make object properties optional if their value type includes undefined.\n * @category Schema\n */\nexport type TypeObjectFixOptional<T> = {\n [K in keyof T as undefined extends T[K] ? K : never]?: T[K] & {}\n} & {\n [K in keyof T as undefined extends T[K] ? never : K]: T[K] & {}\n}\n\n/**\n * Utility type for pretty-printing object types\n */\ntype TypeObjectPretty<V> = Extract<{ [K in keyof V]: V[K] }, unknown>\n\n/**\n * Main object type utility\n */\ntype TypeObject<T> = TypeObjectPretty<TypeObjectFixOptional<{\n [K in keyof T]: Infer<T[K]>\n}>>\n\n/**\n * Creates an object type validator with specified properties\n */\nexport function object<T>(tobj: T): Type<TypeObject<T>> {\n return new Type('object', {\n _check: isObject,\n _object: tobj,\n })\n}\n\n/**\n * Creates a record type validator (object with string keys and uniform value type)\n */\nexport function record<T extends Type>(valueType: T): Type<Record<string, Infer<T>>> {\n return new Type('record', {\n _check: isObject,\n _type: valueType,\n })\n}\n\n// =============================================================================\n// Union Types\n// =============================================================================\n\n/**\n * Utility type for union of types.\n * @category Schema\n */\nexport type TypeUnion<T extends Type<any>[]> = {\n [K in keyof T]: T[K] extends Type<infer U> ? U : never\n}[number]\n\n/**\n * Creates a union type validator (like `string | number | boolean`)\n */\nexport function union<T extends Type<any>[]>(options: T): Type<TypeUnion<T>> {\n return new Type('union', {\n _check: (v: any) => options.some(option => option._check?.(v) ?? false),\n _union: options,\n })\n}\n\n// =============================================================================\n// Literal Types\n// =============================================================================\n\n/**\n * Utility type for literal types.\n * @category Schema\n */\nexport type TypeLiterals = string | number | bigint | boolean\n\n/**\n * Creates a literal value validator\n */\nexport function literal<T extends TypeLiterals>(value: T): Type<T> {\n return new Type('literal', {\n _check: (v: any) => v === value,\n _default: value,\n })\n}\n\n/**\n * Creates a string literal union validator (like `\"a\" | \"b\" | \"c\"`)\n */\nexport function stringLiterals<const T extends readonly string[]>(values: T): Type<T[number]> {\n return new Type('string', {\n _check: (v: any) => typeof v === 'string' && (values as readonly string[]).includes(v),\n _enumValues: values,\n })\n}\n\n// =============================================================================\n// Collection Types\n// =============================================================================\n\n/**\n * Utility type for tuple types.\n * @category Schema\n */\nexport type TypeTuple<T extends readonly Type[]> = {\n -readonly [K in keyof T]: T[K] extends Type<infer U> ? U : never\n}\n\n/**\n * Output type for TypeArray.\n * @category Schema\n */\nexport type TypeArrayOutput<Head extends Type[], Rest extends Type | undefined> = [\n ...TypeTuple<Head>,\n ...(Rest extends Type ? Infer<Rest>[] : []),\n]\n\n/**\n * Utility type for array types.\n * @category Schema\n */\nexport type TypeArray<Head extends Type[] = Type[], Rest extends Type | undefined = Type | undefined> = Type<TypeArrayOutput<Head, Rest>>\n\n/**\n * Creates a tuple type validator with fixed length and types e.g. [string, number, boolean]\n */\nexport function tuple<const T extends readonly Type[]>(items: T): Type<TypeTuple<T>> {\n return new Type('tuple', {\n _check: (v: any) => Array.isArray(v) && v.length === items.length && items.every((item, i) => (item as Type)._check?.(v[i]) ?? false),\n _type: items,\n })\n}\n\n/**\n * Creates an array type validator for a specific item type\n */\nexport function array<T>(itemType: Type<T>): Type<T[]> {\n return new Type('array', {\n _check: isArray,\n _type: itemType,\n })\n}\n\n// =============================================================================\n// Function Types\n// =============================================================================\n\n/**\n * Creates a regular function type validator\n */\nexport function func<\n TypeFuncArgs extends [Type<unknown>, ...Type<any>[]] | [],\n TypeFuncRet = Type,\n T = (...args: TypeTuple<TypeFuncArgs>) => Infer<TypeFuncRet>,\n>(args: TypeFuncArgs, ret: TypeFuncRet): Type<T> {\n return new Type('function', {\n _check: isFunction,\n _args: args,\n _ret: ret,\n })\n}\n\n/**\n * Creates an RPC function type validator that takes one argument and returns a promise\n */\nexport function rpc<\n TypeRpcInfo extends Type<unknown> | undefined = undefined,\n TypeRpcRet extends Type<unknown> = Type<void>,\n T = TypeRpcInfo extends undefined\n ? () => Infer<TypeRpcRet>\n : (info: Infer<TypeRpcInfo>) => Infer<TypeRpcRet> | Promise<Infer<TypeRpcRet>>,\n>(info?: TypeRpcInfo, ret?: TypeRpcRet): Type<T> {\n return new Type('rpc', {\n _check: isFunction,\n _info: info,\n _ret: ret ?? none(),\n })\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{M as h,N as B,g as w,h as u}from"./chunk-6GMDX4A4.js";import{a as m}from"./chunk-VF3ZWSJS.js";import{
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{g as D}from"./chunk-ESODSJEY.js";import{M as h,N as B,g as w,h as u}from"./chunk-6GMDX4A4.js";import{a as m}from"./chunk-VF3ZWSJS.js";import{a as o}from"./chunk-5NKC2EQJ.js";var x="Unexpected end of array",c="Integer out of Range",p=class{static{o(this,"BinDecoder")}arr;pos;constructor(n){this.arr=n,this.pos=0}};function I(r){return new p(r)}o(I,"createDecoder");function C(r){return r.pos!==r.arr.length}o(C,"hasContent");function O(r,n=r.pos){let t=I(r.arr);return t.pos=n,t}o(O,"clone");function b(r,n){let t=m(r.arr.buffer,r.pos+r.arr.byteOffset,n);return r.pos+=n,t}o(b,"readUint8Array");function a(r){let n=0,t=1,e=r.arr.length;for(;r.pos<e;){let i=r.arr[r.pos++];if(n=n+(i&127)*t,t*=128,i<128)return n;if(n>Number.MAX_SAFE_INTEGER)throw new Error(c)}throw new Error(x)}o(a,"readVarUint");function y(r){return b(r,a(r))}o(y,"readVarUint8Array");function R(r){return b(r,r.arr.length-r.pos)}o(R,"readTailAsUint8Array");function N(r){return r.pos++}o(N,"skip8");function f(r){return r.arr[r.pos++]}o(f,"readUint8");function P(r){let n=r.arr[r.pos]+(r.arr[r.pos+1]<<8);return r.pos+=2,n}o(P,"readUint16");function L(r){let n=r.arr[r.pos]+(r.arr[r.pos+1]<<8)+(r.arr[r.pos+2]<<16)+(r.arr[r.pos+3]<<24)>>>0;return r.pos+=4,n}o(L,"readUint32");function v(r){let n=r.arr[r.pos+3]+(r.arr[r.pos+2]<<8)+(r.arr[r.pos+1]<<16)+(r.arr[r.pos]<<24)>>>0;return r.pos+=4,n}o(v,"readUint32BigEndian");function G(r){return r.arr[r.pos]}o(G,"peekUint8");function M(r){return r.arr[r.pos]+(r.arr[r.pos+1]<<8)}o(M,"peekUint16");function X(r){return r.arr[r.pos]+(r.arr[r.pos+1]<<8)+(r.arr[r.pos+2]<<16)+(r.arr[r.pos+3]<<24)>>>0}o(X,"peekUint32");function U(r){let n=r.arr[r.pos++],t=n&63,e=64,i=(n&64)>0?-1:1;if((n&128)===0)return i*t;let A=r.arr.length;for(;r.pos<A;){if(n=r.arr[r.pos++],t=t+(n&127)*e,e*=128,n<128)return i*t;if(t>Number.MAX_SAFE_INTEGER)throw new Error(c)}throw new Error(x)}o(U,"readVarInt");function j(r){let n=r.pos,t=a(r);return r.pos=n,t}o(j,"peekVarUint");function q(r){let n=r.pos,t=U(r);return r.pos=n,t}o(q,"peekVarInt");function E(r){let n=a(r);if(n===0)return"";{let t=String.fromCodePoint(f(r));if(--n<100)for(;n--;)t+=String.fromCodePoint(f(r));else for(;n>0;){let e=n<1e4?n:1e4,i=r.arr.subarray(r.pos,r.pos+e);r.pos+=e,t+=String.fromCodePoint.apply(null,i),n-=e}return decodeURIComponent(escape(t))}}o(E,"_readVarStringPolyfill");function l(r){let n=D();return n?n.decode(y(r)):E(r)}o(l,"readVarString");function z(r){let n=r.pos,t=l(r);return r.pos=n,t}o(z,"peekVarString");function s(r,n){let t=new DataView(r.arr.buffer,r.arr.byteOffset+r.pos,n);return r.pos+=n,t}o(s,"readFromDataView");function V(r){return s(r,4).getFloat32(0,!1)}o(V,"readFloat32");function S(r){return s(r,8).getFloat64(0,!1)}o(S,"readFloat64");function T(r){return s(r,8).getBigInt64(0,!1)}o(T,"readBigInt64");function H(r){return s(r,8).getBigUint64(0,!1)}o(H,"readBigUint64");var _=[r=>{},r=>null,U,V,S,T,r=>!1,r=>!0,l,r=>{let n=a(r),t={};for(let e=0;e<n;e++){let i=l(r);t[i]=g(r)}return t},r=>{let n=a(r),t=[];for(let e=0;e<n;e++)t.push(g(r));return t},y];function g(r){return _[127-f(r)](r)}o(g,"readAny");export{p as a,I as b,C as c,O as d,b as e,a as f,y as g,R as h,N as i,f as j,P as k,L as l,v as m,G as n,M as o,X as p,U as q,j as r,q as s,l as t,z as u,s as v,V as w,S as x,T as y,H as z,g as A};
|
|
2
|
+
//# sourceMappingURL=chunk-5WAO44ET.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _chunk3ZBLU4D6cjs = require('./chunk-3ZBLU4D6.cjs');var _chunkL5OF6DSHcjs = require('./chunk-L5OF6DSH.cjs');var _chunkSHOLGUSOcjs = require('./chunk-SHOLGUSO.cjs');var _chunkIA2OMOCBcjs = require('./chunk-IA2OMOCB.cjs');var _chunkGFMSFYKEcjs = require('./chunk-GFMSFYKE.cjs');var _chunk3P4XRJ23cjs = require('./chunk-3P4XRJ23.cjs');var _chunkVX3R7DUJcjs = require('./chunk-VX3R7DUJ.cjs');var _chunkP7XCQ7WVcjs = require('./chunk-P7XCQ7WV.cjs');var _process = require('process'); var _process2 = _interopRequireDefault(_process);function T(e,r){return _chunkVX3R7DUJcjs.a.call(void 0, t=>{let i=[_chunk3ZBLU4D6cjs.d.call(void 0, {padding:32,nameBrackets:!1})],m=_nullishCoalesce(_process2.default.env.ZEED_LOG, () => (_process2.default.env.LOG)),c=_chunk3P4XRJ23cjs.f.call(void 0, _process2.default.env.ZEED_TIME,!0),E=_chunk3P4XRJ23cjs.f.call(void 0, _process2.default.env.ZEED_PRETTY,!1),v=_chunkSHOLGUSOcjs.a.call(void 0, _process2.default.env.ZEED_ROTATE);m&&i.unshift(_chunkL5OF6DSHcjs.a.call(void 0, _chunkIA2OMOCBcjs.e.call(void 0, m),{time:c,pretty:E,rotation:v})),t.setHandlers(i)})(e,r)}_chunkP7XCQ7WVcjs.a.call(void 0, T,"Logger");function F(e,r,t){return _chunkGFMSFYKEcjs.a.call(void 0, T,e,r,t)}_chunkP7XCQ7WVcjs.a.call(void 0, F,"LoggerFromConfig");exports.a = T; exports.b = F;
|
|
2
|
+
//# sourceMappingURL=chunk-DAD3M2IM.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/zeed/zeed/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/zeed/zeed/dist/chunk-DAD3M2IM.cjs","../src/node/log/log-context-node.ts"],"names":["Logger","name","level","getGlobalLogger","context","handlers","LoggerNodeHandler","logFilePath","process","time","valueToBoolean","pretty","rotation","parseLogRotationConfigEnv","LoggerFileHandler","toPath","__name","LoggerFromConfig","config","_LoggerFromConfig"],"mappings":"AAAA,qUAAwC,wDAAyC,wDAAyC,wDAAyC,wDAAoC,wDAAyC,wDAAyC,wDAAyC,oFCE9S,SASJA,CAAAA,CAAOC,CAAAA,CAAeC,CAAAA,CAA4C,CAChF,OAAOC,iCAAAA,CAAiBC,EAAY,CAClC,IAAMC,CAAAA,CAAW,CACfC,iCAAAA,CACE,OAAA,CAAS,EAAA,CACT,YAAA,CAAc,CAAA,CAEhB,CAAC,CACH,CAAA,CAEMC,CAAAA,kBAAcC,iBAAAA,CAAQ,GAAA,CAAI,QAAA,SAAYA,iBAAAA,CAAQ,GAAA,CAAI,KAAA,CAClDC,CAAAA,CAAOC,iCAAAA,iBAAeF,CAAQ,GAAA,CAAI,SAAA,CAAW,CAAA,CAAI,CAAA,CACjDG,CAAAA,CAASD,iCAAAA,iBAAeF,CAAQ,GAAA,CAAI,WAAA,CAAa,CAAA,CAAK,CAAA,CACtDI,CAAAA,CAAWC,iCAAAA,iBAA0BL,CAAQ,GAAA,CAAI,WAAW,CAAA,CAC9DD,CAAAA,EACFF,CAAAA,CAAS,OAAA,CAAQS,iCAAAA,iCAAkBC,CAAkB,CAAA,CAAG,CAAE,IAAA,CAAAN,CAAAA,CAAM,MAAA,CAAAE,CAAAA,CAAQ,QAAA,CAAAC,CAAS,CAAC,CAAC,CAAA,CAErFR,CAAAA,CAAQ,WAAA,CAAYC,CAAQ,CAC9B,CAAC,CAAA,CAAEJ,CAAAA,CAAMC,CAAK,CAChB,CAnBgBc,iCAAAA,CAAAhB,CAAA,QAAA,CAAA,CAsBT,SAASiB,CAAAA,CAAiBC,CAAAA,CAAmBjB,CAAAA,CAAcC,CAAAA,CAA4C,CAC5G,OAAOiB,iCAAAA,CAAkBnB,CAAQkB,CAAAA,CAAQjB,CAAAA,CAAMC,CAAK,CACtD,CAFgBc,iCAAAA,CAAAC,CAAA,kBAAA,CAAA,CAAA,6BAAA","file":"/home/runner/work/zeed/zeed/dist/chunk-DAD3M2IM.cjs","sourcesContent":[null,"import type { LoggerInterface, LogLevelAliasType } from '../../common/log/log-base'\nimport type { LogConfig } from '../../common/log/log-config'\nimport process from 'node:process'\nimport { valueToBoolean } from '../../common/data/convert'\nimport { getGlobalLogger } from '../../common/log/log'\nimport { _LoggerFromConfig } from '../../common/log/log-config'\nimport { toPath } from '../env'\nimport { LoggerFileHandler } from './log-file'\nimport { parseLogRotationConfigEnv } from './log-file-rotation'\nimport { LoggerNodeHandler } from './log-node'\n\nexport function Logger(name?: string, level?: LogLevelAliasType): LoggerInterface {\n return getGlobalLogger((context) => {\n const handlers = [\n LoggerNodeHandler({\n padding: 32,\n nameBrackets: false,\n // levelHelper: false,\n }),\n ]\n\n const logFilePath = process.env.ZEED_LOG ?? process.env.LOG\n const time = valueToBoolean(process.env.ZEED_TIME, true)\n const pretty = valueToBoolean(process.env.ZEED_PRETTY, false)\n const rotation = parseLogRotationConfigEnv(process.env.ZEED_ROTATE)\n if (logFilePath)\n handlers.unshift(LoggerFileHandler(toPath(logFilePath), { time, pretty, rotation }))\n\n context.setHandlers(handlers)\n })(name, level)\n}\n\n/** See LogConfig */\nexport function LoggerFromConfig(config: LogConfig, name: string, level?: LogLevelAliasType): LoggerInterface {\n return _LoggerFromConfig(Logger, config, name, level)\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{M as x,N as l,O as u,g as S,h as B,ja as T}from"./chunk-6GMDX4A4.js";import{a as w}from"./chunk-VF3ZWSJS.js";import{
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{e as h,f as U}from"./chunk-ESODSJEY.js";import{M as x,N as l,O as u,g as S,h as B,ja as T}from"./chunk-6GMDX4A4.js";import{a as w}from"./chunk-VF3ZWSJS.js";import{a as r}from"./chunk-5NKC2EQJ.js";var y=class{static{r(this,"BinEncoder")}cpos;cbuf;bufs;constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}};function R(){return new y}r(R,"createBinEncoder");function k(t){let n=t.cpos;for(let i=0;i<t.bufs.length;i++)n+=t.bufs[i].length;return n}r(k,"length");function F(t){let n=new Uint8Array(k(t)),i=0;for(let e=0;e<t.bufs.length;e++){let o=t.bufs[e];n.set(o,i),i+=o.length}return n.set(w(t.cbuf.buffer,0,t.cpos),i),n}r(F,"encodeToUint8Array");function L(t,n){let i=t.cbuf.length;i-t.cpos<n&&(t.bufs.push(w(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(Math.max(i,n)*2),t.cpos=0)}r(L,"verifyLen");function f(t,n){let i=t.cbuf.length;t.cpos===i&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(i*2),t.cpos=0),t.cbuf[t.cpos++]=n}r(f,"write");function p(t,n,i){let e=null;for(let o=0;o<t.bufs.length&&e===null;o++){let s=t.bufs[o];n<s.length?e=s:n-=s.length}e===null&&(e=t.cbuf),e[n]=i}r(p,"set");var Z=f,q=p;function G(t,n){f(t,n&255),f(t,n>>>8&255)}r(G,"writeUint16");function H(t,n,i){p(t,n,i&255),p(t,n+1,i>>>8&255)}r(H,"setUint16");function J(t,n){for(let i=0;i<4;i++)f(t,n&255),n>>>=8}r(J,"writeUint32");function K(t,n){for(let i=3;i>=0;i--)f(t,n>>>8*i&255)}r(K,"writeUint32BigEndian");function Q(t,n,i){for(let e=0;e<4;e++)p(t,n+e,i&255),i>>>=8}r(Q,"setUint32");function c(t,n){for(;n>127;)f(t,128|127&n),n=Math.floor(n/128);f(t,127&n)}r(c,"writeVarUint");function M(t){return t!==0?t<0:1/t<0}r(M,"isNegativeZero");function v(t,n){let i=M(n);for(i&&(n=-n),f(t,(n>63?128:0)|(i?64:0)|63&n),n=Math.floor(n/64);n>0;)f(t,(n>127?128:0)|127&n),n=Math.floor(n/128)}r(v,"writeVarInt");function I(t,n){let i=t.cbuf.length,e=t.cpos,o=Math.min(i-e,n.length),s=n.length-o;t.cbuf.set(n.subarray(0,o),e),t.cpos+=o,s>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(Math.max(i*2,s)),t.cbuf.set(n.subarray(o)),t.cpos=s)}r(I,"writeUint8Array");function V(t,n){c(t,n.byteLength),I(t,n)}r(V,"writeVarUint8Array");var b,E;function D(t,n){if(b==null&&(b=new Uint8Array(3e4),E=b.length/3),n.length<E){let i=h().encodeInto(n,b).written||0;c(t,i);for(let e=0;e<i;e++)f(t,b[e])}else V(t,U(n))}r(D,"_writeVarStringNative");function N(t,n){let i=unescape(encodeURIComponent(n)),e=i.length;c(t,e);for(let o=0;o<e;o++)f(t,i.codePointAt(o))}r(N,"_writeVarStringPolyfill");function A(t,n){return h()?.encodeInto?D(t,n):N(t,n)}r(A,"writeVarString");function W(t,n){return I(t,F(n))}r(W,"writeBinaryEncoder");function g(t,n){L(t,n);let i=new DataView(t.cbuf.buffer,t.cpos,n);return t.cpos+=n,i}r(g,"writeOnDataView");function _(t,n){return g(t,4).setFloat32(0,n,!1)}r(_,"writeFloat32");function C(t,n){return g(t,8).setFloat64(0,n,!1)}r(C,"writeFloat64");function P(t,n){return g(t,8).setBigInt64(0,n,!1)}r(P,"writeBigInt64");function X(t,n){return g(t,8).setBigUint64(0,n,!1)}r(X,"writeBigUint64");var a;function j(t){return a==null&&(a=new DataView(new ArrayBuffer(4))),a.setFloat32(0,t),a.getFloat32(0)===t}r(j,"isFloat32");function m(t,n){switch(typeof n){case"string":f(t,119),A(t,n);break;case"number":Number.isInteger(n)&&Math.abs(n)<=2147483647?(f(t,125),v(t,n)):j(n)?(f(t,124),_(t,n)):(f(t,123),C(t,n));break;case"bigint":f(t,122),P(t,n);break;case"object":if(n===null)f(t,126);else if(Array.isArray(n)){f(t,117),c(t,n.length);for(let i=0;i<n.length;i++)m(t,n[i])}else if(n instanceof Uint8Array)f(t,116),V(t,n);else{f(t,118);let i=Object.keys(n);i.sort(),c(t,i.length);for(let e=0;e<i.length;e++){let o=i[e];A(t,o),m(t,n[o])}}break;case"boolean":f(t,n?120:121);break;default:f(t,127)}}r(m,"writeAny");export{y as a,R as b,k as c,F as d,L as e,f,p as g,Z as h,q as i,G as j,H as k,J as l,K as m,Q as n,c as o,M as p,v as q,I as r,V as s,A as t,W as u,g as v,_ as w,C as x,P as y,X as z,m as A};
|
|
2
|
+
//# sourceMappingURL=chunk-FGAKPO3O.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as d,b as u,e as U,f as b,g as A,j as B,k as w,l as p,q as l,t as g,w as V}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{A as d,b as u,e as U,f as b,g as A,j as B,k as w,l as p,q as l,t as g,w as V}from"./chunk-5WAO44ET.js";import{A as c,b as y,c as I,d as m,h as x,j as E,l as F,o as S,q as P,r as s,s as h,t as T,w as D}from"./chunk-FGAKPO3O.js";import{c as f}from"./chunk-UVILAVID.js";import{G as i}from"./chunk-TXYP3UN6.js";import{a as e}from"./chunk-5NKC2EQJ.js";var J=class{static{e(this,"BinaryEncoder")}async encode(r){let n=y();return c(n,r),m(n)}async decode(r){return d(u(i(r)))}};function q(t){let r=y();return c(r,t),m(r)}e(q,"encodeJson");function v(t){return d(u(i(t)))}e(v,"decodeJson");function z(t){let r=y();return t!=null&&s(r,i(t)),{writeBytes:e((n,a)=>{let o=i(n);f(!(a!=null&&o.length!==a),`Expected ${a} bytes, got ${o.length}`),s(r,o)},"writeBytes"),writeBytesVar:e(n=>h(r,i(n)),"writeBytesVar"),writeUintVar:e(n=>S(r,n),"writeUintVar"),writeUint8:e(n=>x(r,n),"writeUint8"),writeUint16:e(n=>E(r,n),"writeUint16"),writeUint32:e(n=>F(r,n),"writeUint32"),writeIntVar:e(n=>P(r,n),"writeIntVar"),writeFloat:e(n=>D(r,n),"writeFloat"),writeStringVar:e(n=>T(r,n),"writeStringVar"),write:e(n=>c(r,n),"write"),getUint8Array:e(()=>m(r),"getUint8Array"),getLength:e(()=>I(r),"getLength")}}e(z,"createBinaryStreamEncoder");function G(t){let r=u(i(t));return{readBytes:e(n=>U(r,n),"readBytes"),readBytesVar:e(()=>A(r),"readBytesVar"),readUintVar:e(()=>b(r),"readUintVar"),readUint8:e(()=>B(r),"readUint8"),readUint16:e(()=>w(r),"readUint16"),readUint32:e(()=>p(r),"readUint32"),readIntVar:e(()=>l(r),"readIntVar"),readFloat:e(()=>V(r),"readFloat"),readStringVar:e(()=>g(r),"readStringVar"),read:e(()=>d(r),"read"),getOffset:e(()=>r.pos||0,"getOffset")}}e(G,"createBinaryStreamDecoder");function H(t=0){return{setBit:e((r,n=!0)=>n?t|=1<<r:t&=~(1<<r),"setBit"),unsetBit:e(r=>t&=1<<r,"unsetBit"),toggleBit:e(r=>t^=1<<r,"toggleBit"),getBit:e(r=>(t&1<<r)!==0,"getBit"),getValue:e(()=>t,"getValue")}}e(H,"bitfield");async function $(t){if(t.arrayBuffer)return await t.arrayBuffer();try{return new Promise((r,n)=>{try{let a=new FileReader;a.onloadend=()=>r(a.result),a.onerror=o=>n(o),a.onabort=o=>n(o),a.readAsArrayBuffer(t)}catch(a){n(a)}})}catch{}}e($,"blobToArrayBuffer");async function K(t){let r=await $(t);if(r!=null)return i(r)}e(K,"blobToUint8Array");export{J as a,q as b,v as c,z as d,G as e,H as f,$ as g,K as h};
|
|
2
|
+
//# sourceMappingURL=chunk-IBGLNGGT.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as e,c as r,d as n,e as a,f as o,g as t,h as l,i,j as p,k as s,l as f,m as u,n as c,o as m,p as y,q as b,r as d,s as g}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as e,c as r,d as n,e as a,f as o,g as t,h as l,i,j as p,k as s,l as f,m as u,n as c,o as m,p as y,q as b,r as d,s as g}from"./chunk-LLDVPAUS.js";import{b as x}from"./chunk-5NKC2EQJ.js";var h={};x(h,{any:()=>t,array:()=>b,boolean:()=>a,double:()=>i,enum:()=>m,float:()=>l,func:()=>d,int:()=>n,literal:()=>c,none:()=>o,number:()=>r,object:()=>s,real:()=>p,record:()=>f,rpc:()=>g,string:()=>e,tuple:()=>y,union:()=>u});export{h as a};
|
|
2
|
+
//# sourceMappingURL=chunk-IQWBYSWG.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk5RJ6XORDcjs = require('./chunk-5RJ6XORD.cjs');var _chunkIVUEQANCcjs = require('./chunk-IVUEQANC.cjs');var _chunkP7XCQ7WVcjs = require('./chunk-P7XCQ7WV.cjs');function y(e){let n={type:e.type};if(e._optional!==void 0&&(n.optional=e._optional),e._meta!==void 0&&(n.meta=e._meta),e._default!==void 0&&!_chunkIVUEQANCcjs.b.call(void 0, e._default)&&(n.default=e._default),e._object!==void 0){n.object={};for(let[t,a]of Object.entries(e._object))n.object[t]=y(a)}return e._type!==void 0&&(_chunkIVUEQANCcjs.e.call(void 0, e._type)?n.tupleTypes=e._type.map(t=>y(t)):n.itemType=y(e._type)),e._union!==void 0&&(n.union=e._union.map(t=>y(t))),e._enumValues!==void 0&&(n.enumValues=e._enumValues),e._args!==void 0&&(n.args=e._args.map(t=>y(t))),e._ret!==void 0&&(n.ret=y(e._ret)),e._info!==void 0&&(n.info=y(e._info)),e.type==="literal"&&e._default!==void 0&&(n.literalValue=e._default),n}_chunkP7XCQ7WVcjs.a.call(void 0, y,"serializeSchema");function o(e){let n;switch(e.type){case"string":e.enumValues?n=_chunk5RJ6XORDcjs.o.call(void 0, e.enumValues):n=_chunk5RJ6XORDcjs.b.call(void 0, );break;case"number":n=_chunk5RJ6XORDcjs.c.call(void 0, );break;case"int":n=_chunk5RJ6XORDcjs.d.call(void 0, );break;case"boolean":n=_chunk5RJ6XORDcjs.e.call(void 0, );break;case"none":n=_chunk5RJ6XORDcjs.f.call(void 0, );break;case"any":n=_chunk5RJ6XORDcjs.g.call(void 0, );break;case"object":if(e.object){let t={};for(let[a,u]of Object.entries(e.object))t[a]=o(u);n=_chunk5RJ6XORDcjs.k.call(void 0, t)}else n=_chunk5RJ6XORDcjs.k.call(void 0, {});break;case"record":e.itemType?n=_chunk5RJ6XORDcjs.l.call(void 0, o(e.itemType)):n=_chunk5RJ6XORDcjs.l.call(void 0, _chunk5RJ6XORDcjs.g.call(void 0, ));break;case"array":e.itemType?n=_chunk5RJ6XORDcjs.q.call(void 0, o(e.itemType)):n=_chunk5RJ6XORDcjs.q.call(void 0, _chunk5RJ6XORDcjs.g.call(void 0, ));break;case"tuple":if(e.tupleTypes){let t=e.tupleTypes.map(a=>o(a));n=_chunk5RJ6XORDcjs.p.call(void 0, t)}else n=_chunk5RJ6XORDcjs.p.call(void 0, []);break;case"union":if(e.union){let t=e.union.map(a=>o(a));n=_chunk5RJ6XORDcjs.m.call(void 0, t)}else n=_chunk5RJ6XORDcjs.m.call(void 0, []);break;case"literal":e.literalValue!==void 0?n=_chunk5RJ6XORDcjs.n.call(void 0, e.literalValue):n=_chunk5RJ6XORDcjs.g.call(void 0, );break;case"function":if(e.args&&e.ret){let t=e.args.map(u=>o(u)),a=o(e.ret);n=_chunk5RJ6XORDcjs.r.call(void 0, t,a)}else n=_chunk5RJ6XORDcjs.r.call(void 0, [],_chunk5RJ6XORDcjs.g.call(void 0, ));break;case"rpc":if(e.info&&e.ret){let t=o(e.info),a=o(e.ret);n=_chunk5RJ6XORDcjs.s.call(void 0, t,a)}else if(e.ret){let t=o(e.ret);n=_chunk5RJ6XORDcjs.s.call(void 0, void 0,t)}else n=_chunk5RJ6XORDcjs.s.call(void 0, );break;default:n=_chunk5RJ6XORDcjs.g.call(void 0, );break}return e.optional&&(n=n.optional()),e.default!==void 0&&(n=n.default(e.default)),e.meta&&(n=n.meta(e.meta)),n}_chunkP7XCQ7WVcjs.a.call(void 0, o,"deserializeSchema");exports.a = y; exports.b = o;
|
|
2
|
+
//# sourceMappingURL=chunk-JWON4PLZ.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/zeed/zeed/dist/chunk-67WN7TPU.cjs","../src/common/schema/serialize.ts"],"names":["serializeSchema","schema","result","isFunction","key","value","isArray","__name","deserializeSchema","serialized","stringLiterals","string","number","int","boolean","none","any","obj","object","record","array","types","t","tuple","union","literal","args","ret","func","info","rpc"],"mappings":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AA,CAAkBC,CAAAA,CAAW,GAAG,CAAA,CAC5CR,CAAAA,CAAS6B,iCAAAA,KAAI,CAAA,CAAWH,CAAG,CAC7B,CAAA,KAEE1B,CAAAA,CAAS6B,iCAAAA,CAAI,CAEf,KAAA,CACF,OAAA,CAEE7B,CAAAA,CAASe,iCAAAA,CAAI,CACb,KACJ,CAGA,OAAIP,CAAAA,CAAW,QAAA,EAAA,CACbR,CAAAA,CAASA,CAAAA,CAAO,QAAA,CAAS,CAAA,CAAA,CAIvBQ,CAAAA,CAAW,OAAA,GAAY,KAAA,CAAA,EAAA,CACzBR,CAAAA,CAASA,CAAAA,CAAO,OAAA,CAAQQ,CAAAA,CAAW,OAAO,CAAA,CAAA,CAIxCA,CAAAA,CAAW,IAAA,EAAA,CACbR,CAAAA,CAASA,CAAAA,CAAO,IAAA,CAAKQ,CAAAA,CAAW,IAAI,CAAA,CAAA,CAG/BR,CACT,CAhIgBM,iCAAAA,CAAAC,CAAA,mBAAA,CAAA,CAAA,6BAAA","file":"/home/runner/work/zeed/zeed/dist/chunk-67WN7TPU.cjs","sourcesContent":[null,"// Serialization and Deserialization for Schema Types\n\nimport type { Type, TypeMeta } from './schema'\nimport { isArray, isFunction } from '../data/is'\nimport { any, array, boolean, func, int, literal, none, number, object, record, rpc, string, stringLiterals, tuple, union } from './schema'\n\n// =============================================================================\n// Types\n// =============================================================================\n\n/**\n * Plain JSON representation of a schema type\n */\nexport interface SerializedType {\n type: string\n default?: any\n optional?: boolean\n meta?: TypeMeta\n object?: Record<string, SerializedType>\n itemType?: SerializedType\n union?: SerializedType[]\n enumValues?: any[]\n args?: SerializedType[]\n ret?: SerializedType\n info?: SerializedType\n tupleTypes?: SerializedType[]\n literalValue?: any\n}\n\n// =============================================================================\n// Serialization\n// =============================================================================\n\n/**\n * Serializes a schema Type to a plain JSON object.\n * Functions in _check and _default will not be serialized.\n *\n * @param schema - The schema Type to serialize\n * @returns A plain JSON object representing the schema\n */\nexport function serializeSchema(schema: Type<any>): SerializedType {\n const result: SerializedType = {\n type: schema.type,\n }\n\n if (schema._optional !== undefined) {\n result.optional = schema._optional\n }\n\n if (schema._meta !== undefined) {\n result.meta = schema._meta\n }\n\n // Serialize default value if it's not a function\n if (schema._default !== undefined && !isFunction(schema._default)) {\n result.default = schema._default\n }\n\n // Serialize object properties\n if (schema._object !== undefined) {\n result.object = {}\n for (const [key, value] of Object.entries(schema._object)) {\n result.object[key] = serializeSchema(value as Type<any>)\n }\n }\n\n // Serialize array/record item type\n if (schema._type !== undefined) {\n if (isArray(schema._type)) {\n // Tuple types\n result.tupleTypes = (schema._type as Type<any>[]).map(t => serializeSchema(t))\n }\n else {\n // Array or record item type\n result.itemType = serializeSchema(schema._type as Type<any>)\n }\n }\n\n // Serialize union types\n if (schema._union !== undefined) {\n result.union = (schema._union as Type<any>[]).map(t => serializeSchema(t))\n }\n\n // Serialize enum values\n if (schema._enumValues !== undefined) {\n result.enumValues = schema._enumValues\n }\n\n // Serialize function arguments\n if (schema._args !== undefined) {\n result.args = (schema._args as Type<any>[]).map(t => serializeSchema(t))\n }\n\n // Serialize function return type\n if (schema._ret !== undefined) {\n result.ret = serializeSchema(schema._ret as Type<any>)\n }\n\n // Serialize RPC info type\n if (schema._info !== undefined) {\n result.info = serializeSchema(schema._info as Type<any>)\n }\n\n // Serialize literal value (for literal types)\n if (schema.type === 'literal' && schema._default !== undefined) {\n result.literalValue = schema._default\n }\n\n return result\n}\n\n// =============================================================================\n// Deserialization\n// =============================================================================\n\n/**\n * Deserializes a plain JSON object back to a schema Type.\n * Note: Custom _check functions cannot be restored and will use default validators.\n *\n * @param serialized - The serialized schema object\n * @returns A reconstructed Type instance\n */\nexport function deserializeSchema(serialized: SerializedType): Type<any> {\n let schema: Type<any>\n\n // Create base type based on type name\n switch (serialized.type) {\n case 'string':\n if (serialized.enumValues) {\n schema = stringLiterals(serialized.enumValues as any)\n }\n else {\n schema = string()\n }\n break\n case 'number':\n schema = number()\n break\n case 'int':\n schema = int()\n break\n case 'boolean':\n schema = boolean()\n break\n case 'none':\n schema = none()\n break\n case 'any':\n schema = any()\n break\n case 'object':\n if (serialized.object) {\n const obj: any = {}\n for (const [key, value] of Object.entries(serialized.object)) {\n obj[key] = deserializeSchema(value)\n }\n schema = object(obj)\n }\n else {\n schema = object({})\n }\n break\n case 'record':\n if (serialized.itemType) {\n schema = record(deserializeSchema(serialized.itemType))\n }\n else {\n schema = record(any())\n }\n break\n case 'array':\n if (serialized.itemType) {\n schema = array(deserializeSchema(serialized.itemType))\n }\n else {\n schema = array(any())\n }\n break\n case 'tuple':\n if (serialized.tupleTypes) {\n const types = serialized.tupleTypes.map(t => deserializeSchema(t))\n schema = tuple(types as any)\n }\n else {\n schema = tuple([])\n }\n break\n case 'union':\n if (serialized.union) {\n const types = serialized.union.map(t => deserializeSchema(t))\n schema = union(types as any)\n }\n else {\n schema = union([])\n }\n break\n case 'literal':\n if (serialized.literalValue !== undefined) {\n schema = literal(serialized.literalValue)\n }\n else {\n schema = any()\n }\n break\n case 'function':\n if (serialized.args && serialized.ret) {\n const args = serialized.args.map(t => deserializeSchema(t))\n const ret = deserializeSchema(serialized.ret)\n schema = func(args as any, ret)\n }\n else {\n schema = func([], any())\n }\n break\n case 'rpc':\n if (serialized.info && serialized.ret) {\n const info = deserializeSchema(serialized.info)\n const ret = deserializeSchema(serialized.ret)\n schema = rpc(info, ret)\n }\n else if (serialized.ret) {\n const ret = deserializeSchema(serialized.ret)\n schema = rpc(undefined, ret)\n }\n else {\n schema = rpc()\n }\n break\n default:\n // Unknown type, create a generic any() type\n schema = any()\n break\n }\n\n // Apply optional flag\n if (serialized.optional) {\n schema = schema.optional()\n }\n\n // Apply default value (only if not a function)\n if (serialized.default !== undefined) {\n schema = schema.default(serialized.default)\n }\n\n // Apply metadata\n if (serialized.meta) {\n schema = schema.meta(serialized.meta)\n }\n\n return schema\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/zeed/zeed/dist/chunk-JWON4PLZ.cjs","../src/common/schema/serialize.ts"],"names":["serializeSchema","schema","result","isFunction","key","value","isArray","__name","deserializeSchema","serialized","stringLiterals","string","number","int","boolean","none","any","obj","object","record","array","types","t","tuple","union","literal","args","ret","func","info","rpc"],"mappings":"AAAA,iIAAqI,wDAAgD,wDAAyC,SCwC9MA,CAAAA,CAAgBC,CAAAA,CAAmC,CACjE,IAAMC,CAAAA,CAAyB,CAC7B,IAAA,CAAMD,CAAAA,CAAO,IACf,CAAA,CAgBA,EAAA,CAdIA,CAAAA,CAAO,SAAA,GAAc,KAAA,CAAA,EAAA,CACvBC,CAAAA,CAAO,QAAA,CAAWD,CAAAA,CAAO,SAAA,CAAA,CAGvBA,CAAAA,CAAO,KAAA,GAAU,KAAA,CAAA,EAAA,CACnBC,CAAAA,CAAO,IAAA,CAAOD,CAAAA,CAAO,KAAA,CAAA,CAInBA,CAAAA,CAAO,QAAA,GAAa,KAAA,CAAA,EAAa,CAACE,iCAAAA,CAAWF,CAAO,QAAQ,CAAA,EAAA,CAC9DC,CAAAA,CAAO,OAAA,CAAUD,CAAAA,CAAO,QAAA,CAAA,CAItBA,CAAAA,CAAO,OAAA,GAAY,KAAA,CAAA,CAAW,CAChCC,CAAAA,CAAO,MAAA,CAAS,CAAC,CAAA,CACjB,GAAA,CAAA,GAAW,CAACE,CAAAA,CAAKC,CAAK,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQJ,CAAAA,CAAO,OAAO,CAAA,CACtDC,CAAAA,CAAO,MAAA,CAAOE,CAAG,CAAA,CAAIJ,CAAAA,CAAgBK,CAAkB,CAE3D,CAGA,OAAIJ,CAAAA,CAAO,KAAA,GAAU,KAAA,CAAA,EAAA,CACfK,iCAAAA,CAAQL,CAAO,KAAK,CAAA,CAEtBC,CAAAA,CAAO,UAAA,CAAcD,CAAAA,CAAO,KAAA,CAAsB,GAAA,CAAI,CAAA,EAAKD,CAAAA,CAAgB,CAAC,CAAC,CAAA,CAI7EE,CAAAA,CAAO,QAAA,CAAWF,CAAAA,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A,CAC5CR,CAAAA,CAAS6B,iCAAAA,CAAID,CAAMF,CAAG,CACxB,CAAA,KAAA,EAAA,CACSlB,CAAAA,CAAW,GAAA,CAAK,CACvB,IAAMkB,CAAAA,CAAMnB,CAAAA,CAAkBC,CAAAA,CAAW,GAAG,CAAA,CAC5CR,CAAAA,CAAS6B,iCAAAA,KAAI,CAAA,CAAWH,CAAG,CAC7B,CAAA,KAEE1B,CAAAA,CAAS6B,iCAAAA,CAAI,CAEf,KAAA,CACF,OAAA,CAEE7B,CAAAA,CAASe,iCAAAA,CAAI,CACb,KACJ,CAGA,OAAIP,CAAAA,CAAW,QAAA,EAAA,CACbR,CAAAA,CAASA,CAAAA,CAAO,QAAA,CAAS,CAAA,CAAA,CAIvBQ,CAAAA,CAAW,OAAA,GAAY,KAAA,CAAA,EAAA,CACzBR,CAAAA,CAASA,CAAAA,CAAO,OAAA,CAAQQ,CAAAA,CAAW,OAAO,CAAA,CAAA,CAIxCA,CAAAA,CAAW,IAAA,EAAA,CACbR,CAAAA,CAASA,CAAAA,CAAO,IAAA,CAAKQ,CAAAA,CAAW,IAAI,CAAA,CAAA,CAG/BR,CACT,CAhIgBM,iCAAAA,CAAAC,CAAA,mBAAA,CAAA,CAAA,6BAAA","file":"/home/runner/work/zeed/zeed/dist/chunk-JWON4PLZ.cjs","sourcesContent":[null,"// Serialization and Deserialization for Schema Types\n\nimport type { Type, TypeMeta } from './schema'\nimport { isArray, isFunction } from '../data/is'\nimport { any, array, boolean, func, int, literal, none, number, object, record, rpc, string, stringLiterals, tuple, union } from './schema'\n\n// =============================================================================\n// Types\n// =============================================================================\n\n/**\n * Plain JSON representation of a schema type\n */\nexport interface SerializedType {\n type: string\n default?: any\n optional?: boolean\n meta?: TypeMeta\n object?: Record<string, SerializedType>\n itemType?: SerializedType\n union?: SerializedType[]\n enumValues?: any[]\n args?: SerializedType[]\n ret?: SerializedType\n info?: SerializedType\n tupleTypes?: SerializedType[]\n literalValue?: any\n}\n\n// =============================================================================\n// Serialization\n// =============================================================================\n\n/**\n * Serializes a schema Type to a plain JSON object.\n * Functions in _check and _default will not be serialized.\n *\n * @param schema - The schema Type to serialize\n * @returns A plain JSON object representing the schema\n */\nexport function serializeSchema(schema: Type<any>): SerializedType {\n const result: SerializedType = {\n type: schema.type,\n }\n\n if (schema._optional !== undefined) {\n result.optional = schema._optional\n }\n\n if (schema._meta !== undefined) {\n result.meta = schema._meta\n }\n\n // Serialize default value if it's not a function\n if (schema._default !== undefined && !isFunction(schema._default)) {\n result.default = schema._default\n }\n\n // Serialize object properties\n if (schema._object !== undefined) {\n result.object = {}\n for (const [key, value] of Object.entries(schema._object)) {\n result.object[key] = serializeSchema(value as Type<any>)\n }\n }\n\n // Serialize array/record item type\n if (schema._type !== undefined) {\n if (isArray(schema._type)) {\n // Tuple types\n result.tupleTypes = (schema._type as Type<any>[]).map(t => serializeSchema(t))\n }\n else {\n // Array or record item type\n result.itemType = serializeSchema(schema._type as Type<any>)\n }\n }\n\n // Serialize union types\n if (schema._union !== undefined) {\n result.union = (schema._union as Type<any>[]).map(t => serializeSchema(t))\n }\n\n // Serialize enum values\n if (schema._enumValues !== undefined) {\n result.enumValues = schema._enumValues\n }\n\n // Serialize function arguments\n if (schema._args !== undefined) {\n result.args = (schema._args as Type<any>[]).map(t => serializeSchema(t))\n }\n\n // Serialize function return type\n if (schema._ret !== undefined) {\n result.ret = serializeSchema(schema._ret as Type<any>)\n }\n\n // Serialize RPC info type\n if (schema._info !== undefined) {\n result.info = serializeSchema(schema._info as Type<any>)\n }\n\n // Serialize literal value (for literal types)\n if (schema.type === 'literal' && schema._default !== undefined) {\n result.literalValue = schema._default\n }\n\n return result\n}\n\n// =============================================================================\n// Deserialization\n// =============================================================================\n\n/**\n * Deserializes a plain JSON object back to a schema Type.\n * Note: Custom _check functions cannot be restored and will use default validators.\n *\n * @param serialized - The serialized schema object\n * @returns A reconstructed Type instance\n */\nexport function deserializeSchema(serialized: SerializedType): Type<any> {\n let schema: Type<any>\n\n // Create base type based on type name\n switch (serialized.type) {\n case 'string':\n if (serialized.enumValues) {\n schema = stringLiterals(serialized.enumValues as any)\n }\n else {\n schema = string()\n }\n break\n case 'number':\n schema = number()\n break\n case 'int':\n schema = int()\n break\n case 'boolean':\n schema = boolean()\n break\n case 'none':\n schema = none()\n break\n case 'any':\n schema = any()\n break\n case 'object':\n if (serialized.object) {\n const obj: any = {}\n for (const [key, value] of Object.entries(serialized.object)) {\n obj[key] = deserializeSchema(value)\n }\n schema = object(obj)\n }\n else {\n schema = object({})\n }\n break\n case 'record':\n if (serialized.itemType) {\n schema = record(deserializeSchema(serialized.itemType))\n }\n else {\n schema = record(any())\n }\n break\n case 'array':\n if (serialized.itemType) {\n schema = array(deserializeSchema(serialized.itemType))\n }\n else {\n schema = array(any())\n }\n break\n case 'tuple':\n if (serialized.tupleTypes) {\n const types = serialized.tupleTypes.map(t => deserializeSchema(t))\n schema = tuple(types as any)\n }\n else {\n schema = tuple([])\n }\n break\n case 'union':\n if (serialized.union) {\n const types = serialized.union.map(t => deserializeSchema(t))\n schema = union(types as any)\n }\n else {\n schema = union([])\n }\n break\n case 'literal':\n if (serialized.literalValue !== undefined) {\n schema = literal(serialized.literalValue)\n }\n else {\n schema = any()\n }\n break\n case 'function':\n if (serialized.args && serialized.ret) {\n const args = serialized.args.map(t => deserializeSchema(t))\n const ret = deserializeSchema(serialized.ret)\n schema = func(args as any, ret)\n }\n else {\n schema = func([], any())\n }\n break\n case 'rpc':\n if (serialized.info && serialized.ret) {\n const info = deserializeSchema(serialized.info)\n const ret = deserializeSchema(serialized.ret)\n schema = rpc(info, ret)\n }\n else if (serialized.ret) {\n const ret = deserializeSchema(serialized.ret)\n schema = rpc(undefined, ret)\n }\n else {\n schema = rpc()\n }\n break\n default:\n // Unknown type, create a generic any() type\n schema = any()\n break\n }\n\n // Apply optional flag\n if (serialized.optional) {\n schema = schema.optional()\n }\n\n // Apply default value (only if not a function)\n if (serialized.default !== undefined) {\n schema = schema.default(serialized.default)\n }\n\n // Apply metadata\n if (serialized.meta) {\n schema = schema.meta(serialized.meta)\n }\n\n return schema\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkRMTW3TW2cjs = require('./chunk-RMTW3TW2.cjs');var _chunkTNMEWZPWcjs = require('./chunk-TNMEWZPW.cjs');var _chunkP7XCQ7WVcjs = require('./chunk-P7XCQ7WV.cjs');function p(t){if(t.startsWith("data:"))return _chunkTNMEWZPWcjs.N.call(void 0, t.split(",",2)[1])}_chunkP7XCQ7WVcjs.a.call(void 0, p,"dataUriToUint8Array");function d(t){if(t.startsWith("data:"))return t.slice(5).split(",",2)[0]}_chunkP7XCQ7WVcjs.a.call(void 0, d,"dataUriToMimeType");function l(t){if(t.startsWith("data:")){let[r,a]=t.slice(5).split(",",2),s=_chunkTNMEWZPWcjs.N.call(void 0, a).slice().buffer;return new Blob([s],{type:r})}}_chunkP7XCQ7WVcjs.a.call(void 0, l,"dataUriToBlob");async function b(t){let r=await _chunkRMTW3TW2cjs.g.call(void 0, t);if(r)return`data:${t.type},${_chunkTNMEWZPWcjs.L.call(void 0, r)}`}_chunkP7XCQ7WVcjs.a.call(void 0, b,"blobToDataUri");function m(t,r="application/octet-stream"){return`data:${r},${_chunkTNMEWZPWcjs.L.call(void 0, t)}`}_chunkP7XCQ7WVcjs.a.call(void 0, m,"Uint8ArrayToDataUri");exports.a = p; exports.b = d; exports.c = l; exports.d = b; exports.e = m;
|
|
2
|
+
//# sourceMappingURL=chunk-K4IRAHZV.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/zeed/zeed/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/zeed/zeed/dist/chunk-K4IRAHZV.cjs","../src/common/data/datauri.ts"],"names":["dataUriToUint8Array","dataUri","fromBase64","__name","dataUriToMimeType","dataUriToBlob","mimeString","base64String","buffer","blobToDataUri","blob","bin","blobToArrayBuffer","toBase64"],"mappings":"AAAA,iIAAwC,wDAAgD,wDAAyC,SCGjHA,CAAAA,CAAoBC,CAAAA,CAAyC,CAC3E,EAAA,CAAIA,CAAAA,CAAQ,UAAA,CAAW,OAAO,CAAA,CAC5B,OAAOC,iCAAAA,CAAWD,CAAQ,KAAA,CAAM,GAAA,CAAK,CAAC,CAAA,CAAE,CAAC,CAAC,CAC9C,CAHgBE,iCAAAA,CAAAH,CAAA,qBAAA,CAAA,CAKT,SAASI,CAAAA,CAAkBH,CAAAA,CAAqC,CACrE,EAAA,CAAIA,CAAAA,CAAQ,UAAA,CAAW,OAAO,CAAA,CAC5B,OAAOA,CAAAA,CAAQ,KAAA,CAAM,CAAC,CAAA,CAAE,KAAA,CAAM,GAAA,CAAK,CAAC,CAAA,CAAE,CAAC,CAC3C,CAHgBE,iCAAAA,CAAAC,CAAA,mBAAA,CAAA,CAKT,SAASC,CAAAA,CAAcJ,CAAAA,CAAmC,CAC/D,EAAA,CAAIA,CAAAA,CAAQ,UAAA,CAAW,OAAO,CAAA,CAAG,CAC/B,GAAM,CAACK,CAAAA,CAAYC,CAAY,CAAA,CAAIN,CAAAA,CAAQ,KAAA,CAAM,CAAC,CAAA,CAAE,KAAA,CAAM,GAAA,CAAK,CAAC,CAAA,CAG5DO,CAAAA,CAFIN,iCAAAA,CAAuB,CAAA,CAEhB,KAAA,CAAM,CAAA,CAAE,MAAA,CACzB,OAAO,IAAI,IAAA,CAAK,CAACM,CAAM,CAAA,CAAG,CAAE,IAAA,CAAMF,CAAW,CAAC,CAC9C,CACF,CARgBH,iCAAAA,CAAAE,CAAA,eAAA,CAAA,CAUhB,MAAA,SAAsBI,CAAAA,CAAcC,CAAAA,CAAyC,CAC3E,IAAMC,CAAAA,CAAM,MAAMC,iCAAAA,CAAsB,CAAA,CACxC,EAAA,CAAID,CAAAA,CACF,MAAO,CAAA,KAAA,EAAQD,CAAAA,CAAK,IAAI,CAAA,CAAA,EAAIG,iCAAAA,CAAY,CAAC,CAAA,CAAA","file":"/home/runner/work/zeed/zeed/dist/chunk-K4IRAHZV.cjs","sourcesContent":[null,"import { blobToArrayBuffer } from '../bin'\nimport { fromBase64, toBase64 } from './bin'\n\nexport function dataUriToUint8Array(dataUri: string): Uint8Array | undefined {\n if (dataUri.startsWith('data:'))\n return fromBase64(dataUri.split(',', 2)[1])\n}\n\nexport function dataUriToMimeType(dataUri: string): string | undefined {\n if (dataUri.startsWith('data:'))\n return dataUri.slice(5).split(',', 2)[0]\n}\n\nexport function dataUriToBlob(dataUri: string): Blob | undefined {\n if (dataUri.startsWith('data:')) {\n const [mimeString, base64String] = dataUri.slice(5).split(',', 2)\n const u = fromBase64(base64String)\n // create a plain ArrayBuffer copy (ensures .buffer is an ArrayBuffer, not SharedArrayBuffer)\n const buffer = u.slice().buffer\n return new Blob([buffer], { type: mimeString })\n }\n}\n\nexport async function blobToDataUri(blob: Blob): Promise<string | undefined> {\n const bin = await blobToArrayBuffer(blob)\n if (bin)\n return `data:${blob.type},${toBase64(bin)}`\n}\n\nexport function Uint8ArrayToDataUri(bin: Uint8Array, type = 'application/octet-stream'): string {\n return `data:${type},${toBase64(bin)}`\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as o}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as o}from"./chunk-IQWBYSWG.js";import{f as e}from"./chunk-WFBD5UN5.js";import{a as t}from"./chunk-5NKC2EQJ.js";function r(i){return["daily","weekly","monthly","size"].includes(String(i).trim().toLowerCase())?i:e(i,!1)}t(r,"parseLogRotationConfigEnv");function p(i){if(i)return i===!0||i==="size"?{size:"10M",maxFiles:5,compress:"gzip"}:i==="daily"?{interval:"1d",maxFiles:30,compress:"gzip"}:i==="weekly"?{interval:"7d",maxFiles:30,compress:"gzip"}:i==="monthly"?{interval:"1M",maxFiles:90,compress:"gzip"}:i}t(p,"getLogRotationConfig");function s(i=!1){let n=[o.boolean(),o.literal("daily"),o.literal("weekly"),o.literal("monthly"),o.literal("size")];return i||n.push(o.object({compress:o.union([o.boolean(),o.literal("gzip")]).optional(),encoding:o.string().optional(),history:o.string().optional(),immutable:o.boolean().optional(),initialRotation:o.boolean().optional(),interval:o.string().optional(),intervalBoundary:o.boolean().optional(),intervalUTC:o.boolean().optional(),maxFiles:o.number().optional(),maxSize:o.string().optional(),mode:o.number().optional(),omitExtension:o.boolean().optional(),path:o.string().optional(),rotate:o.number().optional(),size:o.string().optional(),teeToStdout:o.boolean().optional()})),n}t(s,"getLogFileRotationConfigSchemaOptions");export{r as a,p as b,s as c};
|
|
2
|
+
//# sourceMappingURL=chunk-KIKHNNKK.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkWK6DXBUDcjs = require('./chunk-WK6DXBUD.cjs');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkWK6DXBUDcjs = require('./chunk-WK6DXBUD.cjs');var _chunkSHOLGUSOcjs = require('./chunk-SHOLGUSO.cjs');var _chunk47GAJHNOcjs = require('./chunk-47GAJHNO.cjs');var _chunkDLVWYIS2cjs = require('./chunk-DLVWYIS2.cjs');var _chunkSEQAFKIVcjs = require('./chunk-SEQAFKIV.cjs');var _chunkP7XCQ7WVcjs = require('./chunk-P7XCQ7WV.cjs');var _fs = require('fs');var _path = require('path');var _process = require('process'); var _process2 = _interopRequireDefault(_process);var u={};function B(e,v={}){let{level:y=void 0,filter:O=void 0,time:R=!0,pretty:S=!1,rotation:$}=v;e=_path.resolve.call(void 0, _process2.default.cwd(),e);let l=_path.dirname.call(void 0, e);_fs.mkdirSync.call(void 0, l,{recursive:!0});let i=_chunkSHOLGUSOcjs.b.call(void 0, $),a;i?(i.path=l,a=_chunkWK6DXBUDcjs.c.call(void 0, _path.basename.call(void 0, e),i)):a=_fs.createWriteStream.call(void 0, e,{flags:"a"});let b=_chunkDLVWYIS2cjs.b.call(void 0, O),w=_chunkDLVWYIS2cjs.d.call(void 0, y);return t=>{if(!w(t.level)||!b(t.name))return;let o=R?`${new Date().toISOString()} `:"",s=t.name||"",c=u[s||""];c==null&&(u[s]=c);let r=[`[${s||"*"}]`,_chunk47GAJHNOcjs.b.call(void 0, t.messages,{pretty:S})];function n(...F){a.write(`${F.join(" ")}
|
|
2
2
|
`)}switch(_chunkP7XCQ7WVcjs.a.call(void 0, n,"write"),t.level){case 1:n(`${o}I|* `,...r);break;case 2:n(`${o}W|** `,...r);break;case 3:n(`${o}E|***`,...r);break;default:n(`${o}D| `,...r);break}}}_chunkP7XCQ7WVcjs.a.call(void 0, B,"LoggerFileHandler");exports.a = B;
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
//# sourceMappingURL=chunk-L5OF6DSH.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/zeed/zeed/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/zeed/zeed/dist/chunk-L5OF6DSH.cjs","../src/node/log/log-file.ts"],"names":["namespaces","LoggerFileHandler","path","opt","level","filter","time","pretty","rotation","resolve","process","pathFolder","dirname","mkdirSync","rotationOpts","getLogRotationConfig","stream","createRotationStream","basename","createWriteStream","matchesNamespace","useNamespaceFilter","matchesLevel","useLevelFilter","msg","timeNow"],"mappings":"AAAA,iOAAwC,wDAAyC,wDAAyC,wDAAgD,wDAAuD,wDAAyC,wBCE7N,4BACF,oFACvB,IAOdA,CAAAA,CAAkC,CAAC,CAAA,CAoBlC,SAASC,CAAAA,CAAkBC,CAAAA,CAAcC,CAAAA,CAA6B,CAAC,CAAA,CAAG,CAC/E,GAAM,CACJ,KAAA,CAAAC,CAAAA,CAAQ,KAAA,CAAA,CACR,MAAA,CAAAC,CAAAA,CAAS,KAAA,CAAA,CACT,IAAA,CAAAC,CAAAA,CAAO,CAAA,CAAA,CACP,MAAA,CAAAC,CAAAA,CAAS,CAAA,CAAA,CACT,QAAA,CAAAC,CACF,CAAA,CAAIL,CAAAA,CAEJD,CAAAA,CAAOO,2BAAAA,iBAAQC,CAAQ,GAAA,CAAI,CAAA,CAAGR,CAAI,CAAA,CAClC,IAAMS,CAAAA,CAAaC,2BAAAA,CAAY,CAAA,CAC/BC,2BAAAA,CAAUF,CAAY,CAAE,SAAA,CAAW,CAAA,CAAK,CAAC,CAAA,CAGzC,IAAMG,CAAAA,CAAeC,iCAAAA,CAA6B,CAAA,CAE9CC,CAAAA,CACAF,CAAAA,CAAAA,CAEFA,CAAAA,CAAa,IAAA,CAAOH,CAAAA,CACpBK,CAAAA,CAASC,iCAAAA,4BAAqBC,CAAa,CAAA,CAAGJ,CAAY,CAAA,CAAA,CAG1DE,CAAAA,CAASG,mCAAAA,CAAkBjB,CAAM,CAAE,KAAA,CAAO,GAAI,CAAC,CAAA,CAGjD,IAAMkB,CAAAA,CAAmBC,iCAAAA,CAAyB,CAAA,CAC5CC,CAAAA,CAAeC,iCAAAA,CAAoB,CAAA,CACzC,OAAQC,CAAAA,EAAoB,CAG1B,EAAA,CAFI,CAACF,CAAAA,CAAaE,CAAAA,CAAI,KAAK,CAAA,EAEvB,CAACJ,CAAAA,CAAiBI,CAAAA,CAAI,IAAI,CAAA,CAC5B,MAAA,CAEF,IAAMC,CAAAA,CAAUnB,CAAAA,CAAO,CAAA,EAAA;AAlCX","file":"/home/runner/work/zeed/zeed/dist/chunk-L5OF6DSH.cjs","sourcesContent":[null,"import type { LogHandlerOptions, LogMessage } from '../../common/log/log-base'\nimport type { LogRotationOptions } from './log-file-rotation'\nimport { createWriteStream, mkdirSync } from 'node:fs'\nimport { basename, dirname, resolve } from 'node:path'\nimport process from 'node:process'\nimport { renderMessages } from '../../common/data/message'\nimport { LogLevelError, LogLevelInfo, LogLevelWarn } from '../../common/log/log-base'\nimport { useLevelFilter, useNamespaceFilter } from '../../common/log/log-filter'\nimport { getLogRotationConfig } from './log-file-rotation'\nimport { createRotationStream } from './log-rotation'\n\nconst namespaces: Record<string, any> = {}\n\nexport interface LogFileHandlerOptions extends LogHandlerOptions {\n /**\n * Optional rotation options for log files. When provided, enables automatic log rotation.\n * Can be:\n * - `true`: Use default rotation settings (10MB size, 5 files, gzip compression)\n * - Rotation options object: Customize rotation behavior\n * - Shortcut strings: 'daily' | 'weekly' | 'monthly' | 'size'\n *\n * Examples:\n * - Enable with defaults: { rotation: true }\n * - Rotate daily: { rotation: { interval: '1d' } }\n * - Rotate when file reaches 10MB: { rotation: { size: '10M' } }\n * - Keep max 5 files: { rotation: { maxFiles: 5 } }\n * - Compress rotated files: { rotation: { compress: 'gzip' } }\n */\n rotation?: LogRotationOptions\n}\n\nexport function LoggerFileHandler(path: string, opt: LogFileHandlerOptions = {}) {\n const {\n level = undefined,\n filter = undefined,\n time = true,\n pretty = false,\n rotation,\n } = opt\n\n path = resolve(process.cwd(), path)\n const pathFolder = dirname(path)\n mkdirSync(pathFolder, { recursive: true })\n\n // Use rotating stream if rotation options are provided\n const rotationOpts = getLogRotationConfig(rotation)\n\n let stream: ReturnType<typeof createWriteStream> | ReturnType<typeof createRotationStream>\n if (rotationOpts) {\n // ensure rotation writes into the same folder\n rotationOpts.path = pathFolder\n stream = createRotationStream(basename(path), rotationOpts)\n }\n else {\n stream = createWriteStream(path, { flags: 'a' })\n }\n\n const matchesNamespace = useNamespaceFilter(filter)\n const matchesLevel = useLevelFilter(level)\n return (msg: LogMessage) => {\n if (!matchesLevel(msg.level))\n return\n if (!matchesNamespace(msg.name))\n return\n\n const timeNow = time ? `${new Date().toISOString()} ` : ''\n const name = msg.name || ''\n const ninfo = namespaces[name || '']\n if (ninfo == null)\n namespaces[name] = ninfo\n\n const args: string[] = [\n `[${name || '*'}]`,\n renderMessages(msg.messages, { pretty }),\n ]\n\n function write(...args: string[]): void {\n stream.write(`${args.join('\\t')}\\n`)\n }\n\n switch (msg.level) {\n case LogLevelInfo:\n write(`${timeNow}I|* `, ...args)\n break\n case LogLevelWarn:\n write(`${timeNow}W|** `, ...args)\n break\n case LogLevelError:\n write(`${timeNow}E|***`, ...args)\n break\n default:\n write(`${timeNow}D| `, ...args)\n break\n }\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-LAGM3ULD.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as c,b as u,e as h,h as l,i as _,j as m,l as b}from"./chunk-6VFFIKPT.js";import{a as o}from"./chunk-5NKC2EQJ.js";var i=class s{static{o(this,"Type")}type;_default;_optional;_meta;_check;_object;_type;_union;_enumValues;_args;_ret;_info;constructor(e,t={}){this.type=e,Object.assign(this,t)}get"~standard"(){return{version:1,vendor:"zeed",validate:o(e=>this.validate(e),"validate"),types:{input:void 0,output:void 0}}}validate(e){if(e==null)return this._optional?{value:void 0}:this._default!==void 0?{value:u(this._default)?this._default(this):this._default}:{issues:[{message:"Required value is missing",path:[]}]};if(this.type==="literal"&&this._default!==e)return{issues:[{message:`Expected literal value ${this._default}, got ${e}`,path:[]}]};if(this._enumValues&&Array.isArray(this._enumValues)&&!this._enumValues.includes(e))return{issues:[{message:`Expected one of [${this._enumValues.join(", ")}], got ${e}`,path:[]}]};if(this._union&&Array.isArray(this._union)){for(let t of this._union){let n=t.validate(e);if(!n.issues)return n}return{issues:[{message:"Value does not match any union variant",path:[]}]}}if(this.type==="array"||this.type==="tuple"){if(!Array.isArray(e))return{issues:[{message:`Expected array, got ${typeof e}`,path:[]}]};if(this.type==="tuple"&&this._type){let t=this._type;if(e.length!==t.length)return{issues:[{message:`Expected tuple of length ${t.length}, got ${e.length}`,path:[]}]};let n=[];for(let r=0;r<t.length;r++){let a=t[r].validate(e[r]);if(a.issues)for(let p of a.issues)n.push({message:p.message,path:[r,...p.path||[]]})}if(n.length>0)return{issues:n}}else if(this._type){let t=this._type,n=[];for(let r=0;r<e.length;r++){let a=t.validate(e[r]);if(a.issues)for(let p of a.issues)n.push({message:p.message,path:[r,...p.path||[]]})}if(n.length>0)return{issues:n}}}if(this._object){if(!c(e))return{issues:[{message:`Expected object, got ${typeof e}`,path:[]}]};let t=[],n=e;for(let r in this._object){let a=this._object[r],p=n[r],y=a.validate(p);if(y.issues)for(let f of y.issues)t.push({message:f.message,path:[r,...f.path||[]]})}return t.length>0?{issues:t}:{value:e,issues:void 0}}if(this.type==="record"&&this._type){if(!c(e))return{issues:[{message:`Expected object, got ${typeof e}`,path:[]}]};let t=this._type,n=[],r=e;for(let a in r){let p=t.validate(r[a]);if(p.issues)for(let y of p.issues)n.push({message:y.message,path:[a,...y.path||[]]})}if(n.length>0)return{issues:n}}return this._check&&!this._check(e)?{issues:[{message:`Expected ${this.type}, got ${typeof e}`,path:[]}]}:{value:e}}_cloneWithProps(e={}){let t=new s(this.type),n=["_default","_optional","_meta","_check","_object","_type","_union","_enumValues","_args","_ret","_info"];for(let r of n)this[r]!==void 0&&(t[r]=this[r]);return Object.assign(t,e),t}static _copyTypeProperties(e,t){let n=["_check","_default","_meta","_object","_type","_enumValues"];for(let r of n)e[r]!==void 0&&(t[r]=e[r])}optional(){return this._cloneWithProps({_optional:!0})}default(e){return this._cloneWithProps({_default:e})}meta(e){return this._cloneWithProps({_meta:e})}describe(e){let t=this._meta||{};return t.desc=e,this._cloneWithProps({_meta:t})}extend(e){if(!this._object)throw new Error("extend() can only be used on object schemas");let t={...this._object,...e};return T(t)}pick(e){if(!this._object)throw new Error("pick() can only be used on object schemas");let t={};for(let n of Object.keys(e))n in this._object&&(t[n]=this._object[n]);return T(t)}omit(e){if(!this._object)throw new Error("omit() can only be used on object schemas");let t={...this._object};for(let n of Object.keys(e))delete t[n];return T(t)}_transformObjectProperties(e,t){if(!this._object)throw new Error("This operation can only be used on object schemas");let n={},r=this._object;for(let[a,p]of Object.entries(r)){let y=!t||a in t;n[a]=e(a,p,y)}return T(n)}partial(e){if(!this._object)throw new Error("partial() can only be used on object schemas");return this._transformObjectProperties((t,n,r)=>r?s._cloneTypeWithOptional(n,!0):n,e)}required(e){if(!this._object)throw new Error("required() can only be used on object schemas");return this._transformObjectProperties((t,n,r)=>r?s._cloneTypeWithOptional(n,!1):n,e)}static _cloneTypeWithOptional(e,t){let n=new s(e.type);return s._copyTypeProperties(e,n),n._optional=t,n}};function k(){return new i("string",{_check:l})}o(k,"string");function d(){return new i("number",{_check:_})}o(d,"number");function j(){return new i("int",{_check:m})}o(j,"int");function R(){return new i("boolean",{_check:b})}o(R,"boolean");function g(){return new i("none",{_check:o(s=>s==null,"_check"),_optional:!0})}o(g,"none");function K(){return new i("any",{_check:o(s=>s!=null,"_check")})}o(K,"any");var w=d,O=d,P=d;function T(s){return new i("object",{_check:c,_object:s})}o(T,"object");function V(s){return new i("record",{_check:c,_type:s})}o(V,"record");function I(s){return new i("union",{_check:o(e=>s.some(t=>t._check?.(e)??!1),"_check"),_union:s})}o(I,"union");function A(s){return new i("literal",{_check:o(e=>e===s,"_check"),_default:s})}o(A,"literal");function E(s){return new i("string",{_check:o(e=>typeof e=="string"&&s.includes(e),"_check"),_enumValues:s})}o(E,"stringLiterals");function S(s){return new i("tuple",{_check:o(e=>Array.isArray(e)&&e.length===s.length&&s.every((t,n)=>t._check?.(e[n])??!1),"_check"),_type:s})}o(S,"tuple");function $(s){return new i("array",{_check:h,_type:s})}o($,"array");function q(s,e){return new i("function",{_check:u,_args:s,_ret:e})}o(q,"func");function F(s,e){return new i("rpc",{_check:u,_info:s,_ret:e??g()})}o(F,"rpc");export{i as a,k as b,d as c,j as d,R as e,g as f,K as g,w as h,O as i,P as j,T as k,V as l,I as m,A as n,E as o,S as p,$ as q,q as r,F as s};
|
|
2
|
+
//# sourceMappingURL=chunk-LLDVPAUS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/common/schema/schema.ts"],"sourcesContent":["// With many, many inspiration from https://github.com/badrap/valita MIT License as of 2024-09-10\n\nimport type { StandardSchemaV1 } from './schema-standard'\nimport { isArray, isBoolean, isFunction, isInteger, isNumber, isObject, isString } from '../data/is'\n\n/**\n * Metadata interface for type descriptions and additional properties\n */\nexport interface TypeMeta {\n desc?: string\n}\n\n/**\n * Core Type class for schema validation and type inference\n * Implements StandardSchemaV1 for cross-library compatibility\n */\nexport class Type<T = unknown> {\n readonly type: string\n\n _default?: any\n _optional?: boolean\n _meta?: TypeMeta\n _check?: (obj: any) => boolean\n _object?: any\n _type?: any\n _union?: any\n _enumValues?: any\n _args?: any\n _ret?: any\n _info?: any\n\n // [key: `_${string}`]: any // Allow only optional dynamic properties starting with an underscore\n\n constructor(name: string, options: Partial<Type<T>> = {}) {\n this.type = name\n Object.assign(this, options)\n }\n\n /**\n * Standard Schema V1 compliance property\n * Provides a standard interface for validation and type inference\n */\n get '~standard'(): any {\n return {\n version: 1,\n vendor: 'zeed',\n validate: (value: unknown): StandardSchemaV1.Result<T> => {\n return this.validate(value)\n },\n types: {\n input: undefined as any as T,\n output: undefined as any as T,\n },\n }\n }\n\n /**\n * Validation method for standard-schema compliance\n */\n validate(value: any): any {\n // const messages: Array<{ path: string, message: string, type: string, valid: boolean }> = []\n\n // Handle null/undefined cases\n if (value == null) {\n if (this._optional) {\n return { value: undefined as any as T }\n }\n if (this._default !== undefined) {\n const defaultValue = isFunction(this._default) ? this._default(this) : this._default\n return { value: defaultValue }\n }\n return {\n issues: [{\n message: `Required value is missing`,\n path: [],\n }],\n }\n }\n\n // Handle literal types\n if (this.type === 'literal' && this._default !== value) {\n return {\n issues: [{\n message: `Expected literal value ${this._default}, got ${value}`,\n path: [],\n }],\n }\n }\n\n // Handle string literals (enums)\n if (this._enumValues && Array.isArray(this._enumValues)) {\n if (!this._enumValues.includes(value)) {\n return {\n issues: [{\n message: `Expected one of [${this._enumValues.join(', ')}], got ${value}`,\n path: [],\n }],\n }\n }\n }\n\n // Handle union types\n if (this._union && Array.isArray(this._union)) {\n for (const option of this._union) {\n const result = (option as Type<any>).validate(value)\n if (!result.issues) {\n return result\n }\n }\n return {\n issues: [{\n message: `Value does not match any union variant`,\n path: [],\n }],\n }\n }\n\n // Handle array types\n if (this.type === 'array' || this.type === 'tuple') {\n if (!Array.isArray(value)) {\n return {\n issues: [{\n message: `Expected array, got ${typeof value}`,\n path: [],\n }],\n }\n }\n\n if (this.type === 'tuple' && this._type) {\n const items = this._type as Type<any>[]\n if (value.length !== items.length) {\n return {\n issues: [{\n message: `Expected tuple of length ${items.length}, got ${value.length}`,\n path: [],\n }],\n }\n }\n\n const issues: StandardSchemaV1.Issue[] = []\n for (let i = 0; i < items.length; i++) {\n const itemResult = items[i].validate(value[i])\n if (itemResult.issues) {\n for (const issue of itemResult.issues) {\n issues.push({\n message: issue.message,\n path: [i, ...(issue.path || [])],\n })\n }\n }\n }\n\n if (issues.length > 0) {\n return { issues }\n }\n }\n else if (this._type) {\n // Regular array with item type\n const itemType = this._type as Type<any>\n const issues: StandardSchemaV1.Issue[] = []\n\n for (let i = 0; i < value.length; i++) {\n const itemResult = itemType.validate(value[i])\n if (itemResult.issues) {\n for (const issue of itemResult.issues) {\n issues.push({\n message: issue.message,\n path: [i, ...(issue.path || [])],\n })\n }\n }\n }\n\n if (issues.length > 0) {\n return { issues }\n }\n }\n }\n\n // Handle object types\n if (this._object) {\n if (!isObject(value)) {\n return {\n issues: [{\n message: `Expected object, got ${typeof value}`,\n path: [],\n }],\n }\n }\n\n const issues: StandardSchemaV1.Issue[] = []\n const obj = value as Record<string, any>\n\n for (const key in this._object) {\n const propSchema = this._object[key] as Type<any>\n const propValue = obj[key]\n const propResult = propSchema.validate(propValue)\n\n if (propResult.issues) {\n for (const issue of propResult.issues) {\n issues.push({\n message: issue.message,\n path: [key, ...(issue.path || [])],\n })\n }\n }\n }\n\n if (issues.length > 0) {\n return { issues }\n }\n\n return { value: value as T, issues: undefined }\n }\n\n // Handle record types\n if (this.type === 'record' && this._type) {\n if (!isObject(value)) {\n return {\n issues: [{\n message: `Expected object, got ${typeof value}`,\n path: [],\n }],\n }\n }\n\n const valueType = this._type as Type<any>\n const issues: StandardSchemaV1.Issue[] = []\n const obj = value as Record<string, any>\n\n for (const key in obj) {\n const propResult = valueType.validate(obj[key])\n if (propResult.issues) {\n for (const issue of propResult.issues) {\n issues.push({\n message: issue.message,\n path: [key, ...(issue.path || [])],\n })\n }\n }\n }\n\n if (issues.length > 0) {\n return { issues }\n }\n }\n\n // Check primitive types\n if (this._check && !this._check(value)) {\n return {\n issues: [{\n message: `Expected ${this.type}, got ${typeof value}`,\n path: [],\n }],\n }\n }\n\n // Success - return the value\n return { value: value as T }\n }\n\n /**\n * Creates a copy of the type with new properties merged\n */\n private _cloneWithProps<U = T>(newProps: Partial<Type<any>> = {}): Type<U> {\n const cloned = new Type<U>(this.type)\n // Copy all existing properties\n const propertiesToCopy = ['_default', '_optional', '_meta', '_check', '_object', '_type', '_union', '_enumValues', '_args', '_ret', '_info']\n for (const prop of propertiesToCopy) {\n if ((this as any)[prop] !== undefined) {\n (cloned as any)[prop] = (this as any)[prop]\n }\n }\n // Apply new properties\n Object.assign(cloned, newProps)\n return cloned\n }\n\n /**\n * Helper to copy type properties when creating new type instances\n */\n private static _copyTypeProperties(source: Type<any>, target: Type<any>): void {\n const properties = ['_check', '_default', '_meta', '_object', '_type', '_enumValues']\n for (const prop of properties) {\n if ((source as any)[prop] !== undefined) {\n (target as any)[prop] = (source as any)[prop]\n }\n }\n }\n\n /**\n * Marks the type as optional, meaning it can be undefined\n * This is useful for properties that are not required.\n */\n optional(): Type<T | undefined> {\n return this._cloneWithProps<T | undefined>({ _optional: true })\n }\n\n /**\n * Sets a default value for the type, which will be used if the value is not provided\n * The default value can be a function that receives the schema as argument, or a static value.\n */\n default(value: T | ((schema?: this) => T)): Type<T> {\n return this._cloneWithProps<T>({ _default: value })\n }\n\n /**\n * Props / Metadata for the type, like description or other properties\n */\n meta(meta: TypeMeta): Type<T> {\n return this._cloneWithProps<T>({ _meta: meta })\n }\n\n /**\n * Sets the `desc` property for the type, which is a human-readable description\n */\n describe(msg: string): Type<T> {\n const meta = this._meta || {}\n meta.desc = msg\n return this._cloneWithProps<T>({ _meta: meta })\n }\n\n /**\n * Extends the type with an object, merging the properties\n */\n extend<O>(obj: O): Type<T & TypeObject<O>> {\n if (!this._object) {\n throw new Error('extend() can only be used on object schemas')\n }\n const newObj = { ...this._object, ...obj }\n return object(newObj) as any\n }\n\n /**\n * Picks certain keys from an object schema\n */\n pick<K extends keyof T>(keys: Record<K, true>): Type<Pick<T, K>> {\n if (!this._object) {\n throw new Error('pick() can only be used on object schemas')\n }\n const pickedObj: any = {}\n for (const key of Object.keys(keys)) {\n if (key in this._object) {\n pickedObj[key] = (this._object as any)[key]\n }\n }\n return object(pickedObj) as any\n }\n\n /**\n * Omits certain keys from an object schema\n */\n omit<K extends keyof T>(keys: Record<K, true>): Type<Omit<T, K>> {\n if (!this._object) {\n throw new Error('omit() can only be used on object schemas')\n }\n const omittedObj: any = { ...this._object }\n for (const key of Object.keys(keys)) {\n delete omittedObj[key]\n }\n return object(omittedObj) as any\n }\n\n /**\n * Helper method to modify object properties with a transformation function\n */\n private _transformObjectProperties(\n transform: (key: string, type: Type<any>, shouldTransform: boolean) => Type<any>,\n keys?: Record<string, true>,\n ): any {\n if (!this._object) {\n throw new Error('This operation can only be used on object schemas')\n }\n\n const transformedObj: any = {}\n const originalObj = this._object as any\n\n for (const [key, typeInstance] of Object.entries(originalObj)) {\n const shouldTransform = !keys || key in keys\n transformedObj[key] = transform(key, typeInstance as Type<any>, shouldTransform)\n }\n\n return object(transformedObj)\n }\n\n /**\n * Makes some or all properties of an object schema optional\n */\n partial(): Type<Partial<T>>\n partial<K extends keyof T>(keys: Record<K, true>): Type<Partial<Pick<T, K>> & Omit<T, K>>\n partial<K extends keyof T>(keys?: Record<K, true>): Type<Partial<T> | (Partial<Pick<T, K>> & Omit<T, K>)> {\n if (!this._object) {\n throw new Error('partial() can only be used on object schemas')\n }\n return this._transformObjectProperties((key, type, shouldTransform) => {\n if (!shouldTransform)\n return type\n return Type._cloneTypeWithOptional(type, true)\n }, keys)\n }\n\n /**\n * Makes some or all properties of an object schema required\n */\n required(): Type<Required<T>>\n required<K extends keyof T>(keys: Record<K, true>): Type<Required<Pick<T, K>> & Omit<T, K>>\n required<K extends keyof T>(keys?: Record<K, true>): Type<Required<T> | (Required<Pick<T, K>> & Omit<T, K>)> {\n if (!this._object) {\n throw new Error('required() can only be used on object schemas')\n }\n return this._transformObjectProperties((key, type, shouldTransform) => {\n if (!shouldTransform)\n return type\n return Type._cloneTypeWithOptional(type, false)\n }, keys)\n }\n\n /**\n * Helper method to clone a type with optional flag\n */\n private static _cloneTypeWithOptional(originalType: Type<any>, optional: boolean): Type<any> {\n const newType = new Type(originalType.type)\n Type._copyTypeProperties(originalType, newType)\n newType._optional = optional\n return newType\n }\n}\n\n/**\n * Type inference utility for extracting the TypeScript type from a schema Type\n */\nexport type Infer<T> = T extends Type<infer TT> ? TT : never\n\n// =============================================================================\n// Primitive Types\n// =============================================================================\n\n/**\n * Creates a string type validator\n */\nexport function string(): Type<string> {\n return new Type('string', {\n _check: isString,\n })\n}\n\n/**\n * Creates a number type validator\n */\nexport function number(): Type<number> {\n return new Type('number', {\n _check: isNumber,\n })\n}\n\n/**\n * Creates an integer type validator\n */\nexport function int(): Type<number> {\n return new Type('int', {\n _check: isInteger,\n })\n}\n\n/**\n * Creates a boolean type validator\n */\nexport function boolean(): Type<boolean> {\n return new Type('boolean', {\n _check: isBoolean,\n })\n}\n\n/**\n * Creates a none type validator (undefined | null)\n * Like undefined | null in TS and nil in Swift\n */\nexport function none(): Type<undefined> {\n return new Type('none', {\n _check: (v: any) => v == null,\n _optional: true,\n })\n}\n\n/**\n * Creates an any type validator that accepts any non-null value\n */\nexport function any<T = any>(): Type<T> {\n return new Type('any', {\n _check: (v: any) => v != null,\n })\n}\n\n// Aliases for number types\nexport const float = number\nexport const double = number\nexport const real = number\n\n// =============================================================================\n// Object Types\n// =============================================================================\n\n/**\n * Utility type to make object properties optional if their value type includes undefined.\n * @category Schema\n */\nexport type TypeObjectFixOptional<T> = {\n [K in keyof T as undefined extends T[K] ? K : never]?: T[K] & {}\n} & {\n [K in keyof T as undefined extends T[K] ? never : K]: T[K] & {}\n}\n\n/**\n * Utility type for pretty-printing object types\n */\ntype TypeObjectPretty<V> = Extract<{ [K in keyof V]: V[K] }, unknown>\n\n/**\n * Main object type utility\n */\ntype TypeObject<T> = TypeObjectPretty<TypeObjectFixOptional<{\n [K in keyof T]: Infer<T[K]>\n}>>\n\n/**\n * Creates an object type validator with specified properties\n */\nexport function object<T>(tobj: T): Type<TypeObject<T>> {\n return new Type('object', {\n _check: isObject,\n _object: tobj,\n })\n}\n\n/**\n * Creates a record type validator (object with string keys and uniform value type)\n */\nexport function record<T extends Type>(valueType: T): Type<Record<string, Infer<T>>> {\n return new Type('record', {\n _check: isObject,\n _type: valueType,\n })\n}\n\n// =============================================================================\n// Union Types\n// =============================================================================\n\n/**\n * Utility type for union of types.\n * @category Schema\n */\nexport type TypeUnion<T extends Type<any>[]> = {\n [K in keyof T]: T[K] extends Type<infer U> ? U : never\n}[number]\n\n/**\n * Creates a union type validator (like `string | number | boolean`)\n */\nexport function union<T extends Type<any>[]>(options: T): Type<TypeUnion<T>> {\n return new Type('union', {\n _check: (v: any) => options.some(option => option._check?.(v) ?? false),\n _union: options,\n })\n}\n\n// =============================================================================\n// Literal Types\n// =============================================================================\n\n/**\n * Utility type for literal types.\n * @category Schema\n */\nexport type TypeLiterals = string | number | bigint | boolean\n\n/**\n * Creates a literal value validator\n */\nexport function literal<T extends TypeLiterals>(value: T): Type<T> {\n return new Type('literal', {\n _check: (v: any) => v === value,\n _default: value,\n })\n}\n\n/**\n * Creates a string literal union validator (like `\"a\" | \"b\" | \"c\"`)\n */\nexport function stringLiterals<const T extends readonly string[]>(values: T): Type<T[number]> {\n return new Type('string', {\n _check: (v: any) => typeof v === 'string' && (values as readonly string[]).includes(v),\n _enumValues: values,\n })\n}\n\n// =============================================================================\n// Collection Types\n// =============================================================================\n\n/**\n * Utility type for tuple types.\n * @category Schema\n */\nexport type TypeTuple<T extends readonly Type[]> = {\n -readonly [K in keyof T]: T[K] extends Type<infer U> ? U : never\n}\n\n/**\n * Output type for TypeArray.\n * @category Schema\n */\nexport type TypeArrayOutput<Head extends Type[], Rest extends Type | undefined> = [\n ...TypeTuple<Head>,\n ...(Rest extends Type ? Infer<Rest>[] : []),\n]\n\n/**\n * Utility type for array types.\n * @category Schema\n */\nexport type TypeArray<Head extends Type[] = Type[], Rest extends Type | undefined = Type | undefined> = Type<TypeArrayOutput<Head, Rest>>\n\n/**\n * Creates a tuple type validator with fixed length and types e.g. [string, number, boolean]\n */\nexport function tuple<const T extends readonly Type[]>(items: T): Type<TypeTuple<T>> {\n return new Type('tuple', {\n _check: (v: any) => Array.isArray(v) && v.length === items.length && items.every((item, i) => (item as Type)._check?.(v[i]) ?? false),\n _type: items,\n })\n}\n\n/**\n * Creates an array type validator for a specific item type\n */\nexport function array<T>(itemType: Type<T>): Type<T[]> {\n return new Type('array', {\n _check: isArray,\n _type: itemType,\n })\n}\n\n// =============================================================================\n// Function Types\n// =============================================================================\n\n/**\n * Creates a regular function type validator\n */\nexport function func<\n TypeFuncArgs extends [Type<unknown>, ...Type<any>[]] | [],\n TypeFuncRet = Type,\n T = (...args: TypeTuple<TypeFuncArgs>) => Infer<TypeFuncRet>,\n>(args: TypeFuncArgs, ret: TypeFuncRet): Type<T> {\n return new Type('function', {\n _check: isFunction,\n _args: args,\n _ret: ret,\n })\n}\n\n/**\n * Creates an RPC function type validator that takes one argument and returns a promise\n */\nexport function rpc<\n TypeRpcInfo extends Type<unknown> | undefined = undefined,\n TypeRpcRet extends Type<unknown> = Type<void>,\n T = TypeRpcInfo extends undefined\n ? () => Infer<TypeRpcRet>\n : (info: Infer<TypeRpcInfo>) => Infer<TypeRpcRet> | Promise<Infer<TypeRpcRet>>,\n>(info?: TypeRpcInfo, ret?: TypeRpcRet): Type<T> {\n return new Type('rpc', {\n _check: isFunction,\n _info: info,\n _ret: ret ?? none(),\n })\n}\n"],"mappings":"0HAgBO,IAAMA,EAAN,MAAMC,CAAkB,CAhB/B,MAgB+B,CAAAC,EAAA,aACpB,KAET,SACA,UACA,MACA,OACA,QACA,MACA,OACA,YACA,MACA,KACA,MAIA,YAAYC,EAAcC,EAA4B,CAAC,EAAG,CACxD,KAAK,KAAOD,EACZ,OAAO,OAAO,KAAMC,CAAO,CAC7B,CAMA,GAAI,aAAmB,CACrB,MAAO,CACL,QAAS,EACT,OAAQ,OACR,SAAUF,EAACG,GACF,KAAK,SAASA,CAAK,EADlB,YAGV,MAAO,CACL,MAAO,OACP,OAAQ,MACV,CACF,CACF,CAKA,SAASA,EAAiB,CAIxB,GAAIA,GAAS,KACX,OAAI,KAAK,UACA,CAAE,MAAO,MAAsB,EAEpC,KAAK,WAAa,OAEb,CAAE,MADYC,EAAW,KAAK,QAAQ,EAAI,KAAK,SAAS,IAAI,EAAI,KAAK,QAC/C,EAExB,CACL,OAAQ,CAAC,CACP,QAAS,4BACT,KAAM,CAAC,CACT,CAAC,CACH,EAIF,GAAI,KAAK,OAAS,WAAa,KAAK,WAAaD,EAC/C,MAAO,CACL,OAAQ,CAAC,CACP,QAAS,0BAA0B,KAAK,QAAQ,SAASA,CAAK,GAC9D,KAAM,CAAC,CACT,CAAC,CACH,EAIF,GAAI,KAAK,aAAe,MAAM,QAAQ,KAAK,WAAW,GAChD,CAAC,KAAK,YAAY,SAASA,CAAK,EAClC,MAAO,CACL,OAAQ,CAAC,CACP,QAAS,oBAAoB,KAAK,YAAY,KAAK,IAAI,CAAC,UAAUA,CAAK,GACvE,KAAM,CAAC,CACT,CAAC,CACH,EAKJ,GAAI,KAAK,QAAU,MAAM,QAAQ,KAAK,MAAM,EAAG,CAC7C,QAAWE,KAAU,KAAK,OAAQ,CAChC,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AAK,EAA9D,UACR,OAAQlD,CACV,CAAC,CACH,CALgBF,EAAA2D,EAAA,SAoBT,SAASC,EAAgCzD,EAAmB,CACjE,OAAO,IAAIL,EAAK,UAAW,CACzB,OAAQE,EAACoD,GAAWA,IAAMjD,EAAlB,UACR,SAAUA,CACZ,CAAC,CACH,CALgBH,EAAA4D,EAAA,WAUT,SAASC,EAAkDC,EAA4B,CAC5F,OAAO,IAAIhE,EAAK,SAAU,CACxB,OAAQE,EAACoD,GAAW,OAAOA,GAAM,UAAaU,EAA6B,SAASV,CAAC,EAA7E,UACR,YAAaU,CACf,CAAC,CACH,CALgB9D,EAAA6D,EAAA,kBAqCT,SAASE,EAAuCxD,EAA8B,CACnF,OAAO,IAAIT,EAAK,QAAS,CACvB,OAAQE,EAACoD,GAAW,MAAM,QAAQA,CAAC,GAAKA,EAAE,SAAW7C,EAAM,QAAUA,EAAM,MAAM,CAACyD,EAAMvD,IAAOuD,EAAc,SAASZ,EAAE3C,CAAC,CAAC,GAAK,EAAK,EAA5H,UACR,MAAOF,CACT,CAAC,CACH,CALgBP,EAAA+D,EAAA,SAUT,SAASE,EAASrD,EAA8B,CACrD,OAAO,IAAId,EAAK,QAAS,CACvB,OAAQoE,EACR,MAAOtD,CACT,CAAC,CACH,CALgBZ,EAAAiE,EAAA,SAcT,SAASE,EAIdC,EAAoBC,EAA2B,CAC/C,OAAO,IAAIvE,EAAK,WAAY,CAC1B,OAAQM,EACR,MAAOgE,EACP,KAAMC,CACR,CAAC,CACH,CAVgBrE,EAAAmE,EAAA,QAeT,SAASG,EAMdC,EAAoBF,EAA2B,CAC/C,OAAO,IAAIvE,EAAK,MAAO,CACrB,OAAQM,EACR,MAAOmE,EACP,KAAMF,GAAOlB,EAAK,CACpB,CAAC,CACH,CAZgBnD,EAAAsE,EAAA","names":["Type","_Type","__name","name","options","value","isFunction","option","result","items","issues","i","itemResult","issue","itemType","isObject","obj","key","propSchema","propValue","propResult","valueType","newProps","cloned","propertiesToCopy","prop","source","target","properties","meta","msg","newObj","object","keys","pickedObj","omittedObj","transform","transformedObj","originalObj","typeInstance","shouldTransform","type","originalType","optional","newType","string","isString","number","isNumber","int","isInteger","boolean","isBoolean","none","v","any","float","double","real","tobj","record","union","literal","stringLiterals","values","tuple","item","array","isArray","func","args","ret","rpc","info"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";//# sourceMappingURL=chunk-MIEXPALS.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/zeed/zeed/dist/chunk-MIEXPALS.cjs"],"names":[],"mappings":"AAAA","file":"/home/runner/work/zeed/zeed/dist/chunk-MIEXPALS.cjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-MQNZQKBT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";//# sourceMappingURL=chunk-NPQ77LO4.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/zeed/zeed/dist/chunk-NPQ77LO4.cjs"],"names":[],"mappings":"AAAA","file":"/home/runner/work/zeed/zeed/dist/chunk-NPQ77LO4.cjs"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJJKWFF7Bcjs = require('./chunk-JJKWFF7B.cjs');var _chunkL5XYQBG4cjs = require('./chunk-L5XYQBG4.cjs');var _chunk4TLMJAZBcjs = require('./chunk-4TLMJAZB.cjs');var _chunkP7XCQ7WVcjs = require('./chunk-P7XCQ7WV.cjs');var x="Unexpected end of array",c="Integer out of Range",p= exports.a =class{static{_chunkP7XCQ7WVcjs.a.call(void 0, this,"BinDecoder")}constructor(n){this.arr=n,this.pos=0}};function I(r){return new p(r)}_chunkP7XCQ7WVcjs.a.call(void 0, I,"createDecoder");function C(r){return r.pos!==r.arr.length}_chunkP7XCQ7WVcjs.a.call(void 0, C,"hasContent");function O(r,n=r.pos){let t=I(r.arr);return t.pos=n,t}_chunkP7XCQ7WVcjs.a.call(void 0, O,"clone");function b(r,n){let t=_chunk4TLMJAZBcjs.a.call(void 0, r.arr.buffer,r.pos+r.arr.byteOffset,n);return r.pos+=n,t}_chunkP7XCQ7WVcjs.a.call(void 0, b,"readUint8Array");function a(r){let n=0,t=1,e=r.arr.length;for(;r.pos<e;){let i=r.arr[r.pos++];if(n=n+(i&127)*t,t*=128,i<128)return n;if(n>Number.MAX_SAFE_INTEGER)throw new Error(c)}throw new Error(x)}_chunkP7XCQ7WVcjs.a.call(void 0, a,"readVarUint");function y(r){return b(r,a(r))}_chunkP7XCQ7WVcjs.a.call(void 0, y,"readVarUint8Array");function R(r){return b(r,r.arr.length-r.pos)}_chunkP7XCQ7WVcjs.a.call(void 0, R,"readTailAsUint8Array");function N(r){return r.pos++}_chunkP7XCQ7WVcjs.a.call(void 0, N,"skip8");function f(r){return r.arr[r.pos++]}_chunkP7XCQ7WVcjs.a.call(void 0, f,"readUint8");function P(r){let n=r.arr[r.pos]+(r.arr[r.pos+1]<<8);return r.pos+=2,n}_chunkP7XCQ7WVcjs.a.call(void 0, P,"readUint16");function L(r){let n=r.arr[r.pos]+(r.arr[r.pos+1]<<8)+(r.arr[r.pos+2]<<16)+(r.arr[r.pos+3]<<24)>>>0;return r.pos+=4,n}_chunkP7XCQ7WVcjs.a.call(void 0, L,"readUint32");function v(r){let n=r.arr[r.pos+3]+(r.arr[r.pos+2]<<8)+(r.arr[r.pos+1]<<16)+(r.arr[r.pos]<<24)>>>0;return r.pos+=4,n}_chunkP7XCQ7WVcjs.a.call(void 0, v,"readUint32BigEndian");function G(r){return r.arr[r.pos]}_chunkP7XCQ7WVcjs.a.call(void 0, G,"peekUint8");function M(r){return r.arr[r.pos]+(r.arr[r.pos+1]<<8)}_chunkP7XCQ7WVcjs.a.call(void 0, M,"peekUint16");function X(r){return r.arr[r.pos]+(r.arr[r.pos+1]<<8)+(r.arr[r.pos+2]<<16)+(r.arr[r.pos+3]<<24)>>>0}_chunkP7XCQ7WVcjs.a.call(void 0, X,"peekUint32");function U(r){let n=r.arr[r.pos++],t=n&63,e=64,i=(n&64)>0?-1:1;if((n&128)===0)return i*t;let A=r.arr.length;for(;r.pos<A;){if(n=r.arr[r.pos++],t=t+(n&127)*e,e*=128,n<128)return i*t;if(t>Number.MAX_SAFE_INTEGER)throw new Error(c)}throw new Error(x)}_chunkP7XCQ7WVcjs.a.call(void 0, U,"readVarInt");function j(r){let n=r.pos,t=a(r);return r.pos=n,t}_chunkP7XCQ7WVcjs.a.call(void 0, j,"peekVarUint");function q(r){let n=r.pos,t=U(r);return r.pos=n,t}_chunkP7XCQ7WVcjs.a.call(void 0, q,"peekVarInt");function E(r){let n=a(r);if(n===0)return"";{let t=String.fromCodePoint(f(r));if(--n<100)for(;n--;)t+=String.fromCodePoint(f(r));else for(;n>0;){let e=n<1e4?n:1e4,i=r.arr.subarray(r.pos,r.pos+e);r.pos+=e,t+=String.fromCodePoint.apply(null,i),n-=e}return decodeURIComponent(escape(t))}}_chunkP7XCQ7WVcjs.a.call(void 0, E,"_readVarStringPolyfill");function l(r){let n=_chunkJJKWFF7Bcjs.g.call(void 0, );return n?n.decode(y(r)):E(r)}_chunkP7XCQ7WVcjs.a.call(void 0, l,"readVarString");function z(r){let n=r.pos,t=l(r);return r.pos=n,t}_chunkP7XCQ7WVcjs.a.call(void 0, z,"peekVarString");function s(r,n){let t=new DataView(r.arr.buffer,r.arr.byteOffset+r.pos,n);return r.pos+=n,t}_chunkP7XCQ7WVcjs.a.call(void 0, s,"readFromDataView");function V(r){return s(r,4).getFloat32(0,!1)}_chunkP7XCQ7WVcjs.a.call(void 0, V,"readFloat32");function S(r){return s(r,8).getFloat64(0,!1)}_chunkP7XCQ7WVcjs.a.call(void 0, S,"readFloat64");function T(r){return s(r,8).getBigInt64(0,!1)}_chunkP7XCQ7WVcjs.a.call(void 0, T,"readBigInt64");function H(r){return s(r,8).getBigUint64(0,!1)}_chunkP7XCQ7WVcjs.a.call(void 0, H,"readBigUint64");var _=[r=>{},r=>null,U,V,S,T,r=>!1,r=>!0,l,r=>{let n=a(r),t={};for(let e=0;e<n;e++){let i=l(r);t[i]=g(r)}return t},r=>{let n=a(r),t=[];for(let e=0;e<n;e++)t.push(g(r));return t},y];function g(r){return _[127-f(r)](r)}_chunkP7XCQ7WVcjs.a.call(void 0, g,"readAny");exports.a = p; exports.b = I; exports.c = C; exports.d = O; exports.e = b; exports.f = a; exports.g = y; exports.h = R; exports.i = N; exports.j = f; exports.k = P; exports.l = L; exports.m = v; exports.n = G; exports.o = M; exports.p = X; exports.q = U; exports.r = j; exports.s = q; exports.t = l; exports.u = z; exports.v = s; exports.w = V; exports.x = S; exports.y = T; exports.z = H; exports.A = g;
|
|
2
|
+
//# sourceMappingURL=chunk-NVLJOTGF.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/zeed/zeed/dist/chunk-IQQCKTKP.cjs","../src/common/bin/lib0/decoding.ts"],"names":["errorUnexpectedEndOfArray","errorIntegerOutOfRange","BinDecoder","__name","uint8Array","createDecoder","hasContent","decoder","clone","newPos","_decoder","readUint8Array","len","view","createUint8ArrayViewFromArrayBuffer","readVarUint","num","mult","r","readVarUint8Array","readTailAsUint8Array","skip8","readUint8","readUint16","uint","readUint32","readUint32BigEndian","peekUint8","peekUint16","peekUint32","readVarInt","sign","peekVarUint","pos","s","peekVarInt","_readVarStringPolyfill","remainingLen","encodedString","nextLen","bytes","readVarString","utf8TextDecoder","getUtf8TextDecoder","peekVarString","readFromDataView","dv","readFloat32","readFloat64","readBigInt64","readBigUint64","readAnyLookupTable","_","obj","i","key","readAny","arr"],"mappings":"AAAA,iIAA6D,wDA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zeed/zeed/dist/chunk-IQQCKTKP.cjs","sourcesContent":[null,"/**\n * Original at https://github.com/dmonad/lib0\n *\n * Efficient schema-less binary decoding with support for variable length encoding.\n *\n * Use [lib0/decoding] with [lib0/encoding]. Every encoding function has a corresponding decoding function.\n *\n * Encodes numbers in little-endian order (least to most significant byte order)\n * and is compatible with Golang's binary encoding (https://golang.org/pkg/encoding/binary/)\n * which is also used in Protocol Buffers.\n *\n * ```js\n * // encoding step\n * const encoder = new encoding.createEncoder()\n * encoding.writeVarUint(encoder, 256)\n * encoding.writeVarString(encoder, 'Hello world!')\n * const buf = encoding.toUint8Array(encoder)\n * ```\n *\n * ```js\n * // decoding step\n * const decoder = new decoding.createDecoder(buf)\n * decoding.readVarUint(decoder) // => 256\n * decoding.readVarString(decoder) // => 'Hello world!'\n * decoding.hasContent(decoder) // => false - all data is read\n * ```\n */\n\nimport { BIT7, BIT8, BITS6, BITS7 } from './binary'\nimport { createUint8ArrayViewFromArrayBuffer } from './create'\nimport { getUtf8TextDecoder } from './string'\n\nconst errorUnexpectedEndOfArray = 'Unexpected end of array'\nconst errorIntegerOutOfRange = 'Integer out of Range'\n\n/**\n * A BinDecoder handles the decoding of an Uint8Array.\n */\nexport class BinDecoder {\n /** Decoding target. */\n arr: Uint8Array\n /** Current decoding position. */\n pos: number\n\n constructor(uint8Array: Uint8Array) {\n this.arr = uint8Array\n this.pos = 0\n }\n}\n\nexport function createDecoder(uint8Array: Uint8Array): BinDecoder {\n return new BinDecoder(uint8Array)\n}\n\nexport function hasContent(decoder: BinDecoder): boolean {\n return decoder.pos !== decoder.arr.length\n}\n\n/**\n * Clone a decoder instance.\n * Optionally set a new position parameter.\n */\nexport function clone(decoder: BinDecoder, newPos: number = decoder.pos): BinDecoder {\n const _decoder = createDecoder(decoder.arr)\n _decoder.pos = newPos\n return _decoder\n}\n\n/**\n * Create an Uint8Array view of the next `len` bytes and advance the position by `len`.\n *\n * Important: The Uint8Array still points to the underlying ArrayBuffer. Make sure to discard the result as soon as possible to prevent any memory leaks.\n * Use `buffer.copyUint8Array` to copy the result into a new Uint8Array.\n */\nexport function readUint8Array(decoder: BinDecoder, len: number): Uint8Array {\n const view = createUint8ArrayViewFromArrayBuffer(decoder.arr.buffer, decoder.pos + decoder.arr.byteOffset, len)\n decoder.pos += len\n return view\n}\n\n/**\n * Read unsigned integer (32bit) with variable length.\n * 1/8th of the storage is used as encoding overhead.\n * numbers < 2^7 is stored in one bytlength\n * numbers < 2^14 is stored in two bylength\n */\nexport function readVarUint(decoder: BinDecoder): number {\n let num = 0\n let mult = 1\n const len = decoder.arr.length\n while (decoder.pos < len) {\n const r = decoder.arr[decoder.pos++]\n // num = num | ((r & binary.BITS7) << len)\n num = num + (r & BITS7) * mult // shift $r << (7*#iterations) and add it to num\n mult *= 128 // next iteration, shift 7 \"more\" to the left\n if (r < BIT8)\n return num\n if (num > Number.MAX_SAFE_INTEGER)\n throw new Error(errorIntegerOutOfRange)\n }\n throw new Error(errorUnexpectedEndOfArray)\n}\n\n/**\n * Read variable length Uint8Array.\n *\n * Important: The Uint8Array still points to the underlying ArrayBuffer. Make sure to discard the result as soon as possible to prevent any memory leaks.\n * Use `buffer.copyUint8Array` to copy the result into a new Uint8Array.\n */\nexport function readVarUint8Array(decoder: BinDecoder): Uint8Array {\n return readUint8Array(decoder, readVarUint(decoder))\n}\n\n/**\n * Read the rest of the content as an ArrayBuffer\n */\nexport function readTailAsUint8Array(decoder: BinDecoder): Uint8Array {\n return readUint8Array(decoder, decoder.arr.length - decoder.pos)\n}\n\n/**\n * Skip one byte, jump to the next position.\n */\nexport function skip8(decoder: BinDecoder): number {\n return decoder.pos++\n}\n\n/**\n * Read one byte as unsigned integer.\n */\nexport function readUint8(decoder: BinDecoder): number {\n return decoder.arr[decoder.pos++]\n}\n\n/**\n * Read 2 bytes as unsigned integer.\n */\nexport function readUint16(decoder: BinDecoder): number {\n const uint = decoder.arr[decoder.pos]\n + (decoder.arr[decoder.pos + 1] << 8)\n decoder.pos += 2\n return uint\n}\n\n/**\n * Read 4 bytes as unsigned integer.\n */\nexport function readUint32(decoder: BinDecoder): number {\n const uint = (decoder.arr[decoder.pos]\n + (decoder.arr[decoder.pos + 1] << 8)\n + (decoder.arr[decoder.pos + 2] << 16)\n + (decoder.arr[decoder.pos + 3] << 24)) >>> 0\n decoder.pos += 4\n return uint\n}\n\n/**\n * Read 4 bytes as unsigned integer in big endian order.\n * (most significant byte first)\n */\nexport function readUint32BigEndian(decoder: BinDecoder): number {\n const uint = (decoder.arr[decoder.pos + 3]\n + (decoder.arr[decoder.pos + 2] << 8)\n + (decoder.arr[decoder.pos + 1] << 16)\n + (decoder.arr[decoder.pos] << 24)) >>> 0\n decoder.pos += 4\n return uint\n}\n\n/**\n * Look ahead without incrementing the position\n * to the next byte and read it as unsigned integer.\n */\nexport function peekUint8(decoder: BinDecoder): number {\n return decoder.arr[decoder.pos]\n}\n\n/**\n * Look ahead without incrementing the position\n * to the next byte and read it as unsigned integer.\n */\nexport function peekUint16(decoder: BinDecoder): number {\n return decoder.arr[decoder.pos]\n + (decoder.arr[decoder.pos + 1] << 8)\n}\n\n/**\n * Look ahead without incrementing the position\n * to the next byte and read it as unsigned integer.\n */\nexport function peekUint32(decoder: BinDecoder): number {\n return (\n decoder.arr[decoder.pos]\n + (decoder.arr[decoder.pos + 1] << 8)\n + (decoder.arr[decoder.pos + 2] << 16)\n + (decoder.arr[decoder.pos + 3] << 24)\n ) >>> 0\n}\n\n/**\n * Read signed integer (32bit) with variable length.\n * 1/8th of the storage is used as encoding overhead.\n * numbers < 2^7 is stored in one bytlength\n * numbers < 2^14 is stored in two bylength\n * @todo This should probably create the inverse ~num if number is negative - but this would be a breaking change.\n */\nexport function readVarInt(decoder: BinDecoder): number {\n let r = decoder.arr[decoder.pos++]\n let num = r & BITS6\n let mult = 64\n const sign = (r & BIT7) > 0 ? -1 : 1 // use Math.sign(?) for performance?\n if ((r & BIT8) === 0) {\n // don't continue reading\n return sign * num\n }\n const len = decoder.arr.length\n while (decoder.pos < len) {\n r = decoder.arr[decoder.pos++]\n // num = num | ((r & binary.BITS7) << len)\n num = num + (r & BITS7) * mult\n mult *= 128\n if (r < BIT8)\n return sign * num\n\n if (num > Number.MAX_SAFE_INTEGER)\n throw new Error(errorIntegerOutOfRange)\n }\n throw new Error(errorUnexpectedEndOfArray)\n}\n\n/**\n * Look ahead and read varUint without incrementing position\n */\nexport function peekVarUint(decoder: BinDecoder): number {\n const pos = decoder.pos\n const s = readVarUint(decoder)\n decoder.pos = pos\n return s\n}\n\n/**\n * Look ahead and read varUint without incrementing position\n */\nexport function peekVarInt(decoder: BinDecoder): number {\n const pos = decoder.pos\n const s = readVarInt(decoder)\n decoder.pos = pos\n return s\n}\n\n/**\n * We don't test this function anymore as we use native decoding/encoding by default now.\n * Better not modify this anymore..\n *\n * Transforming utf8 to a string is pretty expensive. The code performs 10x better\n * when String.fromCodePoint is fed with all characters as arguments.\n * But most environments have a maximum number of arguments per functions.\n * For effiency reasons we apply a maximum of 10000 characters at once.\n */\nfunction _readVarStringPolyfill(decoder: BinDecoder): string {\n let remainingLen = readVarUint(decoder)\n if (remainingLen === 0) {\n return ''\n }\n else {\n let encodedString = String.fromCodePoint(readUint8(decoder)) // remember to decrease remainingLen\n if (--remainingLen < 100) { // do not create a Uint8Array for small strings\n while (remainingLen--)\n encodedString += String.fromCodePoint(readUint8(decoder))\n }\n else {\n while (remainingLen > 0) {\n const nextLen = remainingLen < 10000 ? remainingLen : 10000\n // this is dangerous, we create a fresh array view from the existing buffer\n const bytes = decoder.arr.subarray(decoder.pos, decoder.pos + nextLen)\n decoder.pos += nextLen\n // Starting with ES5.1 we can supply a generic array-like object as arguments\n encodedString += String.fromCodePoint.apply(null, (bytes as any))\n remainingLen -= nextLen\n }\n }\n return decodeURIComponent(escape(encodedString))\n }\n}\n\n/**\n * Read string of variable length\n * varUint is used to store the length of the string\n */\nexport function readVarString(decoder: BinDecoder): string {\n const utf8TextDecoder = getUtf8TextDecoder()\n return utf8TextDecoder\n ? utf8TextDecoder.decode(readVarUint8Array(decoder))\n : _readVarStringPolyfill(decoder)\n}\n\n/**\n * Look ahead and read varString without incrementing position\n */\nexport function peekVarString(decoder: BinDecoder): string {\n const pos = decoder.pos\n const s = readVarString(decoder)\n decoder.pos = pos\n return s\n}\n\nexport function readFromDataView(decoder: BinDecoder, len: number): DataView {\n const dv = new DataView(decoder.arr.buffer, decoder.arr.byteOffset + decoder.pos, len)\n decoder.pos += len\n return dv\n}\n\nexport function readFloat32(decoder: BinDecoder) {\n return readFromDataView(decoder, 4).getFloat32(0, false)\n}\n\nexport function readFloat64(decoder: BinDecoder) {\n return readFromDataView(decoder, 8).getFloat64(0, false)\n}\n\nexport function readBigInt64(decoder: BinDecoder) {\n return (readFromDataView(decoder, 8)).getBigInt64(0, false)\n}\n\nexport function readBigUint64(decoder: BinDecoder) {\n return (readFromDataView(decoder, 8)).getBigUint64(0, false)\n}\n\nconst readAnyLookupTable: Array<((arg0: BinDecoder) => any)> = [\n _ => undefined, // CASE 127: undefined\n _ => null, // CASE 126: null\n readVarInt, // CASE 125: integer\n readFloat32, // CASE 124: float32\n readFloat64, // CASE 123: float64\n readBigInt64, // CASE 122: bigint\n _ => false, // CASE 121: boolean (false)\n _ => true, // CASE 120: boolean (true)\n readVarString, // CASE 119: string\n (decoder) => { // CASE 118: object<string,any>\n const len = readVarUint(decoder)\n const obj: { [s: string]: any } = {}\n for (let i = 0; i < len; i++) {\n const key = readVarString(decoder)\n obj[key] = readAny(decoder)\n }\n return obj\n },\n (decoder) => { // CASE 117: array<any>\n const len = readVarUint(decoder)\n const arr = []\n for (let i = 0; i < len; i++)\n\n arr.push(readAny(decoder))\n\n return arr\n },\n readVarUint8Array, // CASE 116: Uint8Array\n]\n\nexport function readAny(decoder: BinDecoder) {\n return readAnyLookupTable[127 - readUint8(decoder)](decoder)\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/zeed/zeed/dist/chunk-NVLJOTGF.cjs","../src/common/bin/lib0/decoding.ts"],"names":["errorUnexpectedEndOfArray","errorIntegerOutOfRange","BinDecoder","__name","uint8Array","createDecoder","hasContent","decoder","clone","newPos","_decoder","readUint8Array","len","view","createUint8ArrayViewFromArrayBuffer","readVarUint","num","mult","r","readVarUint8Array","readTailAsUint8Array","skip8","readUint8","readUint16","uint","readUint32","readUint32BigEndian","peekUint8","peekUint16","peekUint32","readVarInt","sign","peekVarUint","pos","s","peekVarInt","_readVarStringPolyfill","remainingLen","encodedString","nextLen","bytes","readVarString","utf8TextDecoder","getUtf8TextDecoder","peekVarString","readFromDataView","dv","readFloat32","readFloat64","readBigInt64","readBigUint64","readAnyLookupTable","_","obj","i","key","readAny","arr"],"mappings":"AAAA,iIAAwC,wDAA8D,wDAAyC,wDAAyC,ICgClLA,CAAAA,CAA4B,yBAAA,CAC5BC,CAAAA,CAAyB,sBAAA,CAKlBC,CAAAA,aAAN,KAAiB,CAtCxB,MAsCwB,CAAAC,iCAAAA,IAAA,CAAA,YAAA,CAAA,CAEtB,WAIA,CAAYC,CAAAA,CAAwB,CAClC,IAAA,CAAK,GAAA,CAAMA,CAAAA,CACX,IAAA,CAAK,GAAA,CAAM,CACb,CACF,CAAA,CAEO,SAASC,CAAAA,CAAcD,CAAAA,CAAoC,CAChE,OAAO,IAAIF,CAAAA,CAAWE,CAAU,CAClC,CAFgBD,iCAAAA,CAAAE,CAAA,eAAA,CAAA,CAIT,SAASC,CAAAA,CAAWC,CAAAA,CAA8B,CACvD,OAAOA,CAAAA,CAAQ,GAAA,GAAQA,CAAAA,CAAQ,GAAA,CAAI,MACrC,CAFgBJ,iCAAAA,CAAAG,CAAA,YAAA,CAAA,CAQT,SAASE,CAAAA,CAAMD,CAAAA,CAAqBE,CAAAA,CAAiBF,CAAAA,CAAQ,GAAA,CAAiB,CACnF,IAAMG,CAAAA,CAAWL,CAAAA,CAAcE,CAAAA,CAAQ,GAAG,CAAA,CAC1C,OAAAG,CAAAA,CAAS,GAAA,CAAMD,CAAAA,CACR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,CACzBkD,CAAAA,CAAM,CAAC,CAAA,CACb,GAAA,CAAA,IAASH,CAAAA,CAAI,CAAA,CAAGA,CAAAA,CAAI1C,CAAAA,CAAK0C,CAAAA,EAAAA,CAEvBG,CAAAA,CAAI,IAAA,CAAKD,CAAAA,CAAQjD,CAAO,CAAC,CAAA,CAE3B,OAAOkD,CACT,CAAA,CACAtC,CACF,CAAA,CAEO,SAASqC,CAAAA,CAAQjD,CAAAA,CAAqB,CAC3C,OAAO4C,CAAAA,CAAmB,GAAA,CAAM7B,CAAAA,CAAUf,CAAO,CAAC,CAAA,CAAEA,CAAO,CAC7D,CAFgBJ,iCAAAA,CAAAqD,CAAA,SAAA,CAAA,CAAA,oZAAA","file":"/home/runner/work/zeed/zeed/dist/chunk-NVLJOTGF.cjs","sourcesContent":[null,"/**\n * Original at https://github.com/dmonad/lib0\n *\n * Efficient schema-less binary decoding with support for variable length encoding.\n *\n * Use [lib0/decoding] with [lib0/encoding]. Every encoding function has a corresponding decoding function.\n *\n * Encodes numbers in little-endian order (least to most significant byte order)\n * and is compatible with Golang's binary encoding (https://golang.org/pkg/encoding/binary/)\n * which is also used in Protocol Buffers.\n *\n * ```js\n * // encoding step\n * const encoder = new encoding.createEncoder()\n * encoding.writeVarUint(encoder, 256)\n * encoding.writeVarString(encoder, 'Hello world!')\n * const buf = encoding.toUint8Array(encoder)\n * ```\n *\n * ```js\n * // decoding step\n * const decoder = new decoding.createDecoder(buf)\n * decoding.readVarUint(decoder) // => 256\n * decoding.readVarString(decoder) // => 'Hello world!'\n * decoding.hasContent(decoder) // => false - all data is read\n * ```\n */\n\nimport { BIT7, BIT8, BITS6, BITS7 } from './binary'\nimport { createUint8ArrayViewFromArrayBuffer } from './create'\nimport { getUtf8TextDecoder } from './string'\n\nconst errorUnexpectedEndOfArray = 'Unexpected end of array'\nconst errorIntegerOutOfRange = 'Integer out of Range'\n\n/**\n * A BinDecoder handles the decoding of an Uint8Array.\n */\nexport class BinDecoder {\n /** Decoding target. */\n arr: Uint8Array\n /** Current decoding position. */\n pos: number\n\n constructor(uint8Array: Uint8Array) {\n this.arr = uint8Array\n this.pos = 0\n }\n}\n\nexport function createDecoder(uint8Array: Uint8Array): BinDecoder {\n return new BinDecoder(uint8Array)\n}\n\nexport function hasContent(decoder: BinDecoder): boolean {\n return decoder.pos !== decoder.arr.length\n}\n\n/**\n * Clone a decoder instance.\n * Optionally set a new position parameter.\n */\nexport function clone(decoder: BinDecoder, newPos: number = decoder.pos): BinDecoder {\n const _decoder = createDecoder(decoder.arr)\n _decoder.pos = newPos\n return _decoder\n}\n\n/**\n * Create an Uint8Array view of the next `len` bytes and advance the position by `len`.\n *\n * Important: The Uint8Array still points to the underlying ArrayBuffer. Make sure to discard the result as soon as possible to prevent any memory leaks.\n * Use `buffer.copyUint8Array` to copy the result into a new Uint8Array.\n */\nexport function readUint8Array(decoder: BinDecoder, len: number): Uint8Array {\n const view = createUint8ArrayViewFromArrayBuffer(decoder.arr.buffer, decoder.pos + decoder.arr.byteOffset, len)\n decoder.pos += len\n return view\n}\n\n/**\n * Read unsigned integer (32bit) with variable length.\n * 1/8th of the storage is used as encoding overhead.\n * numbers < 2^7 is stored in one bytlength\n * numbers < 2^14 is stored in two bylength\n */\nexport function readVarUint(decoder: BinDecoder): number {\n let num = 0\n let mult = 1\n const len = decoder.arr.length\n while (decoder.pos < len) {\n const r = decoder.arr[decoder.pos++]\n // num = num | ((r & binary.BITS7) << len)\n num = num + (r & BITS7) * mult // shift $r << (7*#iterations) and add it to num\n mult *= 128 // next iteration, shift 7 \"more\" to the left\n if (r < BIT8)\n return num\n if (num > Number.MAX_SAFE_INTEGER)\n throw new Error(errorIntegerOutOfRange)\n }\n throw new Error(errorUnexpectedEndOfArray)\n}\n\n/**\n * Read variable length Uint8Array.\n *\n * Important: The Uint8Array still points to the underlying ArrayBuffer. Make sure to discard the result as soon as possible to prevent any memory leaks.\n * Use `buffer.copyUint8Array` to copy the result into a new Uint8Array.\n */\nexport function readVarUint8Array(decoder: BinDecoder): Uint8Array {\n return readUint8Array(decoder, readVarUint(decoder))\n}\n\n/**\n * Read the rest of the content as an ArrayBuffer\n */\nexport function readTailAsUint8Array(decoder: BinDecoder): Uint8Array {\n return readUint8Array(decoder, decoder.arr.length - decoder.pos)\n}\n\n/**\n * Skip one byte, jump to the next position.\n */\nexport function skip8(decoder: BinDecoder): number {\n return decoder.pos++\n}\n\n/**\n * Read one byte as unsigned integer.\n */\nexport function readUint8(decoder: BinDecoder): number {\n return decoder.arr[decoder.pos++]\n}\n\n/**\n * Read 2 bytes as unsigned integer.\n */\nexport function readUint16(decoder: BinDecoder): number {\n const uint = decoder.arr[decoder.pos]\n + (decoder.arr[decoder.pos + 1] << 8)\n decoder.pos += 2\n return uint\n}\n\n/**\n * Read 4 bytes as unsigned integer.\n */\nexport function readUint32(decoder: BinDecoder): number {\n const uint = (decoder.arr[decoder.pos]\n + (decoder.arr[decoder.pos + 1] << 8)\n + (decoder.arr[decoder.pos + 2] << 16)\n + (decoder.arr[decoder.pos + 3] << 24)) >>> 0\n decoder.pos += 4\n return uint\n}\n\n/**\n * Read 4 bytes as unsigned integer in big endian order.\n * (most significant byte first)\n */\nexport function readUint32BigEndian(decoder: BinDecoder): number {\n const uint = (decoder.arr[decoder.pos + 3]\n + (decoder.arr[decoder.pos + 2] << 8)\n + (decoder.arr[decoder.pos + 1] << 16)\n + (decoder.arr[decoder.pos] << 24)) >>> 0\n decoder.pos += 4\n return uint\n}\n\n/**\n * Look ahead without incrementing the position\n * to the next byte and read it as unsigned integer.\n */\nexport function peekUint8(decoder: BinDecoder): number {\n return decoder.arr[decoder.pos]\n}\n\n/**\n * Look ahead without incrementing the position\n * to the next byte and read it as unsigned integer.\n */\nexport function peekUint16(decoder: BinDecoder): number {\n return decoder.arr[decoder.pos]\n + (decoder.arr[decoder.pos + 1] << 8)\n}\n\n/**\n * Look ahead without incrementing the position\n * to the next byte and read it as unsigned integer.\n */\nexport function peekUint32(decoder: BinDecoder): number {\n return (\n decoder.arr[decoder.pos]\n + (decoder.arr[decoder.pos + 1] << 8)\n + (decoder.arr[decoder.pos + 2] << 16)\n + (decoder.arr[decoder.pos + 3] << 24)\n ) >>> 0\n}\n\n/**\n * Read signed integer (32bit) with variable length.\n * 1/8th of the storage is used as encoding overhead.\n * numbers < 2^7 is stored in one bytlength\n * numbers < 2^14 is stored in two bylength\n * @todo This should probably create the inverse ~num if number is negative - but this would be a breaking change.\n */\nexport function readVarInt(decoder: BinDecoder): number {\n let r = decoder.arr[decoder.pos++]\n let num = r & BITS6\n let mult = 64\n const sign = (r & BIT7) > 0 ? -1 : 1 // use Math.sign(?) for performance?\n if ((r & BIT8) === 0) {\n // don't continue reading\n return sign * num\n }\n const len = decoder.arr.length\n while (decoder.pos < len) {\n r = decoder.arr[decoder.pos++]\n // num = num | ((r & binary.BITS7) << len)\n num = num + (r & BITS7) * mult\n mult *= 128\n if (r < BIT8)\n return sign * num\n\n if (num > Number.MAX_SAFE_INTEGER)\n throw new Error(errorIntegerOutOfRange)\n }\n throw new Error(errorUnexpectedEndOfArray)\n}\n\n/**\n * Look ahead and read varUint without incrementing position\n */\nexport function peekVarUint(decoder: BinDecoder): number {\n const pos = decoder.pos\n const s = readVarUint(decoder)\n decoder.pos = pos\n return s\n}\n\n/**\n * Look ahead and read varUint without incrementing position\n */\nexport function peekVarInt(decoder: BinDecoder): number {\n const pos = decoder.pos\n const s = readVarInt(decoder)\n decoder.pos = pos\n return s\n}\n\n/**\n * We don't test this function anymore as we use native decoding/encoding by default now.\n * Better not modify this anymore..\n *\n * Transforming utf8 to a string is pretty expensive. The code performs 10x better\n * when String.fromCodePoint is fed with all characters as arguments.\n * But most environments have a maximum number of arguments per functions.\n * For effiency reasons we apply a maximum of 10000 characters at once.\n */\nfunction _readVarStringPolyfill(decoder: BinDecoder): string {\n let remainingLen = readVarUint(decoder)\n if (remainingLen === 0) {\n return ''\n }\n else {\n let encodedString = String.fromCodePoint(readUint8(decoder)) // remember to decrease remainingLen\n if (--remainingLen < 100) { // do not create a Uint8Array for small strings\n while (remainingLen--)\n encodedString += String.fromCodePoint(readUint8(decoder))\n }\n else {\n while (remainingLen > 0) {\n const nextLen = remainingLen < 10000 ? remainingLen : 10000\n // this is dangerous, we create a fresh array view from the existing buffer\n const bytes = decoder.arr.subarray(decoder.pos, decoder.pos + nextLen)\n decoder.pos += nextLen\n // Starting with ES5.1 we can supply a generic array-like object as arguments\n encodedString += String.fromCodePoint.apply(null, (bytes as any))\n remainingLen -= nextLen\n }\n }\n return decodeURIComponent(escape(encodedString))\n }\n}\n\n/**\n * Read string of variable length\n * varUint is used to store the length of the string\n */\nexport function readVarString(decoder: BinDecoder): string {\n const utf8TextDecoder = getUtf8TextDecoder()\n return utf8TextDecoder\n ? utf8TextDecoder.decode(readVarUint8Array(decoder))\n : _readVarStringPolyfill(decoder)\n}\n\n/**\n * Look ahead and read varString without incrementing position\n */\nexport function peekVarString(decoder: BinDecoder): string {\n const pos = decoder.pos\n const s = readVarString(decoder)\n decoder.pos = pos\n return s\n}\n\nexport function readFromDataView(decoder: BinDecoder, len: number): DataView {\n const dv = new DataView(decoder.arr.buffer, decoder.arr.byteOffset + decoder.pos, len)\n decoder.pos += len\n return dv\n}\n\nexport function readFloat32(decoder: BinDecoder) {\n return readFromDataView(decoder, 4).getFloat32(0, false)\n}\n\nexport function readFloat64(decoder: BinDecoder) {\n return readFromDataView(decoder, 8).getFloat64(0, false)\n}\n\nexport function readBigInt64(decoder: BinDecoder) {\n return (readFromDataView(decoder, 8)).getBigInt64(0, false)\n}\n\nexport function readBigUint64(decoder: BinDecoder) {\n return (readFromDataView(decoder, 8)).getBigUint64(0, false)\n}\n\nconst readAnyLookupTable: Array<((arg0: BinDecoder) => any)> = [\n _ => undefined, // CASE 127: undefined\n _ => null, // CASE 126: null\n readVarInt, // CASE 125: integer\n readFloat32, // CASE 124: float32\n readFloat64, // CASE 123: float64\n readBigInt64, // CASE 122: bigint\n _ => false, // CASE 121: boolean (false)\n _ => true, // CASE 120: boolean (true)\n readVarString, // CASE 119: string\n (decoder) => { // CASE 118: object<string,any>\n const len = readVarUint(decoder)\n const obj: { [s: string]: any } = {}\n for (let i = 0; i < len; i++) {\n const key = readVarString(decoder)\n obj[key] = readAny(decoder)\n }\n return obj\n },\n (decoder) => { // CASE 117: array<any>\n const len = readVarUint(decoder)\n const arr = []\n for (let i = 0; i < len; i++)\n\n arr.push(readAny(decoder))\n\n return arr\n },\n readVarUint8Array, // CASE 116: Uint8Array\n]\n\nexport function readAny(decoder: BinDecoder) {\n return readAnyLookupTable[127 - readUint8(decoder)](decoder)\n}\n"]}
|