@volar/jsdelivr 2.4.0-alpha.8 → 2.4.0
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/lib/npm.js +15 -14
- package/package.json +4 -3
package/lib/npm.js
CHANGED
|
@@ -8,7 +8,7 @@ function createNpmFileSystem(getCdnPath = (uri) => {
|
|
|
8
8
|
return '';
|
|
9
9
|
}
|
|
10
10
|
else if (uri.path.startsWith('/node_modules/')) {
|
|
11
|
-
return uri.path.slice('/node_modules'.length);
|
|
11
|
+
return uri.path.slice('/node_modules/'.length);
|
|
12
12
|
}
|
|
13
13
|
}, getPackageVersion, onFetch) {
|
|
14
14
|
const fetchResults = new Map();
|
|
@@ -116,8 +116,8 @@ function createNpmFileSystem(getCdnPath = (uri) => {
|
|
|
116
116
|
];
|
|
117
117
|
}
|
|
118
118
|
async function _readFile(path) {
|
|
119
|
-
const [_modName, pkgName] = resolvePackageName(path);
|
|
120
|
-
if (!pkgName || !await isValidPackageName(pkgName)) {
|
|
119
|
+
const [_modName, pkgName, _version, pkgFilePath] = resolvePackageName(path);
|
|
120
|
+
if (!pkgName || !pkgFilePath || !await isValidPackageName(pkgName)) {
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
123
|
if (!fetchResults.has(path)) {
|
|
@@ -155,8 +155,8 @@ function createNpmFileSystem(getCdnPath = (uri) => {
|
|
|
155
155
|
if (pkgName.endsWith('/node_modules')) {
|
|
156
156
|
return false;
|
|
157
157
|
}
|
|
158
|
-
// hard code
|
|
159
|
-
if (pkgName.startsWith('@typescript/') || pkgName.startsWith('@types/typescript__')) {
|
|
158
|
+
// hard code to skip known invalid package
|
|
159
|
+
if (pkgName.endsWith('.d.ts') || pkgName.startsWith('@typescript/') || pkgName.startsWith('@types/typescript__')) {
|
|
160
160
|
return false;
|
|
161
161
|
}
|
|
162
162
|
// don't check @types if original package already having types
|
|
@@ -166,15 +166,16 @@ function createNpmFileSystem(getCdnPath = (uri) => {
|
|
|
166
166
|
originalPkgName = '@' + originalPkgName.replace('__', '/');
|
|
167
167
|
}
|
|
168
168
|
const packageJson = await _readFile(`${originalPkgName}/package.json`);
|
|
169
|
-
if (packageJson) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
169
|
+
if (!packageJson) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
const packageJsonObj = JSON.parse(packageJson);
|
|
173
|
+
if (packageJsonObj.types || packageJsonObj.typings) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
const indexDts = await _stat(`${originalPkgName}/index.d.ts`);
|
|
177
|
+
if (indexDts?.type === 1) {
|
|
178
|
+
return false;
|
|
178
179
|
}
|
|
179
180
|
}
|
|
180
181
|
return true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/jsdelivr",
|
|
3
|
-
"version": "2.4.0
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"directory": "packages/jsdelivr"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@volar/language-service": "2.4.0
|
|
15
|
+
"@volar/language-service": "2.4.0",
|
|
16
16
|
"vscode-uri": "^3.0.8"
|
|
17
|
-
}
|
|
17
|
+
},
|
|
18
|
+
"gitHead": "7e98885cfe284451e655cf1c3954786b51aea2f8"
|
|
18
19
|
}
|