@shikijs/twoslash 1.0.0-beta.5 → 1.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.d.mts +41 -16
- package/dist/core.d.ts +41 -16
- package/dist/core.mjs +55 -6
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/package.json +3 -3
- package/style-rich.css +30 -3
package/dist/core.d.mts
CHANGED
|
@@ -2,9 +2,12 @@ import { TwoslashReturn, twoslasher, TwoslashOptions, NodeError, NodeTag, NodeQu
|
|
|
2
2
|
import { CodeToHastOptions, ShikiTransformerContext, ShikiTransformerContextCommon, ShikiTransformer } from '@shikijs/core';
|
|
3
3
|
import { ElementContent, Element, Text } from 'hast';
|
|
4
4
|
|
|
5
|
+
type TwoslashShikiReturn = Pick<TwoslashReturn, 'nodes' | 'code'> & {
|
|
6
|
+
meta?: Partial<Pick<TwoslashReturn['meta'], 'extension'>>;
|
|
7
|
+
};
|
|
5
8
|
declare module '@shikijs/core' {
|
|
6
9
|
interface ShikiTransformerContextMeta {
|
|
7
|
-
twoslash?:
|
|
10
|
+
twoslash?: TwoslashShikiReturn;
|
|
8
11
|
}
|
|
9
12
|
}
|
|
10
13
|
interface TransformerTwoslashOptions {
|
|
@@ -17,7 +20,7 @@ interface TransformerTwoslashOptions {
|
|
|
17
20
|
*
|
|
18
21
|
* @default false
|
|
19
22
|
*/
|
|
20
|
-
explicitTrigger?: boolean;
|
|
23
|
+
explicitTrigger?: boolean | RegExp;
|
|
21
24
|
/**
|
|
22
25
|
* Mapping from language alias to language name
|
|
23
26
|
*/
|
|
@@ -46,15 +49,15 @@ interface TransformerTwoslashOptions {
|
|
|
46
49
|
throws?: boolean;
|
|
47
50
|
}
|
|
48
51
|
interface TwoslashRenderer {
|
|
49
|
-
lineError
|
|
50
|
-
lineCustomTag
|
|
51
|
-
lineQuery
|
|
52
|
-
lineCompletion
|
|
53
|
-
nodeStaticInfo(this: ShikiTransformerContext, info: NodeHover, node: Element | Text)
|
|
54
|
-
nodeError
|
|
55
|
-
nodeQuery
|
|
56
|
-
nodeCompletion
|
|
57
|
-
nodesHighlight
|
|
52
|
+
lineError?: (this: ShikiTransformerContext, error: NodeError) => ElementContent[];
|
|
53
|
+
lineCustomTag?: (this: ShikiTransformerContext, tag: NodeTag) => ElementContent[];
|
|
54
|
+
lineQuery?: (this: ShikiTransformerContext, query: NodeQuery, targetNode?: Element | Text) => ElementContent[];
|
|
55
|
+
lineCompletion?: (this: ShikiTransformerContext, query: NodeCompletion) => ElementContent[];
|
|
56
|
+
nodeStaticInfo: (this: ShikiTransformerContext, info: NodeHover, node: Element | Text) => Partial<ElementContent>;
|
|
57
|
+
nodeError?: (this: ShikiTransformerContext, error: NodeError, node: Element | Text) => Partial<ElementContent>;
|
|
58
|
+
nodeQuery?: (this: ShikiTransformerContext, query: NodeQuery, node: Element | Text) => Partial<ElementContent>;
|
|
59
|
+
nodeCompletion?: (this: ShikiTransformerContext, query: NodeCompletion, node: Element | Text) => Partial<ElementContent>;
|
|
60
|
+
nodesHighlight?: (this: ShikiTransformerContext, highlight: NodeHighlight, nodes: ElementContent[]) => ElementContent[];
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
type CompletionItem = NonNullable<NodeCompletion['completions']>[number];
|
|
@@ -97,6 +100,15 @@ interface RendererRichOptions {
|
|
|
97
100
|
* @default undefined
|
|
98
101
|
*/
|
|
99
102
|
processHoverDocs?: (docs: string) => string;
|
|
103
|
+
/**
|
|
104
|
+
* The way errors should be rendered.
|
|
105
|
+
*
|
|
106
|
+
* - `'line'`: Render the error line after the line of code
|
|
107
|
+
* - `'hover'`: Render the error in the hover popup
|
|
108
|
+
*
|
|
109
|
+
* @default 'line'
|
|
110
|
+
*/
|
|
111
|
+
errorRendering?: 'line' | 'hover';
|
|
100
112
|
/**
|
|
101
113
|
* Classes added to injected elements
|
|
102
114
|
*/
|
|
@@ -109,19 +121,19 @@ interface RendererRichOptions {
|
|
|
109
121
|
/**
|
|
110
122
|
* @deprecated Use `processHoverInfo` instead.
|
|
111
123
|
*/
|
|
112
|
-
formatInfo
|
|
124
|
+
formatInfo?: (info: string) => string;
|
|
113
125
|
/**
|
|
114
126
|
* Custom function to render markdown.
|
|
115
127
|
*
|
|
116
128
|
* By default it pass-through the markdown.
|
|
117
129
|
*/
|
|
118
|
-
renderMarkdown
|
|
130
|
+
renderMarkdown?: (this: ShikiTransformerContextCommon, markdown: string) => ElementContent[];
|
|
119
131
|
/**
|
|
120
132
|
* Custom function to render inline markdown.
|
|
121
133
|
*
|
|
122
134
|
* By default it pass-through the markdown.
|
|
123
135
|
*/
|
|
124
|
-
renderMarkdownInline
|
|
136
|
+
renderMarkdownInline?: (this: ShikiTransformerContextCommon, markdown: string, context: string) => ElementContent[];
|
|
125
137
|
/**
|
|
126
138
|
* Extensions for the genreated HAST tree.
|
|
127
139
|
*/
|
|
@@ -191,6 +203,19 @@ interface RendererRichOptions {
|
|
|
191
203
|
* The token for the error informaton.
|
|
192
204
|
*/
|
|
193
205
|
errorToken?: HastExtension;
|
|
206
|
+
/**
|
|
207
|
+
* The container of the error popup.
|
|
208
|
+
* Only used when `errorRendering` is set to `'hover'`.
|
|
209
|
+
*/
|
|
210
|
+
errorPopup?: HastExtension;
|
|
211
|
+
/**
|
|
212
|
+
* Custom function to compose the error token.
|
|
213
|
+
* Only used when `errorRendering` is set to `'hover'`.
|
|
214
|
+
*/
|
|
215
|
+
errorCompose?: (parts: {
|
|
216
|
+
popup: Element;
|
|
217
|
+
token: Text | Element;
|
|
218
|
+
}) => ElementContent[];
|
|
194
219
|
/**
|
|
195
220
|
* The wrapper for the highlighted nodes.
|
|
196
221
|
*/
|
|
@@ -228,7 +253,7 @@ declare class ShikiTwoslashError extends Error {
|
|
|
228
253
|
*/
|
|
229
254
|
|
|
230
255
|
declare function defaultTwoslashOptions(): TwoslashExecuteOptions;
|
|
231
|
-
type TwoslashFunction = (code: string, lang?: string, options?: TwoslashExecuteOptions) =>
|
|
256
|
+
type TwoslashFunction = (code: string, lang?: string, options?: TwoslashExecuteOptions) => TwoslashShikiReturn;
|
|
232
257
|
declare function createTransformerFactory(defaultTwoslasher: TwoslashFunction, defaultRenderer?: TwoslashRenderer): (options?: TransformerTwoslashOptions) => ShikiTransformer;
|
|
233
258
|
|
|
234
|
-
export { type CompletionItem, type HastExtension, type RendererRichOptions, ShikiTwoslashError, type TransformerTwoslashOptions, type TwoslashRenderer, createTransformerFactory, defaultCompletionIcons, defaultCustomTagIcons, defaultHoverInfoProcessor, defaultTwoslashOptions, rendererClassic, rendererRich };
|
|
259
|
+
export { type CompletionItem, type HastExtension, type RendererRichOptions, ShikiTwoslashError, type TransformerTwoslashOptions, type TwoslashFunction, type TwoslashRenderer, type TwoslashShikiReturn, createTransformerFactory, defaultCompletionIcons, defaultCustomTagIcons, defaultHoverInfoProcessor, defaultTwoslashOptions, rendererClassic, rendererRich };
|
package/dist/core.d.ts
CHANGED
|
@@ -2,9 +2,12 @@ import { TwoslashReturn, twoslasher, TwoslashOptions, NodeError, NodeTag, NodeQu
|
|
|
2
2
|
import { CodeToHastOptions, ShikiTransformerContext, ShikiTransformerContextCommon, ShikiTransformer } from '@shikijs/core';
|
|
3
3
|
import { ElementContent, Element, Text } from 'hast';
|
|
4
4
|
|
|
5
|
+
type TwoslashShikiReturn = Pick<TwoslashReturn, 'nodes' | 'code'> & {
|
|
6
|
+
meta?: Partial<Pick<TwoslashReturn['meta'], 'extension'>>;
|
|
7
|
+
};
|
|
5
8
|
declare module '@shikijs/core' {
|
|
6
9
|
interface ShikiTransformerContextMeta {
|
|
7
|
-
twoslash?:
|
|
10
|
+
twoslash?: TwoslashShikiReturn;
|
|
8
11
|
}
|
|
9
12
|
}
|
|
10
13
|
interface TransformerTwoslashOptions {
|
|
@@ -17,7 +20,7 @@ interface TransformerTwoslashOptions {
|
|
|
17
20
|
*
|
|
18
21
|
* @default false
|
|
19
22
|
*/
|
|
20
|
-
explicitTrigger?: boolean;
|
|
23
|
+
explicitTrigger?: boolean | RegExp;
|
|
21
24
|
/**
|
|
22
25
|
* Mapping from language alias to language name
|
|
23
26
|
*/
|
|
@@ -46,15 +49,15 @@ interface TransformerTwoslashOptions {
|
|
|
46
49
|
throws?: boolean;
|
|
47
50
|
}
|
|
48
51
|
interface TwoslashRenderer {
|
|
49
|
-
lineError
|
|
50
|
-
lineCustomTag
|
|
51
|
-
lineQuery
|
|
52
|
-
lineCompletion
|
|
53
|
-
nodeStaticInfo(this: ShikiTransformerContext, info: NodeHover, node: Element | Text)
|
|
54
|
-
nodeError
|
|
55
|
-
nodeQuery
|
|
56
|
-
nodeCompletion
|
|
57
|
-
nodesHighlight
|
|
52
|
+
lineError?: (this: ShikiTransformerContext, error: NodeError) => ElementContent[];
|
|
53
|
+
lineCustomTag?: (this: ShikiTransformerContext, tag: NodeTag) => ElementContent[];
|
|
54
|
+
lineQuery?: (this: ShikiTransformerContext, query: NodeQuery, targetNode?: Element | Text) => ElementContent[];
|
|
55
|
+
lineCompletion?: (this: ShikiTransformerContext, query: NodeCompletion) => ElementContent[];
|
|
56
|
+
nodeStaticInfo: (this: ShikiTransformerContext, info: NodeHover, node: Element | Text) => Partial<ElementContent>;
|
|
57
|
+
nodeError?: (this: ShikiTransformerContext, error: NodeError, node: Element | Text) => Partial<ElementContent>;
|
|
58
|
+
nodeQuery?: (this: ShikiTransformerContext, query: NodeQuery, node: Element | Text) => Partial<ElementContent>;
|
|
59
|
+
nodeCompletion?: (this: ShikiTransformerContext, query: NodeCompletion, node: Element | Text) => Partial<ElementContent>;
|
|
60
|
+
nodesHighlight?: (this: ShikiTransformerContext, highlight: NodeHighlight, nodes: ElementContent[]) => ElementContent[];
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
type CompletionItem = NonNullable<NodeCompletion['completions']>[number];
|
|
@@ -97,6 +100,15 @@ interface RendererRichOptions {
|
|
|
97
100
|
* @default undefined
|
|
98
101
|
*/
|
|
99
102
|
processHoverDocs?: (docs: string) => string;
|
|
103
|
+
/**
|
|
104
|
+
* The way errors should be rendered.
|
|
105
|
+
*
|
|
106
|
+
* - `'line'`: Render the error line after the line of code
|
|
107
|
+
* - `'hover'`: Render the error in the hover popup
|
|
108
|
+
*
|
|
109
|
+
* @default 'line'
|
|
110
|
+
*/
|
|
111
|
+
errorRendering?: 'line' | 'hover';
|
|
100
112
|
/**
|
|
101
113
|
* Classes added to injected elements
|
|
102
114
|
*/
|
|
@@ -109,19 +121,19 @@ interface RendererRichOptions {
|
|
|
109
121
|
/**
|
|
110
122
|
* @deprecated Use `processHoverInfo` instead.
|
|
111
123
|
*/
|
|
112
|
-
formatInfo
|
|
124
|
+
formatInfo?: (info: string) => string;
|
|
113
125
|
/**
|
|
114
126
|
* Custom function to render markdown.
|
|
115
127
|
*
|
|
116
128
|
* By default it pass-through the markdown.
|
|
117
129
|
*/
|
|
118
|
-
renderMarkdown
|
|
130
|
+
renderMarkdown?: (this: ShikiTransformerContextCommon, markdown: string) => ElementContent[];
|
|
119
131
|
/**
|
|
120
132
|
* Custom function to render inline markdown.
|
|
121
133
|
*
|
|
122
134
|
* By default it pass-through the markdown.
|
|
123
135
|
*/
|
|
124
|
-
renderMarkdownInline
|
|
136
|
+
renderMarkdownInline?: (this: ShikiTransformerContextCommon, markdown: string, context: string) => ElementContent[];
|
|
125
137
|
/**
|
|
126
138
|
* Extensions for the genreated HAST tree.
|
|
127
139
|
*/
|
|
@@ -191,6 +203,19 @@ interface RendererRichOptions {
|
|
|
191
203
|
* The token for the error informaton.
|
|
192
204
|
*/
|
|
193
205
|
errorToken?: HastExtension;
|
|
206
|
+
/**
|
|
207
|
+
* The container of the error popup.
|
|
208
|
+
* Only used when `errorRendering` is set to `'hover'`.
|
|
209
|
+
*/
|
|
210
|
+
errorPopup?: HastExtension;
|
|
211
|
+
/**
|
|
212
|
+
* Custom function to compose the error token.
|
|
213
|
+
* Only used when `errorRendering` is set to `'hover'`.
|
|
214
|
+
*/
|
|
215
|
+
errorCompose?: (parts: {
|
|
216
|
+
popup: Element;
|
|
217
|
+
token: Text | Element;
|
|
218
|
+
}) => ElementContent[];
|
|
194
219
|
/**
|
|
195
220
|
* The wrapper for the highlighted nodes.
|
|
196
221
|
*/
|
|
@@ -228,7 +253,7 @@ declare class ShikiTwoslashError extends Error {
|
|
|
228
253
|
*/
|
|
229
254
|
|
|
230
255
|
declare function defaultTwoslashOptions(): TwoslashExecuteOptions;
|
|
231
|
-
type TwoslashFunction = (code: string, lang?: string, options?: TwoslashExecuteOptions) =>
|
|
256
|
+
type TwoslashFunction = (code: string, lang?: string, options?: TwoslashExecuteOptions) => TwoslashShikiReturn;
|
|
232
257
|
declare function createTransformerFactory(defaultTwoslasher: TwoslashFunction, defaultRenderer?: TwoslashRenderer): (options?: TransformerTwoslashOptions) => ShikiTransformer;
|
|
233
258
|
|
|
234
|
-
export { type CompletionItem, type HastExtension, type RendererRichOptions, ShikiTwoslashError, type TransformerTwoslashOptions, type TwoslashRenderer, createTransformerFactory, defaultCompletionIcons, defaultCustomTagIcons, defaultHoverInfoProcessor, defaultTwoslashOptions, rendererClassic, rendererRich };
|
|
259
|
+
export { type CompletionItem, type HastExtension, type RendererRichOptions, ShikiTwoslashError, type TransformerTwoslashOptions, type TwoslashFunction, type TwoslashRenderer, type TwoslashShikiReturn, createTransformerFactory, defaultCompletionIcons, defaultCustomTagIcons, defaultHoverInfoProcessor, defaultTwoslashOptions, rendererClassic, rendererRich };
|
package/dist/core.mjs
CHANGED
|
@@ -404,6 +404,7 @@ function rendererRich(options = {}) {
|
|
|
404
404
|
processHoverDocs = (docs) => docs,
|
|
405
405
|
classExtra = "",
|
|
406
406
|
jsdoc = true,
|
|
407
|
+
errorRendering = "line",
|
|
407
408
|
renderMarkdown = renderMarkdownPassThrough,
|
|
408
409
|
renderMarkdownInline = renderMarkdownPassThrough,
|
|
409
410
|
hast
|
|
@@ -646,26 +647,61 @@ function rendererRich(options = {}) {
|
|
|
646
647
|
}
|
|
647
648
|
);
|
|
648
649
|
},
|
|
649
|
-
nodeError(
|
|
650
|
+
nodeError(error, node) {
|
|
651
|
+
if (errorRendering !== "hover") {
|
|
652
|
+
return extend(
|
|
653
|
+
hast?.errorToken,
|
|
654
|
+
{
|
|
655
|
+
type: "element",
|
|
656
|
+
tagName: "span",
|
|
657
|
+
properties: {
|
|
658
|
+
class: [`twoslash-error`, getErrorLevelClass(error)].filter(Boolean).join(" ")
|
|
659
|
+
},
|
|
660
|
+
children: [node]
|
|
661
|
+
}
|
|
662
|
+
);
|
|
663
|
+
}
|
|
664
|
+
const popup = extend(
|
|
665
|
+
hast?.errorPopup,
|
|
666
|
+
{
|
|
667
|
+
type: "element",
|
|
668
|
+
tagName: "span",
|
|
669
|
+
properties: {
|
|
670
|
+
class: ["twoslash-popup-container", classExtra].filter(Boolean).join(" ")
|
|
671
|
+
},
|
|
672
|
+
children: [
|
|
673
|
+
{
|
|
674
|
+
type: "element",
|
|
675
|
+
tagName: "div",
|
|
676
|
+
properties: {
|
|
677
|
+
class: "twoslash-popup-error"
|
|
678
|
+
},
|
|
679
|
+
children: renderMarkdown.call(this, error.text)
|
|
680
|
+
}
|
|
681
|
+
]
|
|
682
|
+
}
|
|
683
|
+
);
|
|
650
684
|
return extend(
|
|
651
685
|
hast?.errorToken,
|
|
652
686
|
{
|
|
653
687
|
type: "element",
|
|
654
688
|
tagName: "span",
|
|
655
689
|
properties: {
|
|
656
|
-
class:
|
|
690
|
+
class: `twoslash-error twoslash-error-hover ${getErrorLevelClass(error)}`
|
|
657
691
|
},
|
|
658
|
-
children: [node]
|
|
692
|
+
children: hast?.errorCompose ? hast?.errorCompose({ popup, token: node }) : [popup, node]
|
|
659
693
|
}
|
|
660
694
|
);
|
|
661
695
|
},
|
|
662
696
|
lineError(error) {
|
|
697
|
+
if (errorRendering !== "line")
|
|
698
|
+
return [];
|
|
663
699
|
return [
|
|
664
700
|
{
|
|
665
701
|
type: "element",
|
|
666
702
|
tagName: "div",
|
|
667
703
|
properties: {
|
|
668
|
-
class: ["twoslash-meta-line twoslash-error-line", classExtra].filter(Boolean).join(" ")
|
|
704
|
+
class: ["twoslash-meta-line twoslash-error-line", getErrorLevelClass(error), classExtra].filter(Boolean).join(" ")
|
|
669
705
|
},
|
|
670
706
|
children: [
|
|
671
707
|
{
|
|
@@ -728,6 +764,18 @@ function defaultHoverInfoProcessor(type) {
|
|
|
728
764
|
content = `function ${content}`;
|
|
729
765
|
return content;
|
|
730
766
|
}
|
|
767
|
+
function getErrorLevelClass(error) {
|
|
768
|
+
switch (error.level) {
|
|
769
|
+
case 0:
|
|
770
|
+
return "twoslash-error-level-warning";
|
|
771
|
+
case 1:
|
|
772
|
+
return "";
|
|
773
|
+
case 2:
|
|
774
|
+
return "twoslash-error-level-suggestion";
|
|
775
|
+
default:
|
|
776
|
+
return "twoslash-error-level-info";
|
|
777
|
+
}
|
|
778
|
+
}
|
|
731
779
|
|
|
732
780
|
function rendererClassic() {
|
|
733
781
|
return {
|
|
@@ -926,9 +974,10 @@ function createTransformerFactory(defaultTwoslasher, defaultRenderer) {
|
|
|
926
974
|
renderer = defaultRenderer,
|
|
927
975
|
throws = true
|
|
928
976
|
} = options;
|
|
977
|
+
const trigger = explicitTrigger instanceof RegExp ? explicitTrigger : /\btwoslash\b/;
|
|
929
978
|
if (!renderer)
|
|
930
979
|
throw new ShikiTwoslashError("Missing renderer");
|
|
931
|
-
const filter = options.filter || ((lang, _, options2) => langs.includes(lang) && (!explicitTrigger ||
|
|
980
|
+
const filter = options.filter || ((lang, _, options2) => langs.includes(lang) && (!explicitTrigger || trigger.test(options2.meta?.__raw || "")));
|
|
932
981
|
return {
|
|
933
982
|
preprocess(code) {
|
|
934
983
|
let lang = this.options.lang;
|
|
@@ -937,7 +986,7 @@ function createTransformerFactory(defaultTwoslasher, defaultRenderer) {
|
|
|
937
986
|
if (filter(lang, code, this.options)) {
|
|
938
987
|
const twoslash = twoslasher(code, lang, twoslashOptions);
|
|
939
988
|
this.meta.twoslash = twoslash;
|
|
940
|
-
this.options.lang = twoslash.meta
|
|
989
|
+
this.options.lang = twoslash.meta?.extension || lang;
|
|
941
990
|
return twoslash.code;
|
|
942
991
|
}
|
|
943
992
|
},
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _shikijs_core_dist_chunk_tokens_mjs from '@shikijs/core/dist/chunk-tokens.mjs';
|
|
2
2
|
import { CreateTwoslashOptions } from 'twoslash';
|
|
3
3
|
import { TransformerTwoslashOptions, RendererRichOptions } from './core.mjs';
|
|
4
|
-
export { CompletionItem, HastExtension, ShikiTwoslashError, TwoslashRenderer, createTransformerFactory, defaultCompletionIcons, defaultCustomTagIcons, defaultHoverInfoProcessor, defaultTwoslashOptions, rendererClassic, rendererRich } from './core.mjs';
|
|
4
|
+
export { CompletionItem, HastExtension, ShikiTwoslashError, TwoslashFunction, TwoslashRenderer, TwoslashShikiReturn, createTransformerFactory, defaultCompletionIcons, defaultCustomTagIcons, defaultHoverInfoProcessor, defaultTwoslashOptions, rendererClassic, rendererRich } from './core.mjs';
|
|
5
5
|
import '@shikijs/core';
|
|
6
6
|
import 'hast';
|
|
7
7
|
|
|
@@ -16,6 +16,6 @@ interface TransformerTwoslashIndexOptions extends TransformerTwoslashOptions, Pi
|
|
|
16
16
|
/**
|
|
17
17
|
* Factory function to create a Shiki transformer for twoslash integrations.
|
|
18
18
|
*/
|
|
19
|
-
declare function transformerTwoslash(options?: TransformerTwoslashIndexOptions): _shikijs_core_dist_chunk_tokens_mjs.
|
|
19
|
+
declare function transformerTwoslash(options?: TransformerTwoslashIndexOptions): _shikijs_core_dist_chunk_tokens_mjs.A;
|
|
20
20
|
|
|
21
21
|
export { RendererRichOptions, type TransformerTwoslashIndexOptions, TransformerTwoslashOptions, transformerTwoslash };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _shikijs_core_dist_chunk_tokens_mjs from '@shikijs/core/dist/chunk-tokens.mjs';
|
|
2
2
|
import { CreateTwoslashOptions } from 'twoslash';
|
|
3
3
|
import { TransformerTwoslashOptions, RendererRichOptions } from './core.js';
|
|
4
|
-
export { CompletionItem, HastExtension, ShikiTwoslashError, TwoslashRenderer, createTransformerFactory, defaultCompletionIcons, defaultCustomTagIcons, defaultHoverInfoProcessor, defaultTwoslashOptions, rendererClassic, rendererRich } from './core.js';
|
|
4
|
+
export { CompletionItem, HastExtension, ShikiTwoslashError, TwoslashFunction, TwoslashRenderer, TwoslashShikiReturn, createTransformerFactory, defaultCompletionIcons, defaultCustomTagIcons, defaultHoverInfoProcessor, defaultTwoslashOptions, rendererClassic, rendererRich } from './core.js';
|
|
5
5
|
import '@shikijs/core';
|
|
6
6
|
import 'hast';
|
|
7
7
|
|
|
@@ -16,6 +16,6 @@ interface TransformerTwoslashIndexOptions extends TransformerTwoslashOptions, Pi
|
|
|
16
16
|
/**
|
|
17
17
|
* Factory function to create a Shiki transformer for twoslash integrations.
|
|
18
18
|
*/
|
|
19
|
-
declare function transformerTwoslash(options?: TransformerTwoslashIndexOptions): _shikijs_core_dist_chunk_tokens_mjs.
|
|
19
|
+
declare function transformerTwoslash(options?: TransformerTwoslashIndexOptions): _shikijs_core_dist_chunk_tokens_mjs.A;
|
|
20
20
|
|
|
21
21
|
export { RendererRichOptions, type TransformerTwoslashIndexOptions, TransformerTwoslashOptions, transformerTwoslash };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shikijs/twoslash",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.6",
|
|
5
5
|
"description": "Shiki transformer for twoslash",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"dist"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"twoslash": "^0.1.
|
|
53
|
-
"@shikijs/core": "1.0.0-beta.
|
|
52
|
+
"twoslash": "^0.1.1",
|
|
53
|
+
"@shikijs/core": "1.0.0-beta.6"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@iconify-json/carbon": "^1.1.28",
|
package/style-rich.css
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
--twoslash-highlighted-bg: #c37d0d20;
|
|
7
7
|
--twoslash-popup-bg: #f8f8f8;
|
|
8
8
|
--twoslash-popup-color: inherit;
|
|
9
|
-
--twoslash-popup-shadow: rgba(0, 0, 0.08) 0px 1px 4px;
|
|
9
|
+
--twoslash-popup-shadow: rgba(0, 0, 0, 0.08) 0px 1px 4px;
|
|
10
10
|
--twoslash-docs-color: #888;
|
|
11
11
|
--twoslash-docs-font: sans-serif;
|
|
12
12
|
--twoslash-code-font: inherit;
|
|
@@ -16,10 +16,12 @@
|
|
|
16
16
|
--twoslash-cursor-color: #8888;
|
|
17
17
|
--twoslash-error-color: #d45656;
|
|
18
18
|
--twoslash-error-bg: #d4565620;
|
|
19
|
+
--twoslash-warn-color: #c37d0d;
|
|
20
|
+
--twoslash-warn-bg: #c37d0d20;
|
|
19
21
|
--twoslash-tag-color: #3772cf;
|
|
20
22
|
--twoslash-tag-bg: #3772cf20;
|
|
21
|
-
--twoslash-tag-warn-color:
|
|
22
|
-
--twoslash-tag-warn-bg:
|
|
23
|
+
--twoslash-tag-warn-color: var(--twoslash-warn-color);
|
|
24
|
+
--twoslash-tag-warn-bg: var(--twoslash-warn-bg);
|
|
23
25
|
--twoslash-tag-annotate-color: #1ba673;
|
|
24
26
|
--twoslash-tag-annotate-bg: #1ba67320;
|
|
25
27
|
}
|
|
@@ -67,6 +69,7 @@
|
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
.twoslash .twoslash-hover:hover .twoslash-popup-container,
|
|
72
|
+
.twoslash .twoslash-error-hover:hover .twoslash-popup-container,
|
|
70
73
|
.twoslash .twoslash-query-presisted .twoslash-popup-container {
|
|
71
74
|
opacity: 1;
|
|
72
75
|
pointer-events: auto;
|
|
@@ -90,6 +93,7 @@
|
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
.twoslash .twoslash-popup-code,
|
|
96
|
+
.twoslash .twoslash-popup-error,
|
|
93
97
|
.twoslash .twoslash-popup-docs {
|
|
94
98
|
padding: 6px 8px !important;
|
|
95
99
|
}
|
|
@@ -106,6 +110,13 @@
|
|
|
106
110
|
border-top: 1px solid var(--twoslash-border-color);
|
|
107
111
|
}
|
|
108
112
|
|
|
113
|
+
.twoslash .twoslash-popup-error {
|
|
114
|
+
color: var(--twoslash-error-color);
|
|
115
|
+
background-color: var(--twoslash-error-bg);
|
|
116
|
+
font-family: var(--twoslash-docs-font);
|
|
117
|
+
font-size: 0.8em;
|
|
118
|
+
}
|
|
119
|
+
|
|
109
120
|
.twoslash .twoslash-popup-docs-tags {
|
|
110
121
|
display: flex;
|
|
111
122
|
flex-direction: column;
|
|
@@ -129,6 +140,14 @@
|
|
|
129
140
|
color: var(--twoslash-error-color);
|
|
130
141
|
padding: 6px 12px;
|
|
131
142
|
margin: 0.2em 0;
|
|
143
|
+
min-width: 100%;
|
|
144
|
+
width: max-content;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.twoslash .twoslash-error-line.twoslash-error-level-warning {
|
|
148
|
+
background-color: var(--twoslash-warn-bg);
|
|
149
|
+
border-left: 3px solid var(--twoslash-warn-color);
|
|
150
|
+
color: var(--twoslash-warn-color);
|
|
132
151
|
}
|
|
133
152
|
|
|
134
153
|
.twoslash .twoslash-error {
|
|
@@ -137,6 +156,12 @@
|
|
|
137
156
|
padding-bottom: 2px;
|
|
138
157
|
}
|
|
139
158
|
|
|
159
|
+
.twoslash .twoslash-error.twoslash-error-level-warning {
|
|
160
|
+
background: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%206%203'%20enable-background%3D'new%200%200%206%203'%20height%3D'3'%20width%3D'6'%3E%3Cg%20fill%3D'%23c37d0d'%3E%3Cpolygon%20points%3D'5.5%2C0%202.5%2C3%201.1%2C3%204.1%2C0'%2F%3E%3Cpolygon%20points%3D'4%2C0%206%2C2%206%2C0.6%205.4%2C0'%2F%3E%3Cpolygon%20points%3D'0%2C2%201%2C3%202.4%2C3%200%2C0.6'%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E")
|
|
161
|
+
repeat-x bottom left;
|
|
162
|
+
padding-bottom: 2px;
|
|
163
|
+
}
|
|
164
|
+
|
|
140
165
|
/* ===== Completeions ===== */
|
|
141
166
|
.twoslash .twoslash-completion-cursor {
|
|
142
167
|
position: relative;
|
|
@@ -227,6 +252,8 @@
|
|
|
227
252
|
display: flex;
|
|
228
253
|
align-items: center;
|
|
229
254
|
gap: 0.3em;
|
|
255
|
+
min-width: 100%;
|
|
256
|
+
width: max-content;
|
|
230
257
|
}
|
|
231
258
|
|
|
232
259
|
.twoslash .twoslash-tag-line .twoslash-tag-icon {
|