princess-python-editor 0.1.0 → 0.1.1
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/README.html +1013 -0
- package/README.md +142 -35
- package/dist/PythonEditor.vue.d.ts +27 -0
- package/dist/index.cjs.js +131 -5
- package/dist/index.d.ts +10 -1
- package/dist/index.es.js +1053 -591
- package/dist/runtime/PyodideRunner.d.ts +9 -1
- package/dist/runtime/usePyodide.d.ts +9 -2
- package/dist/style.css +1 -1
- package/dist/types.d.ts +41 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InstallResult, PyodideStatus, RunResult, SyntaxIssue } from '../types';
|
|
1
|
+
import { FsListResult, FsReadResult, FsWriteResult, InstallResult, PyodideStatus, RunResult, SyntaxIssue } from '../types';
|
|
2
2
|
/** 默认 Pyodide CDN 地址(jsDelivr),可通过 options.pyodideUrl 覆盖 */
|
|
3
3
|
export declare const DEFAULT_PYODIDE_URL = "https://cdn.jsdelivr.net/pyodide/v0.27.2/full/";
|
|
4
4
|
export interface PyodideRunnerOptions {
|
|
@@ -8,6 +8,8 @@ export interface PyodideRunnerOptions {
|
|
|
8
8
|
export interface RunHooks {
|
|
9
9
|
/** 执行期间的实时输出回调(stdout / stderr),仅关联本次请求 */
|
|
10
10
|
onOutput?: (stream: 'stdout' | 'stderr', text: string) => void;
|
|
11
|
+
/** 提供给 input() / sys.stdin 的预置文本,按行切分;不传则读取时立即 EOF */
|
|
12
|
+
stdin?: string;
|
|
11
13
|
}
|
|
12
14
|
export type StatusHandler = (status: PyodideStatus, version: string) => void;
|
|
13
15
|
export type OutputHandler = (stream: 'stdout' | 'stderr', text: string) => void;
|
|
@@ -39,6 +41,12 @@ export declare class PyodideRunner {
|
|
|
39
41
|
run(code: string, hooks?: RunHooks): Promise<RunResult>;
|
|
40
42
|
/** 语法检查:仅在运行器就绪时可用,否则返回 null(静默跳过) */
|
|
41
43
|
checkSyntax(code: string): Promise<SyntaxIssue | null>;
|
|
44
|
+
/** 写入虚拟文件系统(UTF-8 文本),相对路径基于当前工作目录 */
|
|
45
|
+
writeFile(path: string, content: string): Promise<FsWriteResult>;
|
|
46
|
+
/** 读取虚拟文件系统中的文本文件;二进制内容会返回失败 */
|
|
47
|
+
readFile(path: string): Promise<FsReadResult>;
|
|
48
|
+
/** 列出虚拟文件系统目录(递归,跳过 __pycache__ / .cache) */
|
|
49
|
+
listFiles(path?: string): Promise<FsListResult>;
|
|
42
50
|
/** 安装第三方包:先尝试内置 wheel(loadPackage),失败后回退 micropip */
|
|
43
51
|
loadPackages(packages: string[], hooks?: RunHooks): Promise<InstallResult>;
|
|
44
52
|
/**
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { InstallResult, OutputLine, PyodideStatus, RunResult, SyntaxIssue } from '../types';
|
|
1
|
+
import { FsListResult, FsReadResult, FsWriteResult, InstallResult, OutputLine, PyodideStatus, RunResult, SyntaxIssue } from '../types';
|
|
2
2
|
export interface UsePyodideOptions {
|
|
3
3
|
/** Pyodide indexURL(以 / 结尾),默认 jsDelivr CDN;仅首次初始化生效 */
|
|
4
4
|
pyodideUrl?: string;
|
|
5
5
|
/** composable 创建时立即预加载 Pyodide */
|
|
6
6
|
preload?: boolean;
|
|
7
|
+
/** 就绪后自动安装的包列表;非空时创建后自动预加载 Pyodide */
|
|
8
|
+
preloadPackages?: string[];
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
11
|
* 独立于编辑器组件使用 Pyodide 的 composable。
|
|
@@ -25,11 +27,16 @@ export declare function usePyodide(options?: UsePyodideOptions): {
|
|
|
25
27
|
stream: import('..').OutputStream;
|
|
26
28
|
text: string;
|
|
27
29
|
}[]>;
|
|
28
|
-
runPython: (code: string
|
|
30
|
+
runPython: (code: string, options?: {
|
|
31
|
+
stdin?: string;
|
|
32
|
+
}) => Promise<RunResult>;
|
|
29
33
|
install: (packages: string[]) => Promise<InstallResult>;
|
|
30
34
|
checkSyntax: (code: string) => Promise<SyntaxIssue | null>;
|
|
31
35
|
interrupt: () => void;
|
|
32
36
|
clearOutputs: () => void;
|
|
37
|
+
writeFile: (path: string, content: string) => Promise<FsWriteResult>;
|
|
38
|
+
readFile: (path: string) => Promise<FsReadResult>;
|
|
39
|
+
listFiles: (path?: string) => Promise<FsListResult>;
|
|
33
40
|
/** 预加载并在就绪后 resolve */
|
|
34
41
|
ready: () => Promise<void>;
|
|
35
42
|
};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.princess-python-editor-host,.vpe-root{--vpe-mono: "JetBrains Mono", "Fira Code", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;--vpe-ui-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif}.vpe-root{--vpe-border: #e5e6eb;--vpe-bg: #ffffff;--vpe-toolbar-bg: #f7f8fa;--vpe-text: #1d2129;--vpe-text-secondary: #86909c;--vpe-hover: rgba(29, 33, 41, .08);--vpe-output-bg: #f7f8fa;--vpe-stdout: #1d2129;--vpe-stderr: #f53f3f;--vpe-system: #86909c;--vpe-accent: #165dff;--vpe-accent-hover: #4080ff;--vpe-danger: #f53f3f;--vpe-ok: #00b42a;--vpe-warn: #ff7d00;--vpe-err-line: rgba(245, 63, 63, .12);--vpe-error-btn-hover: #f76560;color-scheme:light;position:relative;display:flex;flex-direction:column;min-height:0;overflow:hidden;border:1px solid var(--vpe-border);background:var(--vpe-bg);color:var(--vpe-text);font-family:var(--vpe-ui-font)}.vpe-root.vpe-dark{--vpe-border: #3e4451;--vpe-bg: #282c34;--vpe-toolbar-bg: #21252b;--vpe-text: #abb2bf;--vpe-text-secondary: #7f848e;--vpe-hover: rgba(255, 255, 255, .08);--vpe-output-bg: #21252b;--vpe-stdout: #abb2bf;--vpe-stderr: #e06c75;--vpe-system: #7f848e;--vpe-accent: #61afef;--vpe-accent-hover: #528bce;--vpe-danger: #e06c75;--vpe-ok: #98c379;--vpe-warn: #d19a66;--vpe-err-line: rgba(224, 108, 117, .18);--vpe-error-btn-hover: #c25d64;color-scheme:dark}.vpe-root *,.vpe-root *:before,.vpe-root *:after{box-sizing:border-box}.vpe-toolbar{display:flex;align-items:center;flex-shrink:0;gap:6px;padding:6px 10px;overflow-x:auto;background:var(--vpe-toolbar-bg);border-bottom:1px solid var(--vpe-border);scrollbar-width:none}.vpe-toolbar::-webkit-scrollbar{display:none}.vpe-btn{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;gap:6px;height:28px;min-width:28px;padding:0 8px;border:none;border-radius:4px;background:transparent;color:var(--vpe-text);cursor:pointer;font-size:12px;font-family:inherit;line-height:1}.vpe-btn svg{font-size:14px}.vpe-btn:hover:not(:disabled){background:var(--vpe-hover)}.vpe-btn:disabled{opacity:.45;cursor:not-allowed}.vpe-btn--primary{color:#fff;background:var(--vpe-accent)}.vpe-btn--primary:hover:not(:disabled){background:var(--vpe-accent-hover)}.vpe-btn--stop{color:#fff;background:var(--vpe-danger)}.vpe-btn--stop:hover:not(:disabled){background:var(--vpe-error-btn-hover)}.vpe-btn--sm{height:24px;min-width:24px;padding:0 6px}.vpe-btn--copied{color:var(--vpe-ok)}.vpe-divider{flex-shrink:0;width:1px;height:16px;margin:0 2px;background:var(--vpe-border)}.vpe-file{display:inline-flex;align-items:center;flex-shrink:1;gap:5px;height:26px;min-width:0;max-width:180px;padding:0 7px;border:1px solid transparent;border-radius:4px;color:var(--vpe-text-secondary);font-size:12px;line-height:1}.vpe-file:hover,.vpe-file:focus-within{border-color:var(--vpe-border);background:var(--vpe-bg)}.vpe-file svg{flex-shrink:0;font-size:13px}.vpe-file-input{flex:1 1 auto;width:108px;min-width:40px;padding:0;border:none;outline:none;background:transparent;color:var(--vpe-text);font-family:var(--vpe-mono);font-size:12px}.vpe-file-hidden{display:none}.vpe-spacer{flex:1}.vpe-status{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--vpe-text-secondary)}.vpe-status-dot{width:8px;height:8px;border-radius:50%;background:var(--vpe-text-secondary)}.vpe-status--loading .vpe-status-dot{background:var(--vpe-warn);animation:vpe-pulse 1.2s ease-in-out infinite}.vpe-status--ready .vpe-status-dot{background:var(--vpe-ok)}.vpe-status--running .vpe-status-dot{background:var(--vpe-accent);animation:vpe-pulse .8s ease-in-out infinite}@keyframes vpe-pulse{50%{opacity:.35}}.vpe-lang{flex-shrink:0;height:24px;padding:0 6px;border:1px solid var(--vpe-border);border-radius:999px;outline:none;background:transparent;color:var(--vpe-text-secondary);font-family:inherit;font-size:12px;cursor:pointer}.vpe-lang:hover:not(:disabled),.vpe-lang:focus{color:var(--vpe-text);border-color:var(--vpe-accent)}.vpe-lang:disabled{opacity:.45;cursor:not-allowed}.vpe-tabs{display:flex;align-items:center;flex-shrink:0;gap:2px;padding:4px 8px 0;overflow-x:auto;background:var(--vpe-toolbar-bg);border-bottom:1px solid var(--vpe-border);scrollbar-width:thin}.vpe-tab{display:inline-flex;align-items:center;flex-shrink:0;gap:6px;max-width:180px;height:30px;padding:0 6px 0 10px;border:1px solid transparent;border-bottom:none;border-radius:6px 6px 0 0;color:var(--vpe-text-secondary);font-size:12px;white-space:nowrap;cursor:pointer;-webkit-user-select:none;user-select:none}.vpe-tab:hover{color:var(--vpe-text);background:var(--vpe-hover)}.vpe-tab:focus-visible{outline:1px solid var(--vpe-accent);outline-offset:-1px}.vpe-tab--active{color:var(--vpe-text);background:var(--vpe-bg);border-color:var(--vpe-border)}.vpe-tab-name{min-width:0;overflow:hidden;text-overflow:ellipsis}.vpe-tab-dot{flex-shrink:0;width:6px;height:6px;border-radius:50%;background:var(--vpe-text-secondary)}.vpe-tab-dot--python{background:#3776ab}.vpe-tab-dot--sql{background:#e38c00}.vpe-tab-dot--javascript{background:#c9a900}.vpe-tab-dot--json{background:#86909c}.vpe-tab-close{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:18px;height:18px;padding:0;border:none;border-radius:3px;background:transparent;color:inherit;opacity:.55;cursor:pointer}.vpe-tab-close:hover:not(:disabled){opacity:1;background:var(--vpe-hover)}.vpe-tab-close:disabled{opacity:.3;cursor:not-allowed}.vpe-tab-close svg{font-size:11px}.vpe-tabs-add{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:26px;height:26px;margin:0 2px;padding:0;border:none;border-radius:4px;background:transparent;color:var(--vpe-text-secondary);cursor:pointer}.vpe-tabs-add:hover:not(:disabled){color:var(--vpe-text);background:var(--vpe-hover)}.vpe-tabs-add:disabled{opacity:.45;cursor:not-allowed}.vpe-tabs-add svg{font-size:14px}.vpe-editor{flex:1 1 auto;min-height:0;background:var(--vpe-bg)}.vpe-editor .cm-editor{height:100%}.vpe-root .cm-placeholder{color:var(--vpe-text-secondary);font-style:italic}.vpe-error-line{background:var(--vpe-err-line)}.vpe-init-error{height:100%;display:flex;align-items:center;justify-content:center;padding:16px;color:var(--vpe-stderr);font-size:13px;word-break:break-all}.vpe-output{display:flex;flex-direction:column;background:var(--vpe-output-bg);border-top:1px solid var(--vpe-border);flex-shrink:0}.vpe-output-head{display:flex;align-items:center;justify-content:space-between;padding:3px 8px 3px 12px;font-size:12px;color:var(--vpe-text-secondary);border-bottom:1px dashed var(--vpe-border);flex-shrink:0}.vpe-output-body{margin:0;padding:8px 12px;overflow:auto;flex:1;min-height:0;font-size:12px;font-family:var(--vpe-mono);line-height:1.7;white-space:pre-wrap;word-break:break-word}.vpe-line{display:block}.vpe-line--stdout{color:var(--vpe-stdout)}.vpe-line--stderr{color:var(--vpe-stderr)}.vpe-line--system{color:var(--vpe-system);font-style:italic}.vpe-empty{color:var(--vpe-text-secondary);font-style:italic}
|
|
1
|
+
.princess-python-editor-host,.vpe-root{--vpe-mono: "JetBrains Mono", "Fira Code", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;--vpe-ui-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif}.vpe-root{--vpe-border: #e5e6eb;--vpe-bg: #ffffff;--vpe-toolbar-bg: #f7f8fa;--vpe-text: #1d2129;--vpe-text-secondary: #86909c;--vpe-hover: rgba(29, 33, 41, .08);--vpe-output-bg: #f7f8fa;--vpe-stdout: #1d2129;--vpe-stderr: #f53f3f;--vpe-system: #86909c;--vpe-accent: #165dff;--vpe-accent-hover: #4080ff;--vpe-danger: #f53f3f;--vpe-ok: #00b42a;--vpe-warn: #ff7d00;--vpe-err-line: rgba(245, 63, 63, .12);--vpe-error-btn-hover: #f76560;color-scheme:light;position:relative;display:flex;flex-direction:column;min-height:0;overflow:hidden;border:1px solid var(--vpe-border);background:var(--vpe-bg);color:var(--vpe-text);font-family:var(--vpe-ui-font)}.vpe-root.vpe-dark{--vpe-border: #3e4451;--vpe-bg: #282c34;--vpe-toolbar-bg: #21252b;--vpe-text: #abb2bf;--vpe-text-secondary: #7f848e;--vpe-hover: rgba(255, 255, 255, .08);--vpe-output-bg: #21252b;--vpe-stdout: #abb2bf;--vpe-stderr: #e06c75;--vpe-system: #7f848e;--vpe-accent: #61afef;--vpe-accent-hover: #528bce;--vpe-danger: #e06c75;--vpe-ok: #98c379;--vpe-warn: #d19a66;--vpe-err-line: rgba(224, 108, 117, .18);--vpe-error-btn-hover: #c25d64;color-scheme:dark}.vpe-root *,.vpe-root *:before,.vpe-root *:after{box-sizing:border-box}.vpe-toolbar{display:flex;align-items:center;flex-shrink:0;gap:6px;padding:6px 10px;overflow-x:auto;background:var(--vpe-toolbar-bg);border-bottom:1px solid var(--vpe-border);scrollbar-width:none}.vpe-toolbar::-webkit-scrollbar{display:none}.vpe-btn{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;gap:6px;height:28px;min-width:28px;padding:0 8px;border:none;border-radius:4px;background:transparent;color:var(--vpe-text);cursor:pointer;font-size:12px;font-family:inherit;line-height:1}.vpe-btn svg{font-size:14px}.vpe-btn:hover:not(:disabled){background:var(--vpe-hover)}.vpe-btn:disabled{opacity:.45;cursor:not-allowed}.vpe-btn--primary{color:#fff;background:var(--vpe-accent)}.vpe-btn--primary:hover:not(:disabled){background:var(--vpe-accent-hover)}.vpe-btn--stop{color:#fff;background:var(--vpe-danger)}.vpe-btn--stop:hover:not(:disabled){background:var(--vpe-error-btn-hover)}.vpe-btn--sm{height:24px;min-width:24px;padding:0 6px}.vpe-btn--copied{color:var(--vpe-ok)}.vpe-divider{flex-shrink:0;width:1px;height:16px;margin:0 2px;background:var(--vpe-border)}.vpe-file{display:inline-flex;align-items:center;flex-shrink:1;gap:5px;height:26px;min-width:0;max-width:180px;padding:0 7px;border:1px solid transparent;border-radius:4px;color:var(--vpe-text-secondary);font-size:12px;line-height:1}.vpe-file:hover,.vpe-file:focus-within{border-color:var(--vpe-border);background:var(--vpe-bg)}.vpe-file svg{flex-shrink:0;font-size:13px}.vpe-file-input{flex:1 1 auto;width:108px;min-width:40px;padding:0;border:none;outline:none;background:transparent;color:var(--vpe-text);font-family:var(--vpe-mono);font-size:12px}.vpe-file-hidden{display:none}.vpe-spacer{flex:1}.vpe-status{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--vpe-text-secondary)}.vpe-status-dot{width:8px;height:8px;border-radius:50%;background:var(--vpe-text-secondary)}.vpe-status--loading .vpe-status-dot{background:var(--vpe-warn);animation:vpe-pulse 1.2s ease-in-out infinite}.vpe-status--ready .vpe-status-dot{background:var(--vpe-ok)}.vpe-status--running .vpe-status-dot{background:var(--vpe-accent);animation:vpe-pulse .8s ease-in-out infinite}@keyframes vpe-pulse{50%{opacity:.35}}.vpe-lang{flex-shrink:0;height:24px;padding:0 6px;border:1px solid var(--vpe-border);border-radius:999px;outline:none;background:transparent;color:var(--vpe-text-secondary);font-family:inherit;font-size:12px;cursor:pointer}.vpe-lang:hover:not(:disabled),.vpe-lang:focus{color:var(--vpe-text);border-color:var(--vpe-accent)}.vpe-lang:disabled{opacity:.45;cursor:not-allowed}.vpe-tabs{display:flex;align-items:center;flex-shrink:0;gap:2px;padding:4px 8px 0;overflow-x:auto;background:var(--vpe-toolbar-bg);border-bottom:1px solid var(--vpe-border);scrollbar-width:thin}.vpe-tab{display:inline-flex;align-items:center;flex-shrink:0;gap:6px;max-width:180px;height:30px;padding:0 6px 0 10px;border:1px solid transparent;border-bottom:none;border-radius:6px 6px 0 0;color:var(--vpe-text-secondary);font-size:12px;white-space:nowrap;cursor:pointer;-webkit-user-select:none;user-select:none}.vpe-tab:hover{color:var(--vpe-text);background:var(--vpe-hover)}.vpe-tab:focus-visible{outline:1px solid var(--vpe-accent);outline-offset:-1px}.vpe-tab--active{color:var(--vpe-text);background:var(--vpe-bg);border-color:var(--vpe-border)}.vpe-tab-name{min-width:0;overflow:hidden;text-overflow:ellipsis}.vpe-tab-dot{flex-shrink:0;width:6px;height:6px;border-radius:50%;background:var(--vpe-text-secondary)}.vpe-tab-dot--python{background:#3776ab}.vpe-tab-dot--sql{background:#e38c00}.vpe-tab-dot--javascript{background:#c9a900}.vpe-tab-dot--json{background:#86909c}.vpe-tab-close{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:18px;height:18px;padding:0;border:none;border-radius:3px;background:transparent;color:inherit;opacity:.55;cursor:pointer}.vpe-tab-close:hover:not(:disabled){opacity:1;background:var(--vpe-hover)}.vpe-tab-close:disabled{opacity:.3;cursor:not-allowed}.vpe-tab-close svg{font-size:11px}.vpe-tabs-add{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:26px;height:26px;margin:0 2px;padding:0;border:none;border-radius:4px;background:transparent;color:var(--vpe-text-secondary);cursor:pointer}.vpe-tabs-add:hover:not(:disabled){color:var(--vpe-text);background:var(--vpe-hover)}.vpe-tabs-add:disabled{opacity:.45;cursor:not-allowed}.vpe-tabs-add svg{font-size:14px}.vpe-editor{flex:1 1 auto;min-height:0;background:var(--vpe-bg)}.vpe-editor .cm-editor{height:100%}.vpe-root .cm-placeholder{color:var(--vpe-text-secondary);font-style:italic}.vpe-error-line{background:var(--vpe-err-line)}.vpe-init-error{height:100%;display:flex;align-items:center;justify-content:center;padding:16px;color:var(--vpe-stderr);font-size:13px;word-break:break-all}.vpe-output{display:flex;flex-direction:column;background:var(--vpe-output-bg);border-top:1px solid var(--vpe-border);flex-shrink:0}.vpe-output-head{display:flex;align-items:center;justify-content:space-between;padding:3px 8px 3px 12px;font-size:12px;color:var(--vpe-text-secondary);border-bottom:1px dashed var(--vpe-border);flex-shrink:0}.vpe-output-body{margin:0;padding:8px 12px;overflow:auto;flex:1;min-height:0;font-size:12px;font-family:var(--vpe-mono);line-height:1.7;white-space:pre-wrap;word-break:break-word}.vpe-line{display:block}.vpe-line--stdout{color:var(--vpe-stdout)}.vpe-line--stderr{color:var(--vpe-stderr)}.vpe-line--system{color:var(--vpe-system);font-style:italic}.vpe-empty{color:var(--vpe-text-secondary);font-style:italic}.vpe-fs-panel{position:absolute;top:46px;right:10px;z-index:20;display:flex;flex-direction:column;width:min(380px,calc(100% - 20px));max-height:min(420px,calc(100% - 60px));overflow:hidden;border:1px solid var(--vpe-border);border-radius:6px;background:var(--vpe-bg);box-shadow:0 8px 24px #00000029}.vpe-fs-head{display:flex;align-items:center;flex-shrink:0;gap:6px;padding:5px 8px 5px 12px;border-bottom:1px solid var(--vpe-border);background:var(--vpe-toolbar-bg);color:var(--vpe-text-secondary);font-size:12px}.vpe-fs-title{color:var(--vpe-text);font-weight:600}.vpe-fs-body{flex:1 1 auto;min-height:0;padding:4px;overflow:auto}.vpe-fs-empty{padding:20px 12px;color:var(--vpe-text-secondary);font-size:12px;line-height:1.6;text-align:center}.vpe-fs-item{display:flex;align-items:center;gap:8px;padding:4px 6px;border-radius:4px;font-size:12px}.vpe-fs-item:hover{background:var(--vpe-hover)}.vpe-fs-name{flex:1 1 auto;min-width:0;overflow:hidden;color:var(--vpe-text);font-family:var(--vpe-mono);text-overflow:ellipsis;white-space:nowrap}.vpe-fs-item--dir .vpe-fs-name{color:var(--vpe-text-secondary)}.vpe-fs-size{flex-shrink:0;color:var(--vpe-text-secondary)}
|
package/dist/types.d.ts
CHANGED
|
@@ -72,3 +72,44 @@ export interface FileOpenEvent {
|
|
|
72
72
|
/** 根据扩展名推断的语法类型 */
|
|
73
73
|
language: EditorLanguage;
|
|
74
74
|
}
|
|
75
|
+
/** Pyodide 虚拟文件系统中的一个条目 */
|
|
76
|
+
export interface FsEntry {
|
|
77
|
+
/** 文件或目录名 */
|
|
78
|
+
name: string;
|
|
79
|
+
/** 绝对路径 */
|
|
80
|
+
path: string;
|
|
81
|
+
/** 是否为目录 */
|
|
82
|
+
isDirectory: boolean;
|
|
83
|
+
/** 文件大小(字节),目录为 0 */
|
|
84
|
+
size: number;
|
|
85
|
+
}
|
|
86
|
+
/** 写入虚拟文件的结果 */
|
|
87
|
+
export interface FsWriteResult {
|
|
88
|
+
ok: boolean;
|
|
89
|
+
/** 实际写入的绝对路径 */
|
|
90
|
+
path?: string;
|
|
91
|
+
error?: PyError;
|
|
92
|
+
}
|
|
93
|
+
/** 读取虚拟文件的结果(仅支持 UTF-8 文本) */
|
|
94
|
+
export interface FsReadResult {
|
|
95
|
+
ok: boolean;
|
|
96
|
+
/** 实际读取的绝对路径 */
|
|
97
|
+
path?: string;
|
|
98
|
+
content?: string;
|
|
99
|
+
error?: PyError;
|
|
100
|
+
}
|
|
101
|
+
/** 列出虚拟文件的结果 */
|
|
102
|
+
export interface FsListResult {
|
|
103
|
+
ok: boolean;
|
|
104
|
+
/** 被列出的绝对路径 */
|
|
105
|
+
path?: string;
|
|
106
|
+
entries?: FsEntry[];
|
|
107
|
+
error?: PyError;
|
|
108
|
+
}
|
|
109
|
+
/** 下载虚拟文件事件负载 */
|
|
110
|
+
export interface FsDownloadEvent {
|
|
111
|
+
/** 虚拟文件绝对路径 */
|
|
112
|
+
path: string;
|
|
113
|
+
/** 下载时使用的文件名 */
|
|
114
|
+
name: string;
|
|
115
|
+
}
|
package/package.json
CHANGED