@refrakt-md/runes 0.36.0 → 0.37.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/dist/file-ref-resolve.d.ts.map +1 -1
- package/dist/file-ref-resolve.js +36 -1
- package/dist/file-ref-resolve.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/lang-map.d.ts.map +1 -1
- package/dist/lang-map.js +8 -0
- package/dist/lang-map.js.map +1 -1
- package/dist/lib/anchor.d.ts +73 -0
- package/dist/lib/anchor.d.ts.map +1 -0
- package/dist/lib/anchor.js +521 -0
- package/dist/lib/anchor.js.map +1 -0
- package/dist/lib/component.d.ts +1 -1
- package/dist/lib/component.d.ts.map +1 -1
- package/dist/lib/invocation.d.ts +22 -0
- package/dist/lib/invocation.d.ts.map +1 -0
- package/dist/lib/invocation.js +67 -0
- package/dist/lib/invocation.js.map +1 -0
- package/dist/lib/languages.d.ts +163 -0
- package/dist/lib/languages.d.ts.map +1 -0
- package/dist/lib/languages.js +383 -0
- package/dist/lib/languages.js.map +1 -0
- package/dist/lib/line-diff.d.ts +35 -0
- package/dist/lib/line-diff.d.ts.map +1 -0
- package/dist/lib/line-diff.js +77 -0
- package/dist/lib/line-diff.js.map +1 -0
- package/dist/lib/mask.d.ts +116 -0
- package/dist/lib/mask.d.ts.map +1 -0
- package/dist/lib/mask.js +378 -0
- package/dist/lib/mask.js.map +1 -0
- package/dist/lib/node.d.ts +1 -1
- package/dist/lib/node.d.ts.map +1 -1
- package/dist/lib/present.d.ts +73 -0
- package/dist/lib/present.d.ts.map +1 -0
- package/dist/lib/present.js +127 -0
- package/dist/lib/present.js.map +1 -0
- package/dist/lib/read-file.d.ts +21 -1
- package/dist/lib/read-file.d.ts.map +1 -1
- package/dist/lib/read-file.js +46 -0
- package/dist/lib/read-file.js.map +1 -1
- package/dist/lib/renderable.d.ts +7 -3
- package/dist/lib/renderable.d.ts.map +1 -1
- package/dist/lib/renderable.js +2 -2
- package/dist/lib/renderable.js.map +1 -1
- package/dist/lib/review-marker.d.ts +113 -0
- package/dist/lib/review-marker.d.ts.map +1 -0
- package/dist/lib/review-marker.js +173 -0
- package/dist/lib/review-marker.js.map +1 -0
- package/dist/snippet-pipeline.d.ts.map +1 -1
- package/dist/snippet-pipeline.js +70 -2
- package/dist/snippet-pipeline.js.map +1 -1
- package/dist/tags/diff.d.ts.map +1 -1
- package/dist/tags/diff.js +1 -38
- package/dist/tags/diff.js.map +1 -1
- package/dist/tags/file-ref.d.ts.map +1 -1
- package/dist/tags/file-ref.js +59 -1
- package/dist/tags/file-ref.js.map +1 -1
- package/dist/tags/snippet.d.ts.map +1 -1
- package/dist/tags/snippet.js +53 -2
- package/dist/tags/snippet.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invocation.js","sourceRoot":"","sources":["../../src/lib/invocation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,8EAA8E;AAC9E,MAAM,UAAU,SAAS,CAAC,KAAa,EAAE,IAAY;IACpD,OAAO,IAAI,MAAM,CAAC,MAAM,IAAI,oBAAoB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CACjC,KAAa,EACb,IAAY,EACZ,UAAkB;IAElB,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;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AAC,IAAI,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,CAAC;YAAE,OAAO,SAAS,CAAC;QACzB,MAAM,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACnC,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACtC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACxC,OAAO,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,UAAU,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The per-language lexical table (SPEC-131 D15, WORK-597).
|
|
3
|
+
*
|
|
4
|
+
* This module is **data**. The state machine that reads it lives in
|
|
5
|
+
* `mask.ts`, and the split is deliberate — D15 draws the line between what is
|
|
6
|
+
* declarative (comment prefixes, string delimiters, `symbol=` keywords, token
|
|
7
|
+
* pairs, heading shapes, tab width) and what stays code (the masker, the depth
|
|
8
|
+
* counter, continuation lookahead, the balance self-check).
|
|
9
|
+
*
|
|
10
|
+
* **Why a table and not a union regex (D10).** The obvious shortcut is to walk
|
|
11
|
+
* `^\s*(//|#|\*|/\*)` across every language at once. In CSS that eats
|
|
12
|
+
* `#header { … }` as a comment, and a head that silently swallows a preceding
|
|
13
|
+
* rule is exactly the failure class SPEC-131 exists to remove. There are zero
|
|
14
|
+
* such lines in Lumina today, so this repository would never notice — but
|
|
15
|
+
* refrakt ships to projects whose files we have never seen.
|
|
16
|
+
*
|
|
17
|
+
* **A language absent from this table gets no guess.** No comment prefixes
|
|
18
|
+
* means no head absorption and nothing masked, rather than a plausible default
|
|
19
|
+
* that is wrong in a format nobody checked.
|
|
20
|
+
*
|
|
21
|
+
* **No config surface ships with this (D15).** `refrakt.config.json` gains no
|
|
22
|
+
* `languages` or `anchors` key in this milestone. What ships is the
|
|
23
|
+
* {@link mergeLanguages} seam, mirroring `mergeThemeConfig()`, so that
|
|
24
|
+
* declaring a language later is an additive change rather than a retrofit of a
|
|
25
|
+
* hard-coded table.
|
|
26
|
+
*/
|
|
27
|
+
/** A string delimiter and whether it may span a line break. */
|
|
28
|
+
export interface StringDelimiter {
|
|
29
|
+
/** The opening and closing character(s) — the same on both ends. */
|
|
30
|
+
delim: string;
|
|
31
|
+
/** When false (the default) an unterminated string ends at the newline. */
|
|
32
|
+
multiline?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A template delimiter — a string that can contain interpolated code.
|
|
36
|
+
*
|
|
37
|
+
* The interpolation tokens are table data rather than a hard-coded `${`,
|
|
38
|
+
* because the masker must not branch per language (D15).
|
|
39
|
+
*/
|
|
40
|
+
export interface TemplateDelimiter {
|
|
41
|
+
delim: string;
|
|
42
|
+
/** Token that re-enters code state, e.g. `'${'`. Omit for no interpolation. */
|
|
43
|
+
interpolationOpen?: string;
|
|
44
|
+
/** Token that returns to template state, e.g. `'}'`. */
|
|
45
|
+
interpolationClose?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A paired token — WORK-588's `extent="paired"` reads these.
|
|
49
|
+
*
|
|
50
|
+
* Declared here now rather than later because retrofitting a hard-coded table
|
|
51
|
+
* is the expensive part, and the shape is what this module exists to get right.
|
|
52
|
+
*/
|
|
53
|
+
export interface TokenPair {
|
|
54
|
+
open: string;
|
|
55
|
+
close: string;
|
|
56
|
+
/**
|
|
57
|
+
* `asymmetric` — distinct open/close, nests (`{% tabs %}` / `{% /tabs %}`).
|
|
58
|
+
* `symmetric` — same token both ends, cannot nest, first recurrence closes
|
|
59
|
+
* (a ``` fence).
|
|
60
|
+
* `selfClosing` — no close at all (`{% snippet /%}`, `<img>`); a `paired`
|
|
61
|
+
* scan anchored on one returns a single line rather than running to EOF.
|
|
62
|
+
*/
|
|
63
|
+
shape: 'asymmetric' | 'symmetric' | 'selfClosing';
|
|
64
|
+
}
|
|
65
|
+
/** A heading shape — WORK-588's `extent="section"` derives its terminator here. */
|
|
66
|
+
export interface HeadingShape {
|
|
67
|
+
/**
|
|
68
|
+
* Matches a heading line. Capture group 1 must be the part whose **length**
|
|
69
|
+
* gives the nesting level (`###` → 3), so `section` can build a terminator
|
|
70
|
+
* for the anchor's own level without the author doing the arithmetic.
|
|
71
|
+
*/
|
|
72
|
+
pattern: string;
|
|
73
|
+
}
|
|
74
|
+
/** Everything the lexical layer knows about one language. */
|
|
75
|
+
export interface LanguageDefinition {
|
|
76
|
+
/** Line-comment prefixes. Empty means the language has none. */
|
|
77
|
+
lineComments: string[];
|
|
78
|
+
/** Block-comment open/close pairs. */
|
|
79
|
+
blockComments: Array<[open: string, close: string]>;
|
|
80
|
+
/** Quote delimiters. */
|
|
81
|
+
strings: StringDelimiter[];
|
|
82
|
+
/** Template delimiters, which may contain interpolated code. */
|
|
83
|
+
templates: TemplateDelimiter[];
|
|
84
|
+
/** Escape character inside strings and templates. */
|
|
85
|
+
escape?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Annotation prefixes that attach to a declaration (`@Component`,
|
|
88
|
+
* `#[derive]`, `@dataclass`). WORK-587 attaches these to the symbol always,
|
|
89
|
+
* independently of `doc`.
|
|
90
|
+
*/
|
|
91
|
+
annotations: string[];
|
|
92
|
+
/** `symbol=` declaration keywords. */
|
|
93
|
+
keywords: string[];
|
|
94
|
+
/** Declaration modifiers permitted before a keyword. */
|
|
95
|
+
modifiers: string[];
|
|
96
|
+
/** Heading shapes — WORK-588 (`extent="section"`). */
|
|
97
|
+
headings: HeadingShape[];
|
|
98
|
+
/** Token pairs — WORK-588 (`extent="paired"`). */
|
|
99
|
+
tokenPairs: TokenPair[];
|
|
100
|
+
/**
|
|
101
|
+
* Block-fence markers (```` ``` ````, `~~~`).
|
|
102
|
+
*
|
|
103
|
+
* Declaring these switches the masker onto its **Markdown** pass, which is
|
|
104
|
+
* a separate budget line from the C-family state machine and not the same
|
|
105
|
+
* ~40 lines: on a docs site the fences frequently contain the very tokens
|
|
106
|
+
* being counted. `site/content/runes/tabs.md` has a `{% tab %}` in an
|
|
107
|
+
* inline code span, and the pages most worth quoting with `paired` are
|
|
108
|
+
* exactly the ones full of fenced examples of the tags.
|
|
109
|
+
*
|
|
110
|
+
* The fence *marker lines stay visible* and only the interior is blanked,
|
|
111
|
+
* so an author can still anchor on a fence and a symmetric `paired` scan
|
|
112
|
+
* can still find its close.
|
|
113
|
+
*/
|
|
114
|
+
fences: string[];
|
|
115
|
+
/** Inline code-span delimiters. Blanked span and all. */
|
|
116
|
+
inlineCode: string[];
|
|
117
|
+
/** Columns a tab expands to — WORK-588 (`extent="dedent"`). */
|
|
118
|
+
tabWidth: number;
|
|
119
|
+
/**
|
|
120
|
+
* Whether the language belongs to D11's **balanced delimiters** family —
|
|
121
|
+
* the one `extent="auto"` is for, where a `;` or a matching `}` ends a
|
|
122
|
+
* construct.
|
|
123
|
+
*
|
|
124
|
+
* This is a lexical fact, not a strategy (D5): the engine still never
|
|
125
|
+
* guesses which extent to use. What it does is let `auto` refuse in a
|
|
126
|
+
* language where delimiter balance is meaningless, instead of returning a
|
|
127
|
+
* plausible wrong span. Python and YAML are indentation-structured, and
|
|
128
|
+
* Markdoc, Svelte and HTML are tag-paired — pointing `auto` at any of them
|
|
129
|
+
* is the silently-wrong case, so `auto` fails loudly there and the refusal
|
|
130
|
+
* names the strategy that does fit.
|
|
131
|
+
*/
|
|
132
|
+
delimited: boolean;
|
|
133
|
+
}
|
|
134
|
+
/** A partial definition, as an override or a newly declared language. */
|
|
135
|
+
export type LanguageDefinitionOverrides = Partial<LanguageDefinition>;
|
|
136
|
+
/**
|
|
137
|
+
* The built-in table.
|
|
138
|
+
*
|
|
139
|
+
* Keys are the highlight-language identifiers `LANG_MAP` already produces, so
|
|
140
|
+
* extension → language identification is reused rather than duplicated.
|
|
141
|
+
*/
|
|
142
|
+
export declare const BASE_LANGUAGES: Readonly<Record<string, LanguageDefinition>>;
|
|
143
|
+
/**
|
|
144
|
+
* Merge language overrides onto a base table, mirroring `mergeThemeConfig()`.
|
|
145
|
+
*
|
|
146
|
+
* A key with no base entry is a **newly declared language**, not an override,
|
|
147
|
+
* and is taken whole — so the seam supports both extension surfaces D15 names
|
|
148
|
+
* without either of them shipping a config key yet. A key that does exist is
|
|
149
|
+
* merged field by field, with a provided array replacing the base array rather
|
|
150
|
+
* than concatenating: a project narrowing a language's comment prefixes must
|
|
151
|
+
* be able to remove one, which a concatenating merge makes impossible.
|
|
152
|
+
*/
|
|
153
|
+
export declare function mergeLanguages(base: Readonly<Record<string, LanguageDefinition>>, overrides: Record<string, LanguageDefinitionOverrides>): Record<string, LanguageDefinition>;
|
|
154
|
+
/**
|
|
155
|
+
* Look up the lexical definition for a file path or language identifier.
|
|
156
|
+
*
|
|
157
|
+
* Accepts what `inferLanguage` accepts (a path, an extension, or a bare
|
|
158
|
+
* extension) as well as a language id directly. Returns `undefined` for a
|
|
159
|
+
* language not in the table — the caller must treat that as "no lexical
|
|
160
|
+
* knowledge", never as a default.
|
|
161
|
+
*/
|
|
162
|
+
export declare function resolveLanguage(pathOrLang: string, table?: Readonly<Record<string, LanguageDefinition>>): LanguageDefinition | undefined;
|
|
163
|
+
//# sourceMappingURL=languages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"languages.d.ts","sourceRoot":"","sources":["../../src/lib/languages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH,+DAA+D;AAC/D,MAAM,WAAW,eAAe;IAC/B,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,SAAS,CAAC,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MAAM,CAAC;IACjB;;;;;;;;;;;;OAYG;IACH,SAAS,EAAE,OAAO,CAAC;CACnB;AAED,yEAAyE;AACzE,MAAM,MAAM,2BAA2B,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAuBtE;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CA4QtE,CAAC;AAEH;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,EAClD,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,2BAA2B,CAAC,GACpD,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAgBpC;AAuBD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC9B,UAAU,EAAE,MAAM,EAClB,KAAK,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAkB,GAClE,kBAAkB,GAAG,SAAS,CAOhC"}
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The per-language lexical table (SPEC-131 D15, WORK-597).
|
|
3
|
+
*
|
|
4
|
+
* This module is **data**. The state machine that reads it lives in
|
|
5
|
+
* `mask.ts`, and the split is deliberate — D15 draws the line between what is
|
|
6
|
+
* declarative (comment prefixes, string delimiters, `symbol=` keywords, token
|
|
7
|
+
* pairs, heading shapes, tab width) and what stays code (the masker, the depth
|
|
8
|
+
* counter, continuation lookahead, the balance self-check).
|
|
9
|
+
*
|
|
10
|
+
* **Why a table and not a union regex (D10).** The obvious shortcut is to walk
|
|
11
|
+
* `^\s*(//|#|\*|/\*)` across every language at once. In CSS that eats
|
|
12
|
+
* `#header { … }` as a comment, and a head that silently swallows a preceding
|
|
13
|
+
* rule is exactly the failure class SPEC-131 exists to remove. There are zero
|
|
14
|
+
* such lines in Lumina today, so this repository would never notice — but
|
|
15
|
+
* refrakt ships to projects whose files we have never seen.
|
|
16
|
+
*
|
|
17
|
+
* **A language absent from this table gets no guess.** No comment prefixes
|
|
18
|
+
* means no head absorption and nothing masked, rather than a plausible default
|
|
19
|
+
* that is wrong in a format nobody checked.
|
|
20
|
+
*
|
|
21
|
+
* **No config surface ships with this (D15).** `refrakt.config.json` gains no
|
|
22
|
+
* `languages` or `anchors` key in this milestone. What ships is the
|
|
23
|
+
* {@link mergeLanguages} seam, mirroring `mergeThemeConfig()`, so that
|
|
24
|
+
* declaring a language later is an additive change rather than a retrofit of a
|
|
25
|
+
* hard-coded table.
|
|
26
|
+
*/
|
|
27
|
+
import { inferLanguage } from '../lang-map.js';
|
|
28
|
+
/**
|
|
29
|
+
* The C-family lexical core, for the languages that agree on it.
|
|
30
|
+
*
|
|
31
|
+
* A function rather than a shared object so each language gets its own arrays:
|
|
32
|
+
* four definitions pointing at one `blockComments` array is a footgun waiting
|
|
33
|
+
* for the first consumer that mutates what it was handed.
|
|
34
|
+
*/
|
|
35
|
+
function cFamily() {
|
|
36
|
+
return {
|
|
37
|
+
lineComments: ['//'],
|
|
38
|
+
blockComments: [['/*', '*/']],
|
|
39
|
+
strings: [{ delim: '"' }, { delim: "'" }],
|
|
40
|
+
escape: '\\',
|
|
41
|
+
tabWidth: 4,
|
|
42
|
+
delimited: true,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The built-in table.
|
|
47
|
+
*
|
|
48
|
+
* Keys are the highlight-language identifiers `LANG_MAP` already produces, so
|
|
49
|
+
* extension → language identification is reused rather than duplicated.
|
|
50
|
+
*/
|
|
51
|
+
export const BASE_LANGUAGES = Object.freeze({
|
|
52
|
+
typescript: {
|
|
53
|
+
...cFamily(),
|
|
54
|
+
templates: [{ delim: '`', interpolationOpen: '${', interpolationClose: '}' }],
|
|
55
|
+
annotations: ['@'],
|
|
56
|
+
keywords: [
|
|
57
|
+
'interface',
|
|
58
|
+
'type',
|
|
59
|
+
'class',
|
|
60
|
+
'const',
|
|
61
|
+
'let',
|
|
62
|
+
'var',
|
|
63
|
+
'function',
|
|
64
|
+
'enum',
|
|
65
|
+
'namespace',
|
|
66
|
+
],
|
|
67
|
+
modifiers: [
|
|
68
|
+
'export',
|
|
69
|
+
'default',
|
|
70
|
+
'declare',
|
|
71
|
+
'async',
|
|
72
|
+
'abstract',
|
|
73
|
+
'static',
|
|
74
|
+
'public',
|
|
75
|
+
'private',
|
|
76
|
+
'protected',
|
|
77
|
+
'readonly',
|
|
78
|
+
],
|
|
79
|
+
headings: [],
|
|
80
|
+
tokenPairs: [],
|
|
81
|
+
fences: [],
|
|
82
|
+
inlineCode: [],
|
|
83
|
+
},
|
|
84
|
+
javascript: {
|
|
85
|
+
...cFamily(),
|
|
86
|
+
templates: [{ delim: '`', interpolationOpen: '${', interpolationClose: '}' }],
|
|
87
|
+
annotations: ['@'],
|
|
88
|
+
keywords: ['class', 'const', 'let', 'var', 'function'],
|
|
89
|
+
modifiers: ['export', 'default', 'async', 'static'],
|
|
90
|
+
headings: [],
|
|
91
|
+
tokenPairs: [],
|
|
92
|
+
fences: [],
|
|
93
|
+
inlineCode: [],
|
|
94
|
+
},
|
|
95
|
+
json: {
|
|
96
|
+
// JSON has no comments. Giving it `//` would blank a URL inside a string
|
|
97
|
+
// value on any file that reached the masker before the string rule.
|
|
98
|
+
lineComments: [],
|
|
99
|
+
blockComments: [],
|
|
100
|
+
strings: [{ delim: '"' }],
|
|
101
|
+
templates: [],
|
|
102
|
+
escape: '\\',
|
|
103
|
+
annotations: [],
|
|
104
|
+
keywords: [],
|
|
105
|
+
modifiers: [],
|
|
106
|
+
headings: [],
|
|
107
|
+
tokenPairs: [],
|
|
108
|
+
fences: [],
|
|
109
|
+
inlineCode: [],
|
|
110
|
+
tabWidth: 2,
|
|
111
|
+
delimited: true,
|
|
112
|
+
},
|
|
113
|
+
jsonc: {
|
|
114
|
+
lineComments: ['//'],
|
|
115
|
+
blockComments: [['/*', '*/']],
|
|
116
|
+
strings: [{ delim: '"' }],
|
|
117
|
+
templates: [],
|
|
118
|
+
escape: '\\',
|
|
119
|
+
annotations: [],
|
|
120
|
+
keywords: [],
|
|
121
|
+
modifiers: [],
|
|
122
|
+
headings: [],
|
|
123
|
+
tokenPairs: [],
|
|
124
|
+
fences: [],
|
|
125
|
+
inlineCode: [],
|
|
126
|
+
tabWidth: 2,
|
|
127
|
+
delimited: true,
|
|
128
|
+
},
|
|
129
|
+
css: {
|
|
130
|
+
// D10's hazard lives here: CSS has **no** line comment. `#header { … }`
|
|
131
|
+
// is an id selector, and a `#` prefix would swallow the rule above any
|
|
132
|
+
// anchor that followed it.
|
|
133
|
+
lineComments: [],
|
|
134
|
+
blockComments: [['/*', '*/']],
|
|
135
|
+
strings: [{ delim: '"' }, { delim: "'" }],
|
|
136
|
+
templates: [],
|
|
137
|
+
escape: '\\',
|
|
138
|
+
// CSS at-rules are **not** annotations. `@media` and `@layer` open a
|
|
139
|
+
// block; absorbing one as a head would pull an enclosing wrapper into
|
|
140
|
+
// the slice, which is the opposite of what a head is for.
|
|
141
|
+
annotations: [],
|
|
142
|
+
keywords: [],
|
|
143
|
+
modifiers: [],
|
|
144
|
+
headings: [],
|
|
145
|
+
tokenPairs: [],
|
|
146
|
+
fences: [],
|
|
147
|
+
inlineCode: [],
|
|
148
|
+
tabWidth: 2,
|
|
149
|
+
delimited: true,
|
|
150
|
+
},
|
|
151
|
+
python: {
|
|
152
|
+
lineComments: ['#'],
|
|
153
|
+
blockComments: [],
|
|
154
|
+
strings: [
|
|
155
|
+
{ delim: '"""', multiline: true },
|
|
156
|
+
{ delim: "'''", multiline: true },
|
|
157
|
+
{ delim: '"' },
|
|
158
|
+
{ delim: "'" },
|
|
159
|
+
],
|
|
160
|
+
templates: [],
|
|
161
|
+
escape: '\\',
|
|
162
|
+
annotations: ['@'],
|
|
163
|
+
keywords: ['def', 'class'],
|
|
164
|
+
modifiers: ['async'],
|
|
165
|
+
headings: [],
|
|
166
|
+
tokenPairs: [],
|
|
167
|
+
fences: [],
|
|
168
|
+
inlineCode: [],
|
|
169
|
+
tabWidth: 4,
|
|
170
|
+
delimited: false,
|
|
171
|
+
},
|
|
172
|
+
rust: {
|
|
173
|
+
...cFamily(),
|
|
174
|
+
templates: [],
|
|
175
|
+
annotations: ['#['],
|
|
176
|
+
keywords: ['struct', 'impl', 'fn', 'trait', 'enum', 'type', 'const', 'mod'],
|
|
177
|
+
modifiers: ['pub', 'async', 'unsafe', 'default'],
|
|
178
|
+
headings: [],
|
|
179
|
+
tokenPairs: [],
|
|
180
|
+
fences: [],
|
|
181
|
+
inlineCode: [],
|
|
182
|
+
},
|
|
183
|
+
go: {
|
|
184
|
+
...cFamily(),
|
|
185
|
+
strings: [{ delim: '"' }, { delim: "'" }],
|
|
186
|
+
templates: [{ delim: '`' }],
|
|
187
|
+
annotations: [],
|
|
188
|
+
keywords: ['func', 'type', 'var', 'const'],
|
|
189
|
+
modifiers: [],
|
|
190
|
+
headings: [],
|
|
191
|
+
tokenPairs: [],
|
|
192
|
+
fences: [],
|
|
193
|
+
inlineCode: [],
|
|
194
|
+
tabWidth: 8,
|
|
195
|
+
},
|
|
196
|
+
yaml: {
|
|
197
|
+
lineComments: ['#'],
|
|
198
|
+
blockComments: [],
|
|
199
|
+
strings: [{ delim: '"' }, { delim: "'" }],
|
|
200
|
+
templates: [],
|
|
201
|
+
escape: '\\',
|
|
202
|
+
annotations: [],
|
|
203
|
+
keywords: [],
|
|
204
|
+
modifiers: [],
|
|
205
|
+
headings: [],
|
|
206
|
+
tokenPairs: [],
|
|
207
|
+
fences: [],
|
|
208
|
+
inlineCode: [],
|
|
209
|
+
tabWidth: 2,
|
|
210
|
+
delimited: false,
|
|
211
|
+
},
|
|
212
|
+
toml: {
|
|
213
|
+
lineComments: ['#'],
|
|
214
|
+
blockComments: [],
|
|
215
|
+
strings: [{ delim: '"' }, { delim: "'" }],
|
|
216
|
+
templates: [],
|
|
217
|
+
escape: '\\',
|
|
218
|
+
annotations: [],
|
|
219
|
+
keywords: [],
|
|
220
|
+
modifiers: [],
|
|
221
|
+
// A TOML table header is sibling-terminated; every table is level 1, so
|
|
222
|
+
// the capture is the bracket itself.
|
|
223
|
+
headings: [{ pattern: '^(\\[)[^\\[\\]]+\\]\\s*$' }],
|
|
224
|
+
tokenPairs: [],
|
|
225
|
+
fences: [],
|
|
226
|
+
inlineCode: [],
|
|
227
|
+
tabWidth: 2,
|
|
228
|
+
delimited: false,
|
|
229
|
+
},
|
|
230
|
+
bash: {
|
|
231
|
+
lineComments: ['#'],
|
|
232
|
+
blockComments: [],
|
|
233
|
+
strings: [{ delim: '"' }, { delim: "'" }],
|
|
234
|
+
templates: [],
|
|
235
|
+
escape: '\\',
|
|
236
|
+
annotations: [],
|
|
237
|
+
keywords: ['function'],
|
|
238
|
+
modifiers: [],
|
|
239
|
+
headings: [],
|
|
240
|
+
tokenPairs: [],
|
|
241
|
+
fences: [],
|
|
242
|
+
inlineCode: [],
|
|
243
|
+
tabWidth: 4,
|
|
244
|
+
delimited: true,
|
|
245
|
+
},
|
|
246
|
+
html: {
|
|
247
|
+
lineComments: [],
|
|
248
|
+
blockComments: [['<!--', '-->']],
|
|
249
|
+
strings: [{ delim: '"' }, { delim: "'" }],
|
|
250
|
+
templates: [],
|
|
251
|
+
annotations: [],
|
|
252
|
+
keywords: [],
|
|
253
|
+
modifiers: [],
|
|
254
|
+
headings: [],
|
|
255
|
+
tokenPairs: [
|
|
256
|
+
{ open: '<', close: '</', shape: 'asymmetric' },
|
|
257
|
+
{ open: '<img', close: '', shape: 'selfClosing' },
|
|
258
|
+
{ open: '<br', close: '', shape: 'selfClosing' },
|
|
259
|
+
],
|
|
260
|
+
fences: [],
|
|
261
|
+
inlineCode: [],
|
|
262
|
+
tabWidth: 2,
|
|
263
|
+
delimited: false,
|
|
264
|
+
},
|
|
265
|
+
markdoc: {
|
|
266
|
+
// Markdown's masker is recursive — fenced blocks and inline code spans
|
|
267
|
+
// that frequently contain the very tokens being counted. SPEC-131 is
|
|
268
|
+
// explicit that this is "not the same ~40 lines" as the C family, so it
|
|
269
|
+
// is WORK-588's, alongside the strategies that need it. The shapes
|
|
270
|
+
// below are declared now; nothing masks them yet.
|
|
271
|
+
lineComments: [],
|
|
272
|
+
blockComments: [['<!--', '-->']],
|
|
273
|
+
strings: [],
|
|
274
|
+
templates: [],
|
|
275
|
+
annotations: [],
|
|
276
|
+
keywords: [],
|
|
277
|
+
modifiers: [],
|
|
278
|
+
headings: [{ pattern: '^(#{1,6})\\s+\\S' }],
|
|
279
|
+
tokenPairs: [
|
|
280
|
+
{ open: '{%', close: '{% /', shape: 'asymmetric' },
|
|
281
|
+
{ open: '```', close: '```', shape: 'symmetric' },
|
|
282
|
+
{ open: '{%', close: '/%}', shape: 'selfClosing' },
|
|
283
|
+
],
|
|
284
|
+
fences: ['```', '~~~'],
|
|
285
|
+
inlineCode: ['`'],
|
|
286
|
+
tabWidth: 2,
|
|
287
|
+
delimited: false,
|
|
288
|
+
},
|
|
289
|
+
svelte: {
|
|
290
|
+
lineComments: [],
|
|
291
|
+
blockComments: [['<!--', '-->']],
|
|
292
|
+
strings: [{ delim: '"' }, { delim: "'" }],
|
|
293
|
+
templates: [],
|
|
294
|
+
annotations: [],
|
|
295
|
+
keywords: [],
|
|
296
|
+
modifiers: [],
|
|
297
|
+
headings: [],
|
|
298
|
+
tokenPairs: [{ open: '<', close: '</', shape: 'asymmetric' }],
|
|
299
|
+
fences: [],
|
|
300
|
+
inlineCode: [],
|
|
301
|
+
tabWidth: 2,
|
|
302
|
+
delimited: false,
|
|
303
|
+
},
|
|
304
|
+
vue: {
|
|
305
|
+
lineComments: [],
|
|
306
|
+
blockComments: [['<!--', '-->']],
|
|
307
|
+
strings: [{ delim: '"' }, { delim: "'" }],
|
|
308
|
+
templates: [],
|
|
309
|
+
annotations: [],
|
|
310
|
+
keywords: [],
|
|
311
|
+
modifiers: [],
|
|
312
|
+
headings: [],
|
|
313
|
+
tokenPairs: [{ open: '<', close: '</', shape: 'asymmetric' }],
|
|
314
|
+
fences: [],
|
|
315
|
+
inlineCode: [],
|
|
316
|
+
tabWidth: 2,
|
|
317
|
+
delimited: false,
|
|
318
|
+
},
|
|
319
|
+
});
|
|
320
|
+
/**
|
|
321
|
+
* Merge language overrides onto a base table, mirroring `mergeThemeConfig()`.
|
|
322
|
+
*
|
|
323
|
+
* A key with no base entry is a **newly declared language**, not an override,
|
|
324
|
+
* and is taken whole — so the seam supports both extension surfaces D15 names
|
|
325
|
+
* without either of them shipping a config key yet. A key that does exist is
|
|
326
|
+
* merged field by field, with a provided array replacing the base array rather
|
|
327
|
+
* than concatenating: a project narrowing a language's comment prefixes must
|
|
328
|
+
* be able to remove one, which a concatenating merge makes impossible.
|
|
329
|
+
*/
|
|
330
|
+
export function mergeLanguages(base, overrides) {
|
|
331
|
+
const merged = { ...base };
|
|
332
|
+
for (const [name, override] of Object.entries(overrides)) {
|
|
333
|
+
const existing = merged[name];
|
|
334
|
+
if (!existing) {
|
|
335
|
+
merged[name] = normalizeDefinition(override);
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
merged[name] = {
|
|
339
|
+
...existing,
|
|
340
|
+
...override,
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
return merged;
|
|
344
|
+
}
|
|
345
|
+
/** Fill a partial definition out to a complete one — an undeclared field is
|
|
346
|
+
* empty rather than inherited from an unrelated language. */
|
|
347
|
+
function normalizeDefinition(partial) {
|
|
348
|
+
return {
|
|
349
|
+
lineComments: partial.lineComments ?? [],
|
|
350
|
+
blockComments: partial.blockComments ?? [],
|
|
351
|
+
strings: partial.strings ?? [],
|
|
352
|
+
templates: partial.templates ?? [],
|
|
353
|
+
escape: partial.escape,
|
|
354
|
+
annotations: partial.annotations ?? [],
|
|
355
|
+
keywords: partial.keywords ?? [],
|
|
356
|
+
modifiers: partial.modifiers ?? [],
|
|
357
|
+
headings: partial.headings ?? [],
|
|
358
|
+
tokenPairs: partial.tokenPairs ?? [],
|
|
359
|
+
fences: partial.fences ?? [],
|
|
360
|
+
inlineCode: partial.inlineCode ?? [],
|
|
361
|
+
tabWidth: partial.tabWidth ?? 4,
|
|
362
|
+
delimited: partial.delimited ?? false,
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Look up the lexical definition for a file path or language identifier.
|
|
367
|
+
*
|
|
368
|
+
* Accepts what `inferLanguage` accepts (a path, an extension, or a bare
|
|
369
|
+
* extension) as well as a language id directly. Returns `undefined` for a
|
|
370
|
+
* language not in the table — the caller must treat that as "no lexical
|
|
371
|
+
* knowledge", never as a default.
|
|
372
|
+
*/
|
|
373
|
+
export function resolveLanguage(pathOrLang, table = BASE_LANGUAGES) {
|
|
374
|
+
if (typeof pathOrLang !== 'string' || pathOrLang.length === 0)
|
|
375
|
+
return undefined;
|
|
376
|
+
// A language id wins over extension inference, so `resolveLanguage('css')`
|
|
377
|
+
// works without dressing it up as a filename.
|
|
378
|
+
const direct = table[pathOrLang.toLowerCase()];
|
|
379
|
+
if (direct)
|
|
380
|
+
return direct;
|
|
381
|
+
return table[inferLanguage(pathOrLang)];
|
|
382
|
+
}
|
|
383
|
+
//# sourceMappingURL=languages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"languages.js","sourceRoot":"","sources":["../../src/lib/languages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAqH/C;;;;;;GAMG;AACH,SAAS,OAAO;IAIf,OAAO;QACN,YAAY,EAAE,CAAC,IAAI,CAAC;QACpB,aAAa,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC7B,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;QACzC,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,C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,IAAI,EAAE;QAC9B,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,EAAE;QAClC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,EAAE;QACtC,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,EAAE;QAChC,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,EAAE;QAClC,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,EAAE;QAChC,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE;QACpC,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE;QAC5B,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE;QACpC,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,CAAC;QAC/B,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,KAAK;KACrC,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC9B,UAAkB,EAClB,QAAsD,cAAc;IAEpE,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAChF,2EAA2E;IAC3E,8CAA8C;IAC9C,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;IAC/C,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,OAAO,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Line-level LCS diff.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `tags/diff.ts` (WORK-592), where it was module-local, so that
|
|
5
|
+
* both the `diff` rune and the `snippet review` terminal renderer read one
|
|
6
|
+
* implementation. A pure move: the algorithm is unchanged.
|
|
7
|
+
*/
|
|
8
|
+
export interface DiffHunk {
|
|
9
|
+
type: 'equal' | 'add' | 'remove';
|
|
10
|
+
text: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Compute a line-level diff using LCS (Longest Common Subsequence).
|
|
14
|
+
*
|
|
15
|
+
* Returns hunks with type and raw text. Presentation — highlighting, gutters,
|
|
16
|
+
* terminal colour — is the caller's.
|
|
17
|
+
*/
|
|
18
|
+
export declare function computeLineDiff(before: string, after: string): DiffHunk[];
|
|
19
|
+
/**
|
|
20
|
+
* A one-line summary of what changed between two slices.
|
|
21
|
+
*
|
|
22
|
+
* D7's example reads "+2 fields, 1 removed", which requires *interpreting* the
|
|
23
|
+
* diff rather than reporting it. The spec left the granularity open; this is
|
|
24
|
+
* the settled answer, and the reasoning is recorded because it was a real
|
|
25
|
+
* choice:
|
|
26
|
+
*
|
|
27
|
+
* Counting added and removed lines is cheap and honest. Naming *fields* would
|
|
28
|
+
* mean parsing the slice, which needs a language-aware layer this feature does
|
|
29
|
+
* not have and SPEC-131 D1 deliberately declined to build. A count that says
|
|
30
|
+
* "3 added, 1 removed" tells an author how much to expect; a count that claimed
|
|
31
|
+
* "2 fields" while actually counting lines would be worse than the cheap
|
|
32
|
+
* version, because it would sound authoritative.
|
|
33
|
+
*/
|
|
34
|
+
export declare function summarizeDiff(before: string, after: string): string;
|
|
35
|
+
//# sourceMappingURL=line-diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line-diff.d.ts","sourceRoot":"","sources":["../../src/lib/line-diff.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,QAAQ;IACxB,IAAI,EAAE,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,EAAE,CAoCzE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAUnE"}
|