@citisen/litearea 0.1.0
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/LICENSE +21 -0
- package/README.md +514 -0
- package/README.zh.md +362 -0
- package/dist/grammars.cjs +1228 -0
- package/dist/grammars.cjs.map +1 -0
- package/dist/grammars.js +1213 -0
- package/dist/grammars.js.map +1 -0
- package/dist/index.cjs +3103 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +3040 -0
- package/dist/index.js.map +1 -0
- package/dist/react.cjs +3032 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.js +3010 -0
- package/dist/react.js.map +1 -0
- package/dist/styles.cjs +453 -0
- package/dist/styles.cjs.map +1 -0
- package/dist/styles.css +432 -0
- package/dist/styles.js +447 -0
- package/dist/styles.js.map +1 -0
- package/dist/types/core/complete.d.ts +70 -0
- package/dist/types/core/complete.d.ts.map +1 -0
- package/dist/types/core/format.d.ts +34 -0
- package/dist/types/core/format.d.ts.map +1 -0
- package/dist/types/core/grammar.d.ts +14 -0
- package/dist/types/core/grammar.d.ts.map +1 -0
- package/dist/types/core/hover.d.ts +23 -0
- package/dist/types/core/hover.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +12 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/core/inspect.d.ts +34 -0
- package/dist/types/core/inspect.d.ts.map +1 -0
- package/dist/types/core/rank.d.ts +82 -0
- package/dist/types/core/rank.d.ts.map +1 -0
- package/dist/types/core/scan.d.ts +51 -0
- package/dist/types/core/scan.d.ts.map +1 -0
- package/dist/types/core/segments.d.ts +44 -0
- package/dist/types/core/segments.d.ts.map +1 -0
- package/dist/types/core/text.d.ts +113 -0
- package/dist/types/core/text.d.ts.map +1 -0
- package/dist/types/core/types.d.ts +604 -0
- package/dist/types/core/types.d.ts.map +1 -0
- package/dist/types/core/vocabulary.d.ts +82 -0
- package/dist/types/core/vocabulary.d.ts.map +1 -0
- package/dist/types/dom/create.d.ts +17 -0
- package/dist/types/dom/create.d.ts.map +1 -0
- package/dist/types/dom/editing.d.ts +89 -0
- package/dist/types/dom/editing.d.ts.map +1 -0
- package/dist/types/dom/editor.d.ts +366 -0
- package/dist/types/dom/editor.d.ts.map +1 -0
- package/dist/types/dom/index.d.ts +9 -0
- package/dist/types/dom/index.d.ts.map +1 -0
- package/dist/types/dom/mirror.d.ts +107 -0
- package/dist/types/dom/mirror.d.ts.map +1 -0
- package/dist/types/dom/overlay.d.ts +52 -0
- package/dist/types/dom/overlay.d.ts.map +1 -0
- package/dist/types/dom/popup.d.ts +95 -0
- package/dist/types/dom/popup.d.ts.map +1 -0
- package/dist/types/dom/support.d.ts +41 -0
- package/dist/types/dom/support.d.ts.map +1 -0
- package/dist/types/dom/tooltip.d.ts +39 -0
- package/dist/types/dom/tooltip.d.ts.map +1 -0
- package/dist/types/grammars/dshFont.d.ts +127 -0
- package/dist/types/grammars/dshFont.d.ts.map +1 -0
- package/dist/types/grammars/dshSentry.d.ts +84 -0
- package/dist/types/grammars/dshSentry.d.ts.map +1 -0
- package/dist/types/grammars/index.d.ts +3 -0
- package/dist/types/grammars/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/react/index.d.ts +91 -0
- package/dist/types/react/index.d.ts.map +1 -0
- package/dist/types/styles.d.ts +29 -0
- package/dist/types/styles.d.ts.map +1 -0
- package/docs/architecture.md +316 -0
- package/docs/completion.md +320 -0
- package/docs/grammar.md +823 -0
- package/package.json +105 -0
- package/scripts/browser-check.mjs +838 -0
- package/scripts/build-css.mjs +35 -0
- package/scripts/release.mjs +91 -0
- package/scripts/verify-package.mjs +253 -0
- package/src/core/complete.ts +286 -0
- package/src/core/format.ts +71 -0
- package/src/core/grammar.ts +40 -0
- package/src/core/hover.ts +129 -0
- package/src/core/index.ts +98 -0
- package/src/core/inspect.ts +198 -0
- package/src/core/rank.ts +317 -0
- package/src/core/scan.ts +720 -0
- package/src/core/segments.ts +185 -0
- package/src/core/text.ts +238 -0
- package/src/core/types.ts +681 -0
- package/src/core/vocabulary.ts +196 -0
- package/src/dom/create.ts +31 -0
- package/src/dom/editing.ts +213 -0
- package/src/dom/editor.ts +1143 -0
- package/src/dom/index.ts +46 -0
- package/src/dom/mirror.ts +305 -0
- package/src/dom/overlay.ts +106 -0
- package/src/dom/popup.ts +323 -0
- package/src/dom/support.ts +88 -0
- package/src/dom/tooltip.ts +112 -0
- package/src/grammars/dshFont.ts +1004 -0
- package/src/grammars/dshSentry.ts +742 -0
- package/src/grammars/index.ts +57 -0
- package/src/index.ts +122 -0
- package/src/react/index.tsx +248 -0
- package/src/styles.ts +529 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/** Where the caret is, in pixels relative to the field's border box. */
|
|
2
|
+
export interface CaretBox {
|
|
3
|
+
/** Distance from the field's left border edge to the caret. */
|
|
4
|
+
x: number;
|
|
5
|
+
/** Distance from the field's top border edge to the caret's line box. */
|
|
6
|
+
y: number;
|
|
7
|
+
/** The height of the caret's line. */
|
|
8
|
+
height: number;
|
|
9
|
+
/** The line height in force, whether or not it was declared. */
|
|
10
|
+
lineHeight: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* An offscreen element that lays text out exactly as a given textarea does.
|
|
14
|
+
*
|
|
15
|
+
* One instance per field is enough; the editor owns exactly one.
|
|
16
|
+
*/
|
|
17
|
+
export declare class TextMirror {
|
|
18
|
+
/** The measuring element. Kept out of the document's flow by `position: fixed`. */
|
|
19
|
+
readonly element: HTMLDivElement;
|
|
20
|
+
private readonly document;
|
|
21
|
+
private readonly view;
|
|
22
|
+
/** The field this mirror is currently shaped like. */
|
|
23
|
+
private adopted;
|
|
24
|
+
/** The line height measured with the field, or 0 before the first measurement. */
|
|
25
|
+
private measuredLineHeight;
|
|
26
|
+
/**
|
|
27
|
+
* @param ownerDocument - the document to create the element in.
|
|
28
|
+
*/
|
|
29
|
+
constructor(ownerDocument: Document);
|
|
30
|
+
/** Whether the mirror is in a document. */
|
|
31
|
+
get mounted(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Mount the mirror, once, so measurements have a layout to read.
|
|
34
|
+
* @param parent - where to mount it. The body is right unless the document has none.
|
|
35
|
+
*/
|
|
36
|
+
mount(parent?: Element): void;
|
|
37
|
+
/**
|
|
38
|
+
* Shape the mirror like a field.
|
|
39
|
+
*
|
|
40
|
+
* The width is the interesting part. It has to be the field's CONTENT width, or
|
|
41
|
+
* text wraps in one and not the other — and the field's `clientWidth` is its
|
|
42
|
+
* content plus padding but NOT its border, while the mirror is `border-box`. So
|
|
43
|
+
* the borders are added back, and what is deliberately left out is the
|
|
44
|
+
* scrollbar: a field clamped to its maximum height has one, and the text wraps
|
|
45
|
+
* inside the narrower area above it.
|
|
46
|
+
* @param field - the textarea to imitate.
|
|
47
|
+
*/
|
|
48
|
+
adopt(field: HTMLTextAreaElement): void;
|
|
49
|
+
/**
|
|
50
|
+
* The line height in force, measured rather than assumed.
|
|
51
|
+
*
|
|
52
|
+
* `line-height: normal` is a real value and a common one, and it cannot be read
|
|
53
|
+
* as a number — `parseFloat('normal')` is `NaN`. So it is measured by laying one
|
|
54
|
+
* line of text out and taking the height, which is also the only way to be right
|
|
55
|
+
* about a font whose normal leading is not 1.2.
|
|
56
|
+
* @param field - the field to measure against.
|
|
57
|
+
* @returns the line height in pixels.
|
|
58
|
+
*/
|
|
59
|
+
lineHeight(field: HTMLTextAreaElement): number;
|
|
60
|
+
/** The mirror's vertical padding plus border, which every height includes. */
|
|
61
|
+
verticalPadding(): number;
|
|
62
|
+
/**
|
|
63
|
+
* Put text in the mirror with nothing else in it.
|
|
64
|
+
* @param text - the content.
|
|
65
|
+
*/
|
|
66
|
+
setText(text: string): void;
|
|
67
|
+
/**
|
|
68
|
+
* The height a field needs to show a document without scrolling.
|
|
69
|
+
*
|
|
70
|
+
* The trailing-newline problem is handled here. A div with `white-space:
|
|
71
|
+
* pre-wrap` and content ending in `\n` does not lay out a final empty line — the
|
|
72
|
+
* newline breaks the line but nothing follows it — so the measured height comes
|
|
73
|
+
* back one line short and the field grows a scrollbar exactly when the user
|
|
74
|
+
* presses Enter at the end. A zero-width space after the newline gives that last
|
|
75
|
+
* line something to be.
|
|
76
|
+
* @param field - the field being sized.
|
|
77
|
+
* @param value - the text it holds.
|
|
78
|
+
* @returns the border-box height the content requires.
|
|
79
|
+
*/
|
|
80
|
+
contentHeight(field: HTMLTextAreaElement, value: string): number;
|
|
81
|
+
/**
|
|
82
|
+
* Where the caret sits, in pixels relative to the field's border box.
|
|
83
|
+
*
|
|
84
|
+
* The trick is a marker element holding the character AFTER the caret, measured
|
|
85
|
+
* against the mirror. Everything before the caret lays out normally, so the
|
|
86
|
+
* marker lands exactly where the next glyph will be — which is where the caret
|
|
87
|
+
* is. At the end of the document there is no next character, so a zero-width
|
|
88
|
+
* space stands in for it.
|
|
89
|
+
*
|
|
90
|
+
* The field's own scroll offset is subtracted, because the caret's position on
|
|
91
|
+
* screen is what the popup has to be placed against, and a scrolled field moves
|
|
92
|
+
* its text without moving its border box.
|
|
93
|
+
*
|
|
94
|
+
* @param field - the field the caret is in.
|
|
95
|
+
* @param offset - the caret's character offset.
|
|
96
|
+
* @returns the caret box, or undefined when there is no layout to measure.
|
|
97
|
+
*/
|
|
98
|
+
caretBox(field: HTMLTextAreaElement, offset: number): CaretBox | undefined;
|
|
99
|
+
/** Take the mirror out of the document. */
|
|
100
|
+
destroy(): void;
|
|
101
|
+
/**
|
|
102
|
+
* The field this mirror was last shaped like.
|
|
103
|
+
* @returns the field, or undefined before {@link adopt}.
|
|
104
|
+
*/
|
|
105
|
+
get field(): HTMLTextAreaElement | undefined;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=mirror.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mirror.d.ts","sourceRoot":"","sources":["../../../src/dom/mirror.ts"],"names":[],"mappings":"AAiEA,wEAAwE;AACxE,MAAM,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B,GAAG,SAAS,CAE3C;CACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { SegmentInput } from '../core/segments.js';
|
|
2
|
+
/** How the layer turns a scope, a decoration, or a severity into a class. */
|
|
3
|
+
export interface OverlayClassNames {
|
|
4
|
+
scope: (scope: string) => string;
|
|
5
|
+
decoration: (kind: string) => string;
|
|
6
|
+
severity: (severity: string) => string;
|
|
7
|
+
}
|
|
8
|
+
/** The painted layer and the element that holds the paint. */
|
|
9
|
+
export declare class Overlay {
|
|
10
|
+
/** The scroll container. Same box as the field. */
|
|
11
|
+
readonly element: HTMLDivElement;
|
|
12
|
+
/** The element the spans are written into. */
|
|
13
|
+
private readonly paint;
|
|
14
|
+
private readonly document;
|
|
15
|
+
private readonly classNames;
|
|
16
|
+
/** What was painted last, so an unchanged document is not repainted. */
|
|
17
|
+
private paintedText;
|
|
18
|
+
private paintedKey;
|
|
19
|
+
/**
|
|
20
|
+
* @param ownerDocument - the document to build in.
|
|
21
|
+
* @param classNames - the three class-name mappings.
|
|
22
|
+
*/
|
|
23
|
+
constructor(ownerDocument: Document, classNames: OverlayClassNames);
|
|
24
|
+
/**
|
|
25
|
+
* Paint a document.
|
|
26
|
+
*
|
|
27
|
+
* `key` is whatever the caller knows changed. When it and the text both match
|
|
28
|
+
* the last call the work is skipped, which is what keeps a caret move or a
|
|
29
|
+
* mouse hover from rebuilding every span on the page.
|
|
30
|
+
* @param text - the document.
|
|
31
|
+
* @param input - the tokens, decorations, and diagnostics.
|
|
32
|
+
* @param key - a cheap signature of everything that affects the paint.
|
|
33
|
+
* @param fallbackScope - the scope for characters no token covers.
|
|
34
|
+
*/
|
|
35
|
+
render(text: string, input: SegmentInput, key: string, fallbackScope?: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Follow the field's scroll position.
|
|
38
|
+
*
|
|
39
|
+
* The layer is `overflow: hidden` and its content is taller than its box exactly
|
|
40
|
+
* when the field is: an auto-grown field has nothing to scroll and a field
|
|
41
|
+
* clamped to its maximum height has everything to scroll. Copying the offset is
|
|
42
|
+
* therefore enough, and it is more reliable than a transform, which can leave
|
|
43
|
+
* the text on a half pixel.
|
|
44
|
+
* @param field - the textarea.
|
|
45
|
+
*/
|
|
46
|
+
syncScroll(field: HTMLTextAreaElement): void;
|
|
47
|
+
/** Forget what was painted, so the next render rebuilds. */
|
|
48
|
+
invalidate(): void;
|
|
49
|
+
/** Take the layer out of the document. */
|
|
50
|
+
destroy(): void;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=overlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../../src/dom/overlay.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAGvD,6EAA6E;AAC7E,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IAChC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;IACpC,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAA;CACvC;AAED,8DAA8D;AAC9D,qBAAa,OAAO;IAClB,mDAAmD;IACnD,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAA;IAChC,8CAA8C;IAC9C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmB;IAC9C,wEAAwE;IACxE,OAAO,CAAC,WAAW,CAAoB;IACvC,OAAO,CAAC,UAAU,CAAK;IAEvB;;;OAGG;IACH,YAAY,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,iBAAiB,EAUjE;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,SAAS,GAAG,IAAI,CAmBnF;IAED;;;;;;;;;OASG;IACH,UAAU,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAG3C;IAED,4DAA4D;IAC5D,UAAU,IAAI,IAAI,CAGjB;IAED,0CAA0C;IAC1C,OAAO,IAAI,IAAI,CAGd;CACF"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { CompletionRow } from '../core/types.js';
|
|
2
|
+
/** Where a floating element is allowed to sit. */
|
|
3
|
+
export interface AnchorBox {
|
|
4
|
+
/** Distance from the positioning container's left edge. */
|
|
5
|
+
x: number;
|
|
6
|
+
/** Distance from the positioning container's top edge. */
|
|
7
|
+
y: number;
|
|
8
|
+
/** The height of the line the anchor sits on. */
|
|
9
|
+
height: number;
|
|
10
|
+
}
|
|
11
|
+
/** What the list tells its owner. */
|
|
12
|
+
export interface PopupHandlers {
|
|
13
|
+
/** A row was chosen with the mouse. */
|
|
14
|
+
accept(index: number): void;
|
|
15
|
+
/** The pointer moved over a row, which makes it active. */
|
|
16
|
+
hover(index: number): void;
|
|
17
|
+
}
|
|
18
|
+
/** The completion list, with its documentation panel. */
|
|
19
|
+
export declare class Popup {
|
|
20
|
+
/** The positioned container. */
|
|
21
|
+
readonly element: HTMLDivElement;
|
|
22
|
+
/** The scrolling element, which holds the rows and nothing else. */
|
|
23
|
+
readonly list: HTMLDivElement;
|
|
24
|
+
private readonly document;
|
|
25
|
+
private readonly handlers;
|
|
26
|
+
private rows;
|
|
27
|
+
private active;
|
|
28
|
+
private open;
|
|
29
|
+
private showDocs;
|
|
30
|
+
private readonly docs;
|
|
31
|
+
private readonly prefix;
|
|
32
|
+
/**
|
|
33
|
+
* @param ownerDocument - the document to build in.
|
|
34
|
+
* @param handlers - how to report a pick and a hover.
|
|
35
|
+
* @param idPrefix - a stable prefix for row ids, so two editors do not collide.
|
|
36
|
+
*/
|
|
37
|
+
constructor(ownerDocument: Document, handlers: PopupHandlers, idPrefix: string);
|
|
38
|
+
/** Whether the list is showing. */
|
|
39
|
+
get isOpen(): boolean;
|
|
40
|
+
/** The active row's index, or -1. */
|
|
41
|
+
get activeIndex(): number;
|
|
42
|
+
/** The rows currently shown. */
|
|
43
|
+
get items(): readonly CompletionRow[];
|
|
44
|
+
/** The active row, when there is one. */
|
|
45
|
+
get activeRow(): CompletionRow | undefined;
|
|
46
|
+
/** The id the field's `aria-controls` should name. It is the list, not the container. */
|
|
47
|
+
get listId(): string;
|
|
48
|
+
/**
|
|
49
|
+
* The id of the active row, for the field's `aria-activedescendant`.
|
|
50
|
+
*
|
|
51
|
+
* The list does not write that attribute itself: the field belongs to the editor, and a
|
|
52
|
+
* floating list reaching out of its own subtree to find it is the kind of coupling that
|
|
53
|
+
* breaks the moment the two are mounted somewhere unexpected.
|
|
54
|
+
* @returns the row id, or undefined when no row is active.
|
|
55
|
+
*/
|
|
56
|
+
get activeRowId(): string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Show a list.
|
|
59
|
+
* @param rows - the rows, already ranked.
|
|
60
|
+
* @param active - the row to make active.
|
|
61
|
+
* @param showDocs - whether to render the documentation panel.
|
|
62
|
+
*/
|
|
63
|
+
show(rows: readonly CompletionRow[], active: number, showDocs: boolean): void;
|
|
64
|
+
/** Hide the list and forget its rows. */
|
|
65
|
+
close(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Make a row active without rebuilding the list.
|
|
68
|
+
* @param index - the row index.
|
|
69
|
+
*/
|
|
70
|
+
setActive(index: number): void;
|
|
71
|
+
/**
|
|
72
|
+
* Place the list under an anchor, flipping above it when there is no room below.
|
|
73
|
+
*
|
|
74
|
+
* The container's own box is what is measured, so the documentation panel counts towards the
|
|
75
|
+
* height and a popup whose rows and explanation together would run off the bottom flips as a
|
|
76
|
+
* whole rather than being cut in half.
|
|
77
|
+
* @param anchor - the caret's box, in the container's coordinates.
|
|
78
|
+
* @param container - the element the list is positioned against.
|
|
79
|
+
* @param viewport - the visible area to stay inside.
|
|
80
|
+
*/
|
|
81
|
+
place(anchor: AnchorBox, container: HTMLElement, viewport: {
|
|
82
|
+
width: number;
|
|
83
|
+
height: number;
|
|
84
|
+
}): void;
|
|
85
|
+
/** Take the list out of the document. */
|
|
86
|
+
destroy(): void;
|
|
87
|
+
/** The DOM id of a row, which `aria-activedescendant` points at. */
|
|
88
|
+
rowId(index: number): string;
|
|
89
|
+
private render;
|
|
90
|
+
/** Refresh the documentation panel from the active row. */
|
|
91
|
+
private renderDocs;
|
|
92
|
+
private readonly onMouseDown;
|
|
93
|
+
private readonly onMouseMove;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=popup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popup.d.ts","sourceRoot":"","sources":["../../../src/dom/popup.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,aAAa,EAAkB,MAAM,kBAAkB,CAAA;AAGrE,kDAAkD;AAClD,MAAM,WAAW,SAAS;IACxB,2DAA2D;IAC3D,CAAC,EAAE,MAAM,CAAA;IACT,0DAA0D;IAC1D,CAAC,EAAE,MAAM,CAAA;IACT,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAA;CACf;AAED,qCAAqC;AACrC,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,2DAA2D;IAC3D,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAC3B;AAED,yDAAyD;AACzD,qBAAa,KAAK;IAChB,gCAAgC;IAChC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAA;IAChC,oEAAoE;IACpE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAA;IAC7B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IACnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IACxC,OAAO,CAAC,IAAI,CAA+B;IAC3C,OAAO,CAAC,MAAM,CAAK;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AC,WAAW,CAO3B;IAED,OAAO,CAAC,QAAQ,CAAC,WAAW,CAM3B;CACF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Whether a document is available at all, so an import is safe under Node. */
|
|
2
|
+
export declare function hasDocument(): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Whether the browser still offers `document.execCommand`.
|
|
5
|
+
*
|
|
6
|
+
* It is deprecated, and it is also the only way to change a textarea's value while
|
|
7
|
+
* keeping the browser's own undo stack intact — no modern input API can be driven
|
|
8
|
+
* from script, because a synthetic event is untrusted and the browser refuses to
|
|
9
|
+
* treat it as a user edit. So the check is not "is this nice API available" but
|
|
10
|
+
* "can this edit be undone", and the editor degrades honestly when the answer is
|
|
11
|
+
* no: the edit still lands, and the history it should have joined does not.
|
|
12
|
+
* @returns whether an undo-preserving edit is possible.
|
|
13
|
+
*/
|
|
14
|
+
export declare function canEditThroughPipeline(): boolean;
|
|
15
|
+
/** Whether `caretPositionFromPoint` or its WebKit spelling exists. */
|
|
16
|
+
export declare function hasCaretHitTest(): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The character offset a point in the viewport falls on, according to the browser.
|
|
19
|
+
*
|
|
20
|
+
* The browser is asked rather than the editor computing it, because hit-testing
|
|
21
|
+
* wrapped, proportional text is exactly the kind of geometry a hand-written
|
|
22
|
+
* measurement gets subtly wrong. A textarea's transparent text still lays out
|
|
23
|
+
* normally, so the caret APIs answer for it correctly.
|
|
24
|
+
* @param x - viewport x.
|
|
25
|
+
* @param y - viewport y.
|
|
26
|
+
* @returns the offset, or undefined when the browser cannot say.
|
|
27
|
+
*/
|
|
28
|
+
export declare function offsetFromPoint(x: number, y: number): number | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Merge partial option objects without letting an explicit `undefined` win.
|
|
31
|
+
*
|
|
32
|
+
* `{ ...defaults, ...given }` looks right and is wrong the moment a caller passes
|
|
33
|
+
* an optional field it did not fill in: the key exists, so it overwrites the
|
|
34
|
+
* default with `undefined`, and the editor then behaves as if the option had been
|
|
35
|
+
* switched off. This copies only the keys that were actually provided.
|
|
36
|
+
* @param defaults - the base.
|
|
37
|
+
* @param given - the overrides, which may be undefined.
|
|
38
|
+
* @returns the merged object.
|
|
39
|
+
*/
|
|
40
|
+
export declare function withDefaults<T extends object>(defaults: T, given: Partial<T> | undefined): T;
|
|
41
|
+
//# sourceMappingURL=support.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"support.d.ts","sourceRoot":"","sources":["../../../src/dom/support.ts"],"names":[],"mappings":"AAMA,+EAA+E;AAC/E,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD;AAED,sEAAsE;AACtE,wBAAgB,eAAe,IAAI,OAAO,CAUzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgBxE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,CAQ5F"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { HoverInfo } from '../core/types.js';
|
|
2
|
+
/** Where a floating element is allowed to sit. */
|
|
3
|
+
export interface TooltipAnchor {
|
|
4
|
+
/** Distance from the positioning container's left edge. */
|
|
5
|
+
x: number;
|
|
6
|
+
/** Distance from the positioning container's top edge. */
|
|
7
|
+
y: number;
|
|
8
|
+
/** The height of the anchored line or range. */
|
|
9
|
+
height: number;
|
|
10
|
+
}
|
|
11
|
+
/** The hover tooltip. */
|
|
12
|
+
export declare class Tooltip {
|
|
13
|
+
/** The tooltip element. */
|
|
14
|
+
readonly element: HTMLDivElement;
|
|
15
|
+
private readonly document;
|
|
16
|
+
private open;
|
|
17
|
+
/**
|
|
18
|
+
* @param ownerDocument - the document to build in.
|
|
19
|
+
*/
|
|
20
|
+
constructor(ownerDocument: Document);
|
|
21
|
+
/** Whether the tooltip is showing. */
|
|
22
|
+
get isOpen(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Show a hover.
|
|
25
|
+
* @param info - what to say.
|
|
26
|
+
* @param anchor - where the thing being described is.
|
|
27
|
+
* @param container - the element the tooltip is positioned against.
|
|
28
|
+
* @param viewport - the visible area to stay inside.
|
|
29
|
+
*/
|
|
30
|
+
show(info: HoverInfo, anchor: TooltipAnchor, container: HTMLElement, viewport: {
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
}): void;
|
|
34
|
+
/** Hide the tooltip. */
|
|
35
|
+
hide(): void;
|
|
36
|
+
/** Take the tooltip out of the document. */
|
|
37
|
+
destroy(): void;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../src/dom/tooltip.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEjD,kDAAkD;AAClD,MAAM,WAAW,aAAa;IAC5B,2DAA2D;IAC3D,CAAC,EAAE,MAAM,CAAA;IACT,0DAA0D;IAC1D,CAAC,EAAE,MAAM,CAAA;IACT,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAA;CACf;AAED,yBAAyB;AACzB,qBAAa,OAAO;IAClB,2BAA2B;IAC3B,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAA;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IACnC,OAAO,CAAC,IAAI,CAAQ;IAEpB;;OAEG;IACH,YAAY,aAAa,EAAE,QAAQ,EAOlC;IAED,sCAAsC;IACtC,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED;;;;;;OAMG;IACH,IAAI,CACF,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,WAAW,EACtB,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAC1C,IAAI,CAqCN;IAED,wBAAwB;IACxB,IAAI,IAAI,IAAI,CAKX;IAED,4CAA4C;IAC5C,OAAO,IAAI,IAAI,CAGd;CACF"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { Grammar, Severity } from '../core/types.js';
|
|
2
|
+
/** Every weight word the language accepts, mapped to its CSS number. */
|
|
3
|
+
export declare const FONT_WEIGHT_WORDS: Readonly<Record<string, number>>;
|
|
4
|
+
/** The CSS weight scale, in the order a picker shows it. */
|
|
5
|
+
export declare const FONT_WEIGHT_SCALE: readonly number[];
|
|
6
|
+
/** The canonical word per weight — `500` is `medium`. */
|
|
7
|
+
export declare const FONT_WEIGHT_LABELS: Readonly<Record<number, string>>;
|
|
8
|
+
/**
|
|
9
|
+
* Generic CSS families. Valid anywhere in a list, and only useful at the end,
|
|
10
|
+
* which is why they are coloured apart from an installed family: picking one is a
|
|
11
|
+
* different intent from picking a font.
|
|
12
|
+
*/
|
|
13
|
+
export declare const FONT_GENERIC_FAMILIES: readonly string[];
|
|
14
|
+
/**
|
|
15
|
+
* Popular families offered as suggestions even when not detected.
|
|
16
|
+
*
|
|
17
|
+
* Detection cannot see every font and a family may be installed later, so the
|
|
18
|
+
* picker must not present itself as the complete truth. A host that has read the
|
|
19
|
+
* real catalogue passes it in; this list is what a host with no permission to read
|
|
20
|
+
* one can still offer.
|
|
21
|
+
*/
|
|
22
|
+
export declare const FONT_COMMON_FAMILIES: readonly string[];
|
|
23
|
+
/** One entry of the query, as it was found in the source. */
|
|
24
|
+
export interface DshFontEntry {
|
|
25
|
+
/** The whole entry, whitespace included. */
|
|
26
|
+
from: number;
|
|
27
|
+
to: number;
|
|
28
|
+
/** The trimmed core, and its range. */
|
|
29
|
+
coreFrom: number;
|
|
30
|
+
coreTo: number;
|
|
31
|
+
core: string;
|
|
32
|
+
/** Whether the core opens with a quote. */
|
|
33
|
+
quoted: boolean;
|
|
34
|
+
/** The family name, with the quotes and any weight word taken out. */
|
|
35
|
+
name: string;
|
|
36
|
+
nameFrom: number;
|
|
37
|
+
nameTo: number;
|
|
38
|
+
/** The weight word the entry carries, if any. */
|
|
39
|
+
word: string | undefined;
|
|
40
|
+
wordFrom: number;
|
|
41
|
+
wordTo: number;
|
|
42
|
+
/** What the reader made of the entry. */
|
|
43
|
+
kind: 'empty' | 'family' | 'generic' | 'unknown' | 'weight';
|
|
44
|
+
}
|
|
45
|
+
/** A problem the structural pass found. */
|
|
46
|
+
export interface DshFontProblem {
|
|
47
|
+
from: number;
|
|
48
|
+
to: number;
|
|
49
|
+
message: string;
|
|
50
|
+
code: string;
|
|
51
|
+
severity: Severity;
|
|
52
|
+
}
|
|
53
|
+
/** What one pass over the query produced. */
|
|
54
|
+
export interface DshFontState {
|
|
55
|
+
entries: DshFontEntry[];
|
|
56
|
+
/** The family names the entries name, in order. */
|
|
57
|
+
families: string[];
|
|
58
|
+
/** Which of them the browser will actually paint with; -1 when none will. */
|
|
59
|
+
effective: number;
|
|
60
|
+
/** The numeric weight the query states, if it states one. */
|
|
61
|
+
weight: number | undefined;
|
|
62
|
+
weightWord: string | undefined;
|
|
63
|
+
problems: DshFontProblem[];
|
|
64
|
+
}
|
|
65
|
+
/** What a host supplies to describe the machine the query will run on. */
|
|
66
|
+
export interface DshFontQueryOptions {
|
|
67
|
+
/** The family names the machine has. */
|
|
68
|
+
catalogue?: readonly string[];
|
|
69
|
+
/**
|
|
70
|
+
* Whether that catalogue was READ from the machine.
|
|
71
|
+
*
|
|
72
|
+
* It changes what an unrecognized name means. With a read catalogue the browser
|
|
73
|
+
* will fall through to a later family, which is worth warning about; without one
|
|
74
|
+
* the catalogue is only a suggestion list, and the parser has no business
|
|
75
|
+
* second-guessing a name the user typed.
|
|
76
|
+
*/
|
|
77
|
+
enumerated?: boolean;
|
|
78
|
+
/** The face style names of each family, as the Local Font Access API reports them. */
|
|
79
|
+
styles?: Readonly<Record<string, readonly string[]>>;
|
|
80
|
+
/** The weight the axis ships with, offered as a row that takes the word away. */
|
|
81
|
+
shippedWeight?: number;
|
|
82
|
+
/** Families offered even when not detected. */
|
|
83
|
+
commonFamilies?: readonly string[];
|
|
84
|
+
/** The generic CSS families. */
|
|
85
|
+
genericFamilies?: readonly string[];
|
|
86
|
+
/** How many words one unquoted family name may span when matching the catalogue. */
|
|
87
|
+
phraseWords?: number;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The word a numeric weight is spelled with: `500` becomes `medium`.
|
|
91
|
+
* @param weight - a numeric weight.
|
|
92
|
+
* @returns the canonical word, or the number as text when it is off the scale.
|
|
93
|
+
*/
|
|
94
|
+
export declare function fontWeightWord(weight: number): string;
|
|
95
|
+
/**
|
|
96
|
+
* The weights one family actually has, read off its faces' style names.
|
|
97
|
+
*
|
|
98
|
+
* The Local Font Access API reports a face's `style` (`Regular`, `SemiBold`,
|
|
99
|
+
* `Bold Italic`) rather than a number, and is not obliged to spell a two-word
|
|
100
|
+
* style with a hyphen, so `Semi Bold` has to be folded back into one word before
|
|
101
|
+
* the lookup.
|
|
102
|
+
*
|
|
103
|
+
* An empty result means "unknown", never "none": enumerating faces is
|
|
104
|
+
* permission-gated, and a family may report styles this vocabulary cannot read.
|
|
105
|
+
* @param styles - the face style names of one family.
|
|
106
|
+
* @returns the distinct weights, ascending.
|
|
107
|
+
*/
|
|
108
|
+
export declare function fontFaceWeights(styles: readonly string[] | undefined): number[];
|
|
109
|
+
/**
|
|
110
|
+
* Render a family name for a CSS list, quoting it only when CSS requires it.
|
|
111
|
+
*
|
|
112
|
+
* A generic family or a CSS-wide keyword must NOT be quoted, because `"sans-serif"`
|
|
113
|
+
* names a literal font instead of the generic family. A single leading hyphen is
|
|
114
|
+
* part of an identifier (`-apple-system`), so it survives unquoted too.
|
|
115
|
+
* @param family - a bare family name.
|
|
116
|
+
* @returns the CSS token for it.
|
|
117
|
+
*/
|
|
118
|
+
export declare function quoteFontFamily(family: string): string;
|
|
119
|
+
/**
|
|
120
|
+
* Build the grammar for dsh-font's font query.
|
|
121
|
+
* @param options - the machine's catalogue, its faces, and the shipped weight.
|
|
122
|
+
* @returns a grammar that paints, completes, diagnoses, and explains the language.
|
|
123
|
+
*/
|
|
124
|
+
export declare function dshFontQueryGrammar(options?: DshFontQueryOptions): Grammar<DshFontState>;
|
|
125
|
+
/** A diagnostic the grammar rates as informational rather than as a mistake. */
|
|
126
|
+
export declare const DSH_FONT_INFO_CODES: readonly string[];
|
|
127
|
+
//# sourceMappingURL=dshFont.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dshFont.d.ts","sourceRoot":"","sources":["../../../src/grammars/dshFont.ts"],"names":[],"mappings":"AA4CA,OAAO,KAAK,EAEV,OAAO,EAEP,QAAQ,EAET,MAAM,kBAAkB,CAAA;AAIzB,wEAAwE;AACxE,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAoB9D,CAAA;AAED,4DAA4D;AAC5D,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAAkD,CAAA;AAEjG,yDAAyD;AACzD,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAU/D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAclD,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAgDjD,CAAA;AAaD,6DAA6D;AAC7D,MAAM,WAAW,YAAY;IAC3B,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,uCAAuC;IACvC,QAAQ,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IACpD,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,+CAA+C;IAC/C,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAClC,gCAAgC;IAChC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACnC,oFAAoF;IACpF,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GAAG,MAAM,EAAE,CAc/E;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKtD;AAuCD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,YAAY,CAAC,CA8jB5F;AA+ED,gFAAgF;AAChF,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAA4B,CAAA"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Grammar, Severity } from '../core/types.js';
|
|
2
|
+
/** One positional slot of a state line, in the order a bare word fills them. */
|
|
3
|
+
export type DshSentrySlot = 'shape' | 'color' | 'pattern' | 'motion' | 'speed';
|
|
4
|
+
/** The four facts one state's appearance is made of. */
|
|
5
|
+
export interface DshSentryLook {
|
|
6
|
+
shape: string;
|
|
7
|
+
color: string;
|
|
8
|
+
pattern: string;
|
|
9
|
+
motion: string;
|
|
10
|
+
speed: number;
|
|
11
|
+
}
|
|
12
|
+
/** One word of the document, with the range it occupies. */
|
|
13
|
+
export interface DshSentryWord {
|
|
14
|
+
text: string;
|
|
15
|
+
from: number;
|
|
16
|
+
to: number;
|
|
17
|
+
}
|
|
18
|
+
/** A problem the structural walk found, ready to be reported. */
|
|
19
|
+
export interface DshSentryProblem {
|
|
20
|
+
from: number;
|
|
21
|
+
to: number;
|
|
22
|
+
message: string;
|
|
23
|
+
code: string;
|
|
24
|
+
severity: Severity;
|
|
25
|
+
}
|
|
26
|
+
/** One line, read. */
|
|
27
|
+
export interface DshSentryLine {
|
|
28
|
+
/** Zero-based line number, so a completion can find the line the caret is on. */
|
|
29
|
+
number: number;
|
|
30
|
+
/** The state the line opens, as written. */
|
|
31
|
+
state: string | undefined;
|
|
32
|
+
/** Whether that state is one this document understands. */
|
|
33
|
+
known: boolean;
|
|
34
|
+
/** The words on the line, comments removed. */
|
|
35
|
+
words: DshSentryWord[];
|
|
36
|
+
/** The value each positional slot ended up with, whatever syntax put it there. */
|
|
37
|
+
slots: Partial<Record<DshSentrySlot, string>>;
|
|
38
|
+
/** The option keys the line named, in order, whether or not they are known. */
|
|
39
|
+
keys: string[];
|
|
40
|
+
/** The option key whose value the line has not written yet, as `speed=`. */
|
|
41
|
+
pendingKey: string | undefined;
|
|
42
|
+
}
|
|
43
|
+
/** What one pass over the document produced. */
|
|
44
|
+
export interface DshSentryState {
|
|
45
|
+
lines: DshSentryLine[];
|
|
46
|
+
/** What the structural walk found. `validate` reports these verbatim. */
|
|
47
|
+
problems: DshSentryProblem[];
|
|
48
|
+
}
|
|
49
|
+
/** The vocabularies and shipped defaults a host may override. */
|
|
50
|
+
export interface DshSentryStyleOptions {
|
|
51
|
+
/** The states a document may address, in the order the list shows them. */
|
|
52
|
+
states?: readonly string[];
|
|
53
|
+
/** The background shapes a rule may name. */
|
|
54
|
+
shapes?: readonly string[];
|
|
55
|
+
/** The motions a rule may apply. */
|
|
56
|
+
motions?: readonly string[];
|
|
57
|
+
/** The patterns still accepted as `pattern=<name>`. */
|
|
58
|
+
patterns?: readonly string[];
|
|
59
|
+
/** The named palette. Presets on purpose: a free colour can be illegible. */
|
|
60
|
+
colors?: Readonly<Record<string, string>>;
|
|
61
|
+
/** The option keys a rule may write. */
|
|
62
|
+
options?: readonly string[];
|
|
63
|
+
/** The shipped look per state, used to rank and to document. */
|
|
64
|
+
defaults?: Readonly<Record<string, DshSentryLook>>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Build the grammar for dsh-sentry's style document.
|
|
68
|
+
* @param options - the vocabularies and shipped defaults, defaulting to the plugin's.
|
|
69
|
+
* @returns a grammar that paints, completes, diagnoses, and explains the language.
|
|
70
|
+
*/
|
|
71
|
+
export declare function dshSentryStyleGrammar(options?: DshSentryStyleOptions): Grammar<DshSentryState>;
|
|
72
|
+
/** The four states this grammar understands, for a host that wants to list them. */
|
|
73
|
+
export declare const DSH_SENTRY_STATES: readonly string[];
|
|
74
|
+
/** The palette it documents, for a host that wants to draw a swatch. */
|
|
75
|
+
export declare const DSH_SENTRY_COLORS: Readonly<Record<string, string>>;
|
|
76
|
+
/** The value sets it accepts, for a host that wants to validate a stored document. */
|
|
77
|
+
export declare const DSH_SENTRY_VOCABULARY: {
|
|
78
|
+
readonly states: string[];
|
|
79
|
+
readonly shapes: string[];
|
|
80
|
+
readonly motions: string[];
|
|
81
|
+
readonly colors: Readonly<Record<string, string>>;
|
|
82
|
+
readonly options: string[];
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=dshSentry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dshSentry.d.ts","sourceRoot":"","sources":["../../../src/grammars/dshSentry.ts"],"names":[],"mappings":"AAkDA,OAAO,KAAK,EACV,OAAO,EAGP,QAAQ,EAET,MAAM,kBAAkB,CAAA;AAKzB,gFAAgF;AAChF,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;AAE9E,wDAAwD;AACxD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd;AAED,4D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CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACzC,wCAAwC;IACxC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC3B,gEAAgE;IAChE,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAA;CACnD;AAmED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,cAAc,CAAC,CAsfzB;AAsBD,oFAAoF;AACpF,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAAmB,CAAA;AAElE,wEAAwE;AACxE,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAkB,CAAA;AAEjF,sFAAsF;AACtF,eAAO,MAAM,qBAAqB;aAChC,MAAM;aACN,MAAM;aACN,OAAO;aACP,MAAM;aACN,OAAO;CACC,CAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { DSH_FONT_INFO_CODES, FONT_COMMON_FAMILIES, FONT_GENERIC_FAMILIES, FONT_WEIGHT_LABELS, FONT_WEIGHT_SCALE, FONT_WEIGHT_WORDS, dshFontQueryGrammar, fontFaceWeights, fontWeightWord, quoteFontFamily, type DshFontEntry, type DshFontProblem, type DshFontQueryOptions, type DshFontState, } from './dshFont.js';
|
|
2
|
+
export { DSH_SENTRY_COLORS, DSH_SENTRY_STATES, DSH_SENTRY_VOCABULARY, dshSentryStyleGrammar, type DshSentryLine, type DshSentryLook, type DshSentryProblem, type DshSentrySlot, type DshSentryState, type DshSentryStyleOptions, type DshSentryWord, } from './dshSentry.js';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/grammars/index.ts"],"names":[],"mappings":"AA2BA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,eAAe,EACf,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,YAAY,GAClB,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,GACnB,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type { CheckRule, Completion, CompletionContext, CompletionRow, CompletionSource, CompletionTrigger, Decoration, DiagnoseContext, Diagnostic, Grammar, HoverContext, HoverInfo, LineInfo, MatchRule, Range, RegionRule, ResolvedVocabulary, Rule, RuleContext, RuleMatch, Scope, ScopeSpec, Severity, SuggestionItem, Token, VocabularyContext, VocabularyEntry, WordInfo, WordsRule, WordsSource, } from './core/types.js';
|
|
2
|
+
export type { PaintSegment, SegmentInput } from './core/segments.js';
|
|
3
|
+
export { excerpt, fillTemplate, listPhrase } from './core/format.js';
|
|
4
|
+
export { clamp, containsOffset, isEmptyRange, isOffset, isWordChar, lineAt, lineIndexAt, lineStarts, scopeAt, tokenAfter, tokenAt, tokenBefore, tokensOnLine, wordInfoAt, } from './core/text.js';
|
|
5
|
+
export { asResolvedVocabulary, defineVocabulary, resolveWordsSource, vocabularyWords, type VocabularySpec, } from './core/vocabulary.js';
|
|
6
|
+
export { isResolvedGrammar, resolveGrammar, scan, type ResolvedGrammar, type ScanResult, } from './core/scan.js';
|
|
7
|
+
export { inspect, normalizeDiagnostics, type Inspection } from './core/inspect.js';
|
|
8
|
+
export { buildSegments, segmentClasses, } from './core/segments.js';
|
|
9
|
+
export { fuzzyMatch, highlightSegments, isWordStart, rank, type FuzzyMatch, type Ranked, type RankOptions, } from './core/rank.js';
|
|
10
|
+
export { applyCompletion, complete, type AppliedCompletion, type CompletionRequest, } from './core/complete.js';
|
|
11
|
+
export { diagnosticHover, resolveHover } from './core/hover.js';
|
|
12
|
+
export { defineCompletion, defineGrammar } from './core/grammar.js';
|
|
13
|
+
export { LITEAREA_STYLES, decorationClass, injectStyles, scopeClass, severityClass, } from './styles.js';
|
|
14
|
+
export * from './dom/index.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAeA,YAAY,EACV,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,UAAU,EACV,OAAO,EACP,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,SAAS,EACT,KAAK,EACL,UAAU,EACV,kBAAkB,EAClB,IAAI,EACJ,WAAW,EACX,SAAS,EACT,KAAK,EACL,SAAS,EACT,QAAQ,EACR,cAAc,EACd,KAAK,EACL,iBAAiB,EACjB,eAAe,EACf,QAAQ,EACR,SAAS,EACT,WAAW,GACZ,MAAM,iBAAiB,CAAA;AAExB,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEpE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAEpE,OAAO,EACL,KAAK,EACL,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,MAAM,EACN,WAAW,EACX,UAAU,EACV,OAAO,EACP,UAAU,EACV,OAAO,EACP,WAAW,EACX,YAAY,EACZ,UAAU,GACX,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,kBA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