@shikijs/twoslash
Advanced tools
Comparing version 1.0.0-beta.5 to 1.0.0-beta.6
@@ -5,5 +5,8 @@ import { TwoslashReturn, twoslasher, TwoslashOptions, NodeError, NodeTag, NodeQuery, NodeCompletion, NodeHover, NodeHighlight, TwoslashExecuteOptions } from 'twoslash'; | ||
type TwoslashShikiReturn = Pick<TwoslashReturn, 'nodes' | 'code'> & { | ||
meta?: Partial<Pick<TwoslashReturn['meta'], 'extension'>>; | ||
}; | ||
declare module '@shikijs/core' { | ||
interface ShikiTransformerContextMeta { | ||
twoslash?: TwoslashReturn; | ||
twoslash?: TwoslashShikiReturn; | ||
} | ||
@@ -21,3 +24,3 @@ } | ||
*/ | ||
explicitTrigger?: boolean; | ||
explicitTrigger?: boolean | RegExp; | ||
/** | ||
@@ -51,11 +54,11 @@ * Mapping from language alias to language name | ||
interface TwoslashRenderer { | ||
lineError?(this: ShikiTransformerContext, error: NodeError): ElementContent[]; | ||
lineCustomTag?(this: ShikiTransformerContext, tag: NodeTag): ElementContent[]; | ||
lineQuery?(this: ShikiTransformerContext, query: NodeQuery, targetNode?: Element | Text): ElementContent[]; | ||
lineCompletion?(this: ShikiTransformerContext, query: NodeCompletion): ElementContent[]; | ||
nodeStaticInfo(this: ShikiTransformerContext, info: NodeHover, node: Element | Text): Partial<ElementContent>; | ||
nodeError?(this: ShikiTransformerContext, error: NodeError, node: Element | Text): Partial<ElementContent>; | ||
nodeQuery?(this: ShikiTransformerContext, query: NodeQuery, node: Element | Text): Partial<ElementContent>; | ||
nodeCompletion?(this: ShikiTransformerContext, query: NodeCompletion, node: Element | Text): Partial<ElementContent>; | ||
nodesHighlight?(this: ShikiTransformerContext, highlight: NodeHighlight, nodes: ElementContent[]): ElementContent[]; | ||
lineError?: (this: ShikiTransformerContext, error: NodeError) => ElementContent[]; | ||
lineCustomTag?: (this: ShikiTransformerContext, tag: NodeTag) => ElementContent[]; | ||
lineQuery?: (this: ShikiTransformerContext, query: NodeQuery, targetNode?: Element | Text) => ElementContent[]; | ||
lineCompletion?: (this: ShikiTransformerContext, query: NodeCompletion) => ElementContent[]; | ||
nodeStaticInfo: (this: ShikiTransformerContext, info: NodeHover, node: Element | Text) => Partial<ElementContent>; | ||
nodeError?: (this: ShikiTransformerContext, error: NodeError, node: Element | Text) => Partial<ElementContent>; | ||
nodeQuery?: (this: ShikiTransformerContext, query: NodeQuery, node: Element | Text) => Partial<ElementContent>; | ||
nodeCompletion?: (this: ShikiTransformerContext, query: NodeCompletion, node: Element | Text) => Partial<ElementContent>; | ||
nodesHighlight?: (this: ShikiTransformerContext, highlight: NodeHighlight, nodes: ElementContent[]) => ElementContent[]; | ||
} | ||
@@ -104,2 +107,11 @@ | ||
/** | ||
* The way errors should be rendered. | ||
* | ||
* - `'line'`: Render the error line after the line of code | ||
* - `'hover'`: Render the error in the hover popup | ||
* | ||
* @default 'line' | ||
*/ | ||
errorRendering?: 'line' | 'hover'; | ||
/** | ||
* Classes added to injected elements | ||
@@ -116,3 +128,3 @@ */ | ||
*/ | ||
formatInfo?(info: string): string; | ||
formatInfo?: (info: string) => string; | ||
/** | ||
@@ -123,3 +135,3 @@ * Custom function to render markdown. | ||
*/ | ||
renderMarkdown?(this: ShikiTransformerContextCommon, markdown: string): ElementContent[]; | ||
renderMarkdown?: (this: ShikiTransformerContextCommon, markdown: string) => ElementContent[]; | ||
/** | ||
@@ -130,3 +142,3 @@ * Custom function to render inline markdown. | ||
*/ | ||
renderMarkdownInline?(this: ShikiTransformerContextCommon, markdown: string, context: string): ElementContent[]; | ||
renderMarkdownInline?: (this: ShikiTransformerContextCommon, markdown: string, context: string) => ElementContent[]; | ||
/** | ||
@@ -202,2 +214,15 @@ * Extensions for the genreated HAST tree. | ||
/** | ||
* The container of the error popup. | ||
* Only used when `errorRendering` is set to `'hover'`. | ||
*/ | ||
errorPopup?: HastExtension; | ||
/** | ||
* Custom function to compose the error token. | ||
* Only used when `errorRendering` is set to `'hover'`. | ||
*/ | ||
errorCompose?: (parts: { | ||
popup: Element; | ||
token: Text | Element; | ||
}) => ElementContent[]; | ||
/** | ||
* The wrapper for the highlighted nodes. | ||
@@ -239,5 +264,5 @@ */ | ||
declare function defaultTwoslashOptions(): TwoslashExecuteOptions; | ||
type TwoslashFunction = (code: string, lang?: string, options?: TwoslashExecuteOptions) => TwoslashReturn; | ||
type TwoslashFunction = (code: string, lang?: string, options?: TwoslashExecuteOptions) => TwoslashShikiReturn; | ||
declare function createTransformerFactory(defaultTwoslasher: TwoslashFunction, defaultRenderer?: TwoslashRenderer): (options?: TransformerTwoslashOptions) => ShikiTransformer; | ||
export { type CompletionItem, type HastExtension, type RendererRichOptions, ShikiTwoslashError, type TransformerTwoslashOptions, type TwoslashRenderer, createTransformerFactory, defaultCompletionIcons, defaultCustomTagIcons, defaultHoverInfoProcessor, defaultTwoslashOptions, rendererClassic, rendererRich }; | ||
export { type CompletionItem, type HastExtension, type RendererRichOptions, ShikiTwoslashError, type TransformerTwoslashOptions, type TwoslashFunction, type TwoslashRenderer, type TwoslashShikiReturn, createTransformerFactory, defaultCompletionIcons, defaultCustomTagIcons, defaultHoverInfoProcessor, defaultTwoslashOptions, rendererClassic, rendererRich }; |
import * as _shikijs_core_dist_chunk_tokens_mjs from '@shikijs/core/dist/chunk-tokens.mjs'; | ||
import { CreateTwoslashOptions } from 'twoslash'; | ||
import { TransformerTwoslashOptions, RendererRichOptions } from './core.js'; | ||
export { CompletionItem, HastExtension, ShikiTwoslashError, TwoslashRenderer, createTransformerFactory, defaultCompletionIcons, defaultCustomTagIcons, defaultHoverInfoProcessor, defaultTwoslashOptions, rendererClassic, rendererRich } from './core.js'; | ||
export { CompletionItem, HastExtension, ShikiTwoslashError, TwoslashFunction, TwoslashRenderer, TwoslashShikiReturn, createTransformerFactory, defaultCompletionIcons, defaultCustomTagIcons, defaultHoverInfoProcessor, defaultTwoslashOptions, rendererClassic, rendererRich } from './core.js'; | ||
import '@shikijs/core'; | ||
@@ -19,4 +19,4 @@ import 'hast'; | ||
*/ | ||
declare function transformerTwoslash(options?: TransformerTwoslashIndexOptions): _shikijs_core_dist_chunk_tokens_mjs.y; | ||
declare function transformerTwoslash(options?: TransformerTwoslashIndexOptions): _shikijs_core_dist_chunk_tokens_mjs.A; | ||
export { RendererRichOptions, type TransformerTwoslashIndexOptions, TransformerTwoslashOptions, transformerTwoslash }; |
{ | ||
"name": "@shikijs/twoslash", | ||
"type": "module", | ||
"version": "1.0.0-beta.5", | ||
"version": "1.0.0-beta.6", | ||
"description": "Shiki transformer for twoslash", | ||
@@ -52,4 +52,4 @@ "author": "Anthony Fu <anthonyfu117@hotmail.com>", | ||
"dependencies": { | ||
"twoslash": "^0.1.0", | ||
"@shikijs/core": "1.0.0-beta.5" | ||
"twoslash": "^0.1.1", | ||
"@shikijs/core": "1.0.0-beta.6" | ||
}, | ||
@@ -56,0 +56,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70430
1936
+ Added@shikijs/core@1.0.0-beta.6(transitive)
- Removed@shikijs/core@1.0.0-beta.5(transitive)
Updated@shikijs/core@1.0.0-beta.6
Updatedtwoslash@^0.1.1