@analogjs/language-server 0.2.0 → 0.2.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/out/index.js CHANGED
@@ -30,8 +30,23 @@ connection.onInitialize(params => {
30
30
  if (scanner) {
31
31
  servicePlugins.push((0, routingPlugin_1.createRoutingPlugin)(scanner));
32
32
  }
33
+ // Language plugin that resolves angular-embedded-content URIs to HTML
34
+ const angularEmbeddedPlugin = {
35
+ getLanguageId(uri) {
36
+ if (uri.scheme === 'angular-embedded-content') {
37
+ // URI ends with .html or contains /html/
38
+ if (uri.path.endsWith('.html') || uri.path.includes('/html/')) {
39
+ return 'html';
40
+ }
41
+ if (uri.path.endsWith('.css')) {
42
+ return 'css';
43
+ }
44
+ }
45
+ return undefined;
46
+ },
47
+ };
33
48
  return server.initialize(params, (0, node_1.createTypeScriptProject)(tsdk.typescript, tsdk.diagnosticMessages, () => ({
34
- languagePlugins: []
49
+ languagePlugins: [angularEmbeddedPlugin]
35
50
  })), servicePlugins);
36
51
  });
37
52
  // Re-scan routes when watched files change
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.RouteScanner = void 0;
27
27
  const fs = __importStar(require("node:fs"));
28
- const tinyglobby_1 = require("tinyglobby");
28
+ const path = __importStar(require("node:path"));
29
29
  /**
30
30
  * Converts a page filename to a raw path segment.
31
31
  * Adapted from @analogjs/router routes.ts toRawPath().
@@ -65,6 +65,29 @@ function extractParams(urlPath) {
65
65
  }
66
66
  return params;
67
67
  }
68
+ /**
69
+ * Recursively collect files matching a test under a directory.
70
+ */
71
+ function collectFiles(dir, test) {
72
+ const results = [];
73
+ let entries;
74
+ try {
75
+ entries = fs.readdirSync(dir, { withFileTypes: true });
76
+ }
77
+ catch {
78
+ return results;
79
+ }
80
+ for (const entry of entries) {
81
+ const full = path.join(dir, entry.name);
82
+ if (entry.isDirectory()) {
83
+ results.push(...collectFiles(full, test));
84
+ }
85
+ else if (entry.isFile() && test(entry.name)) {
86
+ results.push(full);
87
+ }
88
+ }
89
+ return results;
90
+ }
68
91
  /**
69
92
  * Scans the workspace for Analog page files and builds a route map.
70
93
  */
@@ -77,10 +100,8 @@ class RouteScanner {
77
100
  * Perform initial scan of the pages directory.
78
101
  */
79
102
  scan() {
80
- const pageFiles = (0, tinyglobby_1.globSync)(['src/app/pages/**/*.page.ts'], {
81
- cwd: this.workspaceRoot,
82
- absolute: true,
83
- });
103
+ const pagesDir = path.join(this.workspaceRoot, 'src', 'app', 'pages');
104
+ const pageFiles = collectFiles(pagesDir, (name) => name.endsWith('.page.ts'));
84
105
  this.routes = pageFiles.map((filePath) => {
85
106
  const urlPath = fileToUrlPath(filePath);
86
107
  const serverFilePath = filePath.replace(/\.page\.ts$/, '.server.ts');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@analogjs/language-server",
3
3
  "description": "LSP server for AnalogJS Language Service",
4
- "version": "0.2.0",
4
+ "version": "0.2.1",
5
5
  "main": "out/index.js",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -27,7 +27,6 @@
27
27
  "volar-service-emmet": "0.0.70",
28
28
  "volar-service-html": "0.0.70",
29
29
  "volar-service-typescript": "0.0.70",
30
- "tinyglobby": "^0.2.0",
31
30
  "vscode-languageserver-protocol": "^3.17.5",
32
31
  "vscode-languageserver-textdocument": "^1.0.11",
33
32
  "vscode-uri": "^3.0.8"