spark-html-language-server 0.1.0 → 0.1.2
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 +26 -0
- package/package.json +1 -1
- package/src/analyze.js +11 -2
package/README.md
CHANGED
|
@@ -58,6 +58,32 @@ has. It does not type-check across files (props completion reads the target
|
|
|
58
58
|
file's `export let` names, not their types), and remote URL imports are not
|
|
59
59
|
resolved.
|
|
60
60
|
|
|
61
|
+
## The Spark family
|
|
62
|
+
|
|
63
|
+
Small, single-purpose packages that share one philosophy: no compiler, no
|
|
64
|
+
virtual DOM, no build step required. Add only what you use.
|
|
65
|
+
|
|
66
|
+
| Package | What it does |
|
|
67
|
+
|---|---|
|
|
68
|
+
| [`spark-html`](https://www.npmjs.com/package/spark-html) | The runtime — components, reactivity, stores, forms, scoped styles. 13 kB gzip, 0 deps. |
|
|
69
|
+
| [`spark-html-router`](https://www.npmjs.com/package/spark-html-router) | `<template route>` routing — nested routes/layouts, `route.query`, active links. |
|
|
70
|
+
| [`spark-html-theme`](https://www.npmjs.com/package/spark-html-theme) | Dark/light/system theming in one line — persisted, no flash. |
|
|
71
|
+
| [`spark-html-head`](https://www.npmjs.com/package/spark-html-head) | Reactive `<title>`/`<meta>` per route + a `head` store. |
|
|
72
|
+
| [`spark-html-motion`](https://www.npmjs.com/package/spark-html-motion) | Enter/leave transitions on if/each blocks — `transition="fade|slide|scale"`. |
|
|
73
|
+
| [`spark-html-devtools`](https://www.npmjs.com/package/spark-html-devtools) | In-page devtools — live stores, component tree, patch activity. |
|
|
74
|
+
| [`spark-html-query`](https://www.npmjs.com/package/spark-html-query) | Declarative async data — a self-fetching store (`loading`/`error`/`data`/`refetch`). |
|
|
75
|
+
| [`spark-html-persist`](https://www.npmjs.com/package/spark-html-persist) | Persist stores to localStorage/sessionStorage in one line. |
|
|
76
|
+
| [`spark-html-websocket`](https://www.npmjs.com/package/spark-html-websocket) | A WebSocket as a reactive store — auto-reconnect, JSON, `send()`. |
|
|
77
|
+
| [`spark-prerender`](https://www.npmjs.com/package/spark-prerender) | Build-time SEO prerender + sitemap/robots — no SSR server. |
|
|
78
|
+
| [`spark-html-image`](https://www.npmjs.com/package/spark-html-image) | Build-time image optimization — webp/avif + responsive `srcset`, zero config. |
|
|
79
|
+
| [`spark-html-font`](https://www.npmjs.com/package/spark-html-font) | Font loading optimizer — preload + size-adjusted fallbacks, no FOUT. |
|
|
80
|
+
| [`spark-html-manifest`](https://www.npmjs.com/package/spark-html-manifest) | PWA manifest + icons + head tags (and optional service worker) from one config. |
|
|
81
|
+
| [`spark-html-offline`](https://www.npmjs.com/package/spark-html-offline) | Offline URL imports — a service worker that caches CDN components. |
|
|
82
|
+
| [`spark-html-sri`](https://www.npmjs.com/package/spark-html-sri) | Subresource Integrity — hash + verify assets and remote components. |
|
|
83
|
+
| [`create-spark-html-app`](https://www.npmjs.com/package/create-spark-html-app) | Scaffold a Vite + spark-html app in one command. |
|
|
84
|
+
| [`prettier-plugin-spark`](https://www.npmjs.com/package/prettier-plugin-spark) | Prettier for components — formats `<script>`/`<style>`, markup stays byte-for-byte. |
|
|
85
|
+
| [`spark-html-language-server`](https://www.npmjs.com/package/spark-html-language-server) | LSP — diagnostics, go-to-definition, prop autocomplete, hover docs. |
|
|
86
|
+
|
|
61
87
|
## License
|
|
62
88
|
|
|
63
89
|
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spark-html-language-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Language server (LSP) for spark-html single-file components — diagnostics (undefined bindings, unused imports, script errors, missing key), go-to-definition for component imports and symbols, prop autocomplete from export let, and hover docs for every directive. Zero dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
package/src/analyze.js
CHANGED
|
@@ -343,11 +343,15 @@ function analyzeTemplate(text, tpl) {
|
|
|
343
343
|
});
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
// <template await="expr"> — `await` is in scope inside (then/catch included)
|
|
346
|
+
// <template await="expr"> — `await` is in scope inside (then/catch included),
|
|
347
|
+
// and an `as="user"` alias binds that name inside the block too.
|
|
347
348
|
const awaitRe = /<template\b[^>]*\bawait\s*=\s*"([^"]*)"/gi;
|
|
348
349
|
while ((m = awaitRe.exec(tpl)) !== null) {
|
|
349
350
|
const content = templateContentRange(tpl, m.index);
|
|
350
|
-
|
|
351
|
+
const tagEnd = tpl.indexOf('>', m.index);
|
|
352
|
+
const tag = tpl.slice(m.index, tagEnd === -1 ? tpl.length : tagEnd);
|
|
353
|
+
const asName = tag.match(/\bas\s*=\s*"\s*([A-Za-z_$][\w$]*)\s*"/)?.[1] || null;
|
|
354
|
+
if (content) awaitBlocks.push({ content, asName });
|
|
351
355
|
let expr = m[1];
|
|
352
356
|
let exprOffset = m.index + m[0].length - m[1].length - 1;
|
|
353
357
|
const once = expr.match(/^once\(([\s\S]*)\)$/);
|
|
@@ -421,6 +425,11 @@ export function analyze(text) {
|
|
|
421
425
|
if (b.content && offset < b.content.start && offset >= b.attrOffset &&
|
|
422
426
|
(name === b.itemVar || name === b.indexVar)) return true;
|
|
423
427
|
}
|
|
428
|
+
// <template await … as="user"> binds the alias inside the block.
|
|
429
|
+
for (const b of t.awaitBlocks) {
|
|
430
|
+
if (b.asName === name && b.content &&
|
|
431
|
+
offset >= b.content.start && offset < b.content.end) return true;
|
|
432
|
+
}
|
|
424
433
|
return false;
|
|
425
434
|
};
|
|
426
435
|
|