spark-html-language-server 0.1.1 → 0.1.3

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 CHANGED
@@ -80,7 +80,7 @@ virtual DOM, no build step required. Add only what you use.
80
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
81
  | [`spark-html-offline`](https://www.npmjs.com/package/spark-html-offline) | Offline URL imports — a service worker that caches CDN components. |
82
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. |
83
+ | [`create-spark-html-app`](https://www.npmjs.com/package/create-spark-html-app) | Scaffold a spark-html app in one command. |
84
84
  | [`prettier-plugin-spark`](https://www.npmjs.com/package/prettier-plugin-spark) | Prettier for components — formats `<script>`/`<style>`, markup stays byte-for-byte. |
85
85
  | [`spark-html-language-server`](https://www.npmjs.com/package/spark-html-language-server) | LSP — diagnostics, go-to-definition, prop autocomplete, hover docs. |
86
86
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spark-html-language-server",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
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
- if (content) awaitBlocks.push({ content });
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