@isopodlabs/vscode_utils 0.4.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 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/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
- export declare function iconAttributes(icon?: IconType): {
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
- } | undefined;
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
- if (typeof icon === 'string' || icon instanceof vscode_1.Uri)
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
@@ -9,10 +9,10 @@ export declare function exists(value: Filename): Thenable<boolean>;
9
9
  export declare function check_exists<T extends Filename>(value: T): Thenable<T | undefined>;
10
10
  export declare function getStat(value: Filename): Thenable<FileStat | undefined>;
11
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>;
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>;
16
16
  export interface File {
17
17
  dispose(): void;
18
18
  read(pos: number, length: number): Promise<Uint8Array>;
@@ -22,6 +22,7 @@ export declare function isFile(obj: any): obj is File;
22
22
  interface FileSystem extends FileSystemProvider {
23
23
  openFile(uri: Uri): File | Promise<File>;
24
24
  }
25
+ type MaybeThenable<T> = T | Thenable<T>;
25
26
  export declare abstract class BaseFileSystem implements FileSystem {
26
27
  protected _onDidChangeFile: EventEmitter<FileChangeEvent[]>;
27
28
  constructor(context: ExtensionContext, scheme: string);
@@ -32,8 +33,8 @@ export declare abstract class BaseFileSystem implements FileSystem {
32
33
  readonly recursive: boolean;
33
34
  readonly excludes: readonly string[];
34
35
  }): Disposable;
35
- stat(_uri: Uri): FileStat | Thenable<FileStat>;
36
- readDirectory(_uri: Uri): [string, FileType][];
36
+ stat(_uri: Uri): MaybeThenable<FileStat>;
37
+ readDirectory(_uri: Uri): MaybeThenable<[string, FileType][]>;
37
38
  createDirectory(_uri: Uri): void;
38
39
  writeFile(_uri: Uri, _content: Uint8Array, _options: {
39
40
  readonly create: boolean;
package/dist/fs.js CHANGED
@@ -111,17 +111,32 @@ function getStat(value) {
111
111
  function isDirectory(value) {
112
112
  return vscode_1.workspace.fs.stat(uri(value)).then(stat => stat.type == vscode_1.FileType.Directory, () => ext(value) === "");
113
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}`));
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
+ });
116
119
  }
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));
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
+ });
119
126
  }
120
- function deleteFile(file) {
121
- return vscode_1.workspace.fs.delete(uri(file)).then(() => true, error => (console.log(`Failed to delete ${file} : ${error}`), false));
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
+ });
122
133
  }
123
- function createDirectory(path) {
124
- return vscode_1.workspace.fs.createDirectory(uri(path)).then(() => true, error => (console.log(`Failed to create ${path} : ${error}`), false));
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
+ });
125
140
  }
126
141
  function isFile(obj) {
127
142
  return obj && typeof obj.dispose === 'function' && typeof obj.read === 'function' && typeof obj.write === 'function';
@@ -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 = Array.isArray(children)
61
- ? children.flat().map(child => render(child)).join('')
62
- : render(children);
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;
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isopodlabs/vscode_utils",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "vscode utilities",
5
5
  "repository": {
6
6
  "type": "git",