@jakubmazanec/template 2.0.18-next.65323720 → 2.0.19-next.1031336f

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 CHANGED
@@ -4,7 +4,6 @@
4
4
  # @jakubmazanec/template
5
5
 
6
6
  TypeScript-first library for working with templates using EJS and Zod.
7
-
8
7
  </div>
9
8
  <!-- header -->
10
9
 
@@ -22,7 +21,8 @@ It cannot be required from a CommonJS module.
22
21
  #### Prerequisites
23
22
 
24
23
  - Node.js 24 or later
25
- - TypeScript 5 or later
24
+ - TypeScript 6 or later
25
+
26
26
  <!-- prerequisites -->
27
27
 
28
28
  ## Usage
package/build/Template.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import ejs from "ejs";
3
2
  import fs from "fs-extra";
4
3
  import matter from "gray-matter";
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../source/Template.ts"],
4
4
  "sourcesContent": ["import ejs from 'ejs';\nimport fs from 'fs-extra';\nimport matter from 'gray-matter';\nimport _ from 'lodash';\nimport path from 'node:path';\nimport prettier from 'prettier';\nimport yaml from 'yaml';\nimport {type z, type ZodObject} from 'zod';\n\nimport {NO_INFERRED_PARSER_REGEXP} from './constants.js';\nimport {type TemplateAttributes, templateAttributesSchema} from './TemplateAttributes.js';\nimport {TemplateError} from './TemplateError.js';\nimport {type TemplateFunction} from './TemplateFunction.js';\nimport {type TemplateRender} from './TemplateRender.js';\nimport {type TemplateRenders} from './TemplateRenders.js';\n\nexport type TemplateOptions<\n A extends ZodObject | undefined = undefined,\n D extends ZodObject | undefined = undefined,\n> = {\n /** Template path. */\n path?: string;\n\n /** Template content. */\n content: string;\n\n /** Template attributes. */\n attributes: A extends undefined ? TemplateAttributes\n : TemplateAttributes & z.infer<NonNullable<A>>;\n\n /** Zod schema for custom template attributes. */\n attributesSchema?: A | undefined;\n\n /** Zod schema for template data. */\n dataSchema?: D | undefined;\n};\n\nexport type TemplateReadOptions<\n A extends ZodObject | undefined = undefined,\n D extends ZodObject | undefined = undefined,\n> = {\n /** Zod schema for custom template attributes. */\n attributesSchema?: A | undefined;\n\n /** Zod schema for template data. */\n dataSchema?: D | undefined;\n};\n\nexport type TemplateReadAndRenderOptions<\n A extends ZodObject | undefined = undefined,\n D extends ZodObject | undefined = undefined,\n> = {\n /** Prettier options. */\n prettierOptions?: prettier.Options | undefined;\n\n /** Disable formatting the rendered template using Prettier. */\n disablePrettier?: boolean | undefined;\n\n /** Zod schema for custom template attributes. */\n attributesSchema?: A | undefined;\n\n /** Zod schema for template data. */\n dataSchema?: D | undefined;\n};\n\nexport type TemplateRenderOptions = {\n /** Prettier options. */\n prettierOptions?: prettier.Options | undefined;\n\n /** Disable formatting the rendered template using Prettier. */\n disablePrettier?: boolean | undefined;\n};\n\n/**\n * The `Template` object stores all information about a template and has methods for reading and rendering.\n *\n * ```TypeScript\n * let template = new Template({\n * content: '<%- value %>',\n * attributes: {\n * to: 'value.txt',\n * },\n * dataSchema: z.object({value: z.number()}),\n * });\n *\n * console.log(await template.render({value: 42})); // -> [{attributes: {to: 'value.txt'}, data: {value: 42}, content: '42'}]\n * ```\n *\n * @typeParam A A Zod schema type used to define the custom template attributes type.\n * @typeParam D A Zod schema type used to define the template datatype.\n */\nexport class Template<\n A extends ZodObject | undefined = undefined,\n D extends ZodObject | undefined = undefined,\n> {\n /** Template path. */\n path?: string;\n\n /** Template content. Templates are written in [EJS](https://ejs.co/). */\n readonly content: string;\n\n /** Template attributes. These control how the template is rendered. Some attributes can be written in [EJS](https://ejs.co/) and are rendered before the template content is rendered. It is expected that attribute `if` renders to a string that can be parsed as YAML value; if that value is `false`, the rendering is cancelled. Attribute `to` is also rendered and it represents the path of file the resulting template render is supposed to be written into (by the user). Attribute `variables` is an object that is merged with the data object before rendering. If attribute `variables` is an array of objects, that leads to multiple renders, each with different variables object merged with the data. Each variable that is a string is also rendered. */\n readonly attributes: A extends undefined ? TemplateAttributes\n : TemplateAttributes & z.infer<NonNullable<A>>;\n\n /** Template function. */\n private readonly fn: TemplateFunction;\n\n /** Zod schema for custom template attributes. */\n readonly attributesSchema: A extends ZodObject ? A : null;\n\n /** Zod schema for template data. */\n readonly dataSchema: D extends ZodObject ? D : null;\n\n constructor({\n path: templatePath,\n content,\n attributes,\n attributesSchema,\n dataSchema,\n }: TemplateOptions<A, D>) {\n if (templatePath) {\n this.path = templatePath;\n }\n\n this.content = content;\n this.attributes = attributes;\n this.fn = ejs.compile(this.content);\n\n if (attributesSchema) {\n this.attributesSchema = attributesSchema as A extends ZodObject ? A : null;\n } else {\n this.attributesSchema = null as A extends ZodObject ? A : null;\n }\n\n if (dataSchema) {\n this.dataSchema = dataSchema as D extends ZodObject ? D : null;\n } else {\n this.dataSchema = null as D extends ZodObject ? D : null;\n }\n }\n\n /**\n * Reads a template from a file.\n *\n * @param templatePath Path to the template file.\n */\n static async read<\n A extends ZodObject | undefined = undefined,\n D extends ZodObject | undefined = undefined,\n >(templatePath: string, options?: TemplateReadOptions<A, D>): Promise<Template<A, D>> {\n let {data: rawAttributes, content} = matter(await fs.readFile(templatePath, 'utf8'));\n\n // extending another template\n if (typeof rawAttributes.extends === 'string' && rawAttributes.extends) {\n let extendedTemplate = await Template.read(\n path.join(path.dirname(templatePath), rawAttributes.extends),\n options,\n ); // you can point to any template, but it will be parsed with the same options, including attribute or data schema\n\n // attributes are recursively merged\n rawAttributes = _.merge(extendedTemplate.attributes, rawAttributes);\n\n // if content is empty, use content from the extended template\n if (!content.trim()) {\n content = extendedTemplate.content;\n }\n }\n\n let attributesSchema =\n options?.attributesSchema ?\n templateAttributesSchema.merge(options.attributesSchema)\n : templateAttributesSchema;\n let attributesParseResult = attributesSchema.safeParse(rawAttributes);\n\n if (!attributesParseResult.success) {\n throw new TemplateError('INVALID_ATTRIBUTES', {\n cause: attributesParseResult.error,\n data: {\n path: templatePath,\n zodIssues: attributesParseResult.error.issues,\n },\n });\n }\n\n let attributes = attributesParseResult.data;\n\n return new this({\n path: templatePath,\n attributes,\n content,\n attributesSchema: options?.attributesSchema,\n dataSchema: options?.dataSchema,\n } as TemplateOptions<A, D>);\n }\n\n /**\n * Reads a template from a file and then renders it.\n *\n * @param templatePath Path to the template file.\n * @param data Data used for rendering the template.\n * @param options Options object.\n * @return Template renders.\n */\n static async readAndRender<\n A extends ZodObject | undefined = undefined,\n D extends ZodObject | undefined = undefined,\n >(\n templatePath: string,\n data: D extends undefined ? null : z.infer<NonNullable<D>>,\n options?: TemplateReadAndRenderOptions<A, D>,\n ) {\n let template = await Template.read<A, D>(templatePath, {\n attributesSchema: options?.attributesSchema,\n dataSchema: options?.dataSchema,\n });\n\n return template.render(data, {\n prettierOptions: options?.prettierOptions,\n disablePrettier: options?.disablePrettier,\n });\n }\n\n /**\n * Renders the template using data.\n *\n * @param data Data used for rendering the template.\n * @param options Options object.\n * @return Template renders.\n */\n async render(\n data: D extends undefined ? null : z.infer<NonNullable<D>>,\n options?: TemplateRenderOptions,\n ): Promise<TemplateRenders<A, D>> {\n let renders: TemplateRenders<A, D> = [];\n\n for (let variables of Array.isArray(this.attributes.variables) ?\n this.attributes.variables\n : [this.attributes.variables]) {\n let renderedAttributes = _.omit(this.attributes, ['if']);\n let renderedVariables = variables;\n\n if (renderedVariables) {\n for (let [variableName, variableValue] of Object.entries(renderedVariables)) {\n if (typeof variableValue === 'string') {\n renderedVariables[variableName] = ejs.render(variableValue, {...data});\n } else {\n renderedVariables[variableName] = variableValue;\n }\n }\n\n renderedAttributes.variables = renderedVariables;\n }\n\n let dataWithAttributes = {...data, attributes: renderedAttributes};\n\n if (this.attributes.if) {\n let renderedIf = ejs.render(this.attributes.if, dataWithAttributes);\n let parsedIf = yaml.parse(renderedIf) as unknown;\n\n if (parsedIf === false) {\n continue;\n }\n }\n\n renderedAttributes.to = ejs.render(renderedAttributes.to, dataWithAttributes);\n dataWithAttributes.attributes = renderedAttributes;\n\n let content;\n\n try {\n content = this.fn(dataWithAttributes);\n } catch (error: unknown) {\n throw new TemplateError('FAILED_RENDER', {cause: error});\n }\n\n if (!options?.disablePrettier) {\n try {\n content = await prettier.format(content, {\n ...options?.prettierOptions,\n filepath: renderedAttributes.to,\n });\n } catch (error: unknown) {\n if (!NO_INFERRED_PARSER_REGEXP.test((error as Error).message)) {\n throw new TemplateError('FAILED_FORMAT', {cause: error});\n }\n }\n }\n\n renders.push({\n attributes: renderedAttributes,\n data: data ?? null,\n content,\n } as TemplateRender<A, D>);\n }\n\n return renders;\n }\n}\n"],
5
- "mappings": ";AAAA,OAAO,SAAS;AAChB,OAAO,QAAQ;AACf,OAAO,YAAY;AACnB,OAAO,OAAO;AACd,OAAO,UAAU;AACjB,OAAO,cAAc;AACrB,OAAO,UAAU;AAGjB,SAAQ,iCAAgC;AACxC,SAAiC,gCAA+B;AAChE,SAAQ,qBAAoB;AAgFrB,aAAM,SAGX;AAAA;AAAA,EAEA;AAAA;AAAA,EAGS;AAAA;AAAA,EAGA;AAAA;AAAA,EAIQ;AAAA;AAAA,EAGR;AAAA;AAAA,EAGA;AAAA,EAET,YAAY;AAAA,IACV,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAA0B;AACxB,QAAI,cAAc;AAChB,WAAK,OAAO;AAAA,IACd;AAEA,SAAK,UAAU;AACf,SAAK,aAAa;AAClB,SAAK,KAAK,IAAI,QAAQ,KAAK,OAAO;AAElC,QAAI,kBAAkB;AACpB,WAAK,mBAAmB;AAAA,IAC1B,OAAO;AACL,WAAK,mBAAmB;AAAA,IAC1B;AAEA,QAAI,YAAY;AACd,WAAK,aAAa;AAAA,IACpB,OAAO;AACL,WAAK,aAAa;AAAA,IACpB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,aAAa,KAGX,cAAsB,SAA8D;AACpF,QAAI,EAAC,MAAM,eAAe,QAAO,IAAI,OAAO,MAAM,GAAG,SAAS,cAAc,MAAM,CAAC;AAGnF,QAAI,OAAO,cAAc,YA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,OAAO,kBAAkB,UAAU;AACrC,8BAAkB,YAAY,IAAI,IAAI,OAAO,eAAe,EAAC,GAAG,KAAI,CAAC;AAAA,UACvE,OAAO;AACL,8BAAkB,YAAY,IAAI;AAAA,UACpC;AAAA,QACF;AAEA,2BAAmB,YAAY;AAAA,MACjC;AAEA,UAAI,qBAAqB,EAAC,GAAG,MAAM,YAAY,mBAAkB;AAEjE,UAAI,KAAK,WAAW,IAAI;AACtB,YAAI,aAAa,IAAI,OAAO,KAAK,WAAW,IAAI,kBAAkB;AAClE,YAAI,WAAW,KAAK,MAAM,UAAU;AAEpC,YAAI,aAAa,OAAO;AACtB;AAAA,QACF;AAAA,MACF;AAEA,yBAAmB,KAAK,IAAI,OAAO,mBAAmB,IAAI,kBAAkB;AAC5E,yBAAmB,aAAa;AAEhC,UAAI;AAEJ,UAAI;AACF,kBAAU,KAAK,GAAG,kBAAkB;AAAA,MACtC,SAAS,OAAgB;AACvB,cAAM,IAAI,cAAc,iBAAiB,EAAC,OAAO,MAAK,CAAC;AAAA,MACzD;AAEA,UAAI,CAAC,SAAS,iBAAiB;AAC7B,YAAI;AACF,oBAAU,MAAM,SAAS,OAAO,SAAS;AAAA,YACvC,GAAG,SAAS;AAAA,YACZ,UAAU,mBAAmB;AAAA,UAC/B,CAAC;AAAA,QACH,SAAS,OAAgB;AACvB,cAAI,CAAC,0BAA0B,KAAM,MAAgB,OAAO,GAAG;AAC7D,kBAAM,IAAI,cAAc,iBAAiB,EAAC,OAAO,MAAK,CAAC;AAAA,UACzD;AAAA,QACF;AAAA,MACF;AAEA,cAAQ,KAAK;AAAA,QACX,YAAY;AAAA,QACZ,MAAM,QAAQ;AAAA,QACd;AAAA,MACF,CAAyB;AAAA,IAC3B;AAEA,WAAO;AAAA,EACT;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import { z } from "zod";
3
2
  import { templateVariablesSchema } from "./TemplateVariables.js";
4
3
  export const templateAttributesSchema = z.object({
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../source/TemplateAttributes.ts"],
4
4
  "sourcesContent": ["import {z} from 'zod';\n\nimport {templateVariablesSchema} from './TemplateVariables.js';\n\n/**\n * Zod schema for {@link TemplateAttributes}.\n */\nexport const templateAttributesSchema = z\n .object({\n extends: z.string().optional(),\n to: z.string(),\n if: z.string().optional(),\n variables: templateVariablesSchema.optional(),\n })\n .strict();\n\n/**\n * Type representing template attributes.\n */\nexport type TemplateAttributes = z.infer<typeof templateAttributesSchema>;\n"],
5
- "mappings": ";AAAA,SAAQ,SAAQ;AAEhB,SAAQ,+BAA8B;AAK/B,aAAM,2BAA2B,EACrC,OAAO;AAAA,EACN,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,IAAI,EAAE,OAAO;AAAA,EACb,IAAI,EAAE,OAAO,EAAE,SAAS;AAAA,EACxB,WAAW,wBAAwB,SAAS;AAC9C,CAAC,EACA,OAAO;",
5
+ "mappings": "AAAA,SAAQ,SAAQ;AAEhB,SAAQ,+BAA8B;AAK/B,aAAM,2BAA2B,EACrC,OAAO;AAAA,EACN,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,IAAI,EAAE,OAAO;AAAA,EACb,IAAI,EAAE,OAAO,EAAE,SAAS;AAAA,EACxB,WAAW,wBAAwB,SAAS;AAC9C,CAAC,EACA,OAAO;",
6
6
  "names": []
7
7
  }
@@ -1,2 +1 @@
1
- "use strict";
2
1
  //# sourceMappingURL=TemplateContent.js.map
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import { createCustomErrorWithData } from "@jakubmazanec/error";
3
2
  export const TemplateError = createCustomErrorWithData(
4
3
  "TemplateError",
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../source/TemplateError.ts"],
4
4
  "sourcesContent": ["import {createCustomErrorWithData} from '@jakubmazanec/error';\nimport {type ZodIssue} from 'zod';\n\nimport {type Template} from './Template.js';\n\n/**\n * A subclass of `Error` that indicates a template failure.\n */\nexport const TemplateError = createCustomErrorWithData(\n 'TemplateError',\n {\n INVALID_ATTRIBUTES: 'Invalid template attributes.',\n FAILED_FORMAT: 'Template render formatting has failed.',\n FAILED_RENDER: 'Template rendering has failed.',\n },\n class TemplateErrorData {\n template?: Template;\n path?: string;\n zodIssues?: ZodIssue[];\n },\n);\n"],
5
- "mappings": ";AAAA,SAAQ,iCAAgC;AAQjC,aAAM,gBAAgB;AAAA,EAC3B;AAAA,EACA;AAAA,IACE,oBAAoB;AAAA,IACpB,eAAe;AAAA,IACf,eAAe;AAAA,EACjB;AAAA,EACA,MAAM,kBAAkB;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
5
+ "mappings": "AAAA,SAAQ,iCAAgC;AAQjC,aAAM,gBAAgB;AAAA,EAC3B;AAAA,EACA;AAAA,IACE,oBAAoB;AAAA,IACpB,eAAe;AAAA,IACf,eAAe;AAAA,EACjB;AAAA,EACA,MAAM,kBAAkB;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,2 +1 @@
1
- "use strict";
2
1
  //# sourceMappingURL=TemplateFunction.js.map
@@ -1,2 +1 @@
1
- "use strict";
2
1
  //# sourceMappingURL=TemplateRender.js.map
@@ -1,2 +1 @@
1
- "use strict";
2
1
  //# sourceMappingURL=TemplateRenders.js.map
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import * as z from "zod";
3
2
  export const templateVariablesSchema = z.union([
4
3
  z.record(z.string(), z.unknown()),
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../source/TemplateVariables.ts"],
4
4
  "sourcesContent": ["import * as z from 'zod';\n\n/**\n * Zod schema for {@link TemplateAttributesVariables}.\n */\nexport const templateVariablesSchema = z.union([\n z.record(z.string(), z.unknown()),\n z.array(z.record(z.string(), z.unknown())),\n]);\n\n/**\n * Type of `variables`` property of {@link TemplateAttributes}.\n */\nexport type TemplateAttributesVariables = z.infer<typeof templateVariablesSchema>;\n"],
5
- "mappings": ";AAAA,YAAY,OAAO;AAKZ,aAAM,0BAA0B,EAAE,MAAM;AAAA,EAC7C,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC;AAAA,EAChC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC;AAC3C,CAAC;",
5
+ "mappings": "AAAA,YAAY,OAAO;AAKZ,aAAM,0BAA0B,EAAE,MAAM;AAAA,EAC7C,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC;AAAA,EAChC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC;AAC3C,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1,3 +1,2 @@
1
- "use strict";
2
1
  export const NO_INFERRED_PARSER_REGEXP = /parser.*inferred/i;
3
2
  //# sourceMappingURL=constants.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../source/constants.ts"],
4
4
  "sourcesContent": ["export const NO_INFERRED_PARSER_REGEXP = /parser.*inferred/i;\n"],
5
- "mappings": ";AAAO,aAAM,4BAA4B;",
5
+ "mappings": "AAAO,aAAM,4BAA4B;",
6
6
  "names": []
7
7
  }
package/build/main.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  export * from "./Template.js";
3
2
  export * from "./TemplateAttributes.js";
4
3
  export * from "./TemplateError.js";
package/build/main.js.map CHANGED
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../source/main.ts"],
4
4
  "sourcesContent": ["export * from './Template.js';\nexport * from './TemplateAttributes.js';\nexport type * from './TemplateContent.js';\nexport * from './TemplateError.js';\nexport type * from './TemplateFunction.js';\nexport type * from './TemplateRender.js';\nexport type * from './TemplateRenders.js';\nexport * from './TemplateVariables.js';\n"],
5
- "mappings": ";AAAA,cAAc;AACd,cAAc;AAEd,cAAc;AAId,cAAc;",
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;AAEd,cAAc;AAId,cAAc;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jakubmazanec/template",
3
- "version": "2.0.18-next.65323720",
3
+ "version": "2.0.19-next.1031336f",
4
4
  "description": "TypeScript-first library for working with templates using EJS and Zod.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,31 +27,31 @@
27
27
  "typecheck": "tsc --project tsconfig.typecheck.json"
28
28
  },
29
29
  "dependencies": {
30
- "@jakubmazanec/error": "3.0.17-next.65323720",
31
- "ejs": "^3.1.10",
32
- "fs-extra": "^11.3.2",
30
+ "@jakubmazanec/error": "3.0.18-next.1031336f",
31
+ "ejs": "^6.0.1",
32
+ "fs-extra": "^11.3.6",
33
33
  "gray-matter": "^4.0.3",
34
- "lodash": "^4.17.21",
35
- "prettier": "^3.7.3",
36
- "yaml": "^2.8.2",
37
- "zod": "^4.1.13"
34
+ "lodash": "^4.18.1",
35
+ "prettier": "^3.9.5",
36
+ "yaml": "^2.9.0",
37
+ "zod": "^4.4.3"
38
38
  },
39
39
  "devDependencies": {
40
- "@jakubmazanec/eslint-config": "4.1.11-next.65323720",
40
+ "@jakubmazanec/eslint-config": "5.0.0-next.1031336f",
41
41
  "@types/ejs": "^3.1.5",
42
42
  "@types/fs-extra": "^11.0.4",
43
- "@types/lodash": "^4.17.21",
43
+ "@types/lodash": "^4.17.24",
44
44
  "@types/node": "^24.0.4",
45
- "@vitest/coverage-v8": "^4.0.14",
46
- "concurrently": "^9.2.1",
45
+ "@vitest/coverage-v8": "^4.1.10",
46
+ "concurrently": "^10.0.3",
47
47
  "del-cli": "^7.0.0",
48
- "esbuild": "^0.27.0",
49
- "eslint": "^9.33.0",
50
- "prettier-plugin-packagejson": "^2.5.20",
51
- "typedoc": "^0.28.15",
52
- "typedoc-plugin-markdown": "^4.9.0",
53
- "typescript": "^5.9.3",
54
- "vitest": "^4.0.14"
48
+ "esbuild": "^0.28.1",
49
+ "eslint": "^9.39.4",
50
+ "prettier-plugin-packagejson": "^2.5.22",
51
+ "typedoc": "^0.28.20",
52
+ "typedoc-plugin-markdown": "^4.12.0",
53
+ "typescript": "^6.0.0",
54
+ "vitest": "^4.1.10"
55
55
  },
56
56
  "packageManager": "npm@11.3.0",
57
57
  "engines": {