@analogjs/language-server 0.2.0 → 0.2.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/out/index.js +16 -1
- package/out/routeScanner.d.ts +1 -1
- package/out/routeScanner.js +65 -6
- package/package.json +1 -2
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
|
package/out/routeScanner.d.ts
CHANGED
package/out/routeScanner.js
CHANGED
|
@@ -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
|
|
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,64 @@ 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
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Find all `pages` directories under a root by looking for the
|
|
93
|
+
* `src/app/pages` convention at any nesting depth.
|
|
94
|
+
* Handles both standalone projects (src/app/pages) and monorepos
|
|
95
|
+
* (apps/my-app/src/app/pages, projects/foo/src/app/pages).
|
|
96
|
+
*/
|
|
97
|
+
function findPagesDirs(root) {
|
|
98
|
+
const results = [];
|
|
99
|
+
// Direct project: root/src/app/pages
|
|
100
|
+
const direct = path.join(root, 'src', 'app', 'pages');
|
|
101
|
+
if (fs.existsSync(direct)) {
|
|
102
|
+
results.push(direct);
|
|
103
|
+
}
|
|
104
|
+
// Monorepo: scan common app directories
|
|
105
|
+
const monorepoParents = ['apps', 'projects', 'packages'];
|
|
106
|
+
for (const parent of monorepoParents) {
|
|
107
|
+
const parentDir = path.join(root, parent);
|
|
108
|
+
let entries;
|
|
109
|
+
try {
|
|
110
|
+
entries = fs.readdirSync(parentDir, { withFileTypes: true });
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
for (const entry of entries) {
|
|
116
|
+
if (!entry.isDirectory())
|
|
117
|
+
continue;
|
|
118
|
+
const candidate = path.join(parentDir, entry.name, 'src', 'app', 'pages');
|
|
119
|
+
if (fs.existsSync(candidate)) {
|
|
120
|
+
results.push(candidate);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return results;
|
|
125
|
+
}
|
|
68
126
|
/**
|
|
69
127
|
* Scans the workspace for Analog page files and builds a route map.
|
|
70
128
|
*/
|
|
@@ -74,13 +132,14 @@ class RouteScanner {
|
|
|
74
132
|
this.workspaceRoot = workspaceRoot;
|
|
75
133
|
}
|
|
76
134
|
/**
|
|
77
|
-
* Perform initial scan of
|
|
135
|
+
* Perform initial scan of all pages directories in the workspace.
|
|
78
136
|
*/
|
|
79
137
|
scan() {
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
138
|
+
const pagesDirs = findPagesDirs(this.workspaceRoot);
|
|
139
|
+
const pageFiles = [];
|
|
140
|
+
for (const dir of pagesDirs) {
|
|
141
|
+
pageFiles.push(...collectFiles(dir, (name) => name.endsWith('.page.ts')));
|
|
142
|
+
}
|
|
84
143
|
this.routes = pageFiles.map((filePath) => {
|
|
85
144
|
const urlPath = fileToUrlPath(filePath);
|
|
86
145
|
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.
|
|
4
|
+
"version": "0.2.2",
|
|
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"
|