princess-python-editor 0.1.0 → 0.1.2

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.
@@ -1,5 +1,5 @@
1
1
  import { EditorView } from '@codemirror/view';
2
- import { EditorFile, EditorLanguage } from './types';
2
+ import { EditorFile, EditorLanguage, PythonRuntime, ServerFile, SqlConfig, SqlConfigInput, SqlExecutor, SqlQueryResult } from './types';
3
3
  export interface Props {
4
4
  /** 绑定的代码内容(当前 Tab 的文件内容,v-model) */
5
5
  modelValue?: string;
@@ -35,14 +35,46 @@ export interface Props {
35
35
  fileName?: string;
36
36
  /** 初始语法类型(支持 v-model:language) */
37
37
  language?: EditorLanguage;
38
+ /** 提供给 input() / sys.stdin 的预置文本,按行切分;留空则读取时立即 EOF */
39
+ stdin?: string;
40
+ /** 运行前把 Python Tab 写入虚拟文件系统,便于跨文件 import;默认开启 */
41
+ syncFilesOnRun?: boolean;
42
+ /** 非空时启用草稿持久化(localStorage key),保存全部 Tab 与当前选中项 */
43
+ storageKey?: string;
44
+ /** Pyodide 就绪后自动安装的包列表;非空时挂载后自动开始加载 Pyodide */
45
+ preloadPackages?: string[];
46
+ /** SQL 连接与执行配置(支持 v-model:sql-config) */
47
+ sqlConfig?: SqlConfigInput;
48
+ /** 自定义 SQL 执行器,传入后优先于内置的 sqlite / http 模式 */
49
+ sqlExecutor?: SqlExecutor;
50
+ /** 是否在工具栏显示 SQL 连接配置入口(仅 SQL 文件可见) */
51
+ showSqlConfig?: boolean;
52
+ /** 锁定服务端点:隐藏端点输入框,由宿主通过 sqlConfig.endpoint 预置 */
53
+ sqlEndpointLocked?: boolean;
54
+ /** 服务端文件接口地址(如 http://localhost:8090/api/files),为空时隐藏保存与查询入口 */
55
+ filesEndpoint?: string;
56
+ /** 服务端文件接口附加请求头,例如 X-SQL-Token 鉴权 */
57
+ filesHeaders?: Record<string, string>;
58
+ /** 服务端 Python 执行端点(如 http://localhost:8090/api/python),为空时只能使用浏览器环境 */
59
+ pythonEndpoint?: string;
60
+ /** 服务端 Python 接口附加请求头,例如 X-SQL-Token 鉴权 */
61
+ pythonHeaders?: Record<string, string>;
62
+ /** Python 运行环境,支持 v-model:runtime */
63
+ runtime?: PythonRuntime;
38
64
  }
65
+ /** 清除本地草稿(不影响当前编辑内容) */
66
+ declare function clearPersistedState(): void;
39
67
  /** 读取当前编辑器内容 */
40
68
  declare function getCode(): string;
41
69
  /** 替换编辑器内容(保留撤销历史) */
42
70
  declare function setCode(code: string): void;
71
+ declare function openSqlConfig(): void;
72
+ declare function closeSqlConfig(): void;
73
+ /** 执行指定 SQL;不传参数时执行当前文件内容(会切换当前文件为 SQL) */
74
+ declare function executeSql(sql?: string): Promise<SqlQueryResult | null>;
43
75
  /** 运行当前编辑器中的代码 */
44
76
  declare function run(): void;
45
- /** 中断当前执行(Pyodide 限制:通过终止并重建 Worker 实现) */
77
+ /** 中断当前文件的执行 */
46
78
  declare function stop(): void;
47
79
  /** 清空输出面板 */
48
80
  declare function clearOutput(): void;
@@ -50,7 +82,7 @@ declare function clearOutput(): void;
50
82
  declare function newFile(): void;
51
83
  /** 切换 Tab */
52
84
  declare function switchFile(id: number): void;
53
- /** 关闭 Tab(始终保留至少一个文件) */
85
+ /** 关闭 Tab;关闭最后一个文件时自动补一个空白文件 */
54
86
  declare function closeFile(id: number): void;
55
87
  /** 清空当前文件内容(保留输出面板) */
56
88
  declare function clearCode(): void;
@@ -58,6 +90,18 @@ declare function clearCode(): void;
58
90
  declare function copyCode(): Promise<boolean>;
59
91
  /** 下载当前文件 */
60
92
  declare function download(): string;
93
+ /** 下载虚拟文件系统中的文本文件,返回下载文件名 */
94
+ declare function downloadFile(path: string): Promise<string | null>;
95
+ /** 写入虚拟文件系统(供宿主预置数据文件) */
96
+ declare function writeFile(path: string, content: string): Promise<import('./types').FsWriteResult>;
97
+ /** 读取虚拟文件系统中的文本文件 */
98
+ declare function readFile(path: string): Promise<import('./types').FsReadResult>;
99
+ /** 列出虚拟文件系统目录 */
100
+ declare function listFiles(path?: string): Promise<import('./types').FsListResult>;
101
+ /** 查询服务端已保存文件列表 */
102
+ declare function refreshServerFiles(): Promise<void>;
103
+ /** 保存当前文件到服务端(同名覆盖) */
104
+ declare function saveToServer(): Promise<ServerFile | null>;
61
105
  /** 打开本地文件选择框 */
62
106
  declare function openFile(): void;
63
107
  /** 聚焦编辑器 */
@@ -73,6 +117,8 @@ declare function install(packages: string[]): Promise<import('./types').InstallR
73
117
  }>;
74
118
  /** 语法检查(运行器未就绪时返回 null) */
75
119
  declare function checkSyntax(): Promise<import('./types').SyntaxIssue | null>;
120
+ /** 获取当前 SQL 配置(归一化后的完整配置) */
121
+ declare function getSqlConfig(): SqlConfig;
76
122
  declare function getEditorView(): EditorView | null;
77
123
  /** 获取全部 Tab 文件快照 */
78
124
  declare function getFiles(): EditorFile[];
@@ -92,11 +138,22 @@ declare const _default: import('vue').DefineComponent<Props, {
92
138
  focus: typeof focus;
93
139
  install: typeof install;
94
140
  checkSyntax: typeof checkSyntax;
141
+ executeSql: typeof executeSql;
142
+ getSqlConfig: typeof getSqlConfig;
143
+ openSqlConfig: typeof openSqlConfig;
144
+ closeSqlConfig: typeof closeSqlConfig;
95
145
  getEditorView: typeof getEditorView;
96
146
  getCode: typeof getCode;
97
147
  setCode: typeof setCode;
98
148
  getFiles: typeof getFiles;
99
149
  getActiveFile: typeof getActiveFile;
150
+ writeFile: typeof writeFile;
151
+ readFile: typeof readFile;
152
+ listFiles: typeof listFiles;
153
+ downloadFile: typeof downloadFile;
154
+ saveToServer: typeof saveToServer;
155
+ refreshServerFiles: typeof refreshServerFiles;
156
+ clearPersistedState: typeof clearPersistedState;
100
157
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
101
158
  [x: string]: any;
102
159
  } & {
@@ -105,6 +162,7 @@ declare const _default: import('vue').DefineComponent<Props, {
105
162
  [x: `on${Capitalize<any>}`]: ((...args: any) => any) | undefined;
106
163
  }>, {
107
164
  height: number | string;
165
+ stdin: string;
108
166
  pyodideUrl: string;
109
167
  modelValue: string;
110
168
  theme: "light" | "dark";
@@ -121,10 +179,24 @@ declare const _default: import('vue').DefineComponent<Props, {
121
179
  preload: boolean;
122
180
  fileName: string;
123
181
  language: EditorLanguage;
182
+ syncFilesOnRun: boolean;
183
+ storageKey: string;
184
+ preloadPackages: string[];
185
+ sqlConfig: SqlConfigInput;
186
+ sqlExecutor: SqlExecutor;
187
+ showSqlConfig: boolean;
188
+ sqlEndpointLocked: boolean;
189
+ filesEndpoint: string;
190
+ filesHeaders: Record<string, string>;
191
+ pythonEndpoint: string;
192
+ pythonHeaders: Record<string, string>;
193
+ runtime: PythonRuntime;
124
194
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
195
+ rootEl: HTMLDivElement;
125
196
  tabsEl: HTMLDivElement;
126
197
  fileInputEl: HTMLInputElement;
127
198
  editorEl: HTMLDivElement;
199
+ outputPanelEl: HTMLDivElement;
128
200
  outputEl: HTMLPreElement;
129
201
  }, HTMLDivElement>;
130
202
  export default _default;
package/dist/icons.d.ts CHANGED
@@ -21,3 +21,9 @@ export declare const IconCheck: FunctionalComponent<{}, {}, any, {}>;
21
21
  export declare const IconClose: FunctionalComponent<{}, {}, any, {}>;
22
22
  /** 加号(新建 Tab) */
23
23
  export declare const IconPlus: FunctionalComponent<{}, {}, any, {}>;
24
+ /** 数据库(圆柱) */
25
+ export declare const IconDatabase: FunctionalComponent<{}, {}, any, {}>;
26
+ /** 保存(软盘) */
27
+ export declare const IconSave: FunctionalComponent<{}, {}, any, {}>;
28
+ /** 服务端文件(两层机架) */
29
+ export declare const IconServer: FunctionalComponent<{}, {}, any, {}>;