@bascik/language-server 0.1.0-rc.5 → 1.0.0-rc.1
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 +74 -30
- package/dist/analyzer.d.ts +75 -1
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/analyzer.js +727 -76
- package/dist/analyzer.js.map +1 -1
- package/dist/api-rules.d.ts +7 -0
- package/dist/api-rules.d.ts.map +1 -1
- package/dist/api-rules.js +282 -17
- package/dist/api-rules.js.map +1 -1
- package/dist/bin-args.d.ts +11 -0
- package/dist/bin-args.d.ts.map +1 -0
- package/dist/bin-args.js +21 -0
- package/dist/bin-args.js.map +1 -0
- package/dist/bin.js +17 -5
- package/dist/bin.js.map +1 -1
- package/dist/check.d.ts +14 -1
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +116 -10
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +27 -8
- package/dist/cli.js.map +1 -1
- package/dist/compatibility-rules.json +21 -3
- package/dist/component-metadata.d.ts.map +1 -1
- package/dist/component-metadata.js +3 -1
- package/dist/component-metadata.js.map +1 -1
- package/dist/component-usages.d.ts +47 -0
- package/dist/component-usages.d.ts.map +1 -0
- package/dist/component-usages.js +495 -0
- package/dist/component-usages.js.map +1 -0
- package/dist/config-reader.d.ts +41 -0
- package/dist/config-reader.d.ts.map +1 -0
- package/dist/config-reader.js +461 -0
- package/dist/config-reader.js.map +1 -0
- package/dist/config.d.ts +10 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +25 -30
- package/dist/config.js.map +1 -1
- package/dist/css-brace-balance.d.ts +33 -0
- package/dist/css-brace-balance.d.ts.map +1 -0
- package/dist/css-brace-balance.js +99 -0
- package/dist/css-brace-balance.js.map +1 -0
- package/dist/hand-written-escaper.d.ts +35 -0
- package/dist/hand-written-escaper.d.ts.map +1 -0
- package/dist/hand-written-escaper.js +739 -0
- package/dist/hand-written-escaper.js.map +1 -0
- package/dist/module-specifiers.d.ts +25 -0
- package/dist/module-specifiers.d.ts.map +1 -1
- package/dist/module-specifiers.js +234 -165
- package/dist/module-specifiers.js.map +1 -1
- package/dist/name-groups.d.ts +36 -0
- package/dist/name-groups.d.ts.map +1 -0
- package/dist/name-groups.js +198 -0
- package/dist/name-groups.js.map +1 -0
- package/dist/plain-holes.d.ts +116 -0
- package/dist/plain-holes.d.ts.map +1 -0
- package/dist/plain-holes.js +1970 -0
- package/dist/plain-holes.js.map +1 -0
- package/dist/preserved-targets.d.ts +50 -0
- package/dist/preserved-targets.d.ts.map +1 -0
- package/dist/preserved-targets.js +358 -0
- package/dist/preserved-targets.js.map +1 -0
- package/dist/project.d.ts +68 -1
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +157 -8
- package/dist/project.js.map +1 -1
- package/dist/references.d.ts +47 -0
- package/dist/references.d.ts.map +1 -0
- package/dist/references.js +241 -0
- package/dist/references.js.map +1 -0
- package/dist/script-modules.d.ts +60 -0
- package/dist/script-modules.d.ts.map +1 -0
- package/dist/script-modules.js +382 -0
- package/dist/script-modules.js.map +1 -0
- package/dist/server-script-rules.d.ts +94 -1
- package/dist/server-script-rules.d.ts.map +1 -1
- package/dist/server-script-rules.js +2572 -230
- package/dist/server-script-rules.js.map +1 -1
- package/dist/server-script-templates.d.ts +250 -0
- package/dist/server-script-templates.d.ts.map +1 -0
- package/dist/server-script-templates.js +1685 -0
- package/dist/server-script-templates.js.map +1 -0
- package/dist/server.d.ts +191 -3
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +822 -50
- package/dist/server.js.map +1 -1
- package/dist/start.d.ts +10 -1
- package/dist/start.d.ts.map +1 -1
- package/dist/start.js +14 -2
- package/dist/start.js.map +1 -1
- package/dist/string-typed-flow.d.ts +26 -0
- package/dist/string-typed-flow.d.ts.map +1 -0
- package/dist/string-typed-flow.js +496 -0
- package/dist/string-typed-flow.js.map +1 -0
- package/dist/typescript-blocks.d.ts +205 -0
- package/dist/typescript-blocks.d.ts.map +1 -0
- package/dist/typescript-blocks.js +464 -0
- package/dist/typescript-blocks.js.map +1 -0
- package/dist/typescript-editor-mode.d.ts +28 -0
- package/dist/typescript-editor-mode.d.ts.map +1 -0
- package/dist/typescript-editor-mode.js +161 -0
- package/dist/typescript-editor-mode.js.map +1 -0
- package/dist/typescript-engine.d.ts +115 -0
- package/dist/typescript-engine.d.ts.map +1 -0
- package/dist/typescript-engine.js +286 -0
- package/dist/typescript-engine.js.map +1 -0
- package/dist/typescript-features.d.ts +136 -0
- package/dist/typescript-features.d.ts.map +1 -0
- package/dist/typescript-features.js +374 -0
- package/dist/typescript-features.js.map +1 -0
- package/dist/typescript-loader.d.ts +55 -0
- package/dist/typescript-loader.d.ts.map +1 -0
- package/dist/typescript-loader.js +202 -0
- package/dist/typescript-loader.js.map +1 -0
- package/dist/typescript-lsp.d.ts +8 -0
- package/dist/typescript-lsp.d.ts.map +1 -0
- package/dist/typescript-lsp.js +115 -0
- package/dist/typescript-lsp.js.map +1 -0
- package/dist/typescript-service.d.ts +350 -0
- package/dist/typescript-service.d.ts.map +1 -0
- package/dist/typescript-service.js +1465 -0
- package/dist/typescript-service.js.map +1 -0
- package/dist/typescript-worker.d.ts +11 -0
- package/dist/typescript-worker.d.ts.map +1 -0
- package/dist/typescript-worker.js +107 -0
- package/dist/typescript-worker.js.map +1 -0
- package/package.json +34 -12
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Official Language Server Protocol (LSP) server for Bascik projects.
|
|
4
4
|
|
|
5
|
-
Provides editor-agnostic intelligence for Bascik HTML components, props, slots, mutually exclusive script directives, and scoping diagnostics across any LSP-compatible editor.
|
|
5
|
+
Provides editor-agnostic intelligence for Bascik HTML components, props, slots, mutually exclusive script directives, and scoping diagnostics across any LSP-compatible editor. Use it to wire Bascik into Neovim, Zed, Helix, a coding agent, or CI. In VS Code, install the [Bascik extension](https://bascik.dev/tools/vscode-extension) instead: it bundles this server. Requires Node.js 24.21 or newer. Every rule is documented on the [Linter](https://bascik.dev/tools/linter) page.
|
|
6
6
|
|
|
7
7
|
## Capabilities
|
|
8
8
|
|
|
@@ -10,21 +10,32 @@ Provides editor-agnostic intelligence for Bascik HTML components, props, slots,
|
|
|
10
10
|
- Discovers custom component tags (e.g. `<site-nav>`, `<docs-head>`).
|
|
11
11
|
- Auto-inserts self-closing tags for void components (`<docs-head />`) or slot containers (`<site-nav>$0</site-nav>`).
|
|
12
12
|
- Auto-completes inferred and declared component props (`data-bascik-prop-*`).
|
|
13
|
-
- Auto-completes contextual script directives (`data-bascik-build`, `data-bascik-routes`, `data-bascik-server`, `data-bascik-stream`) with mutual exclusion.
|
|
13
|
+
- Auto-completes contextual script directives (`data-bascik-build`, `data-bascik-build-once`, `data-bascik-routes`, `data-bascik-server`, `data-bascik-stream`) with mutual exclusion.
|
|
14
14
|
- **Hover Documentation (`textDocument/hover`)**:
|
|
15
15
|
- Displays docblock summaries, prop descriptions, and slot requirements from `<!-- @bascik -->` metadata headers.
|
|
16
16
|
- **Jump to Definition (`textDocument/definition`)**:
|
|
17
17
|
- Jump from a component tag directly to its HTML component source file.
|
|
18
18
|
- Jump from build/server script imports (`@/...` or `./...`) to their target source files.
|
|
19
|
-
- **
|
|
19
|
+
- **Find All References (`textDocument/references`)**:
|
|
20
|
+
- Lists every opening tag that uses a component, across pages and components, from a component tag name or from the component's own first line, `<!-- @bascik` comment, or root tag line.
|
|
21
|
+
- Skips tags in comments, attribute values, and `<script>`, `<style>`, or `<textarea>` bodies, as the compiler does. Usages that only appear in build script, Markdown, or server script output are not visible to the source index.
|
|
22
|
+
- **Diagnostics (`textDocument/publishDiagnostics`)**:
|
|
20
23
|
- Unclosed component tag warnings.
|
|
21
24
|
- Paired closing tag warnings on zero-slot components (`prefer-self-closing-component`).
|
|
22
25
|
- Misplaced script directives on non-`<script>` tags.
|
|
23
26
|
- Undeclared prop attributes on component tags.
|
|
24
27
|
- Misplaced `data-bascik-slot` attributes.
|
|
25
28
|
- Scoping compatibility checks in CSS and JavaScript.
|
|
29
|
+
- Unbalanced `{` or `}` in a component's `<style>` or companion stylesheet (`css-unbalanced-braces`, an error, because the build stops on it).
|
|
30
|
+
- A component selector or class query that only preserved elements (`scoping.preserve`, `data-bascik-preserve`) answer, so it never matches (`css-preserved-target`, `js-preserved-target`).
|
|
26
31
|
- In-file ignore comment support (`<!-- bascik-ignore -->`, `/* bascik-ignore */`, `// bascik-ignore`).
|
|
27
|
-
-
|
|
32
|
+
- TypeScript errors in `<script type="text/typescript">` blocks, from TypeScript's own language service, with the source `ts (bascik)`. Each block is checked in the scope it runs in (a page's browser blocks share one scope, a scoped component's and every server-side block are on their own); browser blocks get the DOM and server-side blocks (`data-bascik-build`, `-build-once`, `-routes`, `-server`, `-stream`) get Node.js (its types with `@types/node`; without it, the web globals Node.js and workerd share, and Node.js's globals and modules untyped); `@/` resolves against `scripts.importRoot`, and the project's `tsconfig.json` is the base. See [TypeScript](#typescript) below.
|
|
33
|
+
- Configuration support via `bascik.ext.json`, `.bascikrc.json`, `bascik.ext.ts`, or `bascik.ext.js`. The `.ts` and `.js` forms are read without running them (literal values only), and a config that cannot be read is logged to stderr with its file and line.
|
|
34
|
+
- **Quick Fixes (`textDocument/codeAction`)**:
|
|
35
|
+
- Adds the missing `data-bascik-prop-` prefix to a prop attribute (`missing-prop-prefix`).
|
|
36
|
+
- Converts a paired tag on a zero-slot component to a self-closing tag (`prefer-self-closing-component`).
|
|
37
|
+
- Wraps a server script template literal that returns markup in `` html`...` `` and imports `html` from `@bascik/bascik/html` (`server-script-unescaped-markup`). It imports `html as safeHtml` when the script already uses the name `html`, and is not offered when that name is taken too or a value sits where `html` would throw. This fix is editor-only, because it changes the returned value from a string to `SafeHtml`. The rule runs in build and routes scripts too, and in the `.ts` and `.js` modules directive scripts and API routes import. It is not offered where the template's value reaches a `string` type (a return annotated `: string`, a `const` annotated `: string`, `as string`), since the wrapped value is `SafeHtml`; the message names the type to change.
|
|
38
|
+
- Makes a hand-written HTML escaper whose body is one `return` of its parameter followed only by entity `.replace()` calls call `esc()` from `@bascik/bascik/html`, and imports it (`hand-written-html-escaper`); any other escaper gets only the import of `html`.
|
|
28
39
|
|
|
29
40
|
## Installation & CLI Usage
|
|
30
41
|
|
|
@@ -41,6 +52,36 @@ npm install -g @bascik/language-server
|
|
|
41
52
|
bascik-language-server --stdio
|
|
42
53
|
```
|
|
43
54
|
|
|
55
|
+
## TypeScript
|
|
56
|
+
|
|
57
|
+
TypeScript is an optional peer dependency (`typescript` 5 or 6), never bundled. The server uses, in order: an absolute path to a `typescript` package folder the client passes in `initializationOptions.typescript.path` (a relative one is skipped with a warning, never read from the open project; the VS Code extension passes the `bascik.typescript.path` setting), the editor's own copy in `initializationOptions.typescript.editorPath` (the VS Code extension passes VS Code's), the project's `typescript`, then one beside this package. TypeScript 7 publishes no JavaScript language service, so a TypeScript 7 install is skipped, and so is one older than TypeScript 5 (no `bundler` module resolution, so every `.ts` import would be an error). Without a usable TypeScript, TypeScript checks are off and the server logs why, once per project.
|
|
58
|
+
|
|
59
|
+
`initializationOptions`, all optional:
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"typescript": {
|
|
64
|
+
"enabled": true,
|
|
65
|
+
"path": "/path/to/node_modules/typescript",
|
|
66
|
+
"editorPath": "/path/to/editor/typescript",
|
|
67
|
+
"releaseDelayMs": 30000
|
|
68
|
+
},
|
|
69
|
+
"editorHasEmbeddedTypeScript": false
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
`path` is used first; `editorPath`, the editor's own copy, is used when `path` is missing or cannot be used, before the project's `typescript`. When `path` cannot be used, the server shows the reason once with `window/showMessageRequest` and logs it.
|
|
74
|
+
|
|
75
|
+
Inside these blocks the server answers hover, definition, completion (members, and files in relative and `@/` import paths) and signature help from the same TypeScript, after its own answers: hover and definition only where Bascik has none. `editorHasEmbeddedTypeScript` tells the server the editor already answers about the page's own names there (VS Code's HTML support does, and cannot be turned off; the VS Code extension sends `true` only while it runs). The server then answers only what that mode cannot: symbols, members, globals and calls declared in another file (an import, a package, `@types/node`, the context `@bascik/bascik` gives a directive script), names whose type comes from one, import paths, the names a module exports inside an import's braces, and every member and signature reached through a value the editor's mode types as `any` (a library method on an imported array, for example). A block counts as the editor's only when its open tag has `type="text/typescript"` written exactly so (quoted, lowercase), the only form VS Code's HTML support embeds as TypeScript; a block whose open tag has no lowercase `type` attribute (`TYPE="text/typescript"`) is embedded as JavaScript, with the page's plain scripts, and the server treats its page-local names as the editor's too. In any other block Bascik compiles as TypeScript, the server answers everything. That mode reads every block with `lib.es2020.full` (the DOM), directives ignored, so the server also leaves to it what it types or resolves to that library itself: in a server-side block, a global `@types/node` shares with the DOM (`console`, `setTimeout`, `URL`) and that global's members. `.` and `/` trigger completion in these blocks. The server checks TypeScript in a worker thread after a short pause in typing, so its own diagnostics are published first. A page edit checks that page only; a change to a file the blocks may import, a `tsconfig.json`, a `package.json` or the Bascik config checks every open page. Until a page is checked again, its TypeScript errors move with their blocks, and an edited block's errors are left out rather than shown on the wrong code. Pages due a check are given to TypeScript together, so its programs are built once for all of them. Once no open page has TypeScript blocks for `releaseDelayMs` (default 30000), the worker ends and its memory is freed; the next page with blocks starts it again.
|
|
76
|
+
|
|
77
|
+
A page's browser blocks are checked as one classic script: the names its plain `<script>` elements declare, and those of the component scripts in its scope (with `scoping.scriptBlocks` off), are known as `any`; top-level names are never reported unused; a top-level `var` or `function`, and a plain script's name, is also a property of `window`, `self` and `globalThis`; a `var` a block types again after a plain script sets it is not "used before being assigned"; a top-level `interface Window { ... }` (or a `declare global`) adds to the global interface for that page only, never for another page, and a component's additions hold on every page that uses it; and a block with a syntax error is reported alone and left out, as a browser skips it.
|
|
78
|
+
|
|
79
|
+
## Project Config Discovery
|
|
80
|
+
|
|
81
|
+
The server reads `directory.components` and `scripts.importRoot` from each project's Bascik config, looking for `bascik.config.js`, then `bascik.config.mjs`, then `bascik.config.ts`, the same order the CLI uses. When a folder holds more than one, the first in that order wins, so the editor and the build read the same file.
|
|
82
|
+
|
|
83
|
+
A workspace folder without a Bascik config is still a Bascik project, with the defaults `src/components` and `src`, when its root has a language server config (`bascik.ext.json`, `.bascikrc.json`, `bascik.ext.ts`, or `bascik.ext.js`) or its `package.json` lists `@bascik/bascik` or `@bascik/language-server` in any dependency field. A linter-only component library, or a global install with no `package.json` entry, opts in with a `bascik.ext.json`. Any other folder, such as a React or Vue app with its own `src/components`, gets no diagnostics; navigation, hover, and completion still work there, and the server logs why once. A new `bascik.config.*` turns the checks on right away; a new language server config or dependency turns them on at the next edit.
|
|
84
|
+
|
|
44
85
|
## Editor Configurations
|
|
45
86
|
|
|
46
87
|
### Neovim (`nvim-lspconfig`)
|
|
@@ -56,7 +97,7 @@ if not configs.bascik then
|
|
|
56
97
|
default_config = {
|
|
57
98
|
cmd = { 'npx', '@bascik/language-server', '--stdio' },
|
|
58
99
|
filetypes = { 'html' },
|
|
59
|
-
root_dir = lspconfig.util.root_pattern('bascik.config.
|
|
100
|
+
root_dir = lspconfig.util.root_pattern('bascik.config.js', 'bascik.config.mjs', 'bascik.config.ts', 'bascik.ext.json', '.git'),
|
|
60
101
|
settings = {},
|
|
61
102
|
},
|
|
62
103
|
}
|
|
@@ -65,37 +106,40 @@ end
|
|
|
65
106
|
lspconfig.bascik.setup{}
|
|
66
107
|
```
|
|
67
108
|
|
|
68
|
-
###
|
|
109
|
+
### Coding agents and other LSP clients
|
|
69
110
|
|
|
70
|
-
|
|
111
|
+
The server speaks the Language Server Protocol, not the Model Context Protocol (MCP). Any editor or coding agent that can run an external LSP server (Claude Code through a language server plugin, Cursor, Zed, Helix, and others) can start it with:
|
|
71
112
|
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
command = "npx"
|
|
75
|
-
args = ["@bascik/language-server", "--stdio"]
|
|
76
|
-
|
|
77
|
-
[[language]]
|
|
78
|
-
name = "html"
|
|
79
|
-
language-servers = ["vscode-html-language-server", "bascik"]
|
|
113
|
+
```sh
|
|
114
|
+
bascik-language-server --stdio
|
|
80
115
|
```
|
|
81
116
|
|
|
82
|
-
|
|
117
|
+
It also accepts `--node-ipc` and `--socket=<port>`, as editors pass them. Register it for HTML files in the project root.
|
|
83
118
|
|
|
84
|
-
|
|
119
|
+
## One-shot check
|
|
85
120
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
121
|
+
For CI or an agent that wants a single pass instead of a running server, `--check` prints the same diagnostics, one per line, for a folder or file and exits:
|
|
122
|
+
|
|
123
|
+
```sh
|
|
124
|
+
npx @bascik/language-server --check # the current folder
|
|
125
|
+
npx @bascik/language-server --check src # one folder or file
|
|
126
|
+
npx @bascik/language-server --check --fix # also apply the fixes that have one correct answer
|
|
127
|
+
npx @bascik/language-server --check --typescript # also report TypeScript errors in type="text/typescript" blocks
|
|
97
128
|
```
|
|
98
129
|
|
|
99
|
-
|
|
130
|
+
`--project <path>` names the project when the target lives outside it, such as a monorepo's shared components. The exit code is 1 when any error is found, otherwise 0. `--fix` applies the prop prefix and self-closing fixes above and rewrites those files; the `html` wrap fix is never applied there. `--typescript` is opt-in, uses the project's own `typescript`, and without a usable one prints a single `note:` line and checks the rest.
|
|
131
|
+
|
|
132
|
+
## Development
|
|
133
|
+
|
|
134
|
+
The diagnostics, completions, hovers, and definitions are implemented once, here in `src/`; the VS Code extension bundles this server rather than reimplementing any of it. From the repository root:
|
|
135
|
+
|
|
136
|
+
```sh
|
|
137
|
+
yarn lsp:build # compile dist/
|
|
138
|
+
yarn lsp:typecheck # TypeScript type check
|
|
139
|
+
yarn lsp:unit # unit tests
|
|
140
|
+
yarn lsp:linear-time # linear-time scaling checks (CPU growth on large input; CI runs them on Linux)
|
|
141
|
+
yarn lsp:coverage # unit tests with coverage, written to lsp/test-coverage.json
|
|
142
|
+
yarn lsp:check # build, then run --check on the repository
|
|
143
|
+
```
|
|
100
144
|
|
|
101
|
-
|
|
145
|
+
When you change `src/server.ts` (project discovery, file watching, publishing), also run `yarn ext:unit` and `yarn ext:e2e`, which start the real server bundle.
|
package/dist/analyzer.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Diagnostic, type Position, type Range, type CompletionItem, type LocationLink, type Hover, type CodeAction, type TextEdit } from "vscode-languageserver";
|
|
2
2
|
import { type TextDocumentLike } from "./types.js";
|
|
3
3
|
import { type ProjectSnapshot } from "./project.js";
|
|
4
|
+
import { type ScriptModules } from "./script-modules.js";
|
|
4
5
|
import { type ComponentMetadata } from "./component-metadata.js";
|
|
5
6
|
export declare const BUILT_IN_HTML_ELEMENTS: Set<string>;
|
|
6
7
|
export declare const SCRIPT_DIRECTIVES: {
|
|
@@ -13,7 +14,28 @@ export declare function maskHtmlRawTextContents(html: string): string;
|
|
|
13
14
|
export declare function escapeRegExp(value: string): string;
|
|
14
15
|
export declare function findMatchingClose(html: string, tagName: string, contentStart: number): number;
|
|
15
16
|
export declare function findNearestParentComponent(source: string, componentMap: Map<string, string>): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* For each offset (ascending), the component that `findNearestParentComponent(source.slice(0, offset))`
|
|
19
|
+
* finds, from one scan of `source`. Rescanning the prefix for every offset was quadratic in the number of
|
|
20
|
+
* offsets (one per `data-bascik-slot` tag).
|
|
21
|
+
*
|
|
22
|
+
* The open-element stack carries, per entry, the nearest component at or below it, so each answer is
|
|
23
|
+
* read in constant time. A tag that starts before an offset but ends after it is not a tag in that prefix
|
|
24
|
+
* (its `>` is cut off), so for that offset the prefix scan is continued from just after its `<`, exactly
|
|
25
|
+
* as the prefix scan would, on a copy of the stack.
|
|
26
|
+
*/
|
|
27
|
+
export declare function findNearestParentComponents(source: string, offsets: readonly number[], componentMap: Map<string, string>): (string | undefined)[];
|
|
16
28
|
export declare function parseScriptOpenTagAttributes(openTag: string): Map<string, string | true>;
|
|
29
|
+
/**
|
|
30
|
+
* Attribute values of any open tag, keyed by lowercased name. A bare attribute
|
|
31
|
+
* maps to `""`, as the DOM reports it. The first occurrence of a name wins, as
|
|
32
|
+
* in the HTML tokenizer, and text inside a quoted value is never read as an
|
|
33
|
+
* attribute. An unquoted value keeps its slashes; a trailing `/>` ends it.
|
|
34
|
+
*
|
|
35
|
+
* @internal Exported for the attribute tokenizer agreement test
|
|
36
|
+
* (skills-tests/tests/attribute-tokenizer-agreement.test.ts).
|
|
37
|
+
*/
|
|
38
|
+
export declare function readOpenTagAttributes(openTag: string): Map<string, string>;
|
|
17
39
|
export declare function resolveScriptTarget(value: string, documentDir: string, importRootAbs: string, kind: "specifier" | "src"): string | undefined;
|
|
18
40
|
export declare function leadingSlashSpecifierMessage(specifier: string): string;
|
|
19
41
|
export declare function collectLeadingSlashDiagnostics(document: TextDocumentLike, openTag: string, scriptBody: string, blockStart: number, attrs: Map<string, string | true>): Diagnostic[];
|
|
@@ -26,10 +48,33 @@ export declare function collectLeadingSlashDiagnostics(document: TextDocumentLik
|
|
|
26
48
|
export declare function escapeMarkdownText(text: string): string;
|
|
27
49
|
export declare function createComponentDocumentationMarkdown(relativePath: string, metadata: ComponentMetadata | undefined): string;
|
|
28
50
|
export declare function completionReplacementRange(document: TextDocumentLike, position: Position): Range;
|
|
51
|
+
/**
|
|
52
|
+
* The `component-name-underscore` message for a component file, or null. The
|
|
53
|
+
* tag is the lowercased file name up to its first dot, as the build derives it
|
|
54
|
+
* (`deriveComponentName` in @bascik/bascik), so `site-nav.my_v2.html` defines
|
|
55
|
+
* `<site-nav>` and gets no warning. An `#id` rule compiles to the class
|
|
56
|
+
* `b_id_<component>_<id>`, so `<a_b>` with `#c` and `<a>` with `#b_c` spell
|
|
57
|
+
* one class, which the build rejects; the example uses the file's own name.
|
|
58
|
+
*/
|
|
59
|
+
/**
|
|
60
|
+
* A hyphenated name to suggest for a component file without one: camelCase and underscores split into
|
|
61
|
+
* words (`MyCard.html` -> `my-card`), a single word gets an `app-` prefix (`card.html` -> `app-card`).
|
|
62
|
+
*/
|
|
63
|
+
export declare const suggestHyphenatedName: (fileName: string) => string;
|
|
64
|
+
export declare const componentNameUnderscoreMessage: (fileName: string) => string | null;
|
|
65
|
+
/**
|
|
66
|
+
* createDiagnostics, or one analysis-failed warning when it throws, so one
|
|
67
|
+
* file cannot stop `bascik --check` or end the language server. The
|
|
68
|
+
* template scanners keep their nesting on an explicit stack, so deep
|
|
69
|
+
* nesting does not throw; this is the net for whatever else does.
|
|
70
|
+
*/
|
|
71
|
+
export declare function createDiagnosticsSafely(...args: Parameters<typeof createDiagnostics>): Diagnostic[];
|
|
29
72
|
export declare function createDiagnostics(document: TextDocumentLike, fsPath: string, snapshot: ProjectSnapshot | undefined, openDocumentTexts?: {
|
|
30
73
|
fsPath: string;
|
|
31
74
|
text: string;
|
|
32
|
-
}[]
|
|
75
|
+
}[],
|
|
76
|
+
/** The files that run in Node (see script-modules.ts); found from the snapshot when left out. */
|
|
77
|
+
scriptModules?: ScriptModules): Diagnostic[];
|
|
33
78
|
export declare function createCompletions(document: TextDocumentLike, position: Position, snapshot: ProjectSnapshot): CompletionItem[] | undefined;
|
|
34
79
|
export declare function createHover(document: TextDocumentLike, position: Position, snapshot: ProjectSnapshot): Hover | undefined;
|
|
35
80
|
export declare function createDefinition(document: TextDocumentLike, position: Position, snapshot: ProjectSnapshot, fsPath: string): LocationLink[] | undefined;
|
|
@@ -37,6 +82,35 @@ export declare function buildAutoFixEdit(document: TextDocumentLike, diag: Diagn
|
|
|
37
82
|
title: string;
|
|
38
83
|
edit: TextEdit;
|
|
39
84
|
} | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* The quick fix for server-script-unescaped-markup: put `html` before the
|
|
87
|
+
* template's backtick and import it from @bascik/bascik/html (after the
|
|
88
|
+
* script's last import, or merged into an existing import from the module).
|
|
89
|
+
* When the name html is already used in the script's code (a variable, a
|
|
90
|
+
* parameter, another import), it imports `html as safeHtml` instead, so the
|
|
91
|
+
* fix never tags with a binding that means something else; when safeHtml is
|
|
92
|
+
* taken too, or a hole sits where html would throw, it is not offered.
|
|
93
|
+
*/
|
|
94
|
+
export declare function buildWrapHtmlEdits(document: TextDocumentLike, diag: Diagnostic): {
|
|
95
|
+
title: string;
|
|
96
|
+
edits: TextEdit[];
|
|
97
|
+
} | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* The code actions for hand-written-html-escaper. A one-return escaper with
|
|
100
|
+
* one plain parameter gets "Make NAME() call esc()": its body becomes a call
|
|
101
|
+
* to esc() from @bascik/bascik/html (imported, aliased when the name esc is
|
|
102
|
+
* taken, as it is when the escaper itself is called esc). The callers keep
|
|
103
|
+
* working: esc() escapes the same characters and quotes as well. Rewriting
|
|
104
|
+
* the callers to html`...` is not automatic, since a template's value then
|
|
105
|
+
* changes from a string to an html value. Every other escaper (a lookup
|
|
106
|
+
* object, a longer body) gets "Import html from @bascik/bascik/html" when
|
|
107
|
+
* the script does not import it yet, as a start on rewriting by hand.
|
|
108
|
+
*/
|
|
109
|
+
export declare function buildEscaperActions(document: TextDocumentLike, diag: Diagnostic): {
|
|
110
|
+
title: string;
|
|
111
|
+
edits: TextEdit[];
|
|
112
|
+
preferred: boolean;
|
|
113
|
+
}[];
|
|
40
114
|
export declare function createCodeActions(document: TextDocumentLike, range: Range, diagnostics: Diagnostic[], snapshot?: ProjectSnapshot, fsPath?: string): CodeAction[];
|
|
41
115
|
export declare function applyAutoFixes(document: TextDocumentLike, snapshot: ProjectSnapshot | undefined, fsPath?: string): {
|
|
42
116
|
text: string;
|
package/dist/analyzer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,UAAU,EAEf,KAAK,QAAQ,EACb,KAAK,KAAK,EACV,KAAK,cAAc,EAEnB,KAAK,YAAY,EACjB,KAAK,KAAK,E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