-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for the VS Code Web version
- Loading branch information
Showing
11 changed files
with
153 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules | |
package-lock.json | ||
tmp | ||
*.vsix | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
//@ts-check | ||
'use strict'; | ||
|
||
//@ts-check | ||
/** @typedef {import('webpack').Configuration} WebpackConfig **/ | ||
|
||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
|
||
module.exports = /** @type WebpackConfig */ { | ||
context: path.dirname(__dirname), | ||
mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production') | ||
target: 'webworker', // extensions run in a webworker context | ||
entry: { | ||
extension: './src/extension.ts', | ||
}, | ||
resolve: { | ||
mainFields: ['module', 'main'], | ||
extensions: ['.ts', '.js'], // support ts-files and js-files | ||
alias: {}, | ||
fallback: { | ||
assert: require.resolve('assert'), | ||
path: require.resolve('path-browserify'), | ||
}, | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.ts$/, | ||
exclude: /node_modules/, | ||
use: [ | ||
{ | ||
loader: 'ts-loader', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
plugins: [ | ||
new webpack.ProvidePlugin({ | ||
process: 'process/browser', | ||
}), | ||
], | ||
externals: { | ||
vscode: 'commonjs vscode', // ignored because it doesn't exist | ||
}, | ||
performance: { | ||
hints: false, | ||
}, | ||
output: { | ||
filename: '[name].js', | ||
path: path.join(__dirname, '../out/web'), | ||
libraryTarget: 'commonjs', | ||
}, | ||
devtool: 'nosources-source-map', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ | ||
"name": "path-autocomplete", | ||
"displayName": "Path Autocomplete", | ||
"description": "Provides path completion for visual studio code.", | ||
"version": "1.19.1", | ||
"description": "Provides path completion for visual studio code and VS Code for Web.", | ||
"version": "1.20.0", | ||
"publisher": "ionutvmi", | ||
"icon": "icon.png", | ||
"repository": { | ||
|
@@ -14,7 +14,7 @@ | |
"email": "[email protected]" | ||
}, | ||
"engines": { | ||
"vscode": "^1.64.0" | ||
"vscode": "^1.69.0" | ||
}, | ||
"keywords": [ | ||
"path", | ||
|
@@ -30,26 +30,34 @@ | |
"*" | ||
], | ||
"main": "./out/src/extension", | ||
"browser": "./out/web/extension.js", | ||
"scripts": { | ||
"vscode:prepublish": "npm run compile", | ||
"vscode:prepublish": "npm run compile && npm run compile-web", | ||
"compile": "tsc -p ./", | ||
"watch": "tsc -watch -p ./", | ||
"type-check": "tsc -p ./tsconfig.json --noEmit", | ||
"lint": "eslint -c .eslintrc.js --ext .ts" | ||
"lint": "eslint -c .eslintrc.js --ext .ts", | ||
"compile-web": "webpack --config ./build/web-extension.webpack.config.js", | ||
"watch-web": "webpack --watch --config ./build/web-extension.webpack.config.js" | ||
}, | ||
"dependencies": { | ||
"minimatch": "5.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/minimatch": "^3.0.5", | ||
"@types/node": "^17.0.21", | ||
"@types/vscode": "^1.64.0", | ||
"@typescript-eslint/eslint-plugin": "^5.13.0", | ||
"@typescript-eslint/parser": "^5.13.0", | ||
"eslint": "^8.10.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"@types/minimatch": "3.0.5", | ||
"@types/node": "18.6.2", | ||
"@types/vscode": "1.69.0", | ||
"@typescript-eslint/eslint-plugin": "5.31.0", | ||
"@typescript-eslint/parser": "5.31.0", | ||
"eslint": "8.20.0", | ||
"eslint-config-prettier": "8.5.0", | ||
"path-browserify": "1.0.1", | ||
"prettier": "2.5.1", | ||
"typescript": "^4.6.2" | ||
"process": "0.11.10", | ||
"ts-loader": "9.3.1", | ||
"typescript": "4.7.4", | ||
"webpack": "5.74.0", | ||
"webpack-cli": "4.10.0" | ||
}, | ||
"contributes": { | ||
"configuration": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,23 @@ | ||
import fs from 'fs'; | ||
import fsAsync from 'fs/promises'; | ||
import vs from 'vscode'; | ||
|
||
export function pathExists(localPath: string) { | ||
return fsAsync | ||
.access(localPath, fs.constants.F_OK) | ||
.then(() => true) | ||
.catch(() => false); | ||
export async function pathExists(localPath: string): Promise<boolean> { | ||
try { | ||
await vs.workspace.fs.stat(vs.Uri.file(localPath)); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
|
||
const originalFs = getFsModule(); | ||
|
||
export async function isDirectory(filePath: string): Promise<boolean> { | ||
return new Promise((resolve, reject) => { | ||
originalFs.stat(filePath, (err, statInfo) => { | ||
if (err) { | ||
reject(err); | ||
return; | ||
} | ||
|
||
resolve(statInfo.isDirectory()); | ||
}); | ||
}); | ||
} | ||
|
||
function getFsModule() { | ||
try { | ||
// throws an error if module is not found (remote ssh environment) | ||
require.resolve("original-fs"); | ||
|
||
// using original-fs rather than fs to deal with .asar file | ||
// ref: https://github.com/microsoft/vscode/issues/143393#issuecomment-1047518447 | ||
return require('original-fs') as typeof fs; | ||
const stat = await vs.workspace.fs.stat(vs.Uri.file(filePath)); | ||
return stat.type === vs.FileType.Directory; | ||
} catch (e) { | ||
console.log("original-fs not found, falling back to the default fs module"); | ||
return fs; | ||
return false; | ||
} | ||
} | ||
|
||
export async function readDirectory(filePath: string) { | ||
return vs.workspace.fs.readDirectory(vs.Uri.file(filePath)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters