princess-python-editor 0.0.0-stage → 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/LICENSE +21 -0
- package/README.html +1013 -0
- package/README.md +461 -2
- package/dist/PythonEditor.vue.d.ts +157 -0
- package/dist/editor/createEditor.d.ts +18 -0
- package/dist/editor/pythonLint.d.ts +8 -0
- package/dist/icons.d.ts +23 -0
- package/dist/index.cjs.js +228 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.es.js +1582 -0
- package/dist/languages.d.ts +15 -0
- package/dist/runtime/PyodideRunner.d.ts +66 -0
- package/dist/runtime/usePyodide.d.ts +42 -0
- package/dist/runtime/workerSource.d.ts +8 -0
- package/dist/style.css +1 -0
- package/dist/types.d.ts +115 -0
- package/package.json +90 -4
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Extension } from '@codemirror/state';
|
|
2
|
+
import { EditorLanguage } from './types';
|
|
3
|
+
export interface LanguageOption {
|
|
4
|
+
value: EditorLanguage;
|
|
5
|
+
label: string;
|
|
6
|
+
/** 默认文件扩展名(不含点) */
|
|
7
|
+
extension: string;
|
|
8
|
+
}
|
|
9
|
+
/** 工具栏语言下拉选项 */
|
|
10
|
+
export declare const LANGUAGE_OPTIONS: LanguageOption[];
|
|
11
|
+
export declare function getLanguageOption(language: EditorLanguage): LanguageOption;
|
|
12
|
+
/** 根据语法类型返回 CodeMirror 语言扩展 */
|
|
13
|
+
export declare function getLanguageExtension(language: EditorLanguage): Extension;
|
|
14
|
+
/** 根据文件扩展名推断语法类型,无法识别时按 Python 处理 */
|
|
15
|
+
export declare function inferLanguageFromFileName(name: string): EditorLanguage;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { FsListResult, FsReadResult, FsWriteResult, InstallResult, PyodideStatus, RunResult, SyntaxIssue } from '../types';
|
|
2
|
+
/** 默认 Pyodide CDN 地址(jsDelivr),可通过 options.pyodideUrl 覆盖 */
|
|
3
|
+
export declare const DEFAULT_PYODIDE_URL = "https://cdn.jsdelivr.net/pyodide/v0.27.2/full/";
|
|
4
|
+
export interface PyodideRunnerOptions {
|
|
5
|
+
/** Pyodide indexURL(以 / 结尾),默认使用 jsDelivr CDN */
|
|
6
|
+
pyodideUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface RunHooks {
|
|
9
|
+
/** 执行期间的实时输出回调(stdout / stderr),仅关联本次请求 */
|
|
10
|
+
onOutput?: (stream: 'stdout' | 'stderr', text: string) => void;
|
|
11
|
+
/** 提供给 input() / sys.stdin 的预置文本,按行切分;不传则读取时立即 EOF */
|
|
12
|
+
stdin?: string;
|
|
13
|
+
}
|
|
14
|
+
export type StatusHandler = (status: PyodideStatus, version: string) => void;
|
|
15
|
+
export type OutputHandler = (stream: 'stdout' | 'stderr', text: string) => void;
|
|
16
|
+
export type InitErrorHandler = (message: string) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Pyodide 运行器:封装 Blob Worker 与 Pyodide 通信。
|
|
19
|
+
* 所有请求经过内部串行队列;模块级共享单例(getRunner)避免重复加载 WASM。
|
|
20
|
+
*/
|
|
21
|
+
export declare class PyodideRunner {
|
|
22
|
+
status: PyodideStatus;
|
|
23
|
+
version: string;
|
|
24
|
+
private pyodideUrl;
|
|
25
|
+
private worker;
|
|
26
|
+
private pending;
|
|
27
|
+
private seq;
|
|
28
|
+
private chain;
|
|
29
|
+
/** Worker 生命周期代数:interrupt 后递增,用于废弃旧的 waitReady 等待 */
|
|
30
|
+
private generation;
|
|
31
|
+
private statusHandlers;
|
|
32
|
+
private outputHandlers;
|
|
33
|
+
private initErrorHandlers;
|
|
34
|
+
constructor(options?: PyodideRunnerOptions);
|
|
35
|
+
on(event: 'status', handler: StatusHandler): () => void;
|
|
36
|
+
on(event: 'output', handler: OutputHandler): () => void;
|
|
37
|
+
on(event: 'initError', handler: InitErrorHandler): () => void;
|
|
38
|
+
/** 预加载 Pyodide(返回 Promise,在就绪或失败时 settle) */
|
|
39
|
+
waitReady(timeoutMs?: number): Promise<void>;
|
|
40
|
+
/** 执行一段 Python 代码(支持顶层 await);运行器未就绪时先等待初始化完成 */
|
|
41
|
+
run(code: string, hooks?: RunHooks): Promise<RunResult>;
|
|
42
|
+
/** 语法检查:仅在运行器就绪时可用,否则返回 null(静默跳过) */
|
|
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>;
|
|
50
|
+
/** 安装第三方包:先尝试内置 wheel(loadPackage),失败后回退 micropip */
|
|
51
|
+
loadPackages(packages: string[], hooks?: RunHooks): Promise<InstallResult>;
|
|
52
|
+
/**
|
|
53
|
+
* 中断当前执行:terminate Worker(Pyodide 无法真正中断同步计算),
|
|
54
|
+
* 所有未决请求以 interrupted 结果结束;下次请求时自动重建 Worker。
|
|
55
|
+
*/
|
|
56
|
+
interrupt(): void;
|
|
57
|
+
private ensureWorker;
|
|
58
|
+
private handleMessage;
|
|
59
|
+
private send;
|
|
60
|
+
private setStatus;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 获取共享运行器(模块级单例)。首次调用时的配置生效,
|
|
64
|
+
* Pyodide WASM 体积较大,多组件/多 composable 共享同一实例。
|
|
65
|
+
*/
|
|
66
|
+
export declare function getRunner(options?: PyodideRunnerOptions): PyodideRunner;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { FsListResult, FsReadResult, FsWriteResult, InstallResult, OutputLine, PyodideStatus, RunResult, SyntaxIssue } from '../types';
|
|
2
|
+
export interface UsePyodideOptions {
|
|
3
|
+
/** Pyodide indexURL(以 / 结尾),默认 jsDelivr CDN;仅首次初始化生效 */
|
|
4
|
+
pyodideUrl?: string;
|
|
5
|
+
/** composable 创建时立即预加载 Pyodide */
|
|
6
|
+
preload?: boolean;
|
|
7
|
+
/** 就绪后自动安装的包列表;非空时创建后自动预加载 Pyodide */
|
|
8
|
+
preloadPackages?: string[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 独立于编辑器组件使用 Pyodide 的 composable。
|
|
12
|
+
* 与 PythonEditor 共享同一个底层运行器(WASM 实例全局唯一)。
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const { status, outputs, runPython } = usePyodide()
|
|
16
|
+
* const res = await runPython('print(1 + 1)')
|
|
17
|
+
*/
|
|
18
|
+
export declare function usePyodide(options?: UsePyodideOptions): {
|
|
19
|
+
status: import('vue').Ref<PyodideStatus, PyodideStatus>;
|
|
20
|
+
version: import('vue').Ref<string, string>;
|
|
21
|
+
outputs: import('vue').Ref<{
|
|
22
|
+
id: number;
|
|
23
|
+
stream: import('..').OutputStream;
|
|
24
|
+
text: string;
|
|
25
|
+
}[], OutputLine[] | {
|
|
26
|
+
id: number;
|
|
27
|
+
stream: import('..').OutputStream;
|
|
28
|
+
text: string;
|
|
29
|
+
}[]>;
|
|
30
|
+
runPython: (code: string, options?: {
|
|
31
|
+
stdin?: string;
|
|
32
|
+
}) => Promise<RunResult>;
|
|
33
|
+
install: (packages: string[]) => Promise<InstallResult>;
|
|
34
|
+
checkSyntax: (code: string) => Promise<SyntaxIssue | null>;
|
|
35
|
+
interrupt: () => void;
|
|
36
|
+
clearOutputs: () => void;
|
|
37
|
+
writeFile: (path: string, content: string) => Promise<FsWriteResult>;
|
|
38
|
+
readFile: (path: string) => Promise<FsReadResult>;
|
|
39
|
+
listFiles: (path?: string) => Promise<FsListResult>;
|
|
40
|
+
/** 预加载并在就绪后 resolve */
|
|
41
|
+
ready: () => Promise<void>;
|
|
42
|
+
};
|
package/dist/style.css
ADDED
|
@@ -0,0 +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}.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
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/** 编辑器支持的语法类型 */
|
|
2
|
+
export type EditorLanguage = 'python' | 'sql' | 'javascript' | 'json';
|
|
3
|
+
/** 编辑器中的一个文件(对应一个 Tab) */
|
|
4
|
+
export interface EditorFile {
|
|
5
|
+
/** 内部唯一标识 */
|
|
6
|
+
id: number;
|
|
7
|
+
/** 文件名(含扩展名) */
|
|
8
|
+
name: string;
|
|
9
|
+
/** 语法类型 */
|
|
10
|
+
language: EditorLanguage;
|
|
11
|
+
/** 文件内容 */
|
|
12
|
+
code: string;
|
|
13
|
+
}
|
|
14
|
+
/** Pyodide 运行器状态机 */
|
|
15
|
+
export type PyodideStatus = 'idle' | 'loading' | 'ready' | 'running';
|
|
16
|
+
/** 输出行流类型:stdout / stderr / system(系统消息) */
|
|
17
|
+
export type OutputStream = 'stdout' | 'stderr' | 'system';
|
|
18
|
+
/** 输出面板中的一行 */
|
|
19
|
+
export interface OutputLine {
|
|
20
|
+
id: number;
|
|
21
|
+
stream: OutputStream;
|
|
22
|
+
text: string;
|
|
23
|
+
}
|
|
24
|
+
/** 运行时 Python 异常(从 traceback 解析而来) */
|
|
25
|
+
export interface PyError {
|
|
26
|
+
/** 异常类型名,如 NameError、ZeroDivisionError */
|
|
27
|
+
type: string;
|
|
28
|
+
/** 异常消息 */
|
|
29
|
+
message: string;
|
|
30
|
+
/** 出错行号(1 起,可能缺失) */
|
|
31
|
+
line?: number;
|
|
32
|
+
/** 完整 traceback 文本 */
|
|
33
|
+
traceback: string;
|
|
34
|
+
}
|
|
35
|
+
/** 语法检查结果(一条语法问题) */
|
|
36
|
+
export interface SyntaxIssue {
|
|
37
|
+
/** 1 起的行号 */
|
|
38
|
+
line: number;
|
|
39
|
+
/** 1 起的列号 */
|
|
40
|
+
column: number;
|
|
41
|
+
/** 错误消息 */
|
|
42
|
+
message: string;
|
|
43
|
+
}
|
|
44
|
+
/** 执行结果 */
|
|
45
|
+
export interface RunResult {
|
|
46
|
+
ok: boolean;
|
|
47
|
+
/** 表达式结果(若有) */
|
|
48
|
+
value?: string;
|
|
49
|
+
error?: PyError;
|
|
50
|
+
/** 是否被用户中断 */
|
|
51
|
+
interrupted?: boolean;
|
|
52
|
+
/** 执行耗时(毫秒) */
|
|
53
|
+
durationMs: number;
|
|
54
|
+
}
|
|
55
|
+
/** 安装第三方包的结果 */
|
|
56
|
+
export interface InstallResult {
|
|
57
|
+
ok: boolean;
|
|
58
|
+
error?: PyError;
|
|
59
|
+
durationMs: number;
|
|
60
|
+
}
|
|
61
|
+
/** 输出事件负载 */
|
|
62
|
+
export interface RunOutputEvent {
|
|
63
|
+
stream: 'stdout' | 'stderr';
|
|
64
|
+
text: string;
|
|
65
|
+
}
|
|
66
|
+
/** 打开本地文件事件负载 */
|
|
67
|
+
export interface FileOpenEvent {
|
|
68
|
+
/** 文件名(含扩展名) */
|
|
69
|
+
name: string;
|
|
70
|
+
/** 文件文本内容 */
|
|
71
|
+
code: string;
|
|
72
|
+
/** 根据扩展名推断的语法类型 */
|
|
73
|
+
language: EditorLanguage;
|
|
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
|
@@ -1,6 +1,92 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "princess-python-editor",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Vue 3 + TypeScript Python editor component: CodeMirror 6 editing, in-browser Python execution powered by Pyodide, live syntax checking.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"vue3",
|
|
7
|
+
"vue",
|
|
8
|
+
"python",
|
|
9
|
+
"editor",
|
|
10
|
+
"code-editor",
|
|
11
|
+
"codemirror",
|
|
12
|
+
"pyodide",
|
|
13
|
+
"playground",
|
|
14
|
+
"typescript"
|
|
15
|
+
],
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://gitee.com/template_custom/python-editor.git"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://gitee.com/template_custom/python-editor#readme",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://gitee.com/template_custom/python-editor/issues"
|
|
24
|
+
},
|
|
25
|
+
"type": "module",
|
|
26
|
+
"sideEffects": [
|
|
27
|
+
"*.css"
|
|
28
|
+
],
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"main": "./dist/index.cjs.js",
|
|
33
|
+
"module": "./dist/index.es.js",
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"import": "./dist/index.es.js",
|
|
39
|
+
"require": "./dist/index.cjs.js"
|
|
40
|
+
},
|
|
41
|
+
"./style.css": "./dist/style.css"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"dev": "vite --config vite.playground.config.ts",
|
|
45
|
+
"build": "vue-tsc --noEmit -p tsconfig.json && vite build --config vite.config.ts",
|
|
46
|
+
"lint": "eslint .",
|
|
47
|
+
"format": "prettier --write .",
|
|
48
|
+
"typecheck": "vue-tsc --noEmit -p tsconfig.json",
|
|
49
|
+
"prepublishOnly": "pnpm build"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@codemirror/autocomplete": "^6.18.6",
|
|
53
|
+
"@codemirror/commands": "^6.8.0",
|
|
54
|
+
"@codemirror/lang-javascript": "^6.2.5",
|
|
55
|
+
"@codemirror/lang-json": "^6.0.2",
|
|
56
|
+
"@codemirror/lang-python": "^6.1.7",
|
|
57
|
+
"@codemirror/lang-sql": "^6.10.0",
|
|
58
|
+
"@codemirror/language": "^6.10.8",
|
|
59
|
+
"@codemirror/lint": "^6.8.4",
|
|
60
|
+
"@codemirror/state": "^6.5.2",
|
|
61
|
+
"@codemirror/theme-one-dark": "^6.1.2",
|
|
62
|
+
"@codemirror/view": "^6.36.2"
|
|
63
|
+
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"vue": ">=3.3.0"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@arco-design/web-vue": "^2.57.0",
|
|
69
|
+
"@eslint/js": "^9.21.0",
|
|
70
|
+
"@types/node": "^22.13.10",
|
|
71
|
+
"@vitejs/plugin-vue": "^5.2.1",
|
|
72
|
+
"@vue/eslint-config-prettier": "^10.2.0",
|
|
73
|
+
"@vue/eslint-config-typescript": "^14.4.0",
|
|
74
|
+
"eslint": "^9.21.0",
|
|
75
|
+
"eslint-plugin-vue": "^10.0.1",
|
|
76
|
+
"prettier": "^3.5.3",
|
|
77
|
+
"typescript": "~5.8.2",
|
|
78
|
+
"typescript-eslint": "^8.26.1",
|
|
79
|
+
"vite": "^6.2.2",
|
|
80
|
+
"vite-plugin-dts": "^4.5.3",
|
|
81
|
+
"vite-plugin-vue-devtools": "^8.2.1",
|
|
82
|
+
"vue": "^3.5.13",
|
|
83
|
+
"vue-tsc": "^2.2.8"
|
|
84
|
+
},
|
|
85
|
+
"engines": {
|
|
86
|
+
"node": ">=18"
|
|
87
|
+
},
|
|
88
|
+
"publishConfig": {
|
|
89
|
+
"registry": "https://registry.npmjs.org/",
|
|
90
|
+
"access": "public"
|
|
91
|
+
}
|
|
92
|
+
}
|