@desktalk/miniapp-text-edit 0.1.0-alpha.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DeskTalk contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,5 @@
1
+ import type { MiniAppManifest, MiniAppContext, MiniAppBackendActivation } from '@desktalk/sdk';
2
+ export declare const manifest: MiniAppManifest;
3
+ export declare function activate(ctx: MiniAppContext): MiniAppBackendActivation;
4
+ export declare function deactivate(): void;
5
+ //# sourceMappingURL=backend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAK/F,eAAO,MAAM,QAAQ,EAAE,eAoDtB,CAAC;AA4BF,wBAAgB,QAAQ,CAAC,GAAG,EAAE,cAAc,GAAG,wBAAwB,CAsDtE;AAED,wBAAgB,UAAU,IAAI,IAAI,CAEjC"}
@@ -0,0 +1,111 @@
1
+ // src/backend.ts
2
+ var manifest = {
3
+ id: "text-edit",
4
+ name: "TextEdit",
5
+ icon: "\u{1F4DD}",
6
+ version: "0.1.0",
7
+ description: "Code and text editor powered by Monaco Editor",
8
+ fileAssociations: {
9
+ extensions: [
10
+ ".md",
11
+ ".markdown",
12
+ ".txt",
13
+ ".log",
14
+ ".json",
15
+ ".jsonc",
16
+ ".ts",
17
+ ".tsx",
18
+ ".js",
19
+ ".jsx",
20
+ ".mjs",
21
+ ".cjs",
22
+ ".py",
23
+ ".html",
24
+ ".htm",
25
+ ".css",
26
+ ".scss",
27
+ ".sass",
28
+ ".yaml",
29
+ ".yml",
30
+ ".toml",
31
+ ".sh",
32
+ ".bash",
33
+ ".zsh",
34
+ ".xml",
35
+ ".svg",
36
+ ".sql",
37
+ ".rs",
38
+ ".go",
39
+ ".java",
40
+ ".c",
41
+ ".h",
42
+ ".cpp",
43
+ ".hpp",
44
+ ".cc",
45
+ ".rb",
46
+ ".csv",
47
+ ".ini",
48
+ ".cfg",
49
+ ".env",
50
+ ".gitignore",
51
+ ".editorconfig"
52
+ ]
53
+ }
54
+ };
55
+ var MAX_FILE_SIZE = 5 * 1024 * 1024;
56
+ var BINARY_CHECK_SIZE = 8192;
57
+ function fileName(path) {
58
+ const idx = path.lastIndexOf("/");
59
+ return idx >= 0 ? path.slice(idx + 1) : path;
60
+ }
61
+ function isBinaryContent(content) {
62
+ const sample = content.substring(0, BINARY_CHECK_SIZE);
63
+ return sample.includes("\0");
64
+ }
65
+ function activate(ctx) {
66
+ ctx.logger.info("TextEdit MiniApp activated");
67
+ ctx.messaging.onCommand("textedit.open", async (req) => {
68
+ const path = req.path;
69
+ const stat = await ctx.fs.stat(path);
70
+ if (stat.type !== "file") {
71
+ throw new Error(`Not a file: ${path}`);
72
+ }
73
+ if (stat.size > MAX_FILE_SIZE) {
74
+ throw new Error(
75
+ `File too large (${(stat.size / 1024 / 1024).toFixed(1)} MB). Maximum size is ${MAX_FILE_SIZE / 1024 / 1024} MB.`
76
+ );
77
+ }
78
+ const content = await ctx.fs.readFile(path);
79
+ if (isBinaryContent(content)) {
80
+ throw new Error("Binary file detected. TextEdit only supports UTF-8 text files.");
81
+ }
82
+ return {
83
+ path,
84
+ name: fileName(path),
85
+ content,
86
+ size: stat.size,
87
+ modifiedAt: stat.modifiedAt
88
+ };
89
+ });
90
+ ctx.messaging.onCommand(
91
+ "textedit.save",
92
+ async (req) => {
93
+ await ctx.fs.writeFile(req.path, req.content);
94
+ const stat = await ctx.fs.stat(req.path);
95
+ ctx.logger.info(`Saved file: ${req.path}`);
96
+ return {
97
+ success: true,
98
+ updatedAt: stat.modifiedAt
99
+ };
100
+ }
101
+ );
102
+ return {};
103
+ }
104
+ function deactivate() {
105
+ }
106
+ export {
107
+ activate,
108
+ deactivate,
109
+ manifest
110
+ };
111
+ //# sourceMappingURL=backend.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/backend.ts"],
4
+ "sourcesContent": ["import type { MiniAppManifest, MiniAppContext, MiniAppBackendActivation } from '@desktalk/sdk';\nimport type { TextEditFile, SaveResult } from './types';\n\n// \u2500\u2500\u2500 Manifest \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const manifest: MiniAppManifest = {\n id: 'text-edit',\n name: 'TextEdit',\n icon: '\\u{1F4DD}',\n version: '0.1.0',\n description: 'Code and text editor powered by Monaco Editor',\n fileAssociations: {\n extensions: [\n '.md',\n '.markdown',\n '.txt',\n '.log',\n '.json',\n '.jsonc',\n '.ts',\n '.tsx',\n '.js',\n '.jsx',\n '.mjs',\n '.cjs',\n '.py',\n '.html',\n '.htm',\n '.css',\n '.scss',\n '.sass',\n '.yaml',\n '.yml',\n '.toml',\n '.sh',\n '.bash',\n '.zsh',\n '.xml',\n '.svg',\n '.sql',\n '.rs',\n '.go',\n '.java',\n '.c',\n '.h',\n '.cpp',\n '.hpp',\n '.cc',\n '.rb',\n '.csv',\n '.ini',\n '.cfg',\n '.env',\n '.gitignore',\n '.editorconfig',\n ],\n },\n};\n\n// \u2500\u2500\u2500 Constants \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** Maximum file size in bytes (5 MB). */\nconst MAX_FILE_SIZE = 5 * 1024 * 1024;\n\n/** Number of bytes to sample for binary detection. */\nconst BINARY_CHECK_SIZE = 8192;\n\n// \u2500\u2500\u2500 Helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction fileName(path: string): string {\n const idx = path.lastIndexOf('/');\n return idx >= 0 ? path.slice(idx + 1) : path;\n}\n\n/**\n * Detect binary content by checking for null bytes in the first chunk.\n * A null byte (0x00) in the first 8 KB strongly indicates a binary file.\n */\nfunction isBinaryContent(content: string): boolean {\n const sample = content.substring(0, BINARY_CHECK_SIZE);\n return sample.includes('\\0');\n}\n\n// \u2500\u2500\u2500 Activate \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport function activate(ctx: MiniAppContext): MiniAppBackendActivation {\n ctx.logger.info('TextEdit MiniApp activated');\n\n // \u2500\u2500\u2500 textedit.open \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n ctx.messaging.onCommand<{ path: string }, TextEditFile>('textedit.open', async (req) => {\n const path = req.path;\n\n // Check file exists and get stat\n const stat = await ctx.fs.stat(path);\n\n if (stat.type !== 'file') {\n throw new Error(`Not a file: ${path}`);\n }\n\n if (stat.size > MAX_FILE_SIZE) {\n throw new Error(\n `File too large (${(stat.size / 1024 / 1024).toFixed(1)} MB). Maximum size is ${MAX_FILE_SIZE / 1024 / 1024} MB.`,\n );\n }\n\n const content = await ctx.fs.readFile(path);\n\n // Binary detection\n if (isBinaryContent(content)) {\n throw new Error('Binary file detected. TextEdit only supports UTF-8 text files.');\n }\n\n return {\n path,\n name: fileName(path),\n content,\n size: stat.size,\n modifiedAt: stat.modifiedAt,\n };\n });\n\n // \u2500\u2500\u2500 textedit.save \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n ctx.messaging.onCommand<{ path: string; content: string }, SaveResult>(\n 'textedit.save',\n async (req) => {\n await ctx.fs.writeFile(req.path, req.content);\n const stat = await ctx.fs.stat(req.path);\n\n ctx.logger.info(`Saved file: ${req.path}`);\n return {\n success: true,\n updatedAt: stat.modifiedAt,\n };\n },\n );\n\n return {};\n}\n\nexport function deactivate(): void {\n // cleanup\n}\n"],
5
+ "mappings": ";AAKO,IAAM,WAA4B;AAAA,EACvC,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAAA,EACT,aAAa;AAAA,EACb,kBAAkB;AAAA,IAChB,YAAY;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;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AAK,IAAI,IAAI;AAEvC,UAAI,OAAO,KAAK,eAAe,IAAI,IAAI,EAAE;AACzC,aAAO;AAAA,QACL,SAAS;AAAA,QACT,WAAW,KAAK;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AAEA,SAAO,CAAC;AACV;AAEO,SAAS,aAAmB;AAEnC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,10 @@
1
+ interface EditorStatusBarProps {
2
+ cursorLine: number;
3
+ cursorColumn: number;
4
+ language: string;
5
+ lineEnding: 'LF' | 'CRLF';
6
+ totalLines: number;
7
+ }
8
+ export declare function EditorStatusBar({ cursorLine, cursorColumn, language, lineEnding, totalLines, }: EditorStatusBarProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
10
+ //# sourceMappingURL=EditorStatusBar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditorStatusBar.d.ts","sourceRoot":"","sources":["../../src/components/EditorStatusBar.tsx"],"names":[],"mappings":"AAGA,UAAU,oBAAoB;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,IAAI,GAAG,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,EAC9B,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,UAAU,GACX,EAAE,oBAAoB,2CAYtB"}
@@ -0,0 +1,9 @@
1
+ interface EditorTitleBarProps {
2
+ filename: string | null;
3
+ isDirty: boolean;
4
+ saveStatus: 'idle' | 'saving' | 'saved';
5
+ onSave: () => void;
6
+ }
7
+ export declare function EditorTitleBar({ filename, isDirty, saveStatus, onSave }: EditorTitleBarProps): import("react/jsx-runtime").JSX.Element | null;
8
+ export {};
9
+ //# sourceMappingURL=EditorTitleBar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditorTitleBar.d.ts","sourceRoot":"","sources":["../../src/components/EditorTitleBar.tsx"],"names":[],"mappings":"AAGA,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IACxC,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,mBAAmB,kDAyB5F"}
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import type { TextEditFile } from '../types';
3
+ /** Handle exposed by TextEditApp for reading/writing editor state. */
4
+ export interface TextEditHandle {
5
+ getContent(): string | null;
6
+ setContent(content: string): void;
7
+ getCursorLine(): number;
8
+ getCursorColumn(): number;
9
+ getSelectedText(): string;
10
+ getTotalLines(): number;
11
+ getLanguage(): string;
12
+ getFilePath(): string | null;
13
+ isDirty(): boolean;
14
+ }
15
+ interface TextEditActionsProps {
16
+ children: React.ReactNode;
17
+ editorHandle: TextEditHandle | null;
18
+ currentFilePath: string | null;
19
+ onFileOpened: (file: TextEditFile) => void;
20
+ onSave: () => void;
21
+ }
22
+ export declare function TextEditActions({ children, editorHandle, currentFilePath, onFileOpened, onSave, }: TextEditActionsProps): import("react/jsx-runtime").JSX.Element;
23
+ export {};
24
+ //# sourceMappingURL=TextEditActions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextEditActions.d.ts","sourceRoot":"","sources":["../../src/components/TextEditActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAE3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AA+C7C,sEAAsE;AACtE,MAAM,WAAW,cAAc;IAC7B,UAAU,IAAI,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,aAAa,IAAI,MAAM,CAAC;IACxB,eAAe,IAAI,MAAM,CAAC;IAC1B,eAAe,IAAI,MAAM,CAAC;IAC1B,aAAa,IAAI,MAAM,CAAC;IACxB,WAAW,IAAI,MAAM,CAAC;IACtB,WAAW,IAAI,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,IAAI,OAAO,CAAC;CACpB;AAED,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,EAAE,cAAc,GAAG,IAAI,CAAC;IACpC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,YAAY,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;IAC3C,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,MAAM,GACP,EAAE,oBAAoB,2CA+JtB"}
@@ -0,0 +1,4 @@
1
+ import type { MiniAppFrontendContext } from '@desktalk/sdk';
2
+ export declare function activate(ctx: MiniAppFrontendContext): void;
3
+ export declare function deactivate(): void;
4
+ //# sourceMappingURL=frontend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontend.d.ts","sourceRoot":"","sources":["../src/frontend.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAoV5D,wBAAgB,QAAQ,CAAC,GAAG,EAAE,sBAAsB,GAAG,IAAI,CAU1D;AAED,wBAAgB,UAAU,IAAI,IAAI,CAGjC"}