@isopodlabs/vscode_utils 0.3.0 → 0.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/assets/tree.css +3 -0
- package/dist/fs.d.ts +10 -8
- package/dist/fs.js +54 -35
- package/dist/jsx-runtime.d.ts +2 -1
- package/dist/jsx-runtime.js +2 -2
- package/dist/webview/shared.d.ts +1 -1
- package/dist/webview/shared.js +2 -4
- package/package.json +2 -1
package/assets/tree.css
CHANGED
package/dist/fs.d.ts
CHANGED
|
@@ -4,6 +4,15 @@ export interface FileRange {
|
|
|
4
4
|
fromOffset: number;
|
|
5
5
|
toOffset: number;
|
|
6
6
|
}
|
|
7
|
+
export declare function stat_reject(value: Filename): Thenable<FileStat>;
|
|
8
|
+
export declare function exists(value: Filename): Thenable<boolean>;
|
|
9
|
+
export declare function check_exists<T extends Filename>(value: T): Thenable<T | undefined>;
|
|
10
|
+
export declare function getStat(value: Filename): Thenable<FileStat | undefined>;
|
|
11
|
+
export declare function isDirectory(value: Filename): Thenable<boolean>;
|
|
12
|
+
export declare function loadFile(file: Filename): Promise<Uint8Array | void>;
|
|
13
|
+
export declare function writeFile(file: Filename, bytes: Uint8Array): PromiseLike<boolean>;
|
|
14
|
+
export declare function deleteFile(file: Filename): PromiseLike<boolean>;
|
|
15
|
+
export declare function createDirectory(path: Filename): PromiseLike<boolean>;
|
|
7
16
|
export interface File {
|
|
8
17
|
dispose(): void;
|
|
9
18
|
read(pos: number, length: number): Promise<Uint8Array>;
|
|
@@ -94,14 +103,7 @@ export declare function directories(entries: Entry[]): string[];
|
|
|
94
103
|
export declare function files(entries: Entry[], glob?: string | Glob): string[];
|
|
95
104
|
export declare function search(pattern: string, _exclude?: string | string[], want?: FileType): Promise<string[]>;
|
|
96
105
|
export declare function mapDirs<T>(root: string, glob: string | Glob, onFile: (filename: string) => T, combine: (...results: T[]) => T): Promise<T>;
|
|
97
|
-
export declare function
|
|
98
|
-
export declare function exists(value: Filename): Thenable<boolean>;
|
|
99
|
-
export declare function getStat(value: Filename): Thenable<FileStat | undefined>;
|
|
100
|
-
export declare function isDirectory(value: Filename): Thenable<boolean>;
|
|
101
|
-
export declare function loadFile(file: Filename): Promise<Uint8Array | void>;
|
|
102
|
-
export declare function writeFile(file: Filename, bytes: Uint8Array): PromiseLike<boolean>;
|
|
103
|
-
export declare function deleteFile(file: Filename): PromiseLike<boolean>;
|
|
104
|
-
export declare function createDirectory(path: Filename): PromiseLike<boolean>;
|
|
106
|
+
export declare function searchPath<T extends Filename>(target: T, paths: string[]): Promise<T | undefined>;
|
|
105
107
|
export declare function createNewName(filepath: string): Promise<string>;
|
|
106
108
|
export declare function createNewName(filepath: Uri): Promise<Uri>;
|
|
107
109
|
export declare function copyFile(sourcepath: string, destpath: string): Promise<void>;
|
package/dist/fs.js
CHANGED
|
@@ -34,6 +34,15 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.Change = exports.Glob = exports.SubfileFileSystem = exports.ReadOnlyFilesystem = exports.NormalFile = exports.BaseFileSystem = void 0;
|
|
37
|
+
exports.stat_reject = stat_reject;
|
|
38
|
+
exports.exists = exists;
|
|
39
|
+
exports.check_exists = check_exists;
|
|
40
|
+
exports.getStat = getStat;
|
|
41
|
+
exports.isDirectory = isDirectory;
|
|
42
|
+
exports.loadFile = loadFile;
|
|
43
|
+
exports.writeFile = writeFile;
|
|
44
|
+
exports.deleteFile = deleteFile;
|
|
45
|
+
exports.createDirectory = createDirectory;
|
|
37
46
|
exports.isFile = isFile;
|
|
38
47
|
exports.withOffset = withOffset;
|
|
39
48
|
exports.openFile = openFile;
|
|
@@ -43,14 +52,7 @@ exports.directories = directories;
|
|
|
43
52
|
exports.files = files;
|
|
44
53
|
exports.search = search;
|
|
45
54
|
exports.mapDirs = mapDirs;
|
|
46
|
-
exports.
|
|
47
|
-
exports.exists = exists;
|
|
48
|
-
exports.getStat = getStat;
|
|
49
|
-
exports.isDirectory = isDirectory;
|
|
50
|
-
exports.loadFile = loadFile;
|
|
51
|
-
exports.writeFile = writeFile;
|
|
52
|
-
exports.deleteFile = deleteFile;
|
|
53
|
-
exports.createDirectory = createDirectory;
|
|
55
|
+
exports.searchPath = searchPath;
|
|
54
56
|
exports.createNewName = createNewName;
|
|
55
57
|
exports.copyFile = copyFile;
|
|
56
58
|
exports.copyFileToDir = copyFileToDir;
|
|
@@ -78,16 +80,49 @@ function ext(value) {
|
|
|
78
80
|
function dirname(value) {
|
|
79
81
|
return path.dirname(file(value));
|
|
80
82
|
}
|
|
83
|
+
function isAbsolute(value) {
|
|
84
|
+
return path.isAbsolute(file(value));
|
|
85
|
+
}
|
|
81
86
|
function pathComponents(value) {
|
|
82
87
|
return path.parse(file(value));
|
|
83
88
|
}
|
|
84
89
|
function withPathComponents(value, ...comp) {
|
|
85
90
|
const p = path.join(...comp);
|
|
86
|
-
return value instanceof vscode_1.Uri ? value.with({ path: p }) : p;
|
|
91
|
+
return value instanceof vscode_1.Uri ? value.with({ path: p }) : path.join(p, value);
|
|
87
92
|
}
|
|
88
93
|
function join(directory, ...comp) {
|
|
89
94
|
return withPathComponents(directory, file(directory), ...comp);
|
|
90
95
|
}
|
|
96
|
+
//-----------------------------------------------------------------------------
|
|
97
|
+
// helpers
|
|
98
|
+
//-----------------------------------------------------------------------------
|
|
99
|
+
function stat_reject(value) {
|
|
100
|
+
return vscode_1.workspace.fs.stat(uri(value));
|
|
101
|
+
}
|
|
102
|
+
function exists(value) {
|
|
103
|
+
return vscode_1.workspace.fs.stat(uri(value)).then(() => true, () => false);
|
|
104
|
+
}
|
|
105
|
+
function check_exists(value) {
|
|
106
|
+
return vscode_1.workspace.fs.stat(uri(value)).then(() => value, () => undefined);
|
|
107
|
+
}
|
|
108
|
+
function getStat(value) {
|
|
109
|
+
return vscode_1.workspace.fs.stat(uri(value)).then(stat => stat, () => undefined);
|
|
110
|
+
}
|
|
111
|
+
function isDirectory(value) {
|
|
112
|
+
return vscode_1.workspace.fs.stat(uri(value)).then(stat => stat.type == vscode_1.FileType.Directory, () => ext(value) === "");
|
|
113
|
+
}
|
|
114
|
+
async function loadFile(file) {
|
|
115
|
+
return vscode_1.workspace.fs.readFile(uri(file)).then(bytes => bytes, error => console.log(`Failed to load ${file} : ${error}`));
|
|
116
|
+
}
|
|
117
|
+
function writeFile(file, bytes) {
|
|
118
|
+
return vscode_1.workspace.fs.writeFile(uri(file), bytes).then(() => true, error => (console.log(`Failed to save ${file} : ${error}`), false));
|
|
119
|
+
}
|
|
120
|
+
function deleteFile(file) {
|
|
121
|
+
return vscode_1.workspace.fs.delete(uri(file)).then(() => true, error => (console.log(`Failed to delete ${file} : ${error}`), false));
|
|
122
|
+
}
|
|
123
|
+
function createDirectory(path) {
|
|
124
|
+
return vscode_1.workspace.fs.createDirectory(uri(path)).then(() => true, error => (console.log(`Failed to create ${path} : ${error}`), false));
|
|
125
|
+
}
|
|
91
126
|
function isFile(obj) {
|
|
92
127
|
return obj && typeof obj.dispose === 'function' && typeof obj.read === 'function' && typeof obj.write === 'function';
|
|
93
128
|
}
|
|
@@ -385,32 +420,16 @@ async function mapDirs(root, glob, onFile, combine) {
|
|
|
385
420
|
const glob2 = typeof glob === 'string' ? new Glob(glob) : glob;
|
|
386
421
|
return readDirectory(root).then(async (dir) => combine(...await Promise.all(files(dir, glob).map(i => onFile(path.join(root, i)))), ...await Promise.all(directories(dir).map(async (i) => mapDirs(path.join(root, i), glob2, onFile, combine)))));
|
|
387
422
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
return vscode_1.workspace.fs.stat(uri(value)).then(stat => stat, () => undefined);
|
|
399
|
-
}
|
|
400
|
-
function isDirectory(value) {
|
|
401
|
-
return vscode_1.workspace.fs.stat(uri(value)).then(stat => stat.type == vscode_1.FileType.Directory, () => ext(value) === "");
|
|
402
|
-
}
|
|
403
|
-
async function loadFile(file) {
|
|
404
|
-
return vscode_1.workspace.fs.readFile(uri(file)).then(bytes => bytes, error => console.log(`Failed to load ${file} : ${error}`));
|
|
405
|
-
}
|
|
406
|
-
function writeFile(file, bytes) {
|
|
407
|
-
return vscode_1.workspace.fs.writeFile(uri(file), bytes).then(() => true, error => (console.log(`Failed to save ${file} : ${error}`), false));
|
|
408
|
-
}
|
|
409
|
-
function deleteFile(file) {
|
|
410
|
-
return vscode_1.workspace.fs.delete(uri(file)).then(() => true, error => (console.log(`Failed to delete ${file} : ${error}`), false));
|
|
411
|
-
}
|
|
412
|
-
function createDirectory(path) {
|
|
413
|
-
return vscode_1.workspace.fs.createDirectory(uri(path)).then(() => true, error => (console.log(`Failed to create ${path} : ${error}`), false));
|
|
423
|
+
async function searchPath(target, paths) {
|
|
424
|
+
if (isAbsolute(target))
|
|
425
|
+
return check_exists(target);
|
|
426
|
+
const promises = paths.map(async (i) => check_exists(withPathComponents(target, i)));
|
|
427
|
+
for (const p of promises) {
|
|
428
|
+
const result = await p;
|
|
429
|
+
if (result)
|
|
430
|
+
return result;
|
|
431
|
+
}
|
|
432
|
+
return undefined;
|
|
414
433
|
}
|
|
415
434
|
async function createNewName(filepath) {
|
|
416
435
|
const parsed = pathComponents(filepath);
|
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -16,9 +16,10 @@ export declare namespace JSX {
|
|
|
16
16
|
function render(element: any): string;
|
|
17
17
|
}
|
|
18
18
|
export declare function id_selector(id: string | number): string;
|
|
19
|
-
export declare function Label({ id, display }: {
|
|
19
|
+
export declare function Label({ id, display, title }: {
|
|
20
20
|
id: string;
|
|
21
21
|
display: string;
|
|
22
|
+
title?: string;
|
|
22
23
|
}): JSX.Element;
|
|
23
24
|
export declare class Hash {
|
|
24
25
|
algorithm: string;
|
package/dist/jsx-runtime.js
CHANGED
|
@@ -75,8 +75,8 @@ function id_selector(id) {
|
|
|
75
75
|
id = id.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g, "\\$&");
|
|
76
76
|
return id[0] >= '0' && id[0] <= '9' ? `[id="${id}"]` : `#${id}`;
|
|
77
77
|
}
|
|
78
|
-
function Label({ id, display }) {
|
|
79
|
-
return (0, jsx_runtime_1.jsx)("label", { for: id, children: display });
|
|
78
|
+
function Label({ id, display, title }) {
|
|
79
|
+
return (0, jsx_runtime_1.jsx)("label", { for: id, title: title, children: display });
|
|
80
80
|
}
|
|
81
81
|
//-----------------------------------------------------------------------------
|
|
82
82
|
// CSP
|
package/dist/webview/shared.d.ts
CHANGED
|
@@ -435,6 +435,6 @@ export declare class Tooltip {
|
|
|
435
435
|
show(text: string, x: number, y: number): void;
|
|
436
436
|
hide(): void;
|
|
437
437
|
}
|
|
438
|
-
export declare function template(template: HTMLElement, parent: HTMLElement, values: Record<string, string>[]):
|
|
438
|
+
export declare function template(template: HTMLElement, parent: HTMLElement, values: Record<string, string>[]): HTMLElement[];
|
|
439
439
|
export declare function generateSelector(e: Node | null): string;
|
|
440
440
|
export {};
|
package/dist/webview/shared.js
CHANGED
|
@@ -318,11 +318,9 @@ export function template(template, parent, values) {
|
|
|
318
318
|
replace_in_element(child, /\$\((.*)\)/g, m => i[m[1]]);
|
|
319
319
|
return child;
|
|
320
320
|
});
|
|
321
|
-
// const parent = after.parentNode;
|
|
322
|
-
// const before = after.nextSibling;
|
|
323
|
-
const before = null;
|
|
324
321
|
for (const i of newnodes)
|
|
325
|
-
parent.insertBefore(i,
|
|
322
|
+
parent.insertBefore(i, null);
|
|
323
|
+
return newnodes;
|
|
326
324
|
}
|
|
327
325
|
export function generateSelector(e) {
|
|
328
326
|
const path = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isopodlabs/vscode_utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "vscode utilities",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "tsc -b",
|
|
23
|
+
"watch": "tsc -watch -p ./",
|
|
23
24
|
"lint": "eslint \"src/**/*.ts\""
|
|
24
25
|
},
|
|
25
26
|
"keywords": [
|