@cosense-toolbox/lsp 0.1.0-beta.4 → 0.1.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -10
- package/dist/tokens.d.mts.map +1 -1
- package/dist/tokens.mjs +6 -1
- package/dist/tokens.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
> **beta.** 設定の名前や出力の形はまだ変わりえます。
|
|
4
4
|
|
|
5
|
-
`.csn` / `.csnx`
|
|
6
|
-
どちらも [`@cosense-toolbox/parser`](../parser)
|
|
5
|
+
`.csn` / `.csnx` に対応する Language Server と、サイト内のリンクをまとめて検査する `check` コマンドを提供します。
|
|
6
|
+
どちらも [`@cosense-toolbox/parser`](../parser) で解析するため、記法の解釈が Cosense の描画とそろいます。
|
|
7
|
+
|
|
8
|
+
**ドキュメント → <https://cosense-toolbox.qaynam.dev/lsp/>**
|
|
7
9
|
|
|
8
10
|
## Language Server
|
|
9
11
|
|
|
@@ -16,7 +18,7 @@ csn-lsp --stdio
|
|
|
16
18
|
- `[ページ名]` からそのページのファイルへの定義ジャンプ
|
|
17
19
|
- 存在しないページへのリンクの診断
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
設定はエディターの `initialization_options` で渡します。いずれも省略できます。
|
|
20
22
|
|
|
21
23
|
| 設定 | 内容 | 既定 |
|
|
22
24
|
| :---------------- | :------------------------------------------------------------------------------------- | :----------------- |
|
|
@@ -26,25 +28,24 @@ csn-lsp --stdio
|
|
|
26
28
|
|
|
27
29
|
## check
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
エディター上の診断と同じ判定で、指定したディレクトリ内のページリンクを検査します。CI での利用を想定しています。
|
|
30
32
|
|
|
31
33
|
```sh
|
|
32
34
|
csn-lsp check src/content src/pages
|
|
33
35
|
# src/content/posts/a.csn:5:3 error リンク先のページが見つからない: [無いページ]
|
|
34
36
|
```
|
|
35
37
|
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
- `[! 注意]`
|
|
39
|
-
- エラーが
|
|
38
|
+
- 引数に指定したディレクトリ以下の `.csn` / `.csnx` を読みます。省略した場合は、カレントディレクトリを対象にします。
|
|
39
|
+
- ページ名は各ファイルの 1 行目から取得します。照合では大文字・小文字と空白・`_` の違いを無視します。
|
|
40
|
+
- `[! 注意]` のような文字装飾は Cosense Web と同じ規則で判定し、リンクとして扱いません。
|
|
41
|
+
- エラーが1件以上ある場合は終了コード `1`、エラーがない場合は `0`、オプションが不正な場合は `2` を返します。
|
|
40
42
|
|
|
41
43
|
| オプション | 内容 | 既定 |
|
|
42
44
|
| :--------------------------- | :--------------------------------------------------- | :------ |
|
|
43
45
|
| `--unresolved-links <level>` | `off` / `hint` / `information` / `warning` / `error` | `error` |
|
|
44
46
|
| `--no-frontmatter` | 1 行目の `---` を frontmatter ではなく題名として読む | |
|
|
45
47
|
|
|
46
|
-
`check`
|
|
47
|
-
`--unresolved-links warning` にする (終了コードは 0 になる)。
|
|
48
|
+
`check` はリンク切れを見つけたらビルドを止めるため、重大度の既定値を `error` にしています。報告だけにしたい場合は `--unresolved-links warning` を指定してください (終了コードは `0` になります)。
|
|
48
49
|
|
|
49
50
|
## ライブラリとして
|
|
50
51
|
|
package/dist/tokens.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.d.mts","names":[],"sources":["../src/tokens.ts"],"mappings":";;;;;;;;;;;cAqBa;KAgCD,oBAAoB;;KAG3B,mBAAmB,QAAQ;UAEtB;WACC;WACA;WACA;;KAGC,YACP;WAAkB,MAAM;MACxB;WAAkB;WAA2B;;;;;;;;;;UAUjC;WACN;WACA;;;;;;;;cASE;;;;;;;;cAwDA,WAAY,WAAW,cAAc,cAAY;cAkEjD,gBAAc;;cA2Gd,iBAAkB,OAAO,0BAAwB,OAAO;;;;;cAUxD,UACX,OAAO,uBACP,yBACC,OAAO;
|
|
1
|
+
{"version":3,"file":"tokens.d.mts","names":[],"sources":["../src/tokens.ts"],"mappings":";;;;;;;;;;;cAqBa;KAgCD,oBAAoB;;KAG3B,mBAAmB,QAAQ;UAEtB;WACC;WACA;WACA;;KAGC,YACP;WAAkB,MAAM;MACxB;WAAkB;WAA2B;;;;;;;;;;UAUjC;WACN;WACA;;;;;;;;cASE;;;;;;;;cAwDA,WAAY,WAAW,cAAc,cAAY;cAkEjD,gBAAc;;cA2Gd,iBAAkB,OAAO,0BAAwB,OAAO;;;;;cAUxD,UACX,OAAO,uBACP,yBACC,OAAO;UA6IO;;WAEN;;WAEA,eAAe;;WAEf,YAAY,cAAc;;;;;WAK1B;;;cAIE,gBAAiB,cAAc,UAAS,yBAA4B;;;;;;cAqDpE,eACX,QAAQ,cAAc,WACtB,SAAQ"}
|
package/dist/tokens.mjs
CHANGED
|
@@ -191,6 +191,11 @@ const lineSpans = (type, lines, first, last) => Array.filterMap(Array.range(firs
|
|
|
191
191
|
const componentLine = (page, line) => pipe(Option.fromNullable(page.lines[line]), Option.filter((text) => page.components && COMPONENT_LINE.test(text)));
|
|
192
192
|
/** The `>` and spaces that open a quote line, from its indentation onwards. */
|
|
193
193
|
const quoteToken = (page, node, line) => pipe(onlyIf(node.quote, page.lines[line] ?? ""), Option.map((text) => matchLength(/^[> ]*/, text, node.indent)), Option.filter((length) => length > 0), Option.map((length) => token("quote", line, node.indent, node.indent + length)));
|
|
194
|
+
/**
|
|
195
|
+
* A command line (`$ ls`) is code as a whole: the parser keeps its text as written, with no
|
|
196
|
+
* notation in it, so its one text node is the span to colour.
|
|
197
|
+
*/
|
|
198
|
+
const commandTokens = (line, shift) => Array.map(line.children, (child) => spanToken("code", shift(child.position)));
|
|
194
199
|
/** A token for each of `notations` whose marker opens the decoration. */
|
|
195
200
|
const notationTokens = (notations, node, position) => Array.filterMap(notations, ({ marker, name }) => onlyIf(node.markers.includes(marker), {
|
|
196
201
|
line: position.start.line,
|
|
@@ -220,7 +225,7 @@ const nodeTokens = (page) => (node) => {
|
|
|
220
225
|
table: (table) => leaf(lineSpans("table", page.lines, lineOf(table.position), table.position.end.line + page.offset)),
|
|
221
226
|
line: (line) => pipe(componentLine(page, lineOf(line.position)), Option.match({
|
|
222
227
|
onSome: (text) => leaf(componentTokens(lineOf(line.position), text)),
|
|
223
|
-
onNone: () => branch(Option.toArray(quoteToken(page, line, lineOf(line.position))))
|
|
228
|
+
onNone: () => line.monospace ? leaf(commandTokens(line, shift)) : branch(Option.toArray(quoteToken(page, line, lineOf(line.position))))
|
|
224
229
|
})),
|
|
225
230
|
decoration: (decoration) => branch([...decorationTokenTypes(decoration).map((type) => spanToken(type, shift(decoration.position))), ...notationTokens(page.notations, decoration, shift(decoration.position))])
|
|
226
231
|
}), Match.orElse((other) => branch(pipe(Option.fromNullable(INLINE_TOKEN_TYPE[other.type]), Option.map((type) => spanToken(type, shift(other.position))), Option.toArray))));
|
package/dist/tokens.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.mjs","names":["Arr"],"sources":["../src/tokens.ts"],"sourcesContent":["import type {\n AnyNode,\n AnyNodeType,\n Decoration,\n NodeOfType,\n ParseOptions,\n Position,\n} from \"@cosense-toolbox/parser\"\nimport { normalizeLineEndings, parse } from \"@cosense-toolbox/parser\"\nimport { Array as Arr, Match, Option, Order, pipe } from \"effect\"\n\nimport { branch, gather, leaf, type Picked } from \"./tree\"\n\n/**\n * Cosense notation as LSP semantic tokens.\n *\n * These names are the ones this package reasons in, and they are not what goes on the wire.\n * A client announces the token types it knows at initialize and drops everything else —\n * some send the LSP's own list and nothing more — so `quote` would simply never be drawn.\n * LEGEND below is what is sent, and LSP_TYPE is the translation.\n */\nexport const TOKEN_TYPES = [\n \"title\",\n \"link\",\n \"projectLink\",\n \"externalLink\",\n \"hashtag\",\n \"code\",\n \"codeBlock\",\n \"formula\",\n \"icon\",\n \"quote\",\n \"bold\",\n \"italic\",\n \"strike\",\n \"underline\",\n \"image\",\n \"table\",\n \"bold2\",\n \"bold3\",\n // `.csnx` only: a line that opens with a component tag. The tag's name, its attribute\n // names, and the two kinds of value, as JSX reads them.\n \"component\",\n \"attribute\",\n \"attributeValue\",\n \"expression\",\n // The YAML at the top of the file, which is not Cosense notation at all.\n \"frontmatter\",\n // A notation the caller defines (see `Notation`), such as `[! 注意]`. The token carries\n // the name the caller gave it.\n \"notation\",\n] as const\n\nexport type TokenType = (typeof TOKEN_TYPES)[number]\n\n/** Every token type but `notation`, whose tokens also carry a name. */\ntype BuiltinTokenType = Exclude<TokenType, \"notation\">\n\ninterface Span {\n readonly line: number\n readonly char: number\n readonly length: number\n}\n\nexport type RawToken =\n | (Span & { readonly type: BuiltinTokenType })\n | (Span & { readonly type: \"notation\"; readonly name: string })\n\n/**\n * A name the caller gives to a decoration marker, as `warning` to the `!` of `[! 注意]`: the\n * token type that decoration is sent as.\n *\n * The marker has to be one Cosense decorates with (`` !\"#%&'()*+,-./{|}<>_~= ``), since\n * those are the ones the parser reads as a decoration. Any other, such as `@`, leaves the\n * bracket a link, as it is in Cosense Web: how a notation looks does not change how it parses.\n */\nexport interface Notation {\n readonly marker: string\n readonly name: string\n}\n\n/**\n * The legend sent to the client: the LSP's own token types, in its own order.\n *\n * Every entry is in the set a client is expected to understand, which is what makes the\n * colours appear without the reader configuring anything.\n */\nexport const LEGEND = [\n \"namespace\",\n \"type\",\n \"function\",\n \"variable\",\n \"property\",\n \"parameter\",\n \"decorator\",\n \"macro\",\n \"keyword\",\n \"string\",\n \"number\",\n \"comment\",\n] as const\n\n/**\n * What each notation is drawn as. Chosen so that things a reader separates by eye land on\n * different entries: a link is not a tag, and a quote is not a heading. `bold` and its\n * louder siblings share one entry, because the LSP has no notion of weight and a theme\n * gives each type a single colour.\n */\nconst LSP_TYPE: Record<TokenType, (typeof LEGEND)[number]> = {\n title: \"namespace\",\n link: \"function\",\n projectLink: \"function\",\n externalLink: \"string\",\n icon: \"function\",\n image: \"string\",\n hashtag: \"decorator\",\n code: \"string\",\n codeBlock: \"string\",\n formula: \"number\",\n table: \"property\",\n quote: \"comment\",\n frontmatter: \"comment\",\n component: \"type\",\n attribute: \"parameter\",\n attributeValue: \"string\",\n expression: \"variable\",\n bold: \"keyword\",\n bold2: \"keyword\",\n bold3: \"keyword\",\n italic: \"macro\",\n strike: \"comment\",\n underline: \"variable\",\n // What a caller's notation is sent as when the legend has no type of its name.\n notation: \"decorator\",\n}\n\n/**\n * LEGEND with the names of `notations` after it, each once: the legend for a client that\n * accepts token types of the caller's own naming. The LSP's types keep their places.\n *\n * A client that colours by this package's own names instead passes those to `encodeTokens`\n * (`[...TOKEN_TYPES, ...names]`): a token whose own name is in the legend is sent as that.\n */\nexport const legendOf = (notations: ReadonlyArray<Notation>): ReadonlyArray<string> =>\n Arr.dedupe([...LEGEND, ...Arr.map(notations, (notation) => notation.name)])\n\n/** Leaf inline nodes that map 1:1. Each sits on one line, so no splitting is needed. */\nconst INLINE_TOKEN_TYPE: Partial<Record<AnyNodeType, BuiltinTokenType>> = {\n internalLink: \"link\",\n externalLink: \"externalLink\",\n projectLink: \"projectLink\",\n hashtag: \"hashtag\",\n inlineCode: \"code\",\n image: \"image\",\n icon: \"icon\",\n formula: \"formula\",\n}\n\n/** Top to bottom, then left to right: the order the LSP encoding needs. */\nconst BY_POSITION: Order.Order<RawToken> = Order.combine(\n Order.mapInput(Order.number, (token: RawToken) => token.line),\n Order.mapInput(Order.number, (token: RawToken) => token.char),\n)\n\nconst onlyIf = <A>(condition: boolean, value: A): Option.Option<A> =>\n condition ? Option.some(value) : Option.none()\n\n/** A token over `[from, to)` of one line. */\nconst token = (type: BuiltinTokenType, line: number, from: number, to: number): RawToken => ({\n line,\n char: from,\n length: to - from,\n type,\n})\n\nconst spanToken = (type: BuiltinTokenType, position: Position): RawToken =>\n token(type, position.start.line, position.start.column, position.end.column)\n\n/** How many characters from `from` the `^`-anchored `pattern` takes; 0 when it takes none. */\nconst matchLength = (pattern: RegExp, text: string, from: number): number =>\n pipe(\n Option.fromNullable(pattern.exec(text.slice(from))),\n Option.match({ onNone: () => 0, onSome: ([matched]) => matched.length }),\n )\n\n// --- Emphasis ---------------------------------------------------------------------------\n\n/** Cosense sizes emphasis by asterisk count (`[*]`..`[*****]`); sizeLevel is 0-indexed. */\nconst boldTokenType = (sizeLevel: number): BuiltinTokenType =>\n Match.value(sizeLevel).pipe(\n Match.when(\n (level) => level >= 2,\n (): BuiltinTokenType => \"bold3\",\n ),\n Match.when(1, (): BuiltinTokenType => \"bold2\"),\n Match.orElse((): BuiltinTokenType => \"bold\"),\n )\n\n/** Every decoration a run carries, since Cosense applies all of them: `[-* x]` is both. */\nconst decorationTokenTypes = (node: Decoration): ReadonlyArray<BuiltinTokenType> =>\n Arr.getSomes([\n onlyIf(node.underline, \"underline\" as const),\n onlyIf(node.strike, \"strike\" as const),\n onlyIf(node.italic, \"italic\" as const),\n onlyIf(node.bold, boldTokenType(node.sizeLevel)),\n ])\n\n// --- Component lines (`.csnx`) ----------------------------------------------------------\n\nexport const COMPONENT_LINE = /^\\s*<\\/?[A-Z][A-Za-z0-9_.]*(\\s|\\/?>)/\nconst TAG_OPEN = /^(\\s*<\\/?)([A-Z][A-Za-z0-9_.]*)/\nconst ATTRIBUTE_NAME = /^[A-Za-z_:][A-Za-z0-9_:.-]*/\nconst SPACE = /^\\s*/\n\n/** Where a quoted value opened at `from` ends: after its closing quote, or at the line's end. */\nconst quotedEnd = (text: string, from: number): number =>\n pipe(\n text.indexOf(text.charAt(from), from + 1),\n Option.liftPredicate((close) => close >= 0),\n Option.match({ onNone: () => text.length, onSome: (close) => close + 1 }),\n )\n\n/** Where `{ ... }` opened at `from` ends, counting nested braces: after its `}`, or the line's end. */\nconst bracedEnd = (text: string, from: number): number =>\n pipe(\n text.slice(from).split(\"\"),\n Arr.scan(0, (depth, char) => (char === \"{\" ? depth + 1 : char === \"}\" ? depth - 1 : depth)),\n // scan starts with the depth before any character; the rest line up with the characters.\n Arr.drop(1),\n Arr.findFirstIndex((depth) => depth === 0),\n Option.match({ onNone: () => text.length, onSome: (index) => from + index + 1 }),\n )\n\ntype ValueType = \"attributeValue\" | \"expression\"\n\n/** The attribute value that starts at `from`: its type and where it ends. */\nconst valueAt = (text: string, from: number): Option.Option<readonly [ValueType, number]> =>\n Match.value(text.charAt(from)).pipe(\n Match.when(\n (char) => char === '\"' || char === \"'\",\n () => Option.some([\"attributeValue\", quotedEnd(text, from)] as const),\n ),\n Match.when(\"{\", () => Option.some([\"expression\", bracedEnd(text, from)] as const)),\n Match.orElse(() => Option.none()),\n )\n\n/** The tokens of one attribute, and where the next may start. */\ntype Step = readonly [ReadonlyArray<RawToken>, number]\n\n/** `at` past any whitespace. */\nconst skipSpace = (text: string, at: number): number => at + matchLength(SPACE, text, at)\n\n/** Whether the tag closes at `at`, with `>` or `/>`, or the line ends there. */\nconst closesAt = (text: string, at: number): boolean =>\n at >= text.length || text.startsWith(\">\", at) || text.startsWith(\"/>\", at)\n\n/**\n * An attribute named over `[at, nameEnd)`: the name, then `=` and a value if one follows.\n * A name with no `=` after it stands alone, as JSX reads `<Dialog open>`.\n */\nconst attribute = (line: number, text: string, at: number, nameEnd: number): Step => {\n const name = token(\"attribute\", line, at, nameEnd)\n const afterName = skipSpace(text, nameEnd)\n return pipe(\n Option.liftPredicate(afterName, (equals) => text.charAt(equals) === \"=\"),\n Option.map((equals) => skipSpace(text, equals + 1)),\n Option.match({\n onNone: (): Step => [[name], afterName],\n onSome: (valueStart): Step =>\n pipe(\n valueAt(text, valueStart),\n Option.match({\n onNone: (): Step => [[name], valueStart],\n onSome: ([type, end]): Step => [[name, token(type, line, valueStart, end)], end],\n }),\n ),\n }),\n )\n}\n\n/** One attribute from `from`, or None once the tag has closed. */\nconst attributeStep =\n (line: number, text: string) =>\n (from: number): Option.Option<Step> =>\n pipe(\n Option.liftPredicate(skipSpace(text, from), (at) => !closesAt(text, at)),\n Option.map((at) =>\n pipe(\n Option.liftPredicate(at + matchLength(ATTRIBUTE_NAME, text, at), (end) => end > at),\n Option.match({\n // Not a name: step over the character, since the tag may still go on after it.\n onNone: (): Step => [[], at + 1],\n onSome: (nameEnd) => attribute(line, text, at, nameEnd),\n }),\n ),\n ),\n )\n\n/**\n * The tag that opens a component line, read as JSX: its name, then each attribute and its\n * value, up to the `>` that closes it. Text after the tag is left alone; it is neither\n * Cosense notation nor part of the tag.\n */\nconst componentTokens = (line: number, text: string): ReadonlyArray<RawToken> =>\n pipe(\n Option.fromNullable(TAG_OPEN.exec(text)),\n Option.map(([head, lead = \"\", name = \"\"]) => [\n token(\"component\", line, lead.length, lead.length + name.length),\n ...Arr.flatten(Arr.unfold(head.length, attributeStep(line, text))),\n ]),\n Option.getOrElse(() => []),\n )\n\n// --- The page ---------------------------------------------------------------------------\n\n/** The last line of the `---` fence around YAML at the very top, if the file opens with one. */\nexport const frontmatterEnd = (lines: ReadonlyArray<string>): Option.Option<number> =>\n pipe(\n Option.liftPredicate(lines, (all) => all[0]?.trim() === \"---\"),\n Option.flatMap(Arr.findFirstIndex((line, index) => index > 0 && line.trim() === \"---\")),\n )\n\n/**\n * `frontmatterEnd`, or None when the caller reads no frontmatter: a Cosense page has none,\n * and a page whose title is `---` would otherwise lose its first lines to it.\n */\nexport const fenceOf = (\n lines: ReadonlyArray<string>,\n frontmatter: boolean,\n): Option.Option<number> => Option.flatMap(onlyIf(frontmatter, lines), frontmatterEnd)\n\n/** What the node visitor needs to know about the file around the parsed body. */\ninterface Page {\n readonly lines: ReadonlyArray<string>\n /** Lines before the body: the frontmatter, which the parser never sees. */\n readonly offset: number\n readonly components: boolean\n readonly notations: ReadonlyArray<Notation>\n}\n\n/** Each non-empty line from `first` to `last`, whole. */\nconst lineSpans = (\n type: BuiltinTokenType,\n lines: ReadonlyArray<string>,\n first: number,\n last: number,\n): ReadonlyArray<RawToken> =>\n Arr.filterMap(Arr.range(first, last), (line) =>\n pipe(\n Option.fromNullable(lines[line]),\n Option.filter((text) => text.length > 0),\n Option.map((text) => token(type, line, 0, text.length)),\n ),\n )\n\n/** The line's text, when the file reads components and the line opens with a tag. */\nconst componentLine = (page: Page, line: number): Option.Option<string> =>\n pipe(\n Option.fromNullable(page.lines[line]),\n Option.filter((text) => page.components && COMPONENT_LINE.test(text)),\n )\n\n/** The `>` and spaces that open a quote line, from its indentation onwards. */\nconst quoteToken = (page: Page, node: NodeOfType<\"line\">, line: number): Option.Option<RawToken> =>\n pipe(\n onlyIf(node.quote, page.lines[line] ?? \"\"),\n Option.map((text) => matchLength(/^[> ]*/, text, node.indent)),\n Option.filter((length) => length > 0),\n Option.map((length) => token(\"quote\", line, node.indent, node.indent + length)),\n )\n\n/** A token for each of `notations` whose marker opens the decoration. */\nconst notationTokens = (\n notations: ReadonlyArray<Notation>,\n node: Decoration,\n position: Position,\n): ReadonlyArray<RawToken> =>\n Arr.filterMap(notations, ({ marker, name }) =>\n onlyIf(node.markers.includes(marker), {\n line: position.start.line,\n char: position.start.column,\n length: position.end.column - position.start.column,\n type: \"notation\" as const,\n name,\n }),\n )\n\nconst nodeTokens =\n (page: Page) =>\n (node: AnyNode): Picked<RawToken> => {\n const lineOf = (position: Position) => position.start.line + page.offset\n const shift = (position: Position): Position => ({\n start: { ...position.start, line: position.start.line + page.offset },\n end: { ...position.end, line: position.end.line + page.offset },\n })\n return Match.value(node).pipe(\n Match.discriminators(\"type\")({\n // A page that opens with a component has no title line: the tag is what it is.\n title: (title) =>\n leaf(\n pipe(\n componentLine(page, lineOf(title.position)),\n Option.match({\n onNone: () => [spanToken(\"title\", shift(title.position))],\n onSome: (text) => componentTokens(lineOf(title.position), text),\n }),\n ),\n ),\n codeBlock: (block) =>\n leaf(\n lineSpans(\n \"codeBlock\",\n page.lines,\n lineOf(block.position),\n block.position.end.line + page.offset,\n ),\n ),\n table: (table) =>\n leaf(\n lineSpans(\n \"table\",\n page.lines,\n lineOf(table.position),\n table.position.end.line + page.offset,\n ),\n ),\n // A component tag owns its line, so nothing on it is Cosense notation.\n line: (line) =>\n pipe(\n componentLine(page, lineOf(line.position)),\n Option.match({\n onSome: (text) => leaf(componentTokens(lineOf(line.position), text)),\n onNone: () => branch(Option.toArray(quoteToken(page, line, lineOf(line.position)))),\n }),\n ),\n // Descend: a decoration can wrap a link or an image (`[* [page]]`), and that child\n // needs its own token over the same span.\n decoration: (decoration) =>\n branch([\n ...decorationTokenTypes(decoration).map((type) =>\n spanToken(type, shift(decoration.position)),\n ),\n ...notationTokens(page.notations, decoration, shift(decoration.position)),\n ]),\n }),\n Match.orElse((other) =>\n branch(\n pipe(\n Option.fromNullable(INLINE_TOKEN_TYPE[other.type]),\n Option.map((type) => spanToken(type, shift(other.position))),\n Option.toArray,\n ),\n ),\n ),\n )\n }\n\nexport interface ComputeTokensOptions {\n /** `.csnx` also reads a line that is one component tag. `.csn` never does. */\n readonly components?: boolean\n /** How to parse: the site's own notation extensions, as its build parses with them. */\n readonly parseOptions?: ParseOptions\n /** Notations the caller adds, each sent as a token of its own name (see `Notation`). */\n readonly notations?: ReadonlyArray<Notation>\n /**\n * Whether a `---` fence on the first line opens YAML to skip (default: true). Off for\n * Cosense pages, which have no frontmatter.\n */\n readonly frontmatter?: boolean\n}\n\n/** Pure text -> tokens. The LSP delta encoding lives in encodeTokens, so this stays testable. */\nexport const computeTokens = (text: string, options: ComputeTokensOptions = {}): RawToken[] => {\n const lines = normalizeLineEndings(text).split(\"\\n\")\n const notations = options.notations ?? []\n // Frontmatter is YAML, so the Cosense parser must not see it: `---` would otherwise read\n // as a strikethrough marker and the keys as plain text on the title line.\n const fence = fenceOf(lines, options.frontmatter ?? true)\n const page: Page = {\n lines,\n offset: Option.match(fence, { onNone: () => 0, onSome: (end) => end + 1 }),\n components: options.components ?? false,\n notations,\n }\n\n const frontmatterTokens = Option.match(fence, {\n onNone: () => [],\n onSome: (end) => lineSpans(\"frontmatter\", lines, 0, end),\n })\n const body = parse(lines.slice(page.offset).join(\"\\n\"), options.parseOptions ?? {})\n\n return pipe(\n [...frontmatterTokens, ...gather(body, nodeTokens(page))],\n Arr.filter((t) => t.length > 0),\n Arr.sort(BY_POSITION),\n )\n}\n\n/** The name a token goes by: a notation's is the caller's, any other's its type. */\nconst ownName = (token: RawToken): string =>\n Match.value(token).pipe(\n Match.when({ type: \"notation\" }, (notation) => notation.name),\n Match.orElse((builtin) => builtin.type),\n )\n\n/**\n * Each token's place in `legend`: its own name when the legend has it, else the LSP type\n * its kind is drawn as. LEGEND holds none of the own names, so it always gets the LSP type.\n */\nconst legendIndex = (legend: ReadonlyArray<string>) => {\n const placeOf = (type: string): Option.Option<number> =>\n Option.liftPredicate(legend.indexOf(type), (index) => index >= 0)\n return (token: RawToken): number =>\n pipe(\n placeOf(ownName(token)),\n Option.orElse(() => placeOf(LSP_TYPE[token.type])),\n Option.getOrElse(() => 0),\n )\n}\n\n/**\n * LSP relative encoding: [deltaLine, deltaStartChar, length, tokenType, tokenModifiers]*.\n * `legend` is the one sent at initialize: LEGEND, `legendOf(notations)`, or a legend of the\n * client's own naming such as `[...TOKEN_TYPES, ...names]`.\n */\nexport const encodeTokens = (\n tokens: ReadonlyArray<RawToken>,\n legend: ReadonlyArray<string> = LEGEND,\n): number[] => {\n const indexOf = legendIndex(legend)\n return pipe(\n Arr.sort(tokens, BY_POSITION),\n Arr.mapAccum({ line: 0, char: 0 }, (previous, t) => [\n { line: t.line, char: t.char },\n [\n t.line - previous.line,\n t.line === previous.line ? t.char - previous.char : t.char,\n t.length,\n indexOf(t),\n 0,\n ],\n ]),\n ([, rows]) => Arr.flatten(rows),\n )\n}\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAa,cAAc;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;CACA;CACA;CACA;CAEA;CAGA;AACF;;;;;;;AAoCA,MAAa,SAAS;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;AAQA,MAAM,WAAuD;CA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SAAS,MAAM,KAAK,CAAC,GACjD,OAAO,gBAAgB,CAAC,CAC1B;AACJ;;;;;;AAOA,MAAa,gBACX,QACA,SAAgC,WACnB;CACb,MAAM,UAAU,YAAY,MAAM;CAClC,OAAO,KACLA,MAAI,KAAK,QAAQ,WAAW,GAC5BA,MAAI,SAAS;EAAE,MAAM;EAAG,MAAM;CAAE,IAAI,UAAU,MAAM,CAClD;EAAE,MAAM,EAAE;EAAM,MAAM,EAAE;CAAK,GAC7B;EACE,EAAE,OAAO,SAAS;EAClB,EAAE,SAAS,SAAS,OAAO,EAAE,OAAO,SAAS,OAAO,EAAE;EACtD,EAAE;EACF,QAAQ,CAAC;EACT;CACF,CACF,CAAC,IACA,GAAG,UAAUA,MAAI,QAAQ,IAAI,CAChC;AACF"}
|
|
1
|
+
{"version":3,"file":"tokens.mjs","names":["Arr"],"sources":["../src/tokens.ts"],"sourcesContent":["import type {\n AnyNode,\n AnyNodeType,\n Decoration,\n NodeOfType,\n ParseOptions,\n Position,\n} from \"@cosense-toolbox/parser\"\nimport { normalizeLineEndings, parse } from \"@cosense-toolbox/parser\"\nimport { Array as Arr, Match, Option, Order, pipe } from \"effect\"\n\nimport { branch, gather, leaf, type Picked } from \"./tree\"\n\n/**\n * Cosense notation as LSP semantic tokens.\n *\n * These names are the ones this package reasons in, and they are not what goes on the wire.\n * A client announces the token types it knows at initialize and drops everything else —\n * some send the LSP's own list and nothing more — so `quote` would simply never be drawn.\n * LEGEND below is what is sent, and LSP_TYPE is the translation.\n */\nexport const TOKEN_TYPES = [\n \"title\",\n \"link\",\n \"projectLink\",\n \"externalLink\",\n \"hashtag\",\n \"code\",\n \"codeBlock\",\n \"formula\",\n \"icon\",\n \"quote\",\n \"bold\",\n \"italic\",\n \"strike\",\n \"underline\",\n \"image\",\n \"table\",\n \"bold2\",\n \"bold3\",\n // `.csnx` only: a line that opens with a component tag. The tag's name, its attribute\n // names, and the two kinds of value, as JSX reads them.\n \"component\",\n \"attribute\",\n \"attributeValue\",\n \"expression\",\n // The YAML at the top of the file, which is not Cosense notation at all.\n \"frontmatter\",\n // A notation the caller defines (see `Notation`), such as `[! 注意]`. The token carries\n // the name the caller gave it.\n \"notation\",\n] as const\n\nexport type TokenType = (typeof TOKEN_TYPES)[number]\n\n/** Every token type but `notation`, whose tokens also carry a name. */\ntype BuiltinTokenType = Exclude<TokenType, \"notation\">\n\ninterface Span {\n readonly line: number\n readonly char: number\n readonly length: number\n}\n\nexport type RawToken =\n | (Span & { readonly type: BuiltinTokenType })\n | (Span & { readonly type: \"notation\"; readonly name: string })\n\n/**\n * A name the caller gives to a decoration marker, as `warning` to the `!` of `[! 注意]`: the\n * token type that decoration is sent as.\n *\n * The marker has to be one Cosense decorates with (`` !\"#%&'()*+,-./{|}<>_~= ``), since\n * those are the ones the parser reads as a decoration. Any other, such as `@`, leaves the\n * bracket a link, as it is in Cosense Web: how a notation looks does not change how it parses.\n */\nexport interface Notation {\n readonly marker: string\n readonly name: string\n}\n\n/**\n * The legend sent to the client: the LSP's own token types, in its own order.\n *\n * Every entry is in the set a client is expected to understand, which is what makes the\n * colours appear without the reader configuring anything.\n */\nexport const LEGEND = [\n \"namespace\",\n \"type\",\n \"function\",\n \"variable\",\n \"property\",\n \"parameter\",\n \"decorator\",\n \"macro\",\n \"keyword\",\n \"string\",\n \"number\",\n \"comment\",\n] as const\n\n/**\n * What each notation is drawn as. Chosen so that things a reader separates by eye land on\n * different entries: a link is not a tag, and a quote is not a heading. `bold` and its\n * louder siblings share one entry, because the LSP has no notion of weight and a theme\n * gives each type a single colour.\n */\nconst LSP_TYPE: Record<TokenType, (typeof LEGEND)[number]> = {\n title: \"namespace\",\n link: \"function\",\n projectLink: \"function\",\n externalLink: \"string\",\n icon: \"function\",\n image: \"string\",\n hashtag: \"decorator\",\n code: \"string\",\n codeBlock: \"string\",\n formula: \"number\",\n table: \"property\",\n quote: \"comment\",\n frontmatter: \"comment\",\n component: \"type\",\n attribute: \"parameter\",\n attributeValue: \"string\",\n expression: \"variable\",\n bold: \"keyword\",\n bold2: \"keyword\",\n bold3: \"keyword\",\n italic: \"macro\",\n strike: \"comment\",\n underline: \"variable\",\n // What a caller's notation is sent as when the legend has no type of its name.\n notation: \"decorator\",\n}\n\n/**\n * LEGEND with the names of `notations` after it, each once: the legend for a client that\n * accepts token types of the caller's own naming. The LSP's types keep their places.\n *\n * A client that colours by this package's own names instead passes those to `encodeTokens`\n * (`[...TOKEN_TYPES, ...names]`): a token whose own name is in the legend is sent as that.\n */\nexport const legendOf = (notations: ReadonlyArray<Notation>): ReadonlyArray<string> =>\n Arr.dedupe([...LEGEND, ...Arr.map(notations, (notation) => notation.name)])\n\n/** Leaf inline nodes that map 1:1. Each sits on one line, so no splitting is needed. */\nconst INLINE_TOKEN_TYPE: Partial<Record<AnyNodeType, BuiltinTokenType>> = {\n internalLink: \"link\",\n externalLink: \"externalLink\",\n projectLink: \"projectLink\",\n hashtag: \"hashtag\",\n inlineCode: \"code\",\n image: \"image\",\n icon: \"icon\",\n formula: \"formula\",\n}\n\n/** Top to bottom, then left to right: the order the LSP encoding needs. */\nconst BY_POSITION: Order.Order<RawToken> = Order.combine(\n Order.mapInput(Order.number, (token: RawToken) => token.line),\n Order.mapInput(Order.number, (token: RawToken) => token.char),\n)\n\nconst onlyIf = <A>(condition: boolean, value: A): Option.Option<A> =>\n condition ? Option.some(value) : Option.none()\n\n/** A token over `[from, to)` of one line. */\nconst token = (type: BuiltinTokenType, line: number, from: number, to: number): RawToken => ({\n line,\n char: from,\n length: to - from,\n type,\n})\n\nconst spanToken = (type: BuiltinTokenType, position: Position): RawToken =>\n token(type, position.start.line, position.start.column, position.end.column)\n\n/** How many characters from `from` the `^`-anchored `pattern` takes; 0 when it takes none. */\nconst matchLength = (pattern: RegExp, text: string, from: number): number =>\n pipe(\n Option.fromNullable(pattern.exec(text.slice(from))),\n Option.match({ onNone: () => 0, onSome: ([matched]) => matched.length }),\n )\n\n// --- Emphasis ---------------------------------------------------------------------------\n\n/** Cosense sizes emphasis by asterisk count (`[*]`..`[*****]`); sizeLevel is 0-indexed. */\nconst boldTokenType = (sizeLevel: number): BuiltinTokenType =>\n Match.value(sizeLevel).pipe(\n Match.when(\n (level) => level >= 2,\n (): BuiltinTokenType => \"bold3\",\n ),\n Match.when(1, (): BuiltinTokenType => \"bold2\"),\n Match.orElse((): BuiltinTokenType => \"bold\"),\n )\n\n/** Every decoration a run carries, since Cosense applies all of them: `[-* x]` is both. */\nconst decorationTokenTypes = (node: Decoration): ReadonlyArray<BuiltinTokenType> =>\n Arr.getSomes([\n onlyIf(node.underline, \"underline\" as const),\n onlyIf(node.strike, \"strike\" as const),\n onlyIf(node.italic, \"italic\" as const),\n onlyIf(node.bold, boldTokenType(node.sizeLevel)),\n ])\n\n// --- Component lines (`.csnx`) ----------------------------------------------------------\n\nexport const COMPONENT_LINE = /^\\s*<\\/?[A-Z][A-Za-z0-9_.]*(\\s|\\/?>)/\nconst TAG_OPEN = /^(\\s*<\\/?)([A-Z][A-Za-z0-9_.]*)/\nconst ATTRIBUTE_NAME = /^[A-Za-z_:][A-Za-z0-9_:.-]*/\nconst SPACE = /^\\s*/\n\n/** Where a quoted value opened at `from` ends: after its closing quote, or at the line's end. */\nconst quotedEnd = (text: string, from: number): number =>\n pipe(\n text.indexOf(text.charAt(from), from + 1),\n Option.liftPredicate((close) => close >= 0),\n Option.match({ onNone: () => text.length, onSome: (close) => close + 1 }),\n )\n\n/** Where `{ ... }` opened at `from` ends, counting nested braces: after its `}`, or the line's end. */\nconst bracedEnd = (text: string, from: number): number =>\n pipe(\n text.slice(from).split(\"\"),\n Arr.scan(0, (depth, char) => (char === \"{\" ? depth + 1 : char === \"}\" ? depth - 1 : depth)),\n // scan starts with the depth before any character; the rest line up with the characters.\n Arr.drop(1),\n Arr.findFirstIndex((depth) => depth === 0),\n Option.match({ onNone: () => text.length, onSome: (index) => from + index + 1 }),\n )\n\ntype ValueType = \"attributeValue\" | \"expression\"\n\n/** The attribute value that starts at `from`: its type and where it ends. */\nconst valueAt = (text: string, from: number): Option.Option<readonly [ValueType, number]> =>\n Match.value(text.charAt(from)).pipe(\n Match.when(\n (char) => char === '\"' || char === \"'\",\n () => Option.some([\"attributeValue\", quotedEnd(text, from)] as const),\n ),\n Match.when(\"{\", () => Option.some([\"expression\", bracedEnd(text, from)] as const)),\n Match.orElse(() => Option.none()),\n )\n\n/** The tokens of one attribute, and where the next may start. */\ntype Step = readonly [ReadonlyArray<RawToken>, number]\n\n/** `at` past any whitespace. */\nconst skipSpace = (text: string, at: number): number => at + matchLength(SPACE, text, at)\n\n/** Whether the tag closes at `at`, with `>` or `/>`, or the line ends there. */\nconst closesAt = (text: string, at: number): boolean =>\n at >= text.length || text.startsWith(\">\", at) || text.startsWith(\"/>\", at)\n\n/**\n * An attribute named over `[at, nameEnd)`: the name, then `=` and a value if one follows.\n * A name with no `=` after it stands alone, as JSX reads `<Dialog open>`.\n */\nconst attribute = (line: number, text: string, at: number, nameEnd: number): Step => {\n const name = token(\"attribute\", line, at, nameEnd)\n const afterName = skipSpace(text, nameEnd)\n return pipe(\n Option.liftPredicate(afterName, (equals) => text.charAt(equals) === \"=\"),\n Option.map((equals) => skipSpace(text, equals + 1)),\n Option.match({\n onNone: (): Step => [[name], afterName],\n onSome: (valueStart): Step =>\n pipe(\n valueAt(text, valueStart),\n Option.match({\n onNone: (): Step => [[name], valueStart],\n onSome: ([type, end]): Step => [[name, token(type, line, valueStart, end)], end],\n }),\n ),\n }),\n )\n}\n\n/** One attribute from `from`, or None once the tag has closed. */\nconst attributeStep =\n (line: number, text: string) =>\n (from: number): Option.Option<Step> =>\n pipe(\n Option.liftPredicate(skipSpace(text, from), (at) => !closesAt(text, at)),\n Option.map((at) =>\n pipe(\n Option.liftPredicate(at + matchLength(ATTRIBUTE_NAME, text, at), (end) => end > at),\n Option.match({\n // Not a name: step over the character, since the tag may still go on after it.\n onNone: (): Step => [[], at + 1],\n onSome: (nameEnd) => attribute(line, text, at, nameEnd),\n }),\n ),\n ),\n )\n\n/**\n * The tag that opens a component line, read as JSX: its name, then each attribute and its\n * value, up to the `>` that closes it. Text after the tag is left alone; it is neither\n * Cosense notation nor part of the tag.\n */\nconst componentTokens = (line: number, text: string): ReadonlyArray<RawToken> =>\n pipe(\n Option.fromNullable(TAG_OPEN.exec(text)),\n Option.map(([head, lead = \"\", name = \"\"]) => [\n token(\"component\", line, lead.length, lead.length + name.length),\n ...Arr.flatten(Arr.unfold(head.length, attributeStep(line, text))),\n ]),\n Option.getOrElse(() => []),\n )\n\n// --- The page ---------------------------------------------------------------------------\n\n/** The last line of the `---` fence around YAML at the very top, if the file opens with one. */\nexport const frontmatterEnd = (lines: ReadonlyArray<string>): Option.Option<number> =>\n pipe(\n Option.liftPredicate(lines, (all) => all[0]?.trim() === \"---\"),\n Option.flatMap(Arr.findFirstIndex((line, index) => index > 0 && line.trim() === \"---\")),\n )\n\n/**\n * `frontmatterEnd`, or None when the caller reads no frontmatter: a Cosense page has none,\n * and a page whose title is `---` would otherwise lose its first lines to it.\n */\nexport const fenceOf = (\n lines: ReadonlyArray<string>,\n frontmatter: boolean,\n): Option.Option<number> => Option.flatMap(onlyIf(frontmatter, lines), frontmatterEnd)\n\n/** What the node visitor needs to know about the file around the parsed body. */\ninterface Page {\n readonly lines: ReadonlyArray<string>\n /** Lines before the body: the frontmatter, which the parser never sees. */\n readonly offset: number\n readonly components: boolean\n readonly notations: ReadonlyArray<Notation>\n}\n\n/** Each non-empty line from `first` to `last`, whole. */\nconst lineSpans = (\n type: BuiltinTokenType,\n lines: ReadonlyArray<string>,\n first: number,\n last: number,\n): ReadonlyArray<RawToken> =>\n Arr.filterMap(Arr.range(first, last), (line) =>\n pipe(\n Option.fromNullable(lines[line]),\n Option.filter((text) => text.length > 0),\n Option.map((text) => token(type, line, 0, text.length)),\n ),\n )\n\n/** The line's text, when the file reads components and the line opens with a tag. */\nconst componentLine = (page: Page, line: number): Option.Option<string> =>\n pipe(\n Option.fromNullable(page.lines[line]),\n Option.filter((text) => page.components && COMPONENT_LINE.test(text)),\n )\n\n/** The `>` and spaces that open a quote line, from its indentation onwards. */\nconst quoteToken = (page: Page, node: NodeOfType<\"line\">, line: number): Option.Option<RawToken> =>\n pipe(\n onlyIf(node.quote, page.lines[line] ?? \"\"),\n Option.map((text) => matchLength(/^[> ]*/, text, node.indent)),\n Option.filter((length) => length > 0),\n Option.map((length) => token(\"quote\", line, node.indent, node.indent + length)),\n )\n\n/**\n * A command line (`$ ls`) is code as a whole: the parser keeps its text as written, with no\n * notation in it, so its one text node is the span to colour.\n */\nconst commandTokens = (\n line: NodeOfType<\"line\">,\n shift: (position: Position) => Position,\n): ReadonlyArray<RawToken> =>\n Arr.map(line.children, (child) => spanToken(\"code\", shift(child.position)))\n\n/** A token for each of `notations` whose marker opens the decoration. */\nconst notationTokens = (\n notations: ReadonlyArray<Notation>,\n node: Decoration,\n position: Position,\n): ReadonlyArray<RawToken> =>\n Arr.filterMap(notations, ({ marker, name }) =>\n onlyIf(node.markers.includes(marker), {\n line: position.start.line,\n char: position.start.column,\n length: position.end.column - position.start.column,\n type: \"notation\" as const,\n name,\n }),\n )\n\nconst nodeTokens =\n (page: Page) =>\n (node: AnyNode): Picked<RawToken> => {\n const lineOf = (position: Position) => position.start.line + page.offset\n const shift = (position: Position): Position => ({\n start: { ...position.start, line: position.start.line + page.offset },\n end: { ...position.end, line: position.end.line + page.offset },\n })\n return Match.value(node).pipe(\n Match.discriminators(\"type\")({\n // A page that opens with a component has no title line: the tag is what it is.\n title: (title) =>\n leaf(\n pipe(\n componentLine(page, lineOf(title.position)),\n Option.match({\n onNone: () => [spanToken(\"title\", shift(title.position))],\n onSome: (text) => componentTokens(lineOf(title.position), text),\n }),\n ),\n ),\n codeBlock: (block) =>\n leaf(\n lineSpans(\n \"codeBlock\",\n page.lines,\n lineOf(block.position),\n block.position.end.line + page.offset,\n ),\n ),\n table: (table) =>\n leaf(\n lineSpans(\n \"table\",\n page.lines,\n lineOf(table.position),\n table.position.end.line + page.offset,\n ),\n ),\n // A component tag owns its line, so nothing on it is Cosense notation.\n line: (line) =>\n pipe(\n componentLine(page, lineOf(line.position)),\n Option.match({\n onSome: (text) => leaf(componentTokens(lineOf(line.position), text)),\n onNone: () =>\n line.monospace\n ? leaf(commandTokens(line, shift))\n : branch(Option.toArray(quoteToken(page, line, lineOf(line.position)))),\n }),\n ),\n // Descend: a decoration can wrap a link or an image (`[* [page]]`), and that child\n // needs its own token over the same span.\n decoration: (decoration) =>\n branch([\n ...decorationTokenTypes(decoration).map((type) =>\n spanToken(type, shift(decoration.position)),\n ),\n ...notationTokens(page.notations, decoration, shift(decoration.position)),\n ]),\n }),\n Match.orElse((other) =>\n branch(\n pipe(\n Option.fromNullable(INLINE_TOKEN_TYPE[other.type]),\n Option.map((type) => spanToken(type, shift(other.position))),\n Option.toArray,\n ),\n ),\n ),\n )\n }\n\nexport interface ComputeTokensOptions {\n /** `.csnx` also reads a line that is one component tag. `.csn` never does. */\n readonly components?: boolean\n /** How to parse: the site's own notation extensions, as its build parses with them. */\n readonly parseOptions?: ParseOptions\n /** Notations the caller adds, each sent as a token of its own name (see `Notation`). */\n readonly notations?: ReadonlyArray<Notation>\n /**\n * Whether a `---` fence on the first line opens YAML to skip (default: true). Off for\n * Cosense pages, which have no frontmatter.\n */\n readonly frontmatter?: boolean\n}\n\n/** Pure text -> tokens. The LSP delta encoding lives in encodeTokens, so this stays testable. */\nexport const computeTokens = (text: string, options: ComputeTokensOptions = {}): RawToken[] => {\n const lines = normalizeLineEndings(text).split(\"\\n\")\n const notations = options.notations ?? []\n // Frontmatter is YAML, so the Cosense parser must not see it: `---` would otherwise read\n // as a strikethrough marker and the keys as plain text on the title line.\n const fence = fenceOf(lines, options.frontmatter ?? true)\n const page: Page = {\n lines,\n offset: Option.match(fence, { onNone: () => 0, onSome: (end) => end + 1 }),\n components: options.components ?? false,\n notations,\n }\n\n const frontmatterTokens = Option.match(fence, {\n onNone: () => [],\n onSome: (end) => lineSpans(\"frontmatter\", lines, 0, end),\n })\n const body = parse(lines.slice(page.offset).join(\"\\n\"), options.parseOptions ?? {})\n\n return pipe(\n [...frontmatterTokens, ...gather(body, nodeTokens(page))],\n Arr.filter((t) => t.length > 0),\n Arr.sort(BY_POSITION),\n )\n}\n\n/** The name a token goes by: a notation's is the caller's, any other's its type. */\nconst ownName = (token: RawToken): string =>\n Match.value(token).pipe(\n Match.when({ type: \"notation\" }, (notation) => notation.name),\n Match.orElse((builtin) => builtin.type),\n )\n\n/**\n * Each token's place in `legend`: its own name when the legend has it, else the LSP type\n * its kind is drawn as. LEGEND holds none of the own names, so it always gets the LSP type.\n */\nconst legendIndex = (legend: ReadonlyArray<string>) => {\n const placeOf = (type: string): Option.Option<number> =>\n Option.liftPredicate(legend.indexOf(type), (index) => index >= 0)\n return (token: RawToken): number =>\n pipe(\n placeOf(ownName(token)),\n Option.orElse(() => placeOf(LSP_TYPE[token.type])),\n Option.getOrElse(() => 0),\n )\n}\n\n/**\n * LSP relative encoding: [deltaLine, deltaStartChar, length, tokenType, tokenModifiers]*.\n * `legend` is the one sent at initialize: LEGEND, `legendOf(notations)`, or a legend of the\n * client's own naming such as `[...TOKEN_TYPES, ...names]`.\n */\nexport const encodeTokens = (\n tokens: ReadonlyArray<RawToken>,\n legend: ReadonlyArray<string> = LEGEND,\n): number[] => {\n const indexOf = legendIndex(legend)\n return pipe(\n Arr.sort(tokens, BY_POSITION),\n Arr.mapAccum({ line: 0, char: 0 }, (previous, t) => [\n { line: t.line, char: t.char },\n [\n t.line - previous.line,\n t.line === previous.line ? t.char - previous.char : t.char,\n t.length,\n indexOf(t),\n 0,\n ],\n ]),\n ([, rows]) => Arr.flatten(rows),\n )\n}\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAa,cAAc;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;CACA;CACA;CACA;CAEA;CAGA;AACF;;;;;;;AAoCA,MAAa,SAAS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,IAAI,aAAa,SAAS,IAAI,GAC5D,MAAM,QAAQ,YAAY,QAAQ,IAAI,CACxC;;;;;AAMF,MAAM,eAAe,WAAkC;CACrD,MAAM,WAAW,SACf,OAAO,cAAc,OAAO,QAAQ,IAAI,IAAI,UAAU,SAAS,CAAC;CAClE,QAAQ,UACN,KACE,QAAQ,QAAQ,KAAK,CAAC,GACtB,OAAO,aAAa,QAAQ,SAAS,MAAM,KAAK,CAAC,GACjD,OAAO,gBAAgB,CAAC,CAC1B;AACJ;;;;;;AAOA,MAAa,gBACX,QACA,SAAgC,WACnB;CACb,MAAM,UAAU,YAAY,MAAM;CAClC,OAAO,KACLA,MAAI,KAAK,QAAQ,WAAW,GAC5BA,MAAI,SAAS;EAAE,MAAM;EAAG,MAAM;CAAE,IAAI,UAAU,MAAM,CAClD;EAAE,MAAM,EAAE;EAAM,MAAM,EAAE;CAAK,GAC7B;EACE,EAAE,OAAO,SAAS;EAClB,EAAE,SAAS,SAAS,OAAO,EAAE,OAAO,SAAS,OAAO,EAAE;EACtD,EAAE;EACF,QAAQ,CAAC;EACT;CACF,CACF,CAAC,IACA,GAAG,UAAUA,MAAI,QAAQ,IAAI,CAChC;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosense-toolbox/lsp",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Language server for .csn and .csnx, and a check of a whole site's links: csn-lsp.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"prepublishOnly": "bun run build"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@cosense-toolbox/parser": "0.1.0-beta.
|
|
54
|
+
"@cosense-toolbox/parser": "0.1.0-beta.6",
|
|
55
55
|
"effect": "^3.22.1",
|
|
56
56
|
"vscode-languageserver": "^10.1.0",
|
|
57
57
|
"vscode-languageserver-textdocument": "^1.0.12"
|