nimbus-docs 0.1.3 → 0.1.4
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/cli/index.js +1 -1
- package/dist/content.d.ts +5 -74
- package/dist/content.d.ts.map +1 -1
- package/dist/content.js +2 -2
- package/dist/content.js.map +1 -1
- package/dist/index.d.ts +925 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -18
- package/dist/index.js.map +1 -1
- package/dist/schemas.d.ts +53 -147
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +108 -30
- package/dist/schemas.js.map +1 -1
- package/dist/strict-keys-D06tc9YZ.js +35 -0
- package/dist/strict-keys-D06tc9YZ.js.map +1 -0
- package/dist/types.d.ts +53 -19
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/NimbusHead.astro +0 -4
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import mdx from "@astrojs/mdx";
|
|
|
3
3
|
import * as astro_content0 from "astro:content";
|
|
4
4
|
import { CollectionEntry } from "astro:content";
|
|
5
5
|
import { AstroGlobal, AstroIntegration, GetStaticPaths } from "astro";
|
|
6
|
-
import { ShikiTransformer } from "shiki";
|
|
7
6
|
|
|
8
7
|
//#region src/_internal/content.d.ts
|
|
9
8
|
/**
|
|
@@ -96,6 +95,923 @@ interface NimbusIntegrationOptions {
|
|
|
96
95
|
}
|
|
97
96
|
declare function nimbus(rawConfig: NimbusConfig, options?: NimbusIntegrationOptions): AstroIntegration;
|
|
98
97
|
//#endregion
|
|
98
|
+
//#region ../../../../node_modules/@types/unist/index.d.ts
|
|
99
|
+
// ## Interfaces
|
|
100
|
+
/**
|
|
101
|
+
* Info associated with nodes by the ecosystem.
|
|
102
|
+
*
|
|
103
|
+
* This space is guaranteed to never be specified by unist or specifications
|
|
104
|
+
* implementing unist.
|
|
105
|
+
* But you can use it in utilities and plugins to store data.
|
|
106
|
+
*
|
|
107
|
+
* This type can be augmented to register custom data.
|
|
108
|
+
* For example:
|
|
109
|
+
*
|
|
110
|
+
* ```ts
|
|
111
|
+
* declare module 'unist' {
|
|
112
|
+
* interface Data {
|
|
113
|
+
* // `someNode.data.myId` is typed as `number | undefined`
|
|
114
|
+
* myId?: number | undefined
|
|
115
|
+
* }
|
|
116
|
+
* }
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
interface Data$1 {}
|
|
120
|
+
/**
|
|
121
|
+
* One place in a source file.
|
|
122
|
+
*/
|
|
123
|
+
interface Point {
|
|
124
|
+
/**
|
|
125
|
+
* Line in a source file (1-indexed integer).
|
|
126
|
+
*/
|
|
127
|
+
line: number;
|
|
128
|
+
/**
|
|
129
|
+
* Column in a source file (1-indexed integer).
|
|
130
|
+
*/
|
|
131
|
+
column: number;
|
|
132
|
+
/**
|
|
133
|
+
* Character in a source file (0-indexed integer).
|
|
134
|
+
*/
|
|
135
|
+
offset?: number | undefined;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Position of a node in a source document.
|
|
139
|
+
*
|
|
140
|
+
* A position is a range between two points.
|
|
141
|
+
*/
|
|
142
|
+
interface Position$1 {
|
|
143
|
+
/**
|
|
144
|
+
* Place of the first character of the parsed source region.
|
|
145
|
+
*/
|
|
146
|
+
start: Point;
|
|
147
|
+
/**
|
|
148
|
+
* Place of the first character after the parsed source region.
|
|
149
|
+
*/
|
|
150
|
+
end: Point;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Abstract unist node.
|
|
154
|
+
*
|
|
155
|
+
* The syntactic unit in unist syntax trees are called nodes.
|
|
156
|
+
*
|
|
157
|
+
* This interface is supposed to be extended.
|
|
158
|
+
* If you can use {@link Literal} or {@link Parent}, you should.
|
|
159
|
+
* But for example in markdown, a `thematicBreak` (`***`), is neither literal
|
|
160
|
+
* nor parent, but still a node.
|
|
161
|
+
*/
|
|
162
|
+
interface Node$1 {
|
|
163
|
+
/**
|
|
164
|
+
* Node type.
|
|
165
|
+
*/
|
|
166
|
+
type: string;
|
|
167
|
+
/**
|
|
168
|
+
* Info from the ecosystem.
|
|
169
|
+
*/
|
|
170
|
+
data?: Data$1 | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* Position of a node in a source document.
|
|
173
|
+
*
|
|
174
|
+
* Nodes that are generated (not in the original source document) must not
|
|
175
|
+
* have a position.
|
|
176
|
+
*/
|
|
177
|
+
position?: Position$1 | undefined;
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region ../../../../node_modules/@types/hast/index.d.ts
|
|
181
|
+
// ## Interfaces
|
|
182
|
+
/**
|
|
183
|
+
* Info associated with hast nodes by the ecosystem.
|
|
184
|
+
*
|
|
185
|
+
* This space is guaranteed to never be specified by unist or hast.
|
|
186
|
+
* But you can use it in utilities and plugins to store data.
|
|
187
|
+
*
|
|
188
|
+
* This type can be augmented to register custom data.
|
|
189
|
+
* For example:
|
|
190
|
+
*
|
|
191
|
+
* ```ts
|
|
192
|
+
* declare module 'hast' {
|
|
193
|
+
* interface Data {
|
|
194
|
+
* // `someNode.data.myId` is typed as `number | undefined`
|
|
195
|
+
* myId?: number | undefined
|
|
196
|
+
* }
|
|
197
|
+
* }
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
interface Data extends Data$1 {}
|
|
201
|
+
/**
|
|
202
|
+
* Info associated with an element.
|
|
203
|
+
*/
|
|
204
|
+
interface Properties {
|
|
205
|
+
[PropertyName: string]: boolean | number | string | null | undefined | Array<string | number>;
|
|
206
|
+
}
|
|
207
|
+
// ## Content maps
|
|
208
|
+
/**
|
|
209
|
+
* Union of registered hast nodes that can occur in {@link Element}.
|
|
210
|
+
*
|
|
211
|
+
* To register mote custom hast nodes, add them to {@link ElementContentMap}.
|
|
212
|
+
* They will be automatically added here.
|
|
213
|
+
*/
|
|
214
|
+
type ElementContent = ElementContentMap[keyof ElementContentMap];
|
|
215
|
+
/**
|
|
216
|
+
* Registry of all hast nodes that can occur as children of {@link Element}.
|
|
217
|
+
*
|
|
218
|
+
* For a union of all {@link Element} children, see {@link ElementContent}.
|
|
219
|
+
*/
|
|
220
|
+
interface ElementContentMap {
|
|
221
|
+
comment: Comment;
|
|
222
|
+
element: Element;
|
|
223
|
+
text: Text;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Union of registered hast nodes that can occur in {@link Root}.
|
|
227
|
+
*
|
|
228
|
+
* To register custom hast nodes, add them to {@link RootContentMap}.
|
|
229
|
+
* They will be automatically added here.
|
|
230
|
+
*/
|
|
231
|
+
type RootContent = RootContentMap[keyof RootContentMap];
|
|
232
|
+
/**
|
|
233
|
+
* Registry of all hast nodes that can occur as children of {@link Root}.
|
|
234
|
+
*
|
|
235
|
+
* > 👉 **Note**: {@link Root} does not need to be an entire document.
|
|
236
|
+
* > it can also be a fragment.
|
|
237
|
+
*
|
|
238
|
+
* For a union of all {@link Root} children, see {@link RootContent}.
|
|
239
|
+
*/
|
|
240
|
+
interface RootContentMap {
|
|
241
|
+
comment: Comment;
|
|
242
|
+
doctype: Doctype;
|
|
243
|
+
element: Element;
|
|
244
|
+
text: Text;
|
|
245
|
+
}
|
|
246
|
+
// ## Abstract nodes
|
|
247
|
+
/**
|
|
248
|
+
* Abstract hast node.
|
|
249
|
+
*
|
|
250
|
+
* This interface is supposed to be extended.
|
|
251
|
+
* If you can use {@link Literal} or {@link Parent}, you should.
|
|
252
|
+
* But for example in HTML, a `Doctype` is neither literal nor parent, but
|
|
253
|
+
* still a node.
|
|
254
|
+
*
|
|
255
|
+
* To register custom hast nodes, add them to {@link RootContentMap} and other
|
|
256
|
+
* places where relevant (such as {@link ElementContentMap}).
|
|
257
|
+
*
|
|
258
|
+
* For a union of all registered hast nodes, see {@link Nodes}.
|
|
259
|
+
*/
|
|
260
|
+
interface Node extends Node$1 {
|
|
261
|
+
/**
|
|
262
|
+
* Info from the ecosystem.
|
|
263
|
+
*/
|
|
264
|
+
data?: Data | undefined;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Abstract hast node that contains the smallest possible value.
|
|
268
|
+
*
|
|
269
|
+
* This interface is supposed to be extended if you make custom hast nodes.
|
|
270
|
+
*
|
|
271
|
+
* For a union of all registered hast literals, see {@link Literals}.
|
|
272
|
+
*/
|
|
273
|
+
interface Literal extends Node {
|
|
274
|
+
/**
|
|
275
|
+
* Plain-text value.
|
|
276
|
+
*/
|
|
277
|
+
value: string;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Abstract hast node that contains other hast nodes (*children*).
|
|
281
|
+
*
|
|
282
|
+
* This interface is supposed to be extended if you make custom hast nodes.
|
|
283
|
+
*
|
|
284
|
+
* For a union of all registered hast parents, see {@link Parents}.
|
|
285
|
+
*/
|
|
286
|
+
interface Parent extends Node {
|
|
287
|
+
/**
|
|
288
|
+
* List of children.
|
|
289
|
+
*/
|
|
290
|
+
children: RootContent[];
|
|
291
|
+
}
|
|
292
|
+
// ## Concrete nodes
|
|
293
|
+
/**
|
|
294
|
+
* HTML comment.
|
|
295
|
+
*/
|
|
296
|
+
interface Comment extends Literal {
|
|
297
|
+
/**
|
|
298
|
+
* Node type of HTML comments in hast.
|
|
299
|
+
*/
|
|
300
|
+
type: "comment";
|
|
301
|
+
/**
|
|
302
|
+
* Data associated with the comment.
|
|
303
|
+
*/
|
|
304
|
+
data?: CommentData | undefined;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Info associated with hast comments by the ecosystem.
|
|
308
|
+
*/
|
|
309
|
+
interface CommentData extends Data {}
|
|
310
|
+
/**
|
|
311
|
+
* HTML document type.
|
|
312
|
+
*/
|
|
313
|
+
interface Doctype extends Node$1 {
|
|
314
|
+
/**
|
|
315
|
+
* Node type of HTML document types in hast.
|
|
316
|
+
*/
|
|
317
|
+
type: "doctype";
|
|
318
|
+
/**
|
|
319
|
+
* Data associated with the doctype.
|
|
320
|
+
*/
|
|
321
|
+
data?: DoctypeData | undefined;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Info associated with hast doctypes by the ecosystem.
|
|
325
|
+
*/
|
|
326
|
+
interface DoctypeData extends Data {}
|
|
327
|
+
/**
|
|
328
|
+
* HTML element.
|
|
329
|
+
*/
|
|
330
|
+
interface Element extends Parent {
|
|
331
|
+
/**
|
|
332
|
+
* Node type of elements.
|
|
333
|
+
*/
|
|
334
|
+
type: "element";
|
|
335
|
+
/**
|
|
336
|
+
* Tag name (such as `'body'`) of the element.
|
|
337
|
+
*/
|
|
338
|
+
tagName: string;
|
|
339
|
+
/**
|
|
340
|
+
* Info associated with the element.
|
|
341
|
+
*/
|
|
342
|
+
properties: Properties;
|
|
343
|
+
/**
|
|
344
|
+
* Children of element.
|
|
345
|
+
*/
|
|
346
|
+
children: ElementContent[];
|
|
347
|
+
/**
|
|
348
|
+
* When the `tagName` field is `'template'`, a `content` field can be
|
|
349
|
+
* present.
|
|
350
|
+
*/
|
|
351
|
+
content?: Root | undefined;
|
|
352
|
+
/**
|
|
353
|
+
* Data associated with the element.
|
|
354
|
+
*/
|
|
355
|
+
data?: ElementData | undefined;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Info associated with hast elements by the ecosystem.
|
|
359
|
+
*/
|
|
360
|
+
interface ElementData extends Data {}
|
|
361
|
+
/**
|
|
362
|
+
* Document fragment or a whole document.
|
|
363
|
+
*
|
|
364
|
+
* Should be used as the root of a tree and must not be used as a child.
|
|
365
|
+
*
|
|
366
|
+
* Can also be used as the value for the content field on a `'template'` element.
|
|
367
|
+
*/
|
|
368
|
+
interface Root extends Parent {
|
|
369
|
+
/**
|
|
370
|
+
* Node type of hast root.
|
|
371
|
+
*/
|
|
372
|
+
type: "root";
|
|
373
|
+
/**
|
|
374
|
+
* Children of root.
|
|
375
|
+
*/
|
|
376
|
+
children: RootContent[];
|
|
377
|
+
/**
|
|
378
|
+
* Data associated with the hast root.
|
|
379
|
+
*/
|
|
380
|
+
data?: RootData | undefined;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Info associated with hast root nodes by the ecosystem.
|
|
384
|
+
*/
|
|
385
|
+
interface RootData extends Data {}
|
|
386
|
+
/**
|
|
387
|
+
* HTML character data (plain text).
|
|
388
|
+
*/
|
|
389
|
+
interface Text extends Literal {
|
|
390
|
+
/**
|
|
391
|
+
* Node type of HTML character data (plain text) in hast.
|
|
392
|
+
*/
|
|
393
|
+
type: "text";
|
|
394
|
+
/**
|
|
395
|
+
* Data associated with the text.
|
|
396
|
+
*/
|
|
397
|
+
data?: TextData | undefined;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Info associated with hast texts by the ecosystem.
|
|
401
|
+
*/
|
|
402
|
+
interface TextData extends Data {}
|
|
403
|
+
//#endregion
|
|
404
|
+
//#region ../../../../node_modules/@shikijs/vscode-textmate/dist/index.d.ts
|
|
405
|
+
/**
|
|
406
|
+
* An expression language of ScopePathStr with a binary comma (to indicate alternatives) operator.
|
|
407
|
+
* Examples: `foo.bar boo.baz,quick quack`
|
|
408
|
+
*/
|
|
409
|
+
type ScopePattern = string;
|
|
410
|
+
/**
|
|
411
|
+
* A TextMate theme.
|
|
412
|
+
*/
|
|
413
|
+
interface IRawTheme {
|
|
414
|
+
readonly name?: string;
|
|
415
|
+
readonly settings: IRawThemeSetting[];
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* A single theme setting.
|
|
419
|
+
*/
|
|
420
|
+
interface IRawThemeSetting {
|
|
421
|
+
readonly name?: string;
|
|
422
|
+
readonly scope?: ScopePattern | ScopePattern[];
|
|
423
|
+
readonly settings: {
|
|
424
|
+
readonly fontStyle?: string;
|
|
425
|
+
readonly foreground?: string;
|
|
426
|
+
readonly background?: string;
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
declare const enum FontStyle {
|
|
430
|
+
NotSet = -1,
|
|
431
|
+
None = 0,
|
|
432
|
+
Italic = 1,
|
|
433
|
+
Bold = 2,
|
|
434
|
+
Underline = 4,
|
|
435
|
+
Strikethrough = 8
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* **IMPORTANT** - Immutable!
|
|
439
|
+
*/
|
|
440
|
+
interface StateStack {
|
|
441
|
+
_stackElementBrand: void;
|
|
442
|
+
readonly depth: number;
|
|
443
|
+
clone(): StateStack;
|
|
444
|
+
equals(other: StateStack): boolean;
|
|
445
|
+
}
|
|
446
|
+
//#endregion
|
|
447
|
+
//#region ../../../../node_modules/@shikijs/types/dist/index.d.mts
|
|
448
|
+
interface Nothing {}
|
|
449
|
+
/**
|
|
450
|
+
* type StringLiteralUnion<'foo'> = 'foo' | string
|
|
451
|
+
* This has auto completion whereas `'foo' | string` doesn't
|
|
452
|
+
* Adapted from https://github.com/microsoft/TypeScript/issues/29729
|
|
453
|
+
*/
|
|
454
|
+
type StringLiteralUnion<T extends U, U = string> = T | (U & Nothing); //#endregion
|
|
455
|
+
//#region src/engines.d.ts
|
|
456
|
+
//#endregion
|
|
457
|
+
//#region src/langs.d.ts
|
|
458
|
+
type PlainTextLanguage = 'text' | 'plaintext' | 'txt' | 'plain';
|
|
459
|
+
type AnsiLanguage = 'ansi';
|
|
460
|
+
type SpecialLanguage = PlainTextLanguage | AnsiLanguage;
|
|
461
|
+
//#endregion
|
|
462
|
+
//#region src/decorations.d.ts
|
|
463
|
+
interface DecorationOptions {
|
|
464
|
+
/**
|
|
465
|
+
* Custom decorations to wrap highlighted tokens with.
|
|
466
|
+
*/
|
|
467
|
+
decorations?: DecorationItem[];
|
|
468
|
+
}
|
|
469
|
+
interface DecorationItem {
|
|
470
|
+
/**
|
|
471
|
+
* Start offset or position of the decoration.
|
|
472
|
+
*/
|
|
473
|
+
start: OffsetOrPosition;
|
|
474
|
+
/**
|
|
475
|
+
* End offset or position of the decoration.
|
|
476
|
+
*/
|
|
477
|
+
end: OffsetOrPosition;
|
|
478
|
+
/**
|
|
479
|
+
* Tag name of the element to create.
|
|
480
|
+
* @default 'span'
|
|
481
|
+
*/
|
|
482
|
+
tagName?: string;
|
|
483
|
+
/**
|
|
484
|
+
* Properties of the element to create.
|
|
485
|
+
*/
|
|
486
|
+
properties?: Element['properties'];
|
|
487
|
+
/**
|
|
488
|
+
* A custom function to transform the element after it has been created.
|
|
489
|
+
*/
|
|
490
|
+
transform?: (element: Element, type: DecorationTransformType) => Element | void;
|
|
491
|
+
/**
|
|
492
|
+
* By default when the decoration contains only one token, the decoration will be applied to the token.
|
|
493
|
+
*
|
|
494
|
+
* Set to `true` to always wrap the token with a new element
|
|
495
|
+
*
|
|
496
|
+
* @default false
|
|
497
|
+
*/
|
|
498
|
+
alwaysWrap?: boolean;
|
|
499
|
+
}
|
|
500
|
+
type DecorationTransformType = 'wrapper' | 'line' | 'token';
|
|
501
|
+
interface Position {
|
|
502
|
+
line: number;
|
|
503
|
+
character: number;
|
|
504
|
+
}
|
|
505
|
+
type Offset = number;
|
|
506
|
+
type OffsetOrPosition = Position | Offset;
|
|
507
|
+
//#endregion
|
|
508
|
+
//#region src/themes.d.ts
|
|
509
|
+
type SpecialTheme = 'none';
|
|
510
|
+
interface ThemeRegistrationRaw extends IRawTheme, Partial<Omit<ThemeRegistration, 'name' | 'settings'>> {}
|
|
511
|
+
interface ThemeRegistration extends Partial<ThemeRegistrationResolved> {}
|
|
512
|
+
interface ThemeRegistrationResolved extends IRawTheme {
|
|
513
|
+
/**
|
|
514
|
+
* Theme name
|
|
515
|
+
*/
|
|
516
|
+
name: string;
|
|
517
|
+
/**
|
|
518
|
+
* Display name
|
|
519
|
+
*
|
|
520
|
+
* @field shiki custom property
|
|
521
|
+
*/
|
|
522
|
+
displayName?: string;
|
|
523
|
+
/**
|
|
524
|
+
* Light/dark theme
|
|
525
|
+
*
|
|
526
|
+
* @field shiki custom property
|
|
527
|
+
*/
|
|
528
|
+
type: 'light' | 'dark';
|
|
529
|
+
/**
|
|
530
|
+
* Token rules
|
|
531
|
+
*/
|
|
532
|
+
settings: IRawThemeSetting[];
|
|
533
|
+
/**
|
|
534
|
+
* Same as `settings`, will use as fallback if `settings` is not present.
|
|
535
|
+
*/
|
|
536
|
+
tokenColors?: IRawThemeSetting[];
|
|
537
|
+
/**
|
|
538
|
+
* Default foreground color
|
|
539
|
+
*
|
|
540
|
+
* @field shiki custom property
|
|
541
|
+
*/
|
|
542
|
+
fg: string;
|
|
543
|
+
/**
|
|
544
|
+
* Background color
|
|
545
|
+
*
|
|
546
|
+
* @field shiki custom property
|
|
547
|
+
*/
|
|
548
|
+
bg: string;
|
|
549
|
+
/**
|
|
550
|
+
* A map of color names to new color values.
|
|
551
|
+
*
|
|
552
|
+
* The color key starts with '#' and should be lowercased.
|
|
553
|
+
*
|
|
554
|
+
* @field shiki custom property
|
|
555
|
+
*/
|
|
556
|
+
colorReplacements?: Record<string, string>;
|
|
557
|
+
/**
|
|
558
|
+
* Color map of VS Code options
|
|
559
|
+
*
|
|
560
|
+
* Will be used by shiki on `lang: 'ansi'` to find ANSI colors, and to find the default foreground/background colors.
|
|
561
|
+
*/
|
|
562
|
+
colors?: Record<string, string>;
|
|
563
|
+
/**
|
|
564
|
+
* JSON schema path
|
|
565
|
+
*
|
|
566
|
+
* @field not used by shiki
|
|
567
|
+
*/
|
|
568
|
+
$schema?: string;
|
|
569
|
+
/**
|
|
570
|
+
* Enable semantic highlighting
|
|
571
|
+
*
|
|
572
|
+
* @field not used by shiki
|
|
573
|
+
*/
|
|
574
|
+
semanticHighlighting?: boolean;
|
|
575
|
+
/**
|
|
576
|
+
* Tokens for semantic highlighting
|
|
577
|
+
*
|
|
578
|
+
* @field not used by shiki
|
|
579
|
+
*/
|
|
580
|
+
semanticTokenColors?: Record<string, string>;
|
|
581
|
+
}
|
|
582
|
+
type ThemeRegistrationAny = ThemeRegistrationRaw | ThemeRegistration | ThemeRegistrationResolved;
|
|
583
|
+
//#endregion
|
|
584
|
+
//#region src/tokens.d.ts
|
|
585
|
+
/**
|
|
586
|
+
* GrammarState is a special reference object that holds the state of a grammar.
|
|
587
|
+
*
|
|
588
|
+
* It's used to highlight code snippets that are part of the target language.
|
|
589
|
+
*/
|
|
590
|
+
interface GrammarState {
|
|
591
|
+
readonly lang: string;
|
|
592
|
+
readonly theme: string;
|
|
593
|
+
readonly themes: string[];
|
|
594
|
+
/**
|
|
595
|
+
* @internal
|
|
596
|
+
*/
|
|
597
|
+
getInternalStack: (theme?: string) => StateStack | undefined;
|
|
598
|
+
getScopes: (theme?: string) => string[] | undefined;
|
|
599
|
+
}
|
|
600
|
+
interface CodeToTokensBaseOptions<Languages extends string = string, Themes extends string = string> extends TokenizeWithThemeOptions {
|
|
601
|
+
lang?: Languages | SpecialLanguage;
|
|
602
|
+
theme?: Themes | ThemeRegistrationAny | SpecialTheme;
|
|
603
|
+
}
|
|
604
|
+
type CodeToTokensOptions<Languages extends string = string, Themes extends string = string> = Omit<CodeToTokensBaseOptions<Languages, Themes>, 'theme'> & CodeOptionsThemes<Themes>;
|
|
605
|
+
interface ThemedTokenScopeExplanation {
|
|
606
|
+
scopeName: string;
|
|
607
|
+
themeMatches?: IRawThemeSetting[];
|
|
608
|
+
}
|
|
609
|
+
interface ThemedTokenExplanation {
|
|
610
|
+
content: string;
|
|
611
|
+
scopes: ThemedTokenScopeExplanation[];
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* A single token with color, and optionally with explanation.
|
|
615
|
+
*
|
|
616
|
+
* For example:
|
|
617
|
+
*
|
|
618
|
+
* ```json
|
|
619
|
+
* {
|
|
620
|
+
* "content": "shiki",
|
|
621
|
+
* "color": "#D8DEE9",
|
|
622
|
+
* "explanation": [
|
|
623
|
+
* {
|
|
624
|
+
* "content": "shiki",
|
|
625
|
+
* "scopes": [
|
|
626
|
+
* {
|
|
627
|
+
* "scopeName": "source.js",
|
|
628
|
+
* "themeMatches": []
|
|
629
|
+
* },
|
|
630
|
+
* {
|
|
631
|
+
* "scopeName": "meta.objectliteral.js",
|
|
632
|
+
* "themeMatches": []
|
|
633
|
+
* },
|
|
634
|
+
* {
|
|
635
|
+
* "scopeName": "meta.object.member.js",
|
|
636
|
+
* "themeMatches": []
|
|
637
|
+
* },
|
|
638
|
+
* {
|
|
639
|
+
* "scopeName": "meta.array.literal.js",
|
|
640
|
+
* "themeMatches": []
|
|
641
|
+
* },
|
|
642
|
+
* {
|
|
643
|
+
* "scopeName": "variable.other.object.js",
|
|
644
|
+
* "themeMatches": [
|
|
645
|
+
* {
|
|
646
|
+
* "name": "Variable",
|
|
647
|
+
* "scope": "variable.other",
|
|
648
|
+
* "settings": {
|
|
649
|
+
* "foreground": "#D8DEE9"
|
|
650
|
+
* }
|
|
651
|
+
* },
|
|
652
|
+
* {
|
|
653
|
+
* "name": "[JavaScript] Variable Other Object",
|
|
654
|
+
* "scope": "source.js variable.other.object",
|
|
655
|
+
* "settings": {
|
|
656
|
+
* "foreground": "#D8DEE9"
|
|
657
|
+
* }
|
|
658
|
+
* }
|
|
659
|
+
* ]
|
|
660
|
+
* }
|
|
661
|
+
* ]
|
|
662
|
+
* }
|
|
663
|
+
* ]
|
|
664
|
+
* }
|
|
665
|
+
* ```
|
|
666
|
+
*/
|
|
667
|
+
interface ThemedToken extends TokenStyles, TokenBase {}
|
|
668
|
+
interface TokenBase {
|
|
669
|
+
/**
|
|
670
|
+
* The content of the token
|
|
671
|
+
*/
|
|
672
|
+
content: string;
|
|
673
|
+
/**
|
|
674
|
+
* The start offset of the token, relative to the input code. 0-indexed.
|
|
675
|
+
*/
|
|
676
|
+
offset: number;
|
|
677
|
+
/**
|
|
678
|
+
* Explanation of
|
|
679
|
+
*
|
|
680
|
+
* - token text's matching scopes
|
|
681
|
+
* - reason that token text is given a color (one matching scope matches a rule (scope -> color) in the theme)
|
|
682
|
+
*/
|
|
683
|
+
explanation?: ThemedTokenExplanation[];
|
|
684
|
+
}
|
|
685
|
+
interface TokenStyles {
|
|
686
|
+
/**
|
|
687
|
+
* 6 or 8 digit hex code representation of the token's color
|
|
688
|
+
*/
|
|
689
|
+
color?: string;
|
|
690
|
+
/**
|
|
691
|
+
* 6 or 8 digit hex code representation of the token's background color
|
|
692
|
+
*/
|
|
693
|
+
bgColor?: string;
|
|
694
|
+
/**
|
|
695
|
+
* Font style of token. Can be None/Italic/Bold/Underline
|
|
696
|
+
*/
|
|
697
|
+
fontStyle?: FontStyle;
|
|
698
|
+
/**
|
|
699
|
+
* Override with custom inline style for HTML renderer.
|
|
700
|
+
* When specified, `color` and `fontStyle` will be ignored.
|
|
701
|
+
* Prefer use object style for merging with other styles.
|
|
702
|
+
*/
|
|
703
|
+
htmlStyle?: Record<string, string>;
|
|
704
|
+
/**
|
|
705
|
+
* Extra HTML attributes for the token.
|
|
706
|
+
*/
|
|
707
|
+
htmlAttrs?: Record<string, string>;
|
|
708
|
+
}
|
|
709
|
+
interface TokenizeWithThemeOptions {
|
|
710
|
+
/**
|
|
711
|
+
* Include explanation of why a token is given a color.
|
|
712
|
+
*
|
|
713
|
+
* You can optionally pass `scopeName` to only include explanation for scopes,
|
|
714
|
+
* which is more performant than full explanation.
|
|
715
|
+
*
|
|
716
|
+
* @default false
|
|
717
|
+
*/
|
|
718
|
+
includeExplanation?: boolean | 'scopeName';
|
|
719
|
+
/**
|
|
720
|
+
* A map of color names to new color values.
|
|
721
|
+
*
|
|
722
|
+
* The color key starts with '#' and should be lowercased.
|
|
723
|
+
*
|
|
724
|
+
* This will be merged with theme's `colorReplacements` if any.
|
|
725
|
+
*/
|
|
726
|
+
colorReplacements?: Record<string, string | Record<string, string>>;
|
|
727
|
+
/**
|
|
728
|
+
* Lines above this length will not be tokenized for performance reasons.
|
|
729
|
+
*
|
|
730
|
+
* @default 0 (no limit)
|
|
731
|
+
*/
|
|
732
|
+
tokenizeMaxLineLength?: number;
|
|
733
|
+
/**
|
|
734
|
+
* Time limit in milliseconds for tokenizing a single line.
|
|
735
|
+
*
|
|
736
|
+
* @default 500 (0.5s)
|
|
737
|
+
*/
|
|
738
|
+
tokenizeTimeLimit?: number;
|
|
739
|
+
/**
|
|
740
|
+
* Represent the state of the grammar, allowing to continue tokenizing from a intermediate grammar state.
|
|
741
|
+
*
|
|
742
|
+
* You can get the grammar state from `getLastGrammarState`.
|
|
743
|
+
*/
|
|
744
|
+
grammarState?: GrammarState;
|
|
745
|
+
/**
|
|
746
|
+
* The code context of the grammar.
|
|
747
|
+
* Consider it a prepended code to the input code, that only participate the grammar inference but not presented in the final output.
|
|
748
|
+
*
|
|
749
|
+
* This will be ignored if `grammarState` is provided.
|
|
750
|
+
*/
|
|
751
|
+
grammarContextCode?: string;
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Result of `codeToTokens`, an object with 2D array of tokens and meta info like background and foreground color.
|
|
755
|
+
*/
|
|
756
|
+
interface TokensResult {
|
|
757
|
+
/**
|
|
758
|
+
* 2D array of tokens, first dimension is lines, second dimension is tokens in a line.
|
|
759
|
+
*/
|
|
760
|
+
tokens: ThemedToken[][];
|
|
761
|
+
/**
|
|
762
|
+
* Foreground color of the code.
|
|
763
|
+
*/
|
|
764
|
+
fg?: string;
|
|
765
|
+
/**
|
|
766
|
+
* Background color of the code.
|
|
767
|
+
*/
|
|
768
|
+
bg?: string;
|
|
769
|
+
/**
|
|
770
|
+
* A string representation of themes applied to the token.
|
|
771
|
+
*/
|
|
772
|
+
themeName?: string;
|
|
773
|
+
/**
|
|
774
|
+
* Custom style string to be applied to the root `<pre>` element.
|
|
775
|
+
* When specified, `fg` and `bg` will be ignored.
|
|
776
|
+
*/
|
|
777
|
+
rootStyle?: string | false;
|
|
778
|
+
/**
|
|
779
|
+
* The last grammar state of the code snippet.
|
|
780
|
+
*/
|
|
781
|
+
grammarState?: GrammarState;
|
|
782
|
+
} //#endregion
|
|
783
|
+
//#region src/transformers.d.ts
|
|
784
|
+
interface TransformerOptions {
|
|
785
|
+
/**
|
|
786
|
+
* Transformers for the Shiki pipeline.
|
|
787
|
+
*/
|
|
788
|
+
transformers?: ShikiTransformer[];
|
|
789
|
+
}
|
|
790
|
+
interface ShikiTransformerContextMeta {}
|
|
791
|
+
/**
|
|
792
|
+
* Common transformer context for all transformers hooks
|
|
793
|
+
*/
|
|
794
|
+
interface ShikiTransformerContextCommon {
|
|
795
|
+
meta: ShikiTransformerContextMeta;
|
|
796
|
+
options: CodeToHastOptions;
|
|
797
|
+
codeToHast: (code: string, options: CodeToHastOptions) => Root;
|
|
798
|
+
codeToTokens: (code: string, options: CodeToTokensOptions) => TokensResult;
|
|
799
|
+
}
|
|
800
|
+
interface ShikiTransformerContextSource extends ShikiTransformerContextCommon {
|
|
801
|
+
readonly source: string;
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Transformer context for HAST related hooks
|
|
805
|
+
*/
|
|
806
|
+
interface ShikiTransformerContext extends ShikiTransformerContextSource {
|
|
807
|
+
readonly tokens: ThemedToken[][];
|
|
808
|
+
readonly root: Root;
|
|
809
|
+
readonly pre: Element;
|
|
810
|
+
readonly code: Element;
|
|
811
|
+
readonly lines: Element[];
|
|
812
|
+
readonly structure: CodeToHastOptions['structure'];
|
|
813
|
+
/**
|
|
814
|
+
* Utility to append class to a hast node
|
|
815
|
+
*
|
|
816
|
+
* If the `property.class` is a string, it will be splitted by space and converted to an array.
|
|
817
|
+
*/
|
|
818
|
+
addClassToHast: (hast: Element, className: string | string[]) => Element;
|
|
819
|
+
}
|
|
820
|
+
interface ShikiTransformer {
|
|
821
|
+
/**
|
|
822
|
+
* Name of the transformer
|
|
823
|
+
*/
|
|
824
|
+
name?: string;
|
|
825
|
+
/**
|
|
826
|
+
* Enforce plugin invocation tier similar to webpack loaders. Hooks ordering
|
|
827
|
+
* is still subject to the `order` property in the hook object.
|
|
828
|
+
*
|
|
829
|
+
* Plugin invocation order:
|
|
830
|
+
* - `enforce: 'pre'` plugins
|
|
831
|
+
* - normal plugins
|
|
832
|
+
* - `enforce: 'post'` plugins
|
|
833
|
+
* - shiki post plugins
|
|
834
|
+
*/
|
|
835
|
+
enforce?: 'pre' | 'post';
|
|
836
|
+
/**
|
|
837
|
+
* Transform the raw input code before passing to the highlighter.
|
|
838
|
+
*/
|
|
839
|
+
preprocess?: (this: ShikiTransformerContextCommon, code: string, options: CodeToHastOptions) => string | void;
|
|
840
|
+
/**
|
|
841
|
+
* Transform the full tokens list before converting to HAST.
|
|
842
|
+
* Return a new tokens list will replace the original one.
|
|
843
|
+
*/
|
|
844
|
+
tokens?: (this: ShikiTransformerContextSource, tokens: ThemedToken[][]) => ThemedToken[][] | void;
|
|
845
|
+
/**
|
|
846
|
+
* Transform the entire generated HAST tree. Return a new Node will replace the original one.
|
|
847
|
+
*/
|
|
848
|
+
root?: (this: ShikiTransformerContext, hast: Root) => Root | void;
|
|
849
|
+
/**
|
|
850
|
+
* Transform the `<pre>` element. Return a new Node will replace the original one.
|
|
851
|
+
*/
|
|
852
|
+
pre?: (this: ShikiTransformerContext, hast: Element) => Element | void;
|
|
853
|
+
/**
|
|
854
|
+
* Transform the `<code>` element. Return a new Node will replace the original one.
|
|
855
|
+
*/
|
|
856
|
+
code?: (this: ShikiTransformerContext, hast: Element) => Element | void;
|
|
857
|
+
/**
|
|
858
|
+
* Transform each line `<span class="line">` element.
|
|
859
|
+
*
|
|
860
|
+
* @param hast
|
|
861
|
+
* @param line 1-based line number
|
|
862
|
+
*/
|
|
863
|
+
line?: (this: ShikiTransformerContext, hast: Element, line: number) => Element | void;
|
|
864
|
+
/**
|
|
865
|
+
* Transform each token `<span>` element.
|
|
866
|
+
*/
|
|
867
|
+
span?: (this: ShikiTransformerContext, hast: Element, line: number, col: number, lineElement: Element, token: ThemedToken) => Element | void;
|
|
868
|
+
/**
|
|
869
|
+
* Transform the generated HTML string before returning.
|
|
870
|
+
* This hook will only be called with `codeToHtml`.
|
|
871
|
+
*/
|
|
872
|
+
postprocess?: (this: ShikiTransformerContextCommon, html: string, options: CodeToHastOptions) => string | void;
|
|
873
|
+
} //#endregion
|
|
874
|
+
//#region src/options.d.ts
|
|
875
|
+
interface CodeOptionsSingleTheme<Themes extends string = string> {
|
|
876
|
+
theme: ThemeRegistrationAny | StringLiteralUnion<Themes>;
|
|
877
|
+
}
|
|
878
|
+
interface CodeOptionsMultipleThemes<Themes extends string = string> {
|
|
879
|
+
/**
|
|
880
|
+
* A map of color names to themes.
|
|
881
|
+
* This allows you to specify multiple themes for the generated code.
|
|
882
|
+
*
|
|
883
|
+
* ```ts
|
|
884
|
+
* highlighter.codeToHtml(code, {
|
|
885
|
+
* lang: 'js',
|
|
886
|
+
* themes: {
|
|
887
|
+
* light: 'vitesse-light',
|
|
888
|
+
* dark: 'vitesse-dark',
|
|
889
|
+
* }
|
|
890
|
+
* })
|
|
891
|
+
* ```
|
|
892
|
+
*
|
|
893
|
+
* Will generate:
|
|
894
|
+
*
|
|
895
|
+
* ```html
|
|
896
|
+
* <span style="color:#111;--shiki-dark:#fff;">code</span>
|
|
897
|
+
* ```
|
|
898
|
+
*
|
|
899
|
+
* @see https://shiki.style/guide/dual-themes
|
|
900
|
+
*/
|
|
901
|
+
themes: Partial<Record<string, ThemeRegistrationAny | StringLiteralUnion<Themes>>>;
|
|
902
|
+
/**
|
|
903
|
+
* The default theme applied to the code (via inline `color` style).
|
|
904
|
+
* The rest of the themes are applied via CSS variables, and toggled by CSS overrides.
|
|
905
|
+
*
|
|
906
|
+
* For example, if `defaultColor` is `light`, then `light` theme is applied to the code,
|
|
907
|
+
* and the `dark` theme and other custom themes are applied via CSS variables:
|
|
908
|
+
*
|
|
909
|
+
* ```html
|
|
910
|
+
* <span style="color:#{light};--shiki-dark:#{dark};--shiki-custom:#{custom};">code</span>
|
|
911
|
+
* ```
|
|
912
|
+
*
|
|
913
|
+
* When set to `false`, no default styles will be applied, and totally up to users to apply the styles:
|
|
914
|
+
*
|
|
915
|
+
* ```html
|
|
916
|
+
* <span style="--shiki-light:#{light};--shiki-dark:#{dark};--shiki-custom:#{custom};">code</span>
|
|
917
|
+
* ```
|
|
918
|
+
*
|
|
919
|
+
* When set to `light-dark()`, the default color will be rendered as `light-dark(#{light}, #{dark})`.
|
|
920
|
+
*
|
|
921
|
+
* ```html
|
|
922
|
+
* <span style="color:light-dark(#{light}, #{dark});--shiki-dark:#{dark};--shiki-custom:#{custom};">code</span>
|
|
923
|
+
* ```
|
|
924
|
+
*
|
|
925
|
+
* @default 'light'
|
|
926
|
+
*/
|
|
927
|
+
defaultColor?: StringLiteralUnion<'light' | 'dark'> | 'light-dark()' | false;
|
|
928
|
+
/**
|
|
929
|
+
* The strategy to render multiple colors.
|
|
930
|
+
*
|
|
931
|
+
* - `css-vars`: Render the colors via CSS variables.
|
|
932
|
+
* - `none`: Do not render the colors, only use the default color.
|
|
933
|
+
*
|
|
934
|
+
* @default 'css-vars'
|
|
935
|
+
*/
|
|
936
|
+
colorsRendering?: 'css-vars' | 'none';
|
|
937
|
+
/**
|
|
938
|
+
* Prefix of CSS variables used to store the color of the other theme.
|
|
939
|
+
*
|
|
940
|
+
* @default '--shiki-'
|
|
941
|
+
*/
|
|
942
|
+
cssVariablePrefix?: string;
|
|
943
|
+
}
|
|
944
|
+
type CodeOptionsThemes<Themes extends string = string> = CodeOptionsSingleTheme<Themes> | CodeOptionsMultipleThemes<Themes>;
|
|
945
|
+
type CodeToHastOptions<Languages extends string = string, Themes extends string = string> = CodeToHastOptionsCommon<Languages> & CodeOptionsThemes<Themes> & CodeOptionsMeta;
|
|
946
|
+
interface CodeToHastOptionsCommon<Languages extends string = string> extends TransformerOptions, DecorationOptions, Pick<TokenizeWithThemeOptions, 'colorReplacements' | 'tokenizeMaxLineLength' | 'tokenizeTimeLimit' | 'grammarState' | 'grammarContextCode' | 'includeExplanation'> {
|
|
947
|
+
/**
|
|
948
|
+
* Data to be added to the root `<pre>` element.
|
|
949
|
+
*/
|
|
950
|
+
data?: Record<string, unknown>;
|
|
951
|
+
/**
|
|
952
|
+
* The grammar name for the code.
|
|
953
|
+
*/
|
|
954
|
+
lang: StringLiteralUnion<Languages | SpecialLanguage>;
|
|
955
|
+
/**
|
|
956
|
+
* Custom style string to be applied to the root `<pre>` element.
|
|
957
|
+
*
|
|
958
|
+
* When set to `false`, no style will be applied.
|
|
959
|
+
*/
|
|
960
|
+
rootStyle?: string | false;
|
|
961
|
+
/**
|
|
962
|
+
* Merge whitespace tokens to saving extra `<span>`.
|
|
963
|
+
*
|
|
964
|
+
* When set to true, it will merge whitespace tokens with the next token.
|
|
965
|
+
* When set to false, it keep the output as-is.
|
|
966
|
+
* When set to `never`, it will force to separate leading and trailing spaces from tokens.
|
|
967
|
+
*
|
|
968
|
+
* @default true
|
|
969
|
+
*/
|
|
970
|
+
mergeWhitespaces?: boolean | 'never';
|
|
971
|
+
/**
|
|
972
|
+
* Merge consecutive tokens with the same style to reduce the number of DOM nodes.
|
|
973
|
+
* This can improve rendering performance but may affect the structure of the output.
|
|
974
|
+
*
|
|
975
|
+
* @default false
|
|
976
|
+
*/
|
|
977
|
+
mergeSameStyleTokens?: boolean;
|
|
978
|
+
/**
|
|
979
|
+
* The structure of the generated HAST and HTML.
|
|
980
|
+
*
|
|
981
|
+
* - `classic`: The classic structure with `<pre>` and `<code>` elements, each line wrapped with a `<span class="line">` element.
|
|
982
|
+
* - `inline`: All tokens are rendered as `<span>`, line breaks are rendered as `<br>`. No `<pre>` or `<code>` elements. Default forground and background colors are not applied.
|
|
983
|
+
*
|
|
984
|
+
* @default 'classic'
|
|
985
|
+
*/
|
|
986
|
+
structure?: 'classic' | 'inline';
|
|
987
|
+
/**
|
|
988
|
+
* Tab index of the root `<pre>` element.
|
|
989
|
+
*
|
|
990
|
+
* Set to `false` to disable tab index.
|
|
991
|
+
*
|
|
992
|
+
* @default 0
|
|
993
|
+
*/
|
|
994
|
+
tabindex?: number | string | false;
|
|
995
|
+
}
|
|
996
|
+
interface CodeOptionsMeta {
|
|
997
|
+
/**
|
|
998
|
+
* Meta data passed to Shiki, usually used by plugin integrations to pass the code block header.
|
|
999
|
+
*
|
|
1000
|
+
* Key values in meta will be serialized to the attributes of the root `<pre>` element.
|
|
1001
|
+
*
|
|
1002
|
+
* Keys starting with `_` will be ignored.
|
|
1003
|
+
*
|
|
1004
|
+
* A special key `__raw` key will be used to pass the raw code block header (if the integration supports it).
|
|
1005
|
+
*/
|
|
1006
|
+
meta?: {
|
|
1007
|
+
/**
|
|
1008
|
+
* Raw string of the code block header.
|
|
1009
|
+
*/
|
|
1010
|
+
__raw?: string;
|
|
1011
|
+
[key: string]: any;
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
//#endregion
|
|
99
1015
|
//#region src/_internal/code-transformers.d.ts
|
|
100
1016
|
/**
|
|
101
1017
|
* The canonical Shiki transformer chain for Nimbus. Returns a fresh
|
|
@@ -237,6 +1153,14 @@ declare function getSidebarSections(currentSlug: string, options?: {
|
|
|
237
1153
|
*
|
|
238
1154
|
* Walks the flattened sidebar; returns the surrounding entries. Honors
|
|
239
1155
|
* `prev`/`next` frontmatter overrides if provided.
|
|
1156
|
+
*
|
|
1157
|
+
* When an override uses the object form with an internal `link`
|
|
1158
|
+
* (e.g. `prev: { link: "/getting-started" }`), the link is validated
|
|
1159
|
+
* against every visible content entry's URL at build time. A pointer
|
|
1160
|
+
* to a missing page fails the build with a clear error — the same
|
|
1161
|
+
* staleness-detection mechanism used for `previousSlug` in versioning.
|
|
1162
|
+
* The string form (`prev: "Custom label"`) is a label-only override
|
|
1163
|
+
* and doesn't go through link validation.
|
|
240
1164
|
*/
|
|
241
1165
|
declare function getPrevNext(currentSlug: string, options?: {
|
|
242
1166
|
overrides?: PrevNextOverrides;
|