From e3aa7c9afd36ba7c8fc0cdb1c5a23bbaf99e0acd Mon Sep 17 00:00:00 2001 From: Rishabh Jain Date: Sun, 10 May 2026 17:07:43 +0530 Subject: [PATCH] fix(*): tighten generated transformer types (#668) Signed-off-by: Rishabh Jain --- .../lib/CiceroMarkTransformer.js | 87 +++-- packages/markdown-cicero/types/index.d.ts | 8 +- .../types/lib/CiceroMarkTransformer.d.ts | 189 +++++++--- .../types/lib/cicerorules.d.ts | 32 +- .../types/lib/fromciceromarkrules.d.ts | 4 +- .../lib/CommonMarkTransformer.js | 45 ++- packages/markdown-common/types/index.d.ts | 34 +- .../types/lib/CommonMarkTransformer.d.ts | 119 +++++- .../types/lib/ToMarkdownVisitor.d.ts | 8 +- .../types/lib/fromcommonmarkrules.d.ts | 3 +- .../types/lib/tocommonmarkrules.d.ts | 342 +++++++++--------- packages/markdown-html/src/HtmlTransformer.js | 22 +- packages/markdown-html/types/index.d.ts | 4 +- .../types/lib/HtmlTransformer.d.ts | 45 ++- .../types/lib/ToCiceroMarkVisitor.d.ts | 2 +- .../lib/TemplateMarkTransformer.js | 69 +++- .../src/TemplateMarkTransformer.js | 71 +++- packages/markdown-template/types/index.d.ts | 14 +- .../types/lib/FormulaVisitor.d.ts | 4 +- .../types/lib/TemplateMarkTransformer.d.ts | 150 ++++++-- .../types/lib/fromtemplatemarkrules.d.ts | 20 +- .../types/lib/templaterules.d.ts | 241 ++++++------ 22 files changed, 993 insertions(+), 520 deletions(-) diff --git a/packages/markdown-cicero/lib/CiceroMarkTransformer.js b/packages/markdown-cicero/lib/CiceroMarkTransformer.js index f813df1f..d260d97e 100644 --- a/packages/markdown-cicero/lib/CiceroMarkTransformer.js +++ b/packages/markdown-cicero/lib/CiceroMarkTransformer.js @@ -32,6 +32,40 @@ const {CommonMarkModel,CiceroMarkModel,ConcertoMetaModel} = require('@accordproj const unquoteVariables = require('./UnquoteVariables'); +/** + * @typedef {{ + * type: string, + * tag: string, + * nesting: number, + * attrs?: Array<[string, string]> | null, + * map?: [number, number] | null, + * level?: number, + * children?: MarkdownToken[] | null, + * content?: string, + * markup?: string, + * info?: string, + * meta?: unknown, + * block?: boolean, + * hidden?: boolean + * }} MarkdownToken + */ + +/** + * @typedef {MarkdownToken[]} MarkdownTokenStream + */ + +/** + * @typedef {{ $class: string, [key: string]: unknown }} CommonMarkJson + */ + +/** + * @typedef {{ $class: string, [key: string]: unknown }} CiceroMarkJson + */ + +/** + * @typedef {{ removeFormatting?: boolean, unquoteVariables?: boolean }} CiceroMarkTransformOptions + */ + /** * Converts a CiceroMark DOM to/from a * CommonMark DOM. @@ -57,8 +91,8 @@ class CiceroMarkTransformer { /** * Obtain the Clause text for a Clause node - * @param {*} input CiceroMark DOM - * @returns {*} markdown_cicero string + * @param {CiceroMarkJson} input CiceroMark DOM + * @returns {string} markdown_cicero string */ getClauseText(input) { if (input.$class === `${CiceroMarkModel.NAMESPACE}.Clause`) { @@ -73,10 +107,11 @@ class CiceroMarkTransformer { } } + // eslint-disable-next-line valid-jsdoc /** * Retrieve the serializer used by the parser * - * @returns {*} a serializer capable of dealing with the Concerto + * @returns {import('@accordproject/concerto-core').Serializer} a serializer capable of dealing with the Concerto * object returns by parse */ getSerializer() { @@ -85,8 +120,8 @@ class CiceroMarkTransformer { /** * Converts a CiceroEdit string to a CiceroMark DOM - * @param {*} input - ciceroedit string - * @returns {*} CiceroMark DOM + * @param {string} input - ciceroedit string + * @returns {CiceroMarkJson} CiceroMark DOM */ fromCiceroEdit(input) { const commonMark = this.commonMark.fromMarkdown(input); @@ -106,10 +141,10 @@ class CiceroMarkTransformer { /** * Converts a CiceroMark DOM to a CiceroMark Unwrapped DOM - * @param {object} input - CiceroMark DOM (JSON) - * @param {object} [options] configuration options + * @param {CiceroMarkJson} input - CiceroMark DOM (JSON) + * @param {CiceroMarkTransformOptions} [options] configuration options * @param {boolean} [options.unquoteVariables] if true variable quotations are removed - * @returns {*} CiceroMark DOM + * @returns {CiceroMarkJson} CiceroMark DOM */ toCiceroMarkUnwrapped(input,options) { // remove variables, e.g. {{ variable }}, {{% formula %}} @@ -130,8 +165,8 @@ class CiceroMarkTransformer { /** * Converts a CommonMark DOM to a CiceroMark DOM - * @param {*} input - CommonMark DOM (in JSON) - * @returns {*} CiceroMark DOM + * @param {CommonMarkJson} input - CommonMark DOM (in JSON) + * @returns {CiceroMarkJson} CiceroMark DOM */ fromCommonMark(input) { return input; // Now the identity @@ -140,7 +175,7 @@ class CiceroMarkTransformer { /** * Converts a markdown string to a CiceroMark DOM * @param {string} markdown a markdown string - * @returns {object} ciceromark object (JSON) + * @returns {CiceroMarkJson} ciceromark object (JSON) */ fromMarkdown(markdown) { const commonMarkDom = this.commonMark.fromMarkdown(markdown); @@ -149,9 +184,9 @@ class CiceroMarkTransformer { /** * Converts a CiceroMark DOM to a markdown string - * @param {*} input CiceroMark DOM - * @param {object} [options] configuration options - * @returns {*} markdown string + * @param {CiceroMarkJson} input CiceroMark DOM + * @param {CiceroMarkTransformOptions} [options] configuration options + * @returns {string} markdown string */ toMarkdown(input, options) { const commonMarkDom = this.toCommonMark(input, options); @@ -161,8 +196,8 @@ class CiceroMarkTransformer { /** * Converts a cicero markdown string to a CiceroMark DOM * @param {string} markdown a cicero markdown string - * @param {object} [options] configuration options - * @returns {object} ciceromark object (JSON) + * @param {CiceroMarkTransformOptions} [options] configuration options + * @returns {CiceroMarkJson} ciceromark object (JSON) */ fromMarkdownCicero(markdown, options) { const tokens = this.toTokens(markdown); @@ -171,7 +206,7 @@ class CiceroMarkTransformer { /** * Converts a CiceroMark DOM to a cicero markdown string - * @param {object} input CiceroMark DOM + * @param {CiceroMarkJson} input CiceroMark DOM * @returns {string} json commonmark object */ toMarkdownCicero(input) { @@ -181,11 +216,11 @@ class CiceroMarkTransformer { /** * Converts a CiceroMark DOM to a CommonMark DOM - * @param {*} input CiceroMark DOM - * @param {object} [options] configuration options + * @param {CiceroMarkJson} input CiceroMark DOM + * @param {CiceroMarkTransformOptions} [options] configuration options * @param {boolean} [options.removeFormatting] if true the formatting nodes are removed * @param {boolean} [options.unquoteVariables] if true variable quotations are removed - * @returns {*} json commonmark object + * @returns {CommonMarkJson} json commonmark object */ toCommonMark(input, options) { let json = this.toCiceroMarkUnwrapped(input,options); @@ -211,8 +246,8 @@ class CiceroMarkTransformer { /** * Unquotes a CiceroMark DOM - * @param {object} input CiceroMark DOM - * @returns {object} unquoted CiceroMark DOM + * @param {CiceroMarkJson} input CiceroMark DOM + * @returns {CiceroMarkJson} unquoted CiceroMark DOM */ unquote(input) { return unquoteVariables(input); @@ -222,7 +257,7 @@ class CiceroMarkTransformer { * Converts a ciceromark string into a token stream * * @param {string} input the string to parse - * @returns {*} a markdown-it token stream + * @returns {MarkdownTokenStream} a markdown-it token stream */ toTokens(input) { const parser = new MarkdownIt({html:true}).use(MarkdownItCicero); // XXX HTML inlines and code blocks true @@ -233,8 +268,8 @@ class CiceroMarkTransformer { /** * Converts a token stream into a CiceroMark DOM object. * - * @param {object} tokenStream the token stream - * @returns {*} the CiceroMark DOM (JSON) + * @param {MarkdownTokenStream} tokenStream the token stream + * @returns {CiceroMarkJson} the CiceroMark DOM (JSON) */ fromTokens(tokenStream) { const fromMarkdownIt = new FromMarkdownIt(cicerorules); @@ -246,4 +281,4 @@ class CiceroMarkTransformer { } } -module.exports = CiceroMarkTransformer; \ No newline at end of file +module.exports = CiceroMarkTransformer; diff --git a/packages/markdown-cicero/types/index.d.ts b/packages/markdown-cicero/types/index.d.ts index c9528b41..20190342 100644 --- a/packages/markdown-cicero/types/index.d.ts +++ b/packages/markdown-cicero/types/index.d.ts @@ -1,4 +1,4 @@ -export const CiceroMarkTransformer: typeof import("./lib/CiceroMarkTransformer"); -export const FromCiceroEditVisitor: typeof import("./lib/FromCiceroEditVisitor"); -export const ToCommonMarkVisitor: typeof import("./lib/ToCommonMarkVisitor"); -export const Decorators: typeof import("./lib/Decorators"); +export var CiceroMarkTransformer: typeof import("./lib/CiceroMarkTransformer"); +export var FromCiceroEditVisitor: typeof import("./lib/FromCiceroEditVisitor"); +export var ToCommonMarkVisitor: typeof import("./lib/ToCommonMarkVisitor"); +export var Decorators: typeof import("./lib/Decorators"); diff --git a/packages/markdown-cicero/types/lib/CiceroMarkTransformer.d.ts b/packages/markdown-cicero/types/lib/CiceroMarkTransformer.d.ts index ca9e5dc9..a4a47a28 100644 --- a/packages/markdown-cicero/types/lib/CiceroMarkTransformer.d.ts +++ b/packages/markdown-cicero/types/lib/CiceroMarkTransformer.d.ts @@ -1,4 +1,33 @@ export = CiceroMarkTransformer; +/** + * @typedef {{ + * type: string, + * tag: string, + * nesting: number, + * attrs?: Array<[string, string]> | null, + * map?: [number, number] | null, + * level?: number, + * children?: MarkdownToken[] | null, + * content?: string, + * markup?: string, + * info?: string, + * meta?: unknown, + * block?: boolean, + * hidden?: boolean + * }} MarkdownToken + */ +/** + * @typedef {MarkdownToken[]} MarkdownTokenStream + */ +/** + * @typedef {{ $class: string, [key: string]: unknown }} CommonMarkJson + */ +/** + * @typedef {{ $class: string, [key: string]: unknown }} CiceroMarkJson + */ +/** + * @typedef {{ removeFormatting?: boolean, unquoteVariables?: boolean }} CiceroMarkTransformOptions + */ /** * Converts a CiceroMark DOM to/from a * CommonMark DOM. @@ -7,101 +36,167 @@ export = CiceroMarkTransformer; */ declare class CiceroMarkTransformer { commonMark: import("@accordproject/markdown-common/types/lib/CommonMarkTransformer"); - modelManager: ModelManager; - serializer: Serializer; + modelManager: import("@accordproject/concerto-core/dist/modelmanager"); + serializer: import("@accordproject/concerto-core/dist/serializer"); /** * Obtain the Clause text for a Clause node - * @param {*} input CiceroMark DOM - * @returns {*} markdown_cicero string + * @param {CiceroMarkJson} input CiceroMark DOM + * @returns {string} markdown_cicero string */ - getClauseText(input: any): any; + getClauseText(input: CiceroMarkJson): string; /** * Retrieve the serializer used by the parser * - * @returns {*} a serializer capable of dealing with the Concerto + * @returns {import('@accordproject/concerto-core').Serializer} a serializer capable of dealing with the Concerto * object returns by parse */ - getSerializer(): any; + getSerializer(): import('@accordproject/concerto-core').Serializer; /** * Converts a CiceroEdit string to a CiceroMark DOM - * @param {*} input - ciceroedit string - * @returns {*} CiceroMark DOM + * @param {string} input - ciceroedit string + * @returns {CiceroMarkJson} CiceroMark DOM */ - fromCiceroEdit(input: any): any; + fromCiceroEdit(input: string): CiceroMarkJson; /** * Converts a CiceroMark DOM to a CiceroMark Unwrapped DOM - * @param {object} input - CiceroMark DOM (JSON) - * @param {object} [options] configuration options + * @param {CiceroMarkJson} input - CiceroMark DOM (JSON) + * @param {CiceroMarkTransformOptions} [options] configuration options * @param {boolean} [options.unquoteVariables] if true variable quotations are removed - * @returns {*} CiceroMark DOM + * @returns {CiceroMarkJson} CiceroMark DOM */ - toCiceroMarkUnwrapped(input: object, options?: { - unquoteVariables?: boolean; - }): any; + toCiceroMarkUnwrapped(input: CiceroMarkJson, options?: CiceroMarkTransformOptions): CiceroMarkJson; /** * Converts a CommonMark DOM to a CiceroMark DOM - * @param {*} input - CommonMark DOM (in JSON) - * @returns {*} CiceroMark DOM + * @param {CommonMarkJson} input - CommonMark DOM (in JSON) + * @returns {CiceroMarkJson} CiceroMark DOM */ - fromCommonMark(input: any): any; + fromCommonMark(input: CommonMarkJson): CiceroMarkJson; /** * Converts a markdown string to a CiceroMark DOM * @param {string} markdown a markdown string - * @returns {object} ciceromark object (JSON) + * @returns {CiceroMarkJson} ciceromark object (JSON) */ - fromMarkdown(markdown: string): object; + fromMarkdown(markdown: string): CiceroMarkJson; /** * Converts a CiceroMark DOM to a markdown string - * @param {*} input CiceroMark DOM - * @param {object} [options] configuration options - * @returns {*} markdown string + * @param {CiceroMarkJson} input CiceroMark DOM + * @param {CiceroMarkTransformOptions} [options] configuration options + * @returns {string} markdown string */ - toMarkdown(input: any, options?: object): any; + toMarkdown(input: CiceroMarkJson, options?: CiceroMarkTransformOptions): string; /** * Converts a cicero markdown string to a CiceroMark DOM * @param {string} markdown a cicero markdown string - * @param {object} [options] configuration options - * @returns {object} ciceromark object (JSON) + * @param {CiceroMarkTransformOptions} [options] configuration options + * @returns {CiceroMarkJson} ciceromark object (JSON) */ - fromMarkdownCicero(markdown: string, options?: object): object; + fromMarkdownCicero(markdown: string, options?: CiceroMarkTransformOptions): CiceroMarkJson; /** * Converts a CiceroMark DOM to a cicero markdown string - * @param {object} input CiceroMark DOM + * @param {CiceroMarkJson} input CiceroMark DOM * @returns {string} json commonmark object */ - toMarkdownCicero(input: object): string; + toMarkdownCicero(input: CiceroMarkJson): string; /** * Converts a CiceroMark DOM to a CommonMark DOM - * @param {*} input CiceroMark DOM - * @param {object} [options] configuration options + * @param {CiceroMarkJson} input CiceroMark DOM + * @param {CiceroMarkTransformOptions} [options] configuration options * @param {boolean} [options.removeFormatting] if true the formatting nodes are removed * @param {boolean} [options.unquoteVariables] if true variable quotations are removed - * @returns {*} json commonmark object + * @returns {CommonMarkJson} json commonmark object */ - toCommonMark(input: any, options?: { - removeFormatting?: boolean; - unquoteVariables?: boolean; - }): any; + toCommonMark(input: CiceroMarkJson, options?: CiceroMarkTransformOptions): CommonMarkJson; /** * Unquotes a CiceroMark DOM - * @param {object} input CiceroMark DOM - * @returns {object} unquoted CiceroMark DOM + * @param {CiceroMarkJson} input CiceroMark DOM + * @returns {CiceroMarkJson} unquoted CiceroMark DOM */ - unquote(input: object): object; + unquote(input: CiceroMarkJson): CiceroMarkJson; /** * Converts a ciceromark string into a token stream * * @param {string} input the string to parse - * @returns {*} a markdown-it token stream + * @returns {MarkdownTokenStream} a markdown-it token stream */ - toTokens(input: string): any; + toTokens(input: string): { + type: string; + tag: string; + nesting: number; + attrs?: Array<[string, string]> | null; + map?: [number, number] | null; + level?: number; + children?: MarkdownToken[] | null; + content?: string; + markup?: string; + info?: string; + meta?: unknown; + block?: boolean; + hidden?: boolean; + }[]; /** * Converts a token stream into a CiceroMark DOM object. * - * @param {object} tokenStream the token stream - * @returns {*} the CiceroMark DOM (JSON) + * @param {MarkdownTokenStream} tokenStream the token stream + * @returns {CiceroMarkJson} the CiceroMark DOM (JSON) */ - fromTokens(tokenStream: object): any; + fromTokens(tokenStream: { + type: string; + tag: string; + nesting: number; + attrs?: Array<[string, string]> | null; + map?: [number, number] | null; + level?: number; + children?: MarkdownToken[] | null; + content?: string; + markup?: string; + info?: string; + meta?: unknown; + block?: boolean; + hidden?: boolean; + }[]): CiceroMarkJson; +} +declare namespace CiceroMarkTransformer { + export { MarkdownToken, MarkdownTokenStream, CommonMarkJson, CiceroMarkJson, CiceroMarkTransformOptions }; } -import { ModelManager } from "@accordproject/concerto-core"; -import { Serializer } from "@accordproject/concerto-core"; +type CiceroMarkJson = { + [key: string]: unknown; + $class: string; +}; +type CiceroMarkTransformOptions = { + removeFormatting?: boolean; + unquoteVariables?: boolean; +}; +type CommonMarkJson = { + [key: string]: unknown; + $class: string; +}; +type MarkdownToken = { + type: string; + tag: string; + nesting: number; + attrs?: Array<[string, string]> | null; + map?: [number, number] | null; + level?: number; + children?: MarkdownToken[] | null; + content?: string; + markup?: string; + info?: string; + meta?: unknown; + block?: boolean; + hidden?: boolean; +}; +type MarkdownTokenStream = { + type: string; + tag: string; + nesting: number; + attrs?: Array<[string, string]> | null; + map?: [number, number] | null; + level?: number; + children?: MarkdownToken[] | null; + content?: string; + markup?: string; + info?: string; + meta?: unknown; + block?: boolean; + hidden?: boolean; +}[]; diff --git a/packages/markdown-cicero/types/lib/cicerorules.d.ts b/packages/markdown-cicero/types/lib/cicerorules.d.ts index d24072be..ce00b0cb 100644 --- a/packages/markdown-cicero/types/lib/cicerorules.d.ts +++ b/packages/markdown-cicero/types/lib/cicerorules.d.ts @@ -1,37 +1,37 @@ declare namespace formulaRule { - let tag: string; - let leaf: boolean; - let open: boolean; - let close: boolean; - function enter(node: any, token: any, callback: any): void; - let skipEmpty: boolean; + export const tag: string; + export const leaf: boolean; + export const open: boolean; + export const close: boolean; + export function enter(node: any, token: any, callback: any): void; + export const skipEmpty: boolean; } declare namespace clauseOpenRule { - let tag_1: string; + const tag_1: string; export { tag_1 as tag }; - let leaf_1: boolean; + const leaf_1: boolean; export { leaf_1 as leaf }; - let open_1: boolean; + const open_1: boolean; export { open_1 as open }; - let close_1: boolean; + const close_1: boolean; export { close_1 as close }; export function enter_1(node: any, token: any, callback: any): void; export { enter_1 as enter }; } declare namespace clauseCloseRule { - let tag_2: string; + const tag_2: string; export { tag_2 as tag }; - let leaf_2: boolean; + const leaf_2: boolean; export { leaf_2 as leaf }; - let open_2: boolean; + const open_2: boolean; export { open_2 as open }; - let close_2: boolean; + const close_2: boolean; export { close_2 as close }; } -export namespace inlines { +export declare namespace inlines { export { formulaRule as formula }; } -export namespace blocks { +export declare namespace blocks { export { clauseOpenRule as block_clause_open }; export { clauseCloseRule as block_clause_close }; } diff --git a/packages/markdown-cicero/types/lib/fromciceromarkrules.d.ts b/packages/markdown-cicero/types/lib/fromciceromarkrules.d.ts index d37e1105..7d811c9e 100644 --- a/packages/markdown-cicero/types/lib/fromciceromarkrules.d.ts +++ b/packages/markdown-cicero/types/lib/fromciceromarkrules.d.ts @@ -1,2 +1,2 @@ -export function Formula(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; -export function Clause(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export declare function Formula(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export declare function Clause(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; diff --git a/packages/markdown-common/lib/CommonMarkTransformer.js b/packages/markdown-common/lib/CommonMarkTransformer.js index 8ab305c2..b687a0cf 100644 --- a/packages/markdown-common/lib/CommonMarkTransformer.js +++ b/packages/markdown-common/lib/CommonMarkTransformer.js @@ -23,6 +23,32 @@ const ToMarkdownVisitor = require('./ToMarkdownVisitor'); const removeFormatting = require('./removeFormatting'); const CommonMarkModel = require('./externalModels/CommonMarkModel'); +/** + * @typedef {{ + * type: string, + * tag: string, + * nesting: number, + * attrs?: Array<[string, string]> | null, + * map?: [number, number] | null, + * level?: number, + * children?: MarkdownToken[] | null, + * content?: string, + * markup?: string, + * info?: string, + * meta?: unknown, + * block?: boolean, + * hidden?: boolean + * }} MarkdownToken + */ + +/** + * @typedef {MarkdownToken[]} MarkdownTokenStream + */ + +/** + * @typedef {{ $class: string, [key: string]: unknown }} CommonMarkJson + */ + /** * Parses markdown using the commonmark parser into the * intermediate representation: a JSON object that adheres to @@ -41,7 +67,7 @@ class CommonMarkTransformer { /** * Converts a CommonMark DOM to a markdown string - * @param {*} input - CommonMark DOM (in JSON) + * @param {CommonMarkJson} input - CommonMark DOM (in JSON) * @returns {string} the markdown string */ toMarkdown(input) { @@ -51,8 +77,8 @@ class CommonMarkTransformer { /** * Converts a CommonMark DOM to a CommonMark DOM with formatting removed - * @param {*} input - CommonMark DOM (in JSON) - * @returns {string} the CommonMark DOM with formatting nodes removed + * @param {CommonMarkJson} input - CommonMark DOM (in JSON) + * @returns {CommonMarkJson} the CommonMark DOM with formatting nodes removed */ removeFormatting(input) { return removeFormatting(input); @@ -62,7 +88,7 @@ class CommonMarkTransformer { * Converts a markdown string into a token stream * * @param {string} markdown the string to parse - * @returns {*} a markdown-it token stream + * @returns {MarkdownTokenStream} a markdown-it token stream */ toTokens(markdown) { const parser = new MarkdownIt({html:true}); // XXX HTML inlines and code blocks true @@ -73,8 +99,8 @@ class CommonMarkTransformer { /** * Converts a token stream into a CommonMark DOM object. * - * @param {object} tokenStream the token stream - * @returns {*} a Concerto object (DOM) for the markdown content + * @param {MarkdownTokenStream} tokenStream the token stream + * @returns {CommonMarkJson} a Concerto object (DOM) for the markdown content */ fromTokens(tokenStream) { const fromMarkdownIt = new FromMarkdownIt(); @@ -89,17 +115,18 @@ class CommonMarkTransformer { * Converts a markdown string into a CommonMark DOM object. * * @param {string} markdown the string to parse - * @returns {object} a CommonMark DOM (JSON) for the markdown content + * @returns {CommonMarkJson} a CommonMark DOM (JSON) for the markdown content */ fromMarkdown(markdown) { const tokenStream = this.toTokens(markdown); return this.fromTokens(tokenStream); } + // eslint-disable-next-line valid-jsdoc /** * Retrieve the serializer used by the parser * - * @returns {*} a serializer capable of dealing with the Concerto + * @returns {import('@accordproject/concerto-core').Serializer} a serializer capable of dealing with the Concerto */ getSerializer() { return this.serializer; @@ -107,4 +134,4 @@ class CommonMarkTransformer { } -module.exports = CommonMarkTransformer; \ No newline at end of file +module.exports = CommonMarkTransformer; diff --git a/packages/markdown-common/types/index.d.ts b/packages/markdown-common/types/index.d.ts index 6d14d56d..684b531f 100644 --- a/packages/markdown-common/types/index.d.ts +++ b/packages/markdown-common/types/index.d.ts @@ -1,13 +1,25 @@ -export const Stack: typeof import("./lib/Stack"); -export const CommonMarkModel: typeof import("./lib/externalModels/CommonMarkModel"); -export const CiceroMarkModel: typeof import("./lib/externalModels/CiceroMarkModel"); -export const ConcertoMetaModel: typeof import("./lib/externalModels/ConcertoMetaModel"); -export const TemplateMarkModel: typeof import("./lib/externalModels/TemplateMarkModel"); -export const CommonMarkUtils: typeof import("./lib/CommonMarkUtils"); -export const FromCommonMarkVisitor: typeof import("./lib/FromCommonMarkVisitor"); -export const fromcommonmarkrules: { +export var Stack: typeof import("./lib/Stack"); +export var CommonMarkModel: { + NAMESPACE: string; + MODEL: string; +}; +export var CiceroMarkModel: { + NAMESPACE: string; + MODEL: string; +}; +export var ConcertoMetaModel: { + NAMESPACE: string; + MODEL: string; +}; +export var TemplateMarkModel: { + NAMESPACE: string; + MODEL: string; +}; +export var CommonMarkUtils: typeof import("./lib/CommonMarkUtils"); +export var FromCommonMarkVisitor: typeof import("./lib/FromCommonMarkVisitor"); +export var fromcommonmarkrules: { [x: string]: Function; }; -export const CommonMarkTransformer: typeof import("./lib/CommonMarkTransformer"); -export const ToMarkdownVisitor: typeof import("./lib/ToMarkdownVisitor"); -export const FromMarkdownIt: typeof import("./lib/FromMarkdownIt"); +export var CommonMarkTransformer: typeof import("./lib/CommonMarkTransformer"); +export var ToMarkdownVisitor: typeof import("./lib/ToMarkdownVisitor"); +export var FromMarkdownIt: typeof import("./lib/FromMarkdownIt"); diff --git a/packages/markdown-common/types/lib/CommonMarkTransformer.d.ts b/packages/markdown-common/types/lib/CommonMarkTransformer.d.ts index 3788fca9..b4d9a514 100644 --- a/packages/markdown-common/types/lib/CommonMarkTransformer.d.ts +++ b/packages/markdown-common/types/lib/CommonMarkTransformer.d.ts @@ -1,49 +1,136 @@ export = CommonMarkTransformer; +/** + * @typedef {{ + * type: string, + * tag: string, + * nesting: number, + * attrs?: Array<[string, string]> | null, + * map?: [number, number] | null, + * level?: number, + * children?: MarkdownToken[] | null, + * content?: string, + * markup?: string, + * info?: string, + * meta?: unknown, + * block?: boolean, + * hidden?: boolean + * }} MarkdownToken + */ +/** + * @typedef {MarkdownToken[]} MarkdownTokenStream + */ +/** + * @typedef {{ $class: string, [key: string]: unknown }} CommonMarkJson + */ /** * Parses markdown using the commonmark parser into the * intermediate representation: a JSON object that adheres to * the 'org.accordproject.commonmark' Concerto model. */ declare class CommonMarkTransformer { - serializer: Serializer; + serializer: import("@accordproject/concerto-core/dist/serializer"); /** * Converts a CommonMark DOM to a markdown string - * @param {*} input - CommonMark DOM (in JSON) + * @param {CommonMarkJson} input - CommonMark DOM (in JSON) * @returns {string} the markdown string */ - toMarkdown(input: any): string; + toMarkdown(input: CommonMarkJson): string; /** * Converts a CommonMark DOM to a CommonMark DOM with formatting removed - * @param {*} input - CommonMark DOM (in JSON) - * @returns {string} the CommonMark DOM with formatting nodes removed + * @param {CommonMarkJson} input - CommonMark DOM (in JSON) + * @returns {CommonMarkJson} the CommonMark DOM with formatting nodes removed */ - removeFormatting(input: any): string; + removeFormatting(input: CommonMarkJson): CommonMarkJson; /** * Converts a markdown string into a token stream * * @param {string} markdown the string to parse - * @returns {*} a markdown-it token stream + * @returns {MarkdownTokenStream} a markdown-it token stream */ - toTokens(markdown: string): any; + toTokens(markdown: string): { + type: string; + tag: string; + nesting: number; + attrs?: Array<[string, string]> | null; + map?: [number, number] | null; + level?: number; + children?: MarkdownToken[] | null; + content?: string; + markup?: string; + info?: string; + meta?: unknown; + block?: boolean; + hidden?: boolean; + }[]; /** * Converts a token stream into a CommonMark DOM object. * - * @param {object} tokenStream the token stream - * @returns {*} a Concerto object (DOM) for the markdown content + * @param {MarkdownTokenStream} tokenStream the token stream + * @returns {CommonMarkJson} a Concerto object (DOM) for the markdown content */ - fromTokens(tokenStream: object): any; + fromTokens(tokenStream: { + type: string; + tag: string; + nesting: number; + attrs?: Array<[string, string]> | null; + map?: [number, number] | null; + level?: number; + children?: MarkdownToken[] | null; + content?: string; + markup?: string; + info?: string; + meta?: unknown; + block?: boolean; + hidden?: boolean; + }[]): CommonMarkJson; /** * Converts a markdown string into a CommonMark DOM object. * * @param {string} markdown the string to parse - * @returns {object} a CommonMark DOM (JSON) for the markdown content + * @returns {CommonMarkJson} a CommonMark DOM (JSON) for the markdown content */ - fromMarkdown(markdown: string): object; + fromMarkdown(markdown: string): CommonMarkJson; /** * Retrieve the serializer used by the parser * - * @returns {*} a serializer capable of dealing with the Concerto + * @returns {import('@accordproject/concerto-core').Serializer} a serializer capable of dealing with the Concerto */ - getSerializer(): any; + getSerializer(): import('@accordproject/concerto-core').Serializer; +} +declare namespace CommonMarkTransformer { + export { MarkdownToken, MarkdownTokenStream, CommonMarkJson }; } -import { Serializer } from "@accordproject/concerto-core"; +type CommonMarkJson = { + [key: string]: unknown; + $class: string; +}; +type MarkdownToken = { + type: string; + tag: string; + nesting: number; + attrs?: Array<[string, string]> | null; + map?: [number, number] | null; + level?: number; + children?: MarkdownToken[] | null; + content?: string; + markup?: string; + info?: string; + meta?: unknown; + block?: boolean; + hidden?: boolean; +}; +type MarkdownTokenStream = { + type: string; + tag: string; + nesting: number; + attrs?: Array<[string, string]> | null; + map?: [number, number] | null; + level?: number; + children?: MarkdownToken[] | null; + content?: string; + markup?: string; + info?: string; + meta?: unknown; + block?: boolean; + hidden?: boolean; +}[]; diff --git a/packages/markdown-common/types/lib/ToMarkdownVisitor.d.ts b/packages/markdown-common/types/lib/ToMarkdownVisitor.d.ts index e57beb3c..8da0781b 100644 --- a/packages/markdown-common/types/lib/ToMarkdownVisitor.d.ts +++ b/packages/markdown-common/types/lib/ToMarkdownVisitor.d.ts @@ -1,4 +1,5 @@ export = ToMarkdownVisitor; +declare const ToMarkdownVisitor_base: typeof import("./FromCommonMarkVisitor"); /** * Converts a CommonMark DOM to a markdown string. * @@ -9,11 +10,7 @@ export = ToMarkdownVisitor; * * The resulting AST *should* be equivalent however. */ -declare class ToMarkdownVisitor extends FromCommonMarkVisitor { - /** - * Construct the visitor. - */ - constructor(); +declare class ToMarkdownVisitor extends ToMarkdownVisitor_base { /** * Converts a CommonMark DOM to a markdown string * @param {*} input - CommonMark DOM (as a Concerto object) @@ -21,4 +18,3 @@ declare class ToMarkdownVisitor extends FromCommonMarkVisitor { */ toMarkdown(input: any): string; } -import FromCommonMarkVisitor = require("./FromCommonMarkVisitor"); diff --git a/packages/markdown-common/types/lib/fromcommonmarkrules.d.ts b/packages/markdown-common/types/lib/fromcommonmarkrules.d.ts index 01740527..86764986 100644 --- a/packages/markdown-common/types/lib/fromcommonmarkrules.d.ts +++ b/packages/markdown-common/types/lib/fromcommonmarkrules.d.ts @@ -1,5 +1,6 @@ export = rules; /** @type {Object} */ declare const rules: { - [x: string]: Function; + [x: string]: RuleFunction; }; +type RuleFunction = Function; diff --git a/packages/markdown-common/types/lib/tocommonmarkrules.d.ts b/packages/markdown-common/types/lib/tocommonmarkrules.d.ts index 3b567c72..445389c3 100644 --- a/packages/markdown-common/types/lib/tocommonmarkrules.d.ts +++ b/packages/markdown-common/types/lib/tocommonmarkrules.d.ts @@ -1,453 +1,453 @@ declare namespace textRule { - let tag: string; - let leaf: boolean; - let open: boolean; - let close: boolean; - function enter(node: any, token: any, callback: any): void; - let skipEmpty: boolean; + export const tag: string; + export const leaf: boolean; + export const open: boolean; + export const close: boolean; + export function enter(node: any, token: any, callback: any): void; + export const skipEmpty: boolean; } declare namespace codeInlineRule { - let tag_1: string; + const tag_1: string; export { tag_1 as tag }; - let leaf_1: boolean; + const leaf_1: boolean; export { leaf_1 as leaf }; - let open_1: boolean; + const open_1: boolean; export { open_1 as open }; - let close_1: boolean; + const close_1: boolean; export { close_1 as close }; export function enter_1(node: any, token: any, callback: any): void; export { enter_1 as enter }; - let skipEmpty_1: boolean; + const skipEmpty_1: boolean; export { skipEmpty_1 as skipEmpty }; } declare namespace softbreakRule { - let tag_2: string; + const tag_2: string; export { tag_2 as tag }; - let leaf_2: boolean; + const leaf_2: boolean; export { leaf_2 as leaf }; - let open_2: boolean; + const open_2: boolean; export { open_2 as open }; - let close_2: boolean; + const close_2: boolean; export { close_2 as close }; - let skipEmpty_2: boolean; + const skipEmpty_2: boolean; export { skipEmpty_2 as skipEmpty }; } declare namespace hardbreakRule { - let tag_3: string; + const tag_3: string; export { tag_3 as tag }; - let leaf_3: boolean; + const leaf_3: boolean; export { leaf_3 as leaf }; - let open_3: boolean; + const open_3: boolean; export { open_3 as open }; - let close_3: boolean; + const close_3: boolean; export { close_3 as close }; - let skipEmpty_3: boolean; + const skipEmpty_3: boolean; export { skipEmpty_3 as skipEmpty }; } declare namespace htmlInlineRule { - let tag_4: string; + const tag_4: string; export { tag_4 as tag }; - let leaf_4: boolean; + const leaf_4: boolean; export { leaf_4 as leaf }; - let open_4: boolean; + const open_4: boolean; export { open_4 as open }; - let close_4: boolean; + const close_4: boolean; export { close_4 as close }; export function enter_2(node: any, token: any, callback: any): void; export { enter_2 as enter }; - let skipEmpty_4: boolean; + const skipEmpty_4: boolean; export { skipEmpty_4 as skipEmpty }; } declare namespace strongOpenRule { - let tag_5: string; + const tag_5: string; export { tag_5 as tag }; - let leaf_5: boolean; + const leaf_5: boolean; export { leaf_5 as leaf }; - let open_5: boolean; + const open_5: boolean; export { open_5 as open }; - let close_5: boolean; + const close_5: boolean; export { close_5 as close }; - let skipEmpty_5: boolean; + const skipEmpty_5: boolean; export { skipEmpty_5 as skipEmpty }; } declare namespace strongCloseRule { - let tag_6: string; + const tag_6: string; export { tag_6 as tag }; - let leaf_6: boolean; + const leaf_6: boolean; export { leaf_6 as leaf }; - let open_6: boolean; + const open_6: boolean; export { open_6 as open }; - let close_6: boolean; + const close_6: boolean; export { close_6 as close }; - let skipEmpty_6: boolean; + const skipEmpty_6: boolean; export { skipEmpty_6 as skipEmpty }; } declare namespace emphOpenRule { - let tag_7: string; + const tag_7: string; export { tag_7 as tag }; - let leaf_7: boolean; + const leaf_7: boolean; export { leaf_7 as leaf }; - let open_7: boolean; + const open_7: boolean; export { open_7 as open }; - let close_7: boolean; + const close_7: boolean; export { close_7 as close }; - let skipEmpty_7: boolean; + const skipEmpty_7: boolean; export { skipEmpty_7 as skipEmpty }; } declare namespace emphCloseRule { - let tag_8: string; + const tag_8: string; export { tag_8 as tag }; - let leaf_8: boolean; + const leaf_8: boolean; export { leaf_8 as leaf }; - let open_8: boolean; + const open_8: boolean; export { open_8 as open }; - let close_8: boolean; + const close_8: boolean; export { close_8 as close }; - let skipEmpty_8: boolean; + const skipEmpty_8: boolean; export { skipEmpty_8 as skipEmpty }; } declare namespace linkOpenRule { - let tag_9: string; + const tag_9: string; export { tag_9 as tag }; - let leaf_9: boolean; + const leaf_9: boolean; export { leaf_9 as leaf }; - let open_9: boolean; + const open_9: boolean; export { open_9 as open }; - let close_9: boolean; + const close_9: boolean; export { close_9 as close }; export function enter_3(node: any, token: any, callback: any): void; export { enter_3 as enter }; - let skipEmpty_9: boolean; + const skipEmpty_9: boolean; export { skipEmpty_9 as skipEmpty }; } declare namespace linkCloseRule { - let tag_10: string; + const tag_10: string; export { tag_10 as tag }; - let leaf_10: boolean; + const leaf_10: boolean; export { leaf_10 as leaf }; - let open_10: boolean; + const open_10: boolean; export { open_10 as open }; - let close_10: boolean; + const close_10: boolean; export { close_10 as close }; - let skipEmpty_10: boolean; + const skipEmpty_10: boolean; export { skipEmpty_10 as skipEmpty }; } declare namespace imageRule { - let tag_11: string; + const tag_11: string; export { tag_11 as tag }; - let leaf_11: boolean; + const leaf_11: boolean; export { leaf_11 as leaf }; - let open_11: boolean; + const open_11: boolean; export { open_11 as open }; - let close_11: boolean; + const close_11: boolean; export { close_11 as close }; export function enter_4(node: any, token: any, callback: any): void; export { enter_4 as enter }; - let skipEmpty_11: boolean; + const skipEmpty_11: boolean; export { skipEmpty_11 as skipEmpty }; } declare namespace codeBlockRule { - let tag_12: string; + const tag_12: string; export { tag_12 as tag }; - let leaf_12: boolean; + const leaf_12: boolean; export { leaf_12 as leaf }; - let open_12: boolean; + const open_12: boolean; export { open_12 as open }; - let close_12: boolean; + const close_12: boolean; export { close_12 as close }; export function enter_5(node: any, token: any, callback: any): void; export { enter_5 as enter }; } declare namespace fenceRule { } declare namespace htmlBlockRule { - let tag_13: string; + const tag_13: string; export { tag_13 as tag }; - let leaf_13: boolean; + const leaf_13: boolean; export { leaf_13 as leaf }; - let open_13: boolean; + const open_13: boolean; export { open_13 as open }; - let close_13: boolean; + const close_13: boolean; export { close_13 as close }; export function enter_6(node: any, token: any, callback: any): void; export { enter_6 as enter }; } declare namespace hrRule { - let tag_14: string; + const tag_14: string; export { tag_14 as tag }; - let leaf_14: boolean; + const leaf_14: boolean; export { leaf_14 as leaf }; - let open_14: boolean; + const open_14: boolean; export { open_14 as open }; - let close_14: boolean; + const close_14: boolean; export { close_14 as close }; export function enter_7(node: any, token: any, callback: any): void; export { enter_7 as enter }; } declare namespace paragraphOpenRule { - let tag_15: string; + const tag_15: string; export { tag_15 as tag }; - let leaf_15: boolean; + const leaf_15: boolean; export { leaf_15 as leaf }; - let open_15: boolean; + const open_15: boolean; export { open_15 as open }; - let close_15: boolean; + const close_15: boolean; export { close_15 as close }; export function enter_8(node: any, token: any, callback: any): void; export { enter_8 as enter }; } declare namespace paragraphCloseRule { - let tag_16: string; + const tag_16: string; export { tag_16 as tag }; - let leaf_16: boolean; + const leaf_16: boolean; export { leaf_16 as leaf }; - let open_16: boolean; + const open_16: boolean; export { open_16 as open }; - let close_16: boolean; + const close_16: boolean; export { close_16 as close }; } declare namespace headingOpenRule { - let tag_17: string; + const tag_17: string; export { tag_17 as tag }; - let leaf_17: boolean; + const leaf_17: boolean; export { leaf_17 as leaf }; - let open_17: boolean; + const open_17: boolean; export { open_17 as open }; - let close_17: boolean; + const close_17: boolean; export { close_17 as close }; export function enter_9(node: any, token: any, callback: any): void; export { enter_9 as enter }; } declare namespace headingCloseRule { - let tag_18: string; + const tag_18: string; export { tag_18 as tag }; - let leaf_18: boolean; + const leaf_18: boolean; export { leaf_18 as leaf }; - let open_18: boolean; + const open_18: boolean; export { open_18 as open }; - let close_18: boolean; + const close_18: boolean; export { close_18 as close }; } declare namespace blockQuoteOpenRule { - let tag_19: string; + const tag_19: string; export { tag_19 as tag }; - let leaf_19: boolean; + const leaf_19: boolean; export { leaf_19 as leaf }; - let open_19: boolean; + const open_19: boolean; export { open_19 as open }; - let close_19: boolean; + const close_19: boolean; export { close_19 as close }; export function enter_10(node: any, token: any, callback: any): void; export { enter_10 as enter }; } declare namespace blockQuoteCloseRule { - let tag_20: string; + const tag_20: string; export { tag_20 as tag }; - let leaf_20: boolean; + const leaf_20: boolean; export { leaf_20 as leaf }; - let open_20: boolean; + const open_20: boolean; export { open_20 as open }; - let close_20: boolean; + const close_20: boolean; export { close_20 as close }; } declare namespace bulletListOpenRule { - let tag_21: string; + const tag_21: string; export { tag_21 as tag }; - let leaf_21: boolean; + const leaf_21: boolean; export { leaf_21 as leaf }; - let open_21: boolean; + const open_21: boolean; export { open_21 as open }; - let close_21: boolean; + const close_21: boolean; export { close_21 as close }; export function enter_11(node: any, token: any, callback: any): void; export { enter_11 as enter }; } declare namespace bulletListCloseRule { - let tag_22: string; + const tag_22: string; export { tag_22 as tag }; - let leaf_22: boolean; + const leaf_22: boolean; export { leaf_22 as leaf }; - let open_22: boolean; + const open_22: boolean; export { open_22 as open }; - let close_22: boolean; + const close_22: boolean; export { close_22 as close }; } declare namespace orderedListOpenRule { - let tag_23: string; + const tag_23: string; export { tag_23 as tag }; - let leaf_23: boolean; + const leaf_23: boolean; export { leaf_23 as leaf }; - let open_23: boolean; + const open_23: boolean; export { open_23 as open }; - let close_23: boolean; + const close_23: boolean; export { close_23 as close }; export function enter_12(node: any, token: any, callback: any): void; export { enter_12 as enter }; } declare namespace orderedListCloseRule { - let tag_24: string; + const tag_24: string; export { tag_24 as tag }; - let leaf_24: boolean; + const leaf_24: boolean; export { leaf_24 as leaf }; - let open_24: boolean; + const open_24: boolean; export { open_24 as open }; - let close_24: boolean; + const close_24: boolean; export { close_24 as close }; } declare namespace listItemOpenRule { - let tag_25: string; + const tag_25: string; export { tag_25 as tag }; - let leaf_25: boolean; + const leaf_25: boolean; export { leaf_25 as leaf }; - let open_25: boolean; + const open_25: boolean; export { open_25 as open }; - let close_25: boolean; + const close_25: boolean; export { close_25 as close }; export function enter_13(node: any, token: any, callback: any): void; export { enter_13 as enter }; } declare namespace listItemCloseRule { - let tag_26: string; + const tag_26: string; export { tag_26 as tag }; - let leaf_26: boolean; + const leaf_26: boolean; export { leaf_26 as leaf }; - let open_26: boolean; + const open_26: boolean; export { open_26 as open }; - let close_26: boolean; + const close_26: boolean; export { close_26 as close }; } declare namespace tableOpenRule { - let tag_27: string; + const tag_27: string; export { tag_27 as tag }; - let leaf_27: boolean; + const leaf_27: boolean; export { leaf_27 as leaf }; - let open_27: boolean; + const open_27: boolean; export { open_27 as open }; - let close_27: boolean; + const close_27: boolean; export { close_27 as close }; export function enter_14(node: any, token: any, callback: any): void; export { enter_14 as enter }; } declare namespace tableCloseRule { - let tag_28: string; + const tag_28: string; export { tag_28 as tag }; - let leaf_28: boolean; + const leaf_28: boolean; export { leaf_28 as leaf }; - let open_28: boolean; + const open_28: boolean; export { open_28 as open }; - let close_28: boolean; + const close_28: boolean; export { close_28 as close }; } declare namespace tableHeadOpenRule { - let tag_29: string; + const tag_29: string; export { tag_29 as tag }; - let leaf_29: boolean; + const leaf_29: boolean; export { leaf_29 as leaf }; - let open_29: boolean; + const open_29: boolean; export { open_29 as open }; - let close_29: boolean; + const close_29: boolean; export { close_29 as close }; export function enter_15(node: any, token: any, callback: any): void; export { enter_15 as enter }; } declare namespace tableHeadCloseRule { - let tag_30: string; + const tag_30: string; export { tag_30 as tag }; - let leaf_30: boolean; + const leaf_30: boolean; export { leaf_30 as leaf }; - let open_30: boolean; + const open_30: boolean; export { open_30 as open }; - let close_30: boolean; + const close_30: boolean; export { close_30 as close }; } declare namespace tableBodyOpenRule { - let tag_31: string; + const tag_31: string; export { tag_31 as tag }; - let leaf_31: boolean; + const leaf_31: boolean; export { leaf_31 as leaf }; - let open_31: boolean; + const open_31: boolean; export { open_31 as open }; - let close_31: boolean; + const close_31: boolean; export { close_31 as close }; export function enter_16(node: any, token: any, callback: any): void; export { enter_16 as enter }; } declare namespace tableBodyCloseRule { - let tag_32: string; + const tag_32: string; export { tag_32 as tag }; - let leaf_32: boolean; + const leaf_32: boolean; export { leaf_32 as leaf }; - let open_32: boolean; + const open_32: boolean; export { open_32 as open }; - let close_32: boolean; + const close_32: boolean; export { close_32 as close }; } declare namespace tableRowOpenRule { - let tag_33: string; + const tag_33: string; export { tag_33 as tag }; - let leaf_33: boolean; + const leaf_33: boolean; export { leaf_33 as leaf }; - let open_33: boolean; + const open_33: boolean; export { open_33 as open }; - let close_33: boolean; + const close_33: boolean; export { close_33 as close }; export function enter_17(node: any, token: any, callback: any): void; export { enter_17 as enter }; } declare namespace tableRowCloseRule { - let tag_34: string; + const tag_34: string; export { tag_34 as tag }; - let leaf_34: boolean; + const leaf_34: boolean; export { leaf_34 as leaf }; - let open_34: boolean; + const open_34: boolean; export { open_34 as open }; - let close_34: boolean; + const close_34: boolean; export { close_34 as close }; } declare namespace headerCellOpenRule { - let tag_35: string; + const tag_35: string; export { tag_35 as tag }; - let leaf_35: boolean; + const leaf_35: boolean; export { leaf_35 as leaf }; - let open_35: boolean; + const open_35: boolean; export { open_35 as open }; - let close_35: boolean; + const close_35: boolean; export { close_35 as close }; export function enter_18(node: any, token: any, callback: any): void; export { enter_18 as enter }; } declare namespace headerCellCloseRule { - let tag_36: string; + const tag_36: string; export { tag_36 as tag }; - let leaf_36: boolean; + const leaf_36: boolean; export { leaf_36 as leaf }; - let open_36: boolean; + const open_36: boolean; export { open_36 as open }; - let close_36: boolean; + const close_36: boolean; export { close_36 as close }; } declare namespace tableCellOpenRule { - let tag_37: string; + const tag_37: string; export { tag_37 as tag }; - let leaf_37: boolean; + const leaf_37: boolean; export { leaf_37 as leaf }; - let open_37: boolean; + const open_37: boolean; export { open_37 as open }; - let close_37: boolean; + const close_37: boolean; export { close_37 as close }; export function enter_19(node: any, token: any, callback: any): void; export { enter_19 as enter }; } declare namespace tableCellCloseRule { - let tag_38: string; + const tag_38: string; export { tag_38 as tag }; - let leaf_38: boolean; + const leaf_38: boolean; export { leaf_38 as leaf }; - let open_38: boolean; + const open_38: boolean; export { open_38 as open }; - let close_38: boolean; + const close_38: boolean; export { close_38 as close }; } -export namespace inlines { +export declare namespace inlines { export { textRule as text }; export { codeInlineRule as code_inline }; export { softbreakRule as softbreak }; @@ -461,7 +461,7 @@ export namespace inlines { export { linkCloseRule as link_close }; export { imageRule as image }; } -export namespace blocks { +export declare namespace blocks { export { codeBlockRule as code_block }; export { fenceRule as fence }; export { htmlBlockRule as html_block }; diff --git a/packages/markdown-html/src/HtmlTransformer.js b/packages/markdown-html/src/HtmlTransformer.js index e0231bb8..db4f951a 100644 --- a/packages/markdown-html/src/HtmlTransformer.js +++ b/packages/markdown-html/src/HtmlTransformer.js @@ -18,6 +18,22 @@ const ToHtmlStringVisitor = require('./ToHtmlStringVisitor'); const ToCiceroMarkVisitor = require('./ToCiceroMarkVisitor'); const CiceroMarkTransformer = require('@accordproject/markdown-cicero').CiceroMarkTransformer; +/** + * @typedef {{ $class: string, [key: string]: unknown }} CommonMarkJson + */ + +/** + * @typedef {{ $class: string, [key: string]: unknown }} CiceroMarkJson + */ + +/** + * @typedef {{ accept: Function, getType?: Function }} ConcertoTypedNode + */ + +/** + * @typedef {CommonMarkJson | CiceroMarkJson | ConcertoTypedNode} MarkdownDomInput + */ + /** * Converts a CiceroMark or CommonMark DOM to HTML */ @@ -34,7 +50,7 @@ class HtmlTransformer { /** * Converts a CiceroMark DOM to an html string - * @param {*} input - CiceroMark DOM object + * @param {MarkdownDomInput} input - CiceroMark DOM object * @returns {string} the html string */ toHtml(input) { @@ -55,7 +71,7 @@ class HtmlTransformer { /** * Converts an html string to a CiceroMark DOM * @param {string} input - html string - * @returns {*} CiceroMark DOM + * @returns {CiceroMarkJson} CiceroMark DOM */ toCiceroMark(input) { const visitor = new ToCiceroMarkVisitor(this.options); @@ -63,4 +79,4 @@ class HtmlTransformer { } } -module.exports = HtmlTransformer; \ No newline at end of file +module.exports = HtmlTransformer; diff --git a/packages/markdown-html/types/index.d.ts b/packages/markdown-html/types/index.d.ts index c7fd65c9..df4ef8da 100644 --- a/packages/markdown-html/types/index.d.ts +++ b/packages/markdown-html/types/index.d.ts @@ -1,2 +1,2 @@ -export const HtmlTransformer: typeof import("./lib/HtmlTransformer"); -export const ToHtmlStringVisitor: typeof import("./lib/ToHtmlStringVisitor"); +export var HtmlTransformer: typeof import("./lib/HtmlTransformer"); +export var ToHtmlStringVisitor: typeof import("./lib/ToHtmlStringVisitor"); diff --git a/packages/markdown-html/types/lib/HtmlTransformer.d.ts b/packages/markdown-html/types/lib/HtmlTransformer.d.ts index 49e4c0a1..3873d00b 100644 --- a/packages/markdown-html/types/lib/HtmlTransformer.d.ts +++ b/packages/markdown-html/types/lib/HtmlTransformer.d.ts @@ -1,4 +1,16 @@ export = HtmlTransformer; +/** + * @typedef {{ $class: string, [key: string]: unknown }} CommonMarkJson + */ +/** + * @typedef {{ $class: string, [key: string]: unknown }} CiceroMarkJson + */ +/** + * @typedef {{ accept: Function, getType?: Function }} ConcertoTypedNode + */ +/** + * @typedef {CommonMarkJson | CiceroMarkJson | ConcertoTypedNode} MarkdownDomInput + */ /** * Converts a CiceroMark or CommonMark DOM to HTML */ @@ -12,14 +24,39 @@ declare class HtmlTransformer { ciceroMarkTransformer: import("@accordproject/markdown-cicero/types/lib/CiceroMarkTransformer"); /** * Converts a CiceroMark DOM to an html string - * @param {*} input - CiceroMark DOM object + * @param {MarkdownDomInput} input - CiceroMark DOM object * @returns {string} the html string */ - toHtml(input: any): string; + toHtml(input: MarkdownDomInput): string; /** * Converts an html string to a CiceroMark DOM * @param {string} input - html string - * @returns {*} CiceroMark DOM + * @returns {CiceroMarkJson} CiceroMark DOM */ - toCiceroMark(input: string): any; + toCiceroMark(input: string): CiceroMarkJson; +} +declare namespace HtmlTransformer { + export { CommonMarkJson, CiceroMarkJson, ConcertoTypedNode, MarkdownDomInput }; } +type MarkdownDomInput = { + [key: string]: unknown; + $class: string; +} | { + [key: string]: unknown; + $class: string; +} | { + accept: Function; + getType?: Function; +}; +type CiceroMarkJson = { + [key: string]: unknown; + $class: string; +}; +type CommonMarkJson = { + [key: string]: unknown; + $class: string; +}; +type ConcertoTypedNode = { + accept: Function; + getType?: Function; +}; diff --git a/packages/markdown-html/types/lib/ToCiceroMarkVisitor.d.ts b/packages/markdown-html/types/lib/ToCiceroMarkVisitor.d.ts index 5677284a..11f8ebda 100644 --- a/packages/markdown-html/types/lib/ToCiceroMarkVisitor.d.ts +++ b/packages/markdown-html/types/lib/ToCiceroMarkVisitor.d.ts @@ -25,7 +25,7 @@ declare class ToCiceroMarkVisitor { * @param {boolean} ignoreSpace override * @return {Any} node */ - deserializeElement(element: any, ignoreSpace: boolean): Any; + deserializeElement(element: any, ignoreSpace: boolean): any; /** * Deserialize an array of DOM elements. * diff --git a/packages/markdown-template/lib/TemplateMarkTransformer.js b/packages/markdown-template/lib/TemplateMarkTransformer.js index 675d27ef..9939c14a 100644 --- a/packages/markdown-template/lib/TemplateMarkTransformer.js +++ b/packages/markdown-template/lib/TemplateMarkTransformer.js @@ -22,28 +22,67 @@ var { } = require('./templatemarkutil'); var ToMarkdownTemplateVisitor = require('./ToMarkdownTemplateVisitor'); +/** + * @typedef {{ + * type: string, + * tag: string, + * nesting: number, + * attrs?: Array<[string, string]> | null, + * map?: [number, number] | null, + * level?: number, + * children?: MarkdownToken[] | null, + * content?: string, + * markup?: string, + * info?: string, + * meta?: unknown, + * block?: boolean, + * hidden?: boolean + * }} MarkdownToken + */ + +/** + * @typedef {MarkdownToken[]} MarkdownTokenStream + */ + +/** + * @typedef {{ $class: string, [key: string]: unknown }} TemplateMarkJson + */ + +/** + * @typedef {{ fileName?: string, content: string }} TemplateInput + */ + +/** + * @typedef {'clause' | 'contract'} TemplateKind + */ + +/** + * @typedef {{ verbose?: boolean }} TemplateTransformOptions + */ + /** * Support for TemplateMark Templates */ class TemplateMarkTransformer { /** * Converts a template string to a token stream - * @param {object} templateInput the template template - * @returns {object} the token stream + * @param {TemplateInput} templateInput the template template + * @returns {MarkdownTokenStream} the token stream */ toTokens(templateInput) { return templateToTokens(templateInput.content); } + // eslint-disable-next-line valid-jsdoc /** * Converts a template token strean string to a TemplateMark DOM - * @param {object} tokenStream the template token stream - * @param {object} modelManager - the model manager for this template - * @param {string} templateKind - either 'clause' or 'contract' - * @param {object} [options] configuration options + * @param {MarkdownTokenStream} tokenStream the template token stream + * @param {import('@accordproject/concerto-core').ModelManager} modelManager - the model manager for this template + * @param {TemplateKind} templateKind - either 'clause' or 'contract' + * @param {TemplateTransformOptions} [options] configuration options * @param {boolean} [options.verbose] verbose output * @param {string} [conceptFullyQualifiedName] - the fully qualified name of the template concept - * @returns {object} the result of parsing + * @returns {TemplateMarkJson} the result of parsing */ tokensToMarkdownTemplate(tokenStream, modelManager, templateKind, options, conceptFullyQualifiedName) { var template = tokensToUntypedTemplateMark(tokenStream, templateKind); @@ -59,15 +98,16 @@ class TemplateMarkTransformer { return typedTemplate; } + // eslint-disable-next-line valid-jsdoc /** * Converts a markdown string to a TemplateMark DOM - * @param {{fileName:string,content:string}} templateInput the template template - * @param {object} modelManager - the model manager for this template - * @param {string} templateKind - either 'clause' or 'contract' - * @param {object} [options] configuration options + * @param {TemplateInput} templateInput the template template + * @param {import('@accordproject/concerto-core').ModelManager} modelManager - the model manager for this template + * @param {TemplateKind} templateKind - either 'clause' or 'contract' + * @param {TemplateTransformOptions} [options] configuration options * @param {boolean} [options.verbose] verbose output * @param {string} [conceptFullyQualifiedName] - the fully qualified name of the template concept - * @returns {object} the result of parsing + * @returns {TemplateMarkJson} the result of parsing */ fromMarkdownTemplate(templateInput, modelManager, templateKind, options, conceptFullyQualifiedName) { if (!modelManager) { @@ -83,7 +123,7 @@ class TemplateMarkTransformer { /** * Converts a TemplateMark DOM to a template markdown string - * @param {object} input TemplateMark DOM + * @param {TemplateMarkJson} input TemplateMark DOM * @returns {string} the template markdown text */ toMarkdownTemplate(input) { @@ -91,9 +131,10 @@ class TemplateMarkTransformer { return visitor.toMarkdownTemplate(templateMarkManager.serializer, input); } + // eslint-disable-next-line valid-jsdoc /** * Get TemplateMark serializer - * @return {*} templatemark serializer + * @return {import('@accordproject/concerto-core').Serializer} templatemark serializer */ getSerializer() { return templateMarkManager.serializer; diff --git a/packages/markdown-template/src/TemplateMarkTransformer.js b/packages/markdown-template/src/TemplateMarkTransformer.js index f42b1c82..b7082b08 100644 --- a/packages/markdown-template/src/TemplateMarkTransformer.js +++ b/packages/markdown-template/src/TemplateMarkTransformer.js @@ -23,28 +23,67 @@ const { const ToMarkdownTemplateVisitor = require('./ToMarkdownTemplateVisitor'); +/** + * @typedef {{ + * type: string, + * tag: string, + * nesting: number, + * attrs?: Array<[string, string]> | null, + * map?: [number, number] | null, + * level?: number, + * children?: MarkdownToken[] | null, + * content?: string, + * markup?: string, + * info?: string, + * meta?: unknown, + * block?: boolean, + * hidden?: boolean + * }} MarkdownToken + */ + +/** + * @typedef {MarkdownToken[]} MarkdownTokenStream + */ + +/** + * @typedef {{ $class: string, [key: string]: unknown }} TemplateMarkJson + */ + +/** + * @typedef {{ fileName?: string, content: string }} TemplateInput + */ + +/** + * @typedef {'clause' | 'contract'} TemplateKind + */ + +/** + * @typedef {{ verbose?: boolean }} TemplateTransformOptions + */ + /** * Support for TemplateMark Templates */ class TemplateMarkTransformer { /** * Converts a template string to a token stream - * @param {object} templateInput the template template - * @returns {object} the token stream + * @param {TemplateInput} templateInput the template template + * @returns {MarkdownTokenStream} the token stream */ toTokens(templateInput) { return templateToTokens(templateInput.content); } + // eslint-disable-next-line valid-jsdoc /** * Converts a template token strean string to a TemplateMark DOM - * @param {object} tokenStream the template token stream - * @param {object} modelManager - the model manager for this template - * @param {string} templateKind - either 'clause' or 'contract' - * @param {object} [options] configuration options + * @param {MarkdownTokenStream} tokenStream the template token stream + * @param {import('@accordproject/concerto-core').ModelManager} modelManager - the model manager for this template + * @param {TemplateKind} templateKind - either 'clause' or 'contract' + * @param {TemplateTransformOptions} [options] configuration options * @param {boolean} [options.verbose] verbose output * @param {string} [conceptFullyQualifiedName] - the fully qualified name of the template concept - * @returns {object} the result of parsing + * @returns {TemplateMarkJson} the result of parsing */ tokensToMarkdownTemplate(tokenStream, modelManager, templateKind, options, conceptFullyQualifiedName) { const template = tokensToUntypedTemplateMark(tokenStream, templateKind); @@ -60,15 +99,16 @@ class TemplateMarkTransformer { return typedTemplate; } + // eslint-disable-next-line valid-jsdoc /** * Converts a markdown string to a TemplateMark DOM - * @param {{fileName:string,content:string}} templateInput the template template - * @param {object} modelManager - the model manager for this template - * @param {string} templateKind - either 'clause' or 'contract' - * @param {object} [options] configuration options + * @param {TemplateInput} templateInput the template template + * @param {import('@accordproject/concerto-core').ModelManager} modelManager - the model manager for this template + * @param {TemplateKind} templateKind - either 'clause' or 'contract' + * @param {TemplateTransformOptions} [options] configuration options * @param {boolean} [options.verbose] verbose output * @param {string} [conceptFullyQualifiedName] - the fully qualified name of the template concept - * @returns {object} the result of parsing + * @returns {TemplateMarkJson} the result of parsing */ fromMarkdownTemplate(templateInput, modelManager, templateKind, options, conceptFullyQualifiedName) { if (!modelManager) { @@ -85,7 +125,7 @@ class TemplateMarkTransformer { /** * Converts a TemplateMark DOM to a template markdown string - * @param {object} input TemplateMark DOM + * @param {TemplateMarkJson} input TemplateMark DOM * @returns {string} the template markdown text */ toMarkdownTemplate(input) { @@ -93,13 +133,14 @@ class TemplateMarkTransformer { return visitor.toMarkdownTemplate(templateMarkManager.serializer,input); } + // eslint-disable-next-line valid-jsdoc /** * Get TemplateMark serializer - * @return {*} templatemark serializer + * @return {import('@accordproject/concerto-core').Serializer} templatemark serializer */ getSerializer() { return templateMarkManager.serializer; } } -module.exports = TemplateMarkTransformer; \ No newline at end of file +module.exports = TemplateMarkTransformer; diff --git a/packages/markdown-template/types/index.d.ts b/packages/markdown-template/types/index.d.ts index 1434af5a..737cefbf 100644 --- a/packages/markdown-template/types/index.d.ts +++ b/packages/markdown-template/types/index.d.ts @@ -1,6 +1,8 @@ -export const util: typeof import("./lib/util"); -export const templatemarkutil: typeof import("./lib/templatemarkutil"); -export const datetimeutil: typeof import("./lib/datetimeutil"); -export const normalizeNLs: typeof import("./lib/normalize").normalizeNLs; -export const TemplateException: typeof import("./lib/templateexception"); -export const TemplateMarkTransformer: typeof import("./lib/TemplateMarkTransformer"); +export var util: typeof import("./lib/util"); +export var templatemarkutil: typeof import("./lib/templatemarkutil"); +export var datetimeutil: { + setCurrentTime: (currentTime: string) => any; +}; +export var normalizeNLs: (input: string) => string; +export var TemplateException: typeof import("./lib/templateexception"); +export var TemplateMarkTransformer: typeof import("./lib/TemplateMarkTransformer"); diff --git a/packages/markdown-template/types/lib/FormulaVisitor.d.ts b/packages/markdown-template/types/lib/FormulaVisitor.d.ts index 64e1cb65..cd8c248c 100644 --- a/packages/markdown-template/types/lib/FormulaVisitor.d.ts +++ b/packages/markdown-template/types/lib/FormulaVisitor.d.ts @@ -39,7 +39,7 @@ declare class FormulaVisitor { * @returns {*} the formulas */ calculateDependencies(serializer: any, ast: object, options: { - utcOffset?: number; + utcOffset: number; }): any; /** * Process formulas and returns the list of those formulas from a TemplateMark DOM @@ -50,6 +50,6 @@ declare class FormulaVisitor { * @returns {*} the formulas */ processFormulas(serializer: any, ast: object, options: { - utcOffset?: number; + utcOffset: number; }): any; } diff --git a/packages/markdown-template/types/lib/TemplateMarkTransformer.d.ts b/packages/markdown-template/types/lib/TemplateMarkTransformer.d.ts index 6f7ade3c..aa8ad171 100644 --- a/packages/markdown-template/types/lib/TemplateMarkTransformer.d.ts +++ b/packages/markdown-template/types/lib/TemplateMarkTransformer.d.ts @@ -1,52 +1,150 @@ export = TemplateMarkTransformer; +/** + * @typedef {{ + * type: string, + * tag: string, + * nesting: number, + * attrs?: Array<[string, string]> | null, + * map?: [number, number] | null, + * level?: number, + * children?: MarkdownToken[] | null, + * content?: string, + * markup?: string, + * info?: string, + * meta?: unknown, + * block?: boolean, + * hidden?: boolean + * }} MarkdownToken + */ +/** + * @typedef {MarkdownToken[]} MarkdownTokenStream + */ +/** + * @typedef {{ $class: string, [key: string]: unknown }} TemplateMarkJson + */ +/** + * @typedef {{ fileName?: string, content: string }} TemplateInput + */ +/** + * @typedef {'clause' | 'contract'} TemplateKind + */ +/** + * @typedef {{ verbose?: boolean }} TemplateTransformOptions + */ /** * Support for TemplateMark Templates */ declare class TemplateMarkTransformer { /** * Converts a template string to a token stream - * @param {object} templateInput the template template - * @returns {object} the token stream + * @param {TemplateInput} templateInput the template template + * @returns {MarkdownTokenStream} the token stream */ - toTokens(templateInput: object): object; + toTokens(templateInput: TemplateInput): { + type: string; + tag: string; + nesting: number; + attrs?: Array<[string, string]> | null; + map?: [number, number] | null; + level?: number; + children?: MarkdownToken[] | null; + content?: string; + markup?: string; + info?: string; + meta?: unknown; + block?: boolean; + hidden?: boolean; + }[]; /** * Converts a template token strean string to a TemplateMark DOM - * @param {object} tokenStream the template token stream - * @param {object} modelManager - the model manager for this template - * @param {string} templateKind - either 'clause' or 'contract' - * @param {object} [options] configuration options + * @param {MarkdownTokenStream} tokenStream the template token stream + * @param {import('@accordproject/concerto-core').ModelManager} modelManager - the model manager for this template + * @param {TemplateKind} templateKind - either 'clause' or 'contract' + * @param {TemplateTransformOptions} [options] configuration options * @param {boolean} [options.verbose] verbose output * @param {string} [conceptFullyQualifiedName] - the fully qualified name of the template concept - * @returns {object} the result of parsing + * @returns {TemplateMarkJson} the result of parsing */ - tokensToMarkdownTemplate(tokenStream: object, modelManager: object, templateKind: string, options?: { - verbose?: boolean; - }, conceptFullyQualifiedName?: string): object; + tokensToMarkdownTemplate(tokenStream: { + type: string; + tag: string; + nesting: number; + attrs?: Array<[string, string]> | null; + map?: [number, number] | null; + level?: number; + children?: MarkdownToken[] | null; + content?: string; + markup?: string; + info?: string; + meta?: unknown; + block?: boolean; + hidden?: boolean; + }[], modelManager: import('@accordproject/concerto-core').ModelManager, templateKind: TemplateKind, options?: TemplateTransformOptions, conceptFullyQualifiedName?: string): TemplateMarkJson; /** * Converts a markdown string to a TemplateMark DOM - * @param {{fileName:string,content:string}} templateInput the template template - * @param {object} modelManager - the model manager for this template - * @param {string} templateKind - either 'clause' or 'contract' - * @param {object} [options] configuration options + * @param {TemplateInput} templateInput the template template + * @param {import('@accordproject/concerto-core').ModelManager} modelManager - the model manager for this template + * @param {TemplateKind} templateKind - either 'clause' or 'contract' + * @param {TemplateTransformOptions} [options] configuration options * @param {boolean} [options.verbose] verbose output * @param {string} [conceptFullyQualifiedName] - the fully qualified name of the template concept - * @returns {object} the result of parsing + * @returns {TemplateMarkJson} the result of parsing */ - fromMarkdownTemplate(templateInput: { - fileName: string; - content: string; - }, modelManager: object, templateKind: string, options?: { - verbose?: boolean; - }, conceptFullyQualifiedName?: string): object; + fromMarkdownTemplate(templateInput: TemplateInput, modelManager: import('@accordproject/concerto-core').ModelManager, templateKind: TemplateKind, options?: TemplateTransformOptions, conceptFullyQualifiedName?: string): TemplateMarkJson; /** * Converts a TemplateMark DOM to a template markdown string - * @param {object} input TemplateMark DOM + * @param {TemplateMarkJson} input TemplateMark DOM * @returns {string} the template markdown text */ - toMarkdownTemplate(input: object): string; + toMarkdownTemplate(input: TemplateMarkJson): string; /** * Get TemplateMark serializer - * @return {*} templatemark serializer + * @return {import('@accordproject/concerto-core').Serializer} templatemark serializer */ - getSerializer(): any; + getSerializer(): import('@accordproject/concerto-core').Serializer; +} +declare namespace TemplateMarkTransformer { + export { MarkdownToken, MarkdownTokenStream, TemplateMarkJson, TemplateInput, TemplateKind, TemplateTransformOptions }; } +type TemplateInput = { + fileName?: string; + content: string; +}; +type MarkdownToken = { + type: string; + tag: string; + nesting: number; + attrs?: Array<[string, string]> | null; + map?: [number, number] | null; + level?: number; + children?: MarkdownToken[] | null; + content?: string; + markup?: string; + info?: string; + meta?: unknown; + block?: boolean; + hidden?: boolean; +}; +type TemplateKind = "contract" | "clause"; +type TemplateTransformOptions = { + verbose?: boolean; +}; +type TemplateMarkJson = { + [key: string]: unknown; + $class: string; +}; +type MarkdownTokenStream = { + type: string; + tag: string; + nesting: number; + attrs?: Array<[string, string]> | null; + map?: [number, number] | null; + level?: number; + children?: MarkdownToken[] | null; + content?: string; + markup?: string; + info?: string; + meta?: unknown; + block?: boolean; + hidden?: boolean; +}[]; diff --git a/packages/markdown-template/types/lib/fromtemplatemarkrules.d.ts b/packages/markdown-template/types/lib/fromtemplatemarkrules.d.ts index 315d5e70..ae5a560b 100644 --- a/packages/markdown-template/types/lib/fromtemplatemarkrules.d.ts +++ b/packages/markdown-template/types/lib/fromtemplatemarkrules.d.ts @@ -1,10 +1,10 @@ -export function VariableDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; -export function FormattedVariableDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; -export function EnumVariableDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; -export function FormulaDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; -export function ConditionalDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; -export function OptionalDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; -export function WithDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; -export function JoinDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; -export function ListBlockDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; -export function ClauseDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export declare function VariableDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export declare function FormattedVariableDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export declare function EnumVariableDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export declare function FormulaDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export declare function ConditionalDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export declare function OptionalDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export declare function WithDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export declare function JoinDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export declare function ListBlockDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export declare function ClauseDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; diff --git a/packages/markdown-template/types/lib/templaterules.d.ts b/packages/markdown-template/types/lib/templaterules.d.ts index 5254c923..bdf3193a 100644 --- a/packages/markdown-template/types/lib/templaterules.d.ts +++ b/packages/markdown-template/types/lib/templaterules.d.ts @@ -1,225 +1,210 @@ declare namespace variableRule { - let tag: string; - let leaf: boolean; - let open: boolean; - let close: boolean; - function enter(node: any, token: any, callback: any): void; - let skipEmpty: boolean; -} -declare namespace thisRule { - let tag_1: string; + export const tag: string; + export const leaf: boolean; + export const open: boolean; + export const close: boolean; + export function enter(node: any, token: any, callback: any): void; + export const skipEmpty: boolean; +} +declare namespace formulaRule { + const tag_1: string; export { tag_1 as tag }; - let leaf_1: boolean; + const leaf_1: boolean; export { leaf_1 as leaf }; - let open_1: boolean; + const open_1: boolean; export { open_1 as open }; - let close_1: boolean; + const close_1: boolean; export { close_1 as close }; export function enter_1(node: any, token: any, callback: any): void; export { enter_1 as enter }; - let skipEmpty_1: boolean; + const skipEmpty_1: boolean; export { skipEmpty_1 as skipEmpty }; } -declare namespace formulaRule { - let tag_2: string; +declare namespace ifOpenRule { + const tag_2: string; export { tag_2 as tag }; - let leaf_2: boolean; + const leaf_2: boolean; export { leaf_2 as leaf }; - let open_2: boolean; + const open_2: boolean; export { open_2 as open }; - let close_2: boolean; + const close_2: boolean; export { close_2 as close }; export function enter_2(node: any, token: any, callback: any): void; export { enter_2 as enter }; - let skipEmpty_2: boolean; + const skipEmpty_2: boolean; export { skipEmpty_2 as skipEmpty }; } -declare namespace ifOpenRule { - let tag_3: string; +declare namespace ifCloseRule { + const tag_3: string; export { tag_3 as tag }; - let leaf_3: boolean; + const leaf_3: boolean; export { leaf_3 as leaf }; - let open_3: boolean; + const open_3: boolean; export { open_3 as open }; - let close_3: boolean; + const close_3: boolean; export { close_3 as close }; - export function enter_3(node: any, token: any, callback: any): void; - export { enter_3 as enter }; - let skipEmpty_3: boolean; + export function exit(node: any, token: any, callback: any): void; + const skipEmpty_3: boolean; export { skipEmpty_3 as skipEmpty }; } -declare namespace ifCloseRule { - let tag_4: string; +declare namespace optionalOpenRule { + const tag_4: string; export { tag_4 as tag }; - let leaf_4: boolean; + const leaf_4: boolean; export { leaf_4 as leaf }; - let open_4: boolean; + const open_4: boolean; export { open_4 as open }; - let close_4: boolean; + const close_4: boolean; export { close_4 as close }; - export function exit(node: any, token: any, callback: any): void; - let skipEmpty_4: boolean; + export function enter_3(node: any, token: any, callback: any): void; + export { enter_3 as enter }; + const skipEmpty_4: boolean; export { skipEmpty_4 as skipEmpty }; } -declare namespace optionalOpenRule { - let tag_5: string; +declare namespace optionalCloseRule { + const tag_5: string; export { tag_5 as tag }; - let leaf_5: boolean; + const leaf_5: boolean; export { leaf_5 as leaf }; - let open_5: boolean; + const open_5: boolean; export { open_5 as open }; - let close_5: boolean; + const close_5: boolean; export { close_5 as close }; - export function enter_4(node: any, token: any, callback: any): void; - export { enter_4 as enter }; - let skipEmpty_5: boolean; + export function exit_1(node: any, token: any, callback: any): void; + export { exit_1 as exit }; + const skipEmpty_5: boolean; export { skipEmpty_5 as skipEmpty }; } -declare namespace optionalCloseRule { - let tag_6: string; +declare namespace elseRule { + const tag_6: string; export { tag_6 as tag }; - let leaf_6: boolean; + const leaf_6: boolean; export { leaf_6 as leaf }; - let open_6: boolean; + const open_6: boolean; export { open_6 as open }; - let close_6: boolean; + const close_6: boolean; export { close_6 as close }; - export function exit_1(node: any, token: any, callback: any): void; - export { exit_1 as exit }; - let skipEmpty_6: boolean; + export function enter_4(node: any, token: any, callback: any): void; + export { enter_4 as enter }; + const skipEmpty_6: boolean; export { skipEmpty_6 as skipEmpty }; } -declare namespace elseRule { - let tag_7: string; +declare namespace withOpenRule { + const tag_7: string; export { tag_7 as tag }; - let leaf_7: boolean; + const leaf_7: boolean; export { leaf_7 as leaf }; - let open_7: boolean; + const open_7: boolean; export { open_7 as open }; - let close_7: boolean; + const close_7: boolean; export { close_7 as close }; export function enter_5(node: any, token: any, callback: any): void; export { enter_5 as enter }; - let skipEmpty_7: boolean; + const skipEmpty_7: boolean; export { skipEmpty_7 as skipEmpty }; } -declare namespace withOpenRule { - let tag_8: string; +declare namespace withCloseRule { + const tag_8: string; export { tag_8 as tag }; - let leaf_8: boolean; + const leaf_8: boolean; export { leaf_8 as leaf }; - let open_8: boolean; + const open_8: boolean; export { open_8 as open }; - let close_8: boolean; + const close_8: boolean; export { close_8 as close }; - export function enter_6(node: any, token: any, callback: any): void; - export { enter_6 as enter }; - let skipEmpty_8: boolean; - export { skipEmpty_8 as skipEmpty }; } -declare namespace withCloseRule { - let tag_9: string; +declare namespace joinOpenRule { + const tag_9: string; export { tag_9 as tag }; - let leaf_9: boolean; + const leaf_9: boolean; export { leaf_9 as leaf }; - let open_9: boolean; + const open_9: boolean; export { open_9 as open }; - let close_9: boolean; + const close_9: boolean; export { close_9 as close }; + export function enter_6(node: any, token: any, callback: any): void; + export { enter_6 as enter }; + const skipEmpty_8: boolean; + export { skipEmpty_8 as skipEmpty }; } -declare namespace joinOpenRule { - let tag_10: string; +declare namespace joinCloseRule { + const tag_10: string; export { tag_10 as tag }; - let leaf_10: boolean; + const leaf_10: boolean; export { leaf_10 as leaf }; - let open_10: boolean; + const open_10: boolean; export { open_10 as open }; - let close_10: boolean; + const close_10: boolean; export { close_10 as close }; - export function enter_7(node: any, token: any, callback: any): void; - export { enter_7 as enter }; - let skipEmpty_9: boolean; - export { skipEmpty_9 as skipEmpty }; } -declare namespace joinCloseRule { - let tag_11: string; +declare namespace clauseOpenRule { + const tag_11: string; export { tag_11 as tag }; - let leaf_11: boolean; + const leaf_11: boolean; export { leaf_11 as leaf }; - let open_11: boolean; + const open_11: boolean; export { open_11 as open }; - let close_11: boolean; + const close_11: boolean; export { close_11 as close }; + export function enter_7(node: any, token: any, callback: any): void; + export { enter_7 as enter }; } -declare namespace clauseOpenRule { - let tag_12: string; +declare namespace clauseCloseRule { + const tag_12: string; export { tag_12 as tag }; - let leaf_12: boolean; + const leaf_12: boolean; export { leaf_12 as leaf }; - let open_12: boolean; + const open_12: boolean; export { open_12 as open }; - let close_12: boolean; + const close_12: boolean; export { close_12 as close }; - export function enter_8(node: any, token: any, callback: any): void; - export { enter_8 as enter }; } -declare namespace clauseCloseRule { - let tag_13: string; +declare namespace ulistOpenRule { + const tag_13: string; export { tag_13 as tag }; - let leaf_13: boolean; + const leaf_13: boolean; export { leaf_13 as leaf }; - let open_13: boolean; + const open_13: boolean; export { open_13 as open }; - let close_13: boolean; + const close_13: boolean; export { close_13 as close }; + export function enter_8(node: any, token: any, callback: any): void; + export { enter_8 as enter }; } -declare namespace ulistOpenRule { - let tag_14: string; +declare namespace ulistCloseRule { + const tag_14: string; export { tag_14 as tag }; - let leaf_14: boolean; + const leaf_14: boolean; export { leaf_14 as leaf }; - let open_14: boolean; + const open_14: boolean; export { open_14 as open }; - let close_14: boolean; + const close_14: boolean; export { close_14 as close }; - export function enter_9(node: any, token: any, callback: any): void; - export { enter_9 as enter }; } -declare namespace ulistCloseRule { - let tag_15: string; +declare namespace olistOpenRule { + const tag_15: string; export { tag_15 as tag }; - let leaf_15: boolean; + const leaf_15: boolean; export { leaf_15 as leaf }; - let open_15: boolean; + const open_15: boolean; export { open_15 as open }; - let close_15: boolean; + const close_15: boolean; export { close_15 as close }; + export function enter_9(node: any, token: any, callback: any): void; + export { enter_9 as enter }; } -declare namespace olistOpenRule { - let tag_16: string; +declare namespace olistCloseRule { + const tag_16: string; export { tag_16 as tag }; - let leaf_16: boolean; + const leaf_16: boolean; export { leaf_16 as leaf }; - let open_16: boolean; + const open_16: boolean; export { open_16 as open }; - let close_16: boolean; + const close_16: boolean; export { close_16 as close }; - export function enter_10(node: any, token: any, callback: any): void; - export { enter_10 as enter }; } -declare namespace olistCloseRule { - let tag_17: string; - export { tag_17 as tag }; - let leaf_17: boolean; - export { leaf_17 as leaf }; - let open_17: boolean; - export { open_17 as open }; - let close_17: boolean; - export { close_17 as close }; -} -export namespace inlines { +export declare namespace inlines { export { variableRule as variable }; - export { thisRule as this }; export { formulaRule as formula }; export { ifOpenRule as inline_block_if_open }; export { ifCloseRule as inline_block_if_close }; @@ -231,7 +216,7 @@ export namespace inlines { export { joinOpenRule as inline_block_join_open }; export { joinCloseRule as inline_block_join_close }; } -export namespace blocks { +export declare namespace blocks { export { clauseOpenRule as block_clause_open }; export { clauseCloseRule as block_clause_close }; export { ulistOpenRule as block_ulist_open };