Skip to content

Commit

Permalink
更新插件
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Jul 15, 2024
1 parent b0f3fab commit 1b5c301
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 77 deletions.
2 changes: 1 addition & 1 deletion src/plugin/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class Plugin {
for (let i = 0; i < lines.length; i++) {
let line = lines[i];
if (line.startsWith('export ')) {
lines[i] = line.replace(/export\s+(async\s+)function\s+([\w_\u10000-\uFFFFFFFF]+)/, (_, async, name) => {
lines[i] = line.replace(/export\s+(async\s+)?function\s+([\w_\u10000-\uFFFFFFFF]+)/, (_, async, name) => {
this.exports[name] = {
name,
async: async !== '',
Expand Down
3 changes: 2 additions & 1 deletion src/y3-helper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as vscode from 'vscode';
import { fs, log } from './tools';

export * as excel from './editorTable/excel2';
export { fs, log } from './tools';
export * as excel from './editorTable/excel';
export * as table from './editorTable/editorTable';
export * as language from './editorTable/language';
export * from './tools';
Expand Down
151 changes: 76 additions & 75 deletions template/plugin/y3-helper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

declare module 'y3-helper' {
import * as vscode from 'vscode';
export { fs, log } from 'y3-helper/tools';
export * as excel from 'y3-helper/editorTable/excel';
export * as table from 'y3-helper/editorTable/editorTable';
export * as language from 'y3-helper/editorTable/language';
Expand Down Expand Up @@ -39,6 +40,13 @@ declare module 'y3-helper' {
export function sleep(ms: number): Promise<void>;
}

declare module 'y3-helper/tools' {
export { download } from 'y3-helper/tools/download';
export { log } from 'y3-helper/tools/log';
export * as fs from 'y3-helper/tools/fs';
export * as json from 'y3-helper/tools/json';
}

import * as vscode from 'vscode';
export declare function loadFile(uri: vscode.Uri, sheet?: number | string): Promise<(string | undefined)[][] | undefined>;
export declare function init(): void;
Expand Down Expand Up @@ -211,13 +219,6 @@ declare module 'y3-helper/editorTable/language' {
export function keyOf(value: string | number, preferNumber?: boolean): string | number;
}

declare module 'y3-helper/tools' {
export { download } from 'y3-helper/tools/download';
export { log } from 'y3-helper/tools/log';
export * as fs from 'y3-helper/tools/fs';
export * as json from 'y3-helper/tools/json';
}

declare module 'y3-helper/constants' {
export namespace Table {
const path: {
Expand Down Expand Up @@ -407,6 +408,74 @@ declare module 'y3-helper/plugin' {
export function init(): Promise<void>;
}

declare module 'y3-helper/tools/download' {
import * as https from 'https';
export function download(options: string | URL | https.RequestOptions): Promise<Buffer>;
}

declare module 'y3-helper/tools/log' {
import * as vscode from 'vscode';
let log: vscode.LogOutputChannel;
export { log };
}

declare module 'y3-helper/tools/fs' {
import * as vscode from 'vscode';
class File {
write(data: Uint8Array): this;
get buffer(): Buffer;
get string(): string;
}
export function readFile(uri: vscode.Uri | string, relativePath?: string): Promise<File | undefined>;
export function writeFile(uri: vscode.Uri | string, relativePath: string | undefined, data: string): Promise<boolean>;
export function writeFile(uri: vscode.Uri | string, data: string): Promise<boolean>;
interface DeleteOptions {
/**
* 递归删除文件夹
*/
recursive?: boolean;
/**
* 尝试移动到回收站
*/
useTrash?: boolean;
}
export function removeFile(uri: vscode.Uri | string, options?: DeleteOptions): Promise<boolean>;
export function removeFile(uri: vscode.Uri | string, relativePath?: string, options?: DeleteOptions): Promise<boolean>;
export function dir(uri: vscode.Uri | string, relativePath?: string): Promise<[string, vscode.FileType][]>;
export function scan(uri: vscode.Uri | string, relativePath?: string): Promise<[string, vscode.FileType][]>;
export function stat(uri: vscode.Uri | string, relativePath?: string): Promise<vscode.FileStat | undefined>;
export function isFile(uri: vscode.Uri | string, relativePath?: string): Promise<boolean>;
export function isDirectory(uri: vscode.Uri | string, relativePath?: string): Promise<boolean>;
export function isExists(uri: vscode.Uri | string, relativePath?: string): Promise<boolean>;
interface CopyOptions {
overwrite?: boolean;
recursive?: boolean;
nameMap?: string;
pattern?: RegExp;
}
export function copy(source: vscode.Uri | string, target: vscode.Uri | string, options?: CopyOptions): Promise<boolean>;
export function isRelativePath(path: string): boolean;
export function isAbsolutePath(path: string): boolean;
export {};
}

declare module 'y3-helper/tools/json' {
import * as jsonc from 'jsonc-parser';
export type Item = string | boolean | number | null | Object | Array;
export type Array = Item[];
export type Object = {
[key: string]: Item;
};
export class Json {
constructor(text: string);
get text(): string;
get data(): Object | undefined;
get tree(): jsonc.Node | undefined;
get(key: string): Item | undefined;
set(key: string, value: any): boolean;
}
}

declare module 'y3-helper/editor_meta/unit' {
export interface UnitData {
/**
Expand Down Expand Up @@ -2850,71 +2919,3 @@ declare module 'y3-helper/editor_meta/tech' {
}
}

declare module 'y3-helper/tools/download' {
import * as https from 'https';
export function download(options: string | URL | https.RequestOptions): Promise<Buffer>;
}

declare module 'y3-helper/tools/log' {
import * as vscode from 'vscode';
let log: vscode.LogOutputChannel;
export { log };
}

declare module 'y3-helper/tools/fs' {
import * as vscode from 'vscode';
class File {
write(data: Uint8Array): this;
get buffer(): Buffer;
get string(): string;
}
export function readFile(uri: vscode.Uri | string, relativePath?: string): Promise<File | undefined>;
export function writeFile(uri: vscode.Uri | string, relativePath: string | undefined, data: string): Promise<boolean>;
export function writeFile(uri: vscode.Uri | string, data: string): Promise<boolean>;
interface DeleteOptions {
/**
* 递归删除文件夹
*/
recursive?: boolean;
/**
* 尝试移动到回收站
*/
useTrash?: boolean;
}
export function removeFile(uri: vscode.Uri | string, options?: DeleteOptions): Promise<boolean>;
export function removeFile(uri: vscode.Uri | string, relativePath?: string, options?: DeleteOptions): Promise<boolean>;
export function dir(uri: vscode.Uri | string, relativePath?: string): Promise<[string, vscode.FileType][]>;
export function scan(uri: vscode.Uri | string, relativePath?: string): Promise<[string, vscode.FileType][]>;
export function stat(uri: vscode.Uri | string, relativePath?: string): Promise<vscode.FileStat | undefined>;
export function isFile(uri: vscode.Uri | string, relativePath?: string): Promise<boolean>;
export function isDirectory(uri: vscode.Uri | string, relativePath?: string): Promise<boolean>;
export function isExists(uri: vscode.Uri | string, relativePath?: string): Promise<boolean>;
interface CopyOptions {
overwrite?: boolean;
recursive?: boolean;
nameMap?: string;
pattern?: RegExp;
}
export function copy(source: vscode.Uri | string, target: vscode.Uri | string, options?: CopyOptions): Promise<boolean>;
export function isRelativePath(path: string): boolean;
export function isAbsolutePath(path: string): boolean;
export {};
}

declare module 'y3-helper/tools/json' {
import * as jsonc from 'jsonc-parser';
export type Item = string | boolean | number | null | Object | Array;
export type Array = Item[];
export type Object = {
[key: string]: Item;
};
export class Json {
constructor(text: string);
get text(): string;
get data(): Object | undefined;
get tree(): jsonc.Node | undefined;
get(key: string): Item | undefined;
set(key: string, value: any): boolean;
}
}

0 comments on commit 1b5c301

Please sign in to comment.