@isopodlabs/vscode_utils 0.3.0 → 0.5.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/shared.css +27 -0
- package/assets/tree.css +3 -0
- package/dist/codicon.d.ts +4 -2
- package/dist/codicon.js +9 -7
- package/dist/fs.d.ts +13 -10
- package/dist/fs.js +69 -35
- package/dist/jsx-runtime.d.ts +2 -1
- package/dist/jsx-runtime.js +14 -6
- package/dist/webview/shared.d.ts +1 -1
- package/dist/webview/shared.js +2 -4
- package/package.json +2 -1
package/assets/shared.css
CHANGED
|
@@ -73,6 +73,33 @@ body {
|
|
|
73
73
|
to { transform: rotate(360deg); }
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/* For font icons (character in fonticon attribute)*/
|
|
77
|
+
[fonticon]::before {
|
|
78
|
+
content: attr(icon);
|
|
79
|
+
font: normal normal normal 16px/1 var(--icon-font);
|
|
80
|
+
display: inline-block;
|
|
81
|
+
color: var(--icon-color);
|
|
82
|
+
text-decoration: none;
|
|
83
|
+
text-rendering: auto;
|
|
84
|
+
text-align: center;
|
|
85
|
+
vertical-align: text-top;
|
|
86
|
+
-webkit-font-smoothing: antialiased;
|
|
87
|
+
-moz-osx-font-smoothing: grayscale;
|
|
88
|
+
user-select: none;
|
|
89
|
+
-webkit-user-select: none;
|
|
90
|
+
-ms-user-select: none;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* For img icons (img in --icon)*/
|
|
94
|
+
[imgicon]::before {
|
|
95
|
+
content: '';
|
|
96
|
+
display: inline-block;
|
|
97
|
+
text-decoration: none;
|
|
98
|
+
width: 16px;
|
|
99
|
+
height: 16px;
|
|
100
|
+
background-image: var(--icon);
|
|
101
|
+
margin-right: 5px;
|
|
102
|
+
}
|
|
76
103
|
|
|
77
104
|
/* For img icons (img in --icon)*/
|
|
78
105
|
.icon::before {
|
package/assets/tree.css
CHANGED
package/dist/codicon.d.ts
CHANGED
|
@@ -6,11 +6,13 @@ export type IconType = IconType0 | ThemeIcon | {
|
|
|
6
6
|
dark: IconType0;
|
|
7
7
|
};
|
|
8
8
|
export declare function iconAttribute(icon: IconType0): string;
|
|
9
|
-
|
|
9
|
+
declare function iconAttributes1(icon: IconType): {
|
|
10
10
|
icon: string;
|
|
11
11
|
color?: undefined;
|
|
12
12
|
} | {
|
|
13
13
|
icon: string;
|
|
14
14
|
color: string;
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
|
+
export declare function iconAttributes(icon: IconType): ReturnType<typeof iconAttributes1>;
|
|
17
|
+
export declare function iconAttributes(icon?: IconType): ReturnType<typeof iconAttributes1> | undefined;
|
|
16
18
|
export {};
|
package/dist/codicon.js
CHANGED
|
@@ -478,13 +478,15 @@ function getColor(col) {
|
|
|
478
478
|
const id = col instanceof vscode_1.ThemeColor ? col.id : col;
|
|
479
479
|
return `var(--vscode-${id.replace('.', '-')})`;
|
|
480
480
|
}
|
|
481
|
+
function iconAttributes1(icon) {
|
|
482
|
+
if (typeof icon === 'string' || icon instanceof vscode_1.Uri)
|
|
483
|
+
return { icon: iconAttribute(icon) };
|
|
484
|
+
if (icon instanceof vscode_1.ThemeIcon)
|
|
485
|
+
return icon.color ? { icon: exports.codicons[icon.id], color: getColor(icon.color) } : { icon: exports.codicons[icon.id] };
|
|
486
|
+
return { icon: iconAttribute(currentlyLight() ? icon.light : icon.dark) };
|
|
487
|
+
}
|
|
481
488
|
function iconAttributes(icon) {
|
|
482
|
-
if (icon)
|
|
483
|
-
|
|
484
|
-
return { icon: iconAttribute(icon) };
|
|
485
|
-
if (icon instanceof vscode_1.ThemeIcon)
|
|
486
|
-
return icon.color ? { icon: exports.codicons[icon.id], color: getColor(icon.color) } : { icon: exports.codicons[icon.id] };
|
|
487
|
-
return { icon: iconAttribute(currentlyLight() ? icon.light : icon.dark) };
|
|
488
|
-
}
|
|
489
|
+
if (icon)
|
|
490
|
+
return iconAttributes1(icon);
|
|
489
491
|
}
|
|
490
492
|
//# sourceMappingURL=codicon.js.map
|
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, log?: boolean): Promise<Uint8Array | void>;
|
|
13
|
+
export declare function writeFile(file: Filename, bytes: Uint8Array, log?: boolean): PromiseLike<boolean>;
|
|
14
|
+
export declare function deleteFile(file: Filename, log?: boolean): PromiseLike<boolean>;
|
|
15
|
+
export declare function createDirectory(path: Filename, log?: boolean): PromiseLike<boolean>;
|
|
7
16
|
export interface File {
|
|
8
17
|
dispose(): void;
|
|
9
18
|
read(pos: number, length: number): Promise<Uint8Array>;
|
|
@@ -13,6 +22,7 @@ export declare function isFile(obj: any): obj is File;
|
|
|
13
22
|
interface FileSystem extends FileSystemProvider {
|
|
14
23
|
openFile(uri: Uri): File | Promise<File>;
|
|
15
24
|
}
|
|
25
|
+
type MaybeThenable<T> = T | Thenable<T>;
|
|
16
26
|
export declare abstract class BaseFileSystem implements FileSystem {
|
|
17
27
|
protected _onDidChangeFile: EventEmitter<FileChangeEvent[]>;
|
|
18
28
|
constructor(context: ExtensionContext, scheme: string);
|
|
@@ -23,8 +33,8 @@ export declare abstract class BaseFileSystem implements FileSystem {
|
|
|
23
33
|
readonly recursive: boolean;
|
|
24
34
|
readonly excludes: readonly string[];
|
|
25
35
|
}): Disposable;
|
|
26
|
-
stat(_uri: Uri):
|
|
27
|
-
readDirectory(_uri: Uri): [string, FileType][]
|
|
36
|
+
stat(_uri: Uri): MaybeThenable<FileStat>;
|
|
37
|
+
readDirectory(_uri: Uri): MaybeThenable<[string, FileType][]>;
|
|
28
38
|
createDirectory(_uri: Uri): void;
|
|
29
39
|
writeFile(_uri: Uri, _content: Uint8Array, _options: {
|
|
30
40
|
readonly create: boolean;
|
|
@@ -94,14 +104,7 @@ export declare function directories(entries: Entry[]): string[];
|
|
|
94
104
|
export declare function files(entries: Entry[], glob?: string | Glob): string[];
|
|
95
105
|
export declare function search(pattern: string, _exclude?: string | string[], want?: FileType): Promise<string[]>;
|
|
96
106
|
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>;
|
|
107
|
+
export declare function searchPath<T extends Filename>(target: T, paths: string[]): Promise<T | undefined>;
|
|
105
108
|
export declare function createNewName(filepath: string): Promise<string>;
|
|
106
109
|
export declare function createNewName(filepath: Uri): Promise<Uri>;
|
|
107
110
|
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,64 @@ 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, log = false) {
|
|
115
|
+
return vscode_1.workspace.fs.readFile(uri(file)).then(bytes => bytes, error => {
|
|
116
|
+
if (log)
|
|
117
|
+
console.log(`Failed to load ${file} : ${error}`);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function writeFile(file, bytes, log = false) {
|
|
121
|
+
return vscode_1.workspace.fs.writeFile(uri(file), bytes).then(() => true, error => {
|
|
122
|
+
if (log)
|
|
123
|
+
console.log(`Failed to save ${file} : ${error}`);
|
|
124
|
+
return false;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function deleteFile(file, log = false) {
|
|
128
|
+
return vscode_1.workspace.fs.delete(uri(file)).then(() => true, error => {
|
|
129
|
+
if (log)
|
|
130
|
+
console.log(`Failed to delete ${file} : ${error}`);
|
|
131
|
+
return false;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function createDirectory(path, log = false) {
|
|
135
|
+
return vscode_1.workspace.fs.createDirectory(uri(path)).then(() => true, error => {
|
|
136
|
+
if (log)
|
|
137
|
+
console.log(`Failed to create ${path} : ${error}`);
|
|
138
|
+
return false;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
91
141
|
function isFile(obj) {
|
|
92
142
|
return obj && typeof obj.dispose === 'function' && typeof obj.read === 'function' && typeof obj.write === 'function';
|
|
93
143
|
}
|
|
@@ -385,32 +435,16 @@ async function mapDirs(root, glob, onFile, combine) {
|
|
|
385
435
|
const glob2 = typeof glob === 'string' ? new Glob(glob) : glob;
|
|
386
436
|
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
437
|
}
|
|
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));
|
|
438
|
+
async function searchPath(target, paths) {
|
|
439
|
+
if (isAbsolute(target))
|
|
440
|
+
return check_exists(target);
|
|
441
|
+
const promises = paths.map(async (i) => check_exists(withPathComponents(target, i)));
|
|
442
|
+
for (const p of promises) {
|
|
443
|
+
const result = await p;
|
|
444
|
+
if (result)
|
|
445
|
+
return result;
|
|
446
|
+
}
|
|
447
|
+
return undefined;
|
|
414
448
|
}
|
|
415
449
|
async function createNewName(filepath) {
|
|
416
450
|
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
|
@@ -48,6 +48,10 @@ function escape(v) {
|
|
|
48
48
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
49
49
|
var JSX;
|
|
50
50
|
(function (JSX) {
|
|
51
|
+
function renderRawText(element, type) {
|
|
52
|
+
const text = typeof element === 'number' ? element.toString() : String(element ?? '');
|
|
53
|
+
return type === 'script' ? text.replace(/<\/(script)/gi, '<\\/$1') : text;
|
|
54
|
+
}
|
|
51
55
|
function render(element) {
|
|
52
56
|
if (typeof element === 'string')
|
|
53
57
|
return element.replace(/[\\&<>]/g, match => escaped[match]);
|
|
@@ -57,9 +61,13 @@ var JSX;
|
|
|
57
61
|
return '';
|
|
58
62
|
const { type, props } = element;
|
|
59
63
|
const children = props.children;
|
|
60
|
-
const renderedChildren =
|
|
61
|
-
?
|
|
62
|
-
|
|
64
|
+
const renderedChildren = type === 'script' || type === 'style'
|
|
65
|
+
? (Array.isArray(children)
|
|
66
|
+
? children.flat().map(child => renderRawText(child, type)).join('')
|
|
67
|
+
: renderRawText(children, type))
|
|
68
|
+
: (Array.isArray(children)
|
|
69
|
+
? children.flat().map(child => render(child)).join('')
|
|
70
|
+
: render(children));
|
|
63
71
|
return type
|
|
64
72
|
? `<${type}${renderProps(props)}>${renderedChildren}</${type}>`
|
|
65
73
|
: renderedChildren;
|
|
@@ -75,8 +83,8 @@ function id_selector(id) {
|
|
|
75
83
|
id = id.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g, "\\$&");
|
|
76
84
|
return id[0] >= '0' && id[0] <= '9' ? `[id="${id}"]` : `#${id}`;
|
|
77
85
|
}
|
|
78
|
-
function Label({ id, display }) {
|
|
79
|
-
return (0, jsx_runtime_1.jsx)("label", { for: id, children: display });
|
|
86
|
+
function Label({ id, display, title }) {
|
|
87
|
+
return (0, jsx_runtime_1.jsx)("label", { for: id, title: title, children: display });
|
|
80
88
|
}
|
|
81
89
|
//-----------------------------------------------------------------------------
|
|
82
90
|
// CSP
|
|
@@ -116,7 +124,7 @@ function CSPdefault(extension) {
|
|
|
116
124
|
}
|
|
117
125
|
function CSPFunction({ csp, ...others }) {
|
|
118
126
|
const val = (v) => v instanceof Array ? v.map(v => val(v)).join(' ')
|
|
119
|
-
: v instanceof vscode_1.Uri ? v.toString(true)
|
|
127
|
+
: v instanceof vscode_1.Uri ? v.toString(true).replace(/ /g, '%20')
|
|
120
128
|
: v instanceof Hash ? v.toValue()
|
|
121
129
|
: /*typeof v === 'string' ? `'${v}` :*/ v.toString();
|
|
122
130
|
const resolve = (v, parent) => {
|
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.5.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": [
|