@postnzt/docx-js-editor 0.0.33

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.
Files changed (117) hide show
  1. package/dist/ClipboardManager-C0rTRkVQ.d.ts +464 -0
  2. package/dist/ClipboardManager-CgpKW2At.d.mts +464 -0
  3. package/dist/DocumentAgent-BqA9EJ3F.d.mts +442 -0
  4. package/dist/DocumentAgent-CRCXiBT7.d.ts +442 -0
  5. package/dist/FindReplaceDialog-KNJETYJX.js +1 -0
  6. package/dist/FindReplaceDialog-YW3R4FHM.mjs +1 -0
  7. package/dist/FootnotePropertiesDialog-452A4UT5.js +1 -0
  8. package/dist/FootnotePropertiesDialog-H24AC5XK.mjs +1 -0
  9. package/dist/HyperlinkDialog-GBAYMTUE.js +1 -0
  10. package/dist/HyperlinkDialog-HNYTXDCB.mjs +1 -0
  11. package/dist/ImagePositionDialog-B4RLP2W5.mjs +1 -0
  12. package/dist/ImagePositionDialog-M65BYQQE.js +1 -0
  13. package/dist/ImagePropertiesDialog-JOGW3WDU.mjs +1 -0
  14. package/dist/ImagePropertiesDialog-O4WQSF5M.js +1 -0
  15. package/dist/PageSetupDialog-2GIBTKMJ.js +1 -0
  16. package/dist/PageSetupDialog-Q7SHEZIJ.mjs +1 -0
  17. package/dist/TablePropertiesDialog-LMXWX3FI.mjs +1 -0
  18. package/dist/TablePropertiesDialog-WOZ4ES3H.js +1 -0
  19. package/dist/agentApi-BVHzyk2l.d.mts +2239 -0
  20. package/dist/agentApi-BVHzyk2l.d.ts +2239 -0
  21. package/dist/chunk-2HDYCD2Q.mjs +1 -0
  22. package/dist/chunk-377ZVTSE.js +2 -0
  23. package/dist/chunk-37SLIJPH.mjs +58 -0
  24. package/dist/chunk-4VUZBV2S.js +1 -0
  25. package/dist/chunk-6WPRCJ5A.mjs +1 -0
  26. package/dist/chunk-7MGFEP2R.mjs +26 -0
  27. package/dist/chunk-7QTNB64A.mjs +9 -0
  28. package/dist/chunk-AARNCPWR.js +1 -0
  29. package/dist/chunk-AU5NVRHP.js +2 -0
  30. package/dist/chunk-BP3V2HDD.js +261 -0
  31. package/dist/chunk-BUEMG4NW.js +1 -0
  32. package/dist/chunk-DC65PJYE.js +4 -0
  33. package/dist/chunk-DLVLK5FT.mjs +24 -0
  34. package/dist/chunk-EV3CM6TU.js +1 -0
  35. package/dist/chunk-FVUGBRDD.js +1 -0
  36. package/dist/chunk-GZOCOWWB.mjs +2 -0
  37. package/dist/chunk-H5NTJZO4.js +1 -0
  38. package/dist/chunk-IFPN3NT3.js +3 -0
  39. package/dist/chunk-KCOGY3V2.js +10 -0
  40. package/dist/chunk-KUL2SDYC.js +26 -0
  41. package/dist/chunk-LFZXSNOF.mjs +261 -0
  42. package/dist/chunk-LYBG4YI7.mjs +1 -0
  43. package/dist/chunk-M5F4SK3W.mjs +1 -0
  44. package/dist/chunk-P7WEP4JU.js +9 -0
  45. package/dist/chunk-PB7VMDDP.js +24 -0
  46. package/dist/chunk-QAZ4233N.mjs +1 -0
  47. package/dist/chunk-QSUPYUOP.js +2 -0
  48. package/dist/chunk-QTSXJRP6.mjs +1 -0
  49. package/dist/chunk-QVPR2W5S.js +1 -0
  50. package/dist/chunk-RTFUE3KK.mjs +10 -0
  51. package/dist/chunk-SCYTWBF5.mjs +111 -0
  52. package/dist/chunk-SE5EN2QL.js +1 -0
  53. package/dist/chunk-T6X4C2QO.js +111 -0
  54. package/dist/chunk-TAUMSKRE.mjs +1 -0
  55. package/dist/chunk-W53SI3XW.mjs +1 -0
  56. package/dist/chunk-WOHFANC5.mjs +3 -0
  57. package/dist/chunk-X5A54T6S.mjs +4 -0
  58. package/dist/chunk-YKBSKEBS.mjs +2 -0
  59. package/dist/chunk-Z26WOH6R.mjs +2 -0
  60. package/dist/chunk-ZJNGMDRE.js +58 -0
  61. package/dist/clipboard-Cu80iVDh.d.ts +1181 -0
  62. package/dist/clipboard-dFROLI95.d.mts +1181 -0
  63. package/dist/colorResolver-BwI_Uxp3.d.mts +662 -0
  64. package/dist/colorResolver-Dlmk3itT.d.ts +662 -0
  65. package/dist/core-plugins-reexport.d.mts +31 -0
  66. package/dist/core-plugins-reexport.d.ts +31 -0
  67. package/dist/core-plugins-reexport.js +1 -0
  68. package/dist/core-plugins-reexport.mjs +1 -0
  69. package/dist/core-reexport.d.mts +309 -0
  70. package/dist/core-reexport.d.ts +309 -0
  71. package/dist/core-reexport.js +1 -0
  72. package/dist/core-reexport.mjs +1 -0
  73. package/dist/executor-L2MVKMXO.js +1 -0
  74. package/dist/executor-XKBCCVNY.mjs +1 -0
  75. package/dist/fontLoader-BI9ZoACv.d.ts +176 -0
  76. package/dist/fontLoader-DicgJidU.d.mts +176 -0
  77. package/dist/headless-reexport.d.mts +195 -0
  78. package/dist/headless-reexport.d.ts +195 -0
  79. package/dist/headless-reexport.js +4 -0
  80. package/dist/headless-reexport.mjs +4 -0
  81. package/dist/index.css +1 -0
  82. package/dist/index.d.mts +480 -0
  83. package/dist/index.d.ts +480 -0
  84. package/dist/index.js +112 -0
  85. package/dist/index.mjs +112 -0
  86. package/dist/lib-BCT2DRYI.mjs +1 -0
  87. package/dist/lib-U35UU4OU.js +1 -0
  88. package/dist/mcp-reexport.d.mts +156 -0
  89. package/dist/mcp-reexport.d.ts +156 -0
  90. package/dist/mcp-reexport.js +16 -0
  91. package/dist/mcp-reexport.mjs +16 -0
  92. package/dist/processTemplate-5ZST2Q5L.js +1 -0
  93. package/dist/processTemplate-LRHXOWMZ.mjs +1 -0
  94. package/dist/react-Cl2n0F5S.d.ts +1091 -0
  95. package/dist/react-DZlAKNXg.d.mts +1091 -0
  96. package/dist/react.css +1 -0
  97. package/dist/react.d.mts +10 -0
  98. package/dist/react.d.ts +10 -0
  99. package/dist/react.js +1 -0
  100. package/dist/react.mjs +1 -0
  101. package/dist/registry-D4FQ9aKX.d.mts +165 -0
  102. package/dist/registry-DrYyUXQr.d.ts +165 -0
  103. package/dist/selectionRects-DEX5THEG.js +1 -0
  104. package/dist/selectionRects-SQTAHMCH.mjs +1 -0
  105. package/dist/styles.css +1 -0
  106. package/dist/types-B3LkfO0u.d.mts +310 -0
  107. package/dist/types-igZ1x_e4.d.ts +310 -0
  108. package/dist/ui.d.mts +2005 -0
  109. package/dist/ui.d.ts +2005 -0
  110. package/dist/ui.js +1 -0
  111. package/dist/ui.mjs +1 -0
  112. package/dist/variableDetector-CIqTek7A.d.mts +204 -0
  113. package/dist/variableDetector-CkYvLv62.d.ts +204 -0
  114. package/i18n/de.json +745 -0
  115. package/i18n/en.json +745 -0
  116. package/i18n/pl.json +745 -0
  117. package/package.json +127 -0
@@ -0,0 +1,156 @@
1
+ import { M as McpToolDefinition, e as McpSession, J as JsonSchema } from './types-igZ1x_e4.js';
2
+ import './agentApi-BVHzyk2l.js';
3
+
4
+ /**
5
+ * Core MCP Tools
6
+ *
7
+ * Built-in MCP tools for document operations that are always available.
8
+ * These provide basic document manipulation without requiring plugins.
9
+ */
10
+
11
+ /**
12
+ * Load a DOCX document from base64
13
+ */
14
+ declare const loadDocumentTool: McpToolDefinition;
15
+ /**
16
+ * Save a document to base64
17
+ */
18
+ declare const saveDocumentTool: McpToolDefinition;
19
+ /**
20
+ * Close a document
21
+ */
22
+ declare const closeDocumentTool: McpToolDefinition;
23
+ /**
24
+ * Get document information
25
+ */
26
+ declare const getDocumentInfoTool: McpToolDefinition;
27
+ /**
28
+ * Get document plain text
29
+ */
30
+ declare const getDocumentTextTool: McpToolDefinition;
31
+ /**
32
+ * Insert text at a position
33
+ */
34
+ declare const insertTextTool: McpToolDefinition;
35
+ /**
36
+ * Replace text in a range
37
+ */
38
+ declare const replaceTextTool: McpToolDefinition;
39
+ /**
40
+ * Delete text in a range
41
+ */
42
+ declare const deleteTextTool: McpToolDefinition;
43
+ /**
44
+ * Apply text formatting
45
+ */
46
+ declare const formatTextTool: McpToolDefinition;
47
+ /**
48
+ * Apply paragraph style
49
+ */
50
+ declare const applyStyleTool: McpToolDefinition;
51
+ declare const coreMcpTools: McpToolDefinition[];
52
+
53
+ /**
54
+ * MCP Server
55
+ *
56
+ * Model Context Protocol server that exposes document editing tools to AI clients.
57
+ * Discovers and registers tools from the plugin system plus core built-in tools.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * import { createMcpServer, startStdioServer } from '@postnzt/docx-editor/mcp';
62
+ * import { pluginRegistry, docxtemplaterPlugin } from '@postnzt/docx-editor/core-plugins';
63
+ *
64
+ * // Register plugins
65
+ * pluginRegistry.register(docxtemplaterPlugin);
66
+ *
67
+ * // Start MCP server
68
+ * startStdioServer();
69
+ * ```
70
+ */
71
+
72
+ /**
73
+ * MCP Server configuration
74
+ */
75
+ interface McpServerConfig {
76
+ /** Server name */
77
+ name?: string;
78
+ /** Server version */
79
+ version?: string;
80
+ /** Include core tools (default: true) */
81
+ includeCoreTools?: boolean;
82
+ /** Enable debug logging */
83
+ debug?: boolean;
84
+ /** Custom tools to add */
85
+ additionalTools?: McpToolDefinition[];
86
+ }
87
+ /**
88
+ * MCP Server instance
89
+ */
90
+ interface McpServer {
91
+ /** All registered tools */
92
+ tools: Map<string, McpToolDefinition>;
93
+ /** Active session */
94
+ session: McpSession;
95
+ /** Handle a tool call */
96
+ handleToolCall(toolName: string, input: unknown): Promise<unknown>;
97
+ /** List available tools */
98
+ listTools(): McpToolInfo[];
99
+ /** Get server info */
100
+ getInfo(): {
101
+ name: string;
102
+ version: string;
103
+ toolCount: number;
104
+ };
105
+ }
106
+ /**
107
+ * Tool info for listing
108
+ */
109
+ interface McpToolInfo {
110
+ name: string;
111
+ description: string;
112
+ inputSchema: JsonSchema;
113
+ category?: string;
114
+ }
115
+ /**
116
+ * Create an MCP server instance
117
+ *
118
+ * @param config - Server configuration
119
+ * @returns MCP server instance
120
+ */
121
+ declare function createMcpServer(config?: McpServerConfig): McpServer;
122
+ /**
123
+ * JSON-RPC request
124
+ */
125
+ interface JsonRpcRequest {
126
+ jsonrpc: '2.0';
127
+ id: string | number;
128
+ method: string;
129
+ params?: unknown;
130
+ }
131
+ /**
132
+ * JSON-RPC response
133
+ */
134
+ interface JsonRpcResponse {
135
+ jsonrpc: '2.0';
136
+ id: string | number;
137
+ result?: unknown;
138
+ error?: {
139
+ code: number;
140
+ message: string;
141
+ data?: unknown;
142
+ };
143
+ }
144
+ /**
145
+ * Handle a JSON-RPC request
146
+ */
147
+ declare function handleJsonRpcRequest(server: McpServer, request: JsonRpcRequest): Promise<JsonRpcResponse>;
148
+ /**
149
+ * Start the MCP server with stdio transport
150
+ *
151
+ * Reads JSON-RPC requests from stdin, writes responses to stdout.
152
+ * This is the standard way to run an MCP server for Claude Desktop.
153
+ */
154
+ declare function startStdioServer(config?: McpServerConfig): Promise<void>;
155
+
156
+ export { type McpServer, type McpServerConfig, type McpToolInfo, applyStyleTool, closeDocumentTool, coreMcpTools, createMcpServer, deleteTextTool, formatTextTool, getDocumentInfoTool, getDocumentTextTool, handleJsonRpcRequest, insertTextTool, loadDocumentTool, replaceTextTool, saveDocumentTool, startStdioServer };
@@ -0,0 +1,16 @@
1
+ 'use strict';var chunkZJNGMDRE_js=require('./chunk-ZJNGMDRE.js'),chunkAARNCPWR_js=require('./chunk-AARNCPWR.js'),chunkKUL2SDYC_js=require('./chunk-KUL2SDYC.js'),chunkBUEMG4NW_js=require('./chunk-BUEMG4NW.js');require('./chunk-SE5EN2QL.js'),require('./chunk-IFPN3NT3.js'),require('./chunk-H5NTJZO4.js');var u={type:"string",description:"Document ID returned from docx_load"},x={type:"object",properties:{paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},offset:{type:"number",description:"Character offset within the paragraph",minimum:0}},required:["paragraphIndex","offset"]},h={type:"object",properties:{start:x,end:x},required:["start","end"]},D={name:"docx_load",description:`Load a DOCX document from base64-encoded content.
2
+ Returns a document ID that can be used with other tools.
3
+ The document remains in session memory until closed.`,inputSchema:{type:"object",properties:{content:{type:"string",description:"Base64-encoded DOCX file content"},source:{type:"string",description:"Optional source filename or identifier for reference"}},required:["content"]},handler:async(r,s)=>{let{content:e,source:c}=r;try{let t=atob(e),n=new Uint8Array(t.length);for(let l=0;l<t.length;l++)n[l]=t.charCodeAt(l);let o=n.buffer,a=await chunkKUL2SDYC_js.n(o),d=`doc_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;s.session.documents.set(d,{id:d,document:a,buffer:o,source:c,lastModified:Date.now()});let p=a.package.document.content.filter(l=>l.type==="paragraph").length;return {content:[{type:"text",text:JSON.stringify({documentId:d,source:c,paragraphCount:p,message:"Document loaded successfully"})}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to load document: ${t.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},C={name:"docx_save",description:`Export the document to base64-encoded DOCX format.
4
+ Returns the document as a base64 string that can be saved to a file.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r,c=s.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let t;c.buffer?t=await chunkZJNGMDRE_js.i(c.document):t=await chunkZJNGMDRE_js.r(c.document);let n=new Uint8Array(t),o="";for(let d=0;d<n.length;d++)o+=String.fromCharCode(n[d]);let a=btoa(o);return {content:[{type:"text",text:JSON.stringify({documentId:e,base64:a,size:t.byteLength,message:"Document exported successfully"})}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to save document: ${t.message}`}]}}},annotations:{category:"core",readOnly:true,complexity:"low"}},R={name:"docx_close",description:`Close a document and free its memory.
5
+ Use this when done working with a document.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r;return s.session.documents.has(e)?(s.session.documents.delete(e),{content:[{type:"text",text:JSON.stringify({documentId:e,message:"Document closed"})}]}):{isError:true,content:[{type:"text",text:`Document not found: ${e}`}]}},annotations:{category:"core",readOnly:false,complexity:"low"}},k={name:"docx_get_info",description:`Get metadata and statistics about a document.
6
+ Returns paragraph count, word count, table count, and other useful info.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r,c=s.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};let t=c.document,n=t.package.document,o=n.content.filter(p=>p.type==="paragraph"),a=n.content.filter(p=>p.type==="table"),d=0;for(let p of o)if(p.type==="paragraph"){let l=P(p);d+=l.split(/\s+/).filter(y=>y.length>0).length;}return {content:[{type:"text",text:JSON.stringify({documentId:e,paragraphCount:o.length,tableCount:a.length,wordCount:d,hasStyles:!!t.package.styles,hasTheme:!!t.package.theme,source:c.source,lastModified:c.lastModified})}]}},annotations:{category:"core",readOnly:true,complexity:"low"}},$={name:"docx_get_text",description:`Get the plain text content of the document.
7
+ Returns all text concatenated with paragraph breaks.
8
+ Useful for understanding document content before making edits.`,inputSchema:{type:"object",properties:{documentId:u,maxLength:{type:"number",description:"Maximum characters to return (default: 10000)",default:1e4}},required:["documentId"]},handler:async(r,s)=>{let{documentId:e,maxLength:c=1e4}=r,t=s.session.documents.get(e);if(!t)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};let n=t.document.package.document,o=[];for(let p of n.content)p.type==="paragraph"?o.push(P(p)):p.type==="table"&&o.push("[TABLE]");let a=o.join(`
9
+ `),d=a.length>c;return d&&(a=a.slice(0,c)+"..."),{content:[{type:"text",text:JSON.stringify({documentId:e,text:a,truncated:d,totalLength:d?o.join(`
10
+ `).length:a.length})}]}},annotations:{category:"core",readOnly:true,complexity:"low"}},J={name:"docx_insert_text",description:`Insert text at a specific position in the document.
11
+ Position is specified by paragraph index (0-indexed) and character offset.`,inputSchema:{type:"object",properties:{documentId:u,position:x,text:{type:"string",description:"Text to insert"}},required:["documentId","position","text"]},handler:async(r,s)=>{let{documentId:e,position:c,text:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=chunkAARNCPWR_js.a(n.document,{type:"insertText",position:c,text:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,insertedLength:t.length,position:c})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to insert text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},v={name:"docx_replace_text",description:`Replace text in a range with new text.
12
+ Specify start and end positions to define the range to replace.`,inputSchema:{type:"object",properties:{documentId:u,range:h,text:{type:"string",description:"Replacement text"}},required:["documentId","range","text"]},handler:async(r,s)=>{let{documentId:e,range:c,text:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=chunkAARNCPWR_js.a(n.document,{type:"replaceText",range:c,text:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedRange:c,newTextLength:t.length})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to replace text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},j={name:"docx_delete_text",description:`Delete text in a range.
13
+ Specify start and end positions to define the range to delete.`,inputSchema:{type:"object",properties:{documentId:u,range:h},required:["documentId","range"]},handler:async(r,s)=>{let{documentId:e,range:c}=r,t=s.session.documents.get(e);if(!t)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let n=chunkAARNCPWR_js.a(t.document,{type:"deleteText",range:c});return t.document=n,t.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,deletedRange:c})}]}}catch(n){return {isError:true,content:[{type:"text",text:`Failed to delete text: ${n.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},E={name:"docx_format_text",description:`Apply formatting to text in a range.
14
+ Supports bold, italic, underline, font size, font family, color, and highlight.`,inputSchema:{type:"object",properties:{documentId:u,range:h,formatting:{type:"object",description:"Formatting options to apply",properties:{bold:{type:"boolean"},italic:{type:"boolean"},underline:{type:"boolean"},strikethrough:{type:"boolean"},fontSize:{type:"number",description:"Font size in points"},fontFamily:{type:"string"},color:{type:"string",description:'Hex color (e.g., "#FF0000")'},highlight:{type:"string",description:"Highlight color name"}}}},required:["documentId","range","formatting"]},handler:async(r,s)=>{let{documentId:e,range:c,formatting:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=chunkAARNCPWR_js.a(n.document,{type:"formatText",range:c,formatting:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,range:c,appliedFormatting:t})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to format text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"medium"}},O={name:"docx_apply_style",description:`Apply a named style to a paragraph.
15
+ Use document styles like "Heading1", "Heading2", "Normal", etc.`,inputSchema:{type:"object",properties:{documentId:u,paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},styleId:{type:"string",description:'Style ID (e.g., "Heading1", "Normal")'}},required:["documentId","paragraphIndex","styleId"]},handler:async(r,s)=>{let{documentId:e,paragraphIndex:c,styleId:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=chunkAARNCPWR_js.a(n.document,{type:"applyStyle",paragraphIndex:c,styleId:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,paragraphIndex:c,styleId:t})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to apply style: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}};function P(r){let s=[];for(let e of r.content)e.type==="run"?s.push(_(e)):e.type==="hyperlink"&&s.push(A(e));return s.join("")}function _(r){return r.content.filter(s=>s.type==="text").map(s=>s.text).join("")}function A(r){let s=[];for(let e of r.children)e.type==="run"&&s.push(_(e));return s.join("")}var T=[D,C,R,k,$,J,v,j,E,O];function q(r={}){let{name:s="docx-editor",version:e="0.1.0",includeCoreTools:c=true,debug:t=false,additionalTools:n=[]}=r,o=new Map,a={id:`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,documents:new Map,data:new Map};if(c)for(let i of T)o.set(i.name,i),t&&console.log(`[MCP] Registered core tool: ${i.name}`);let d=chunkBUEMG4NW_js.b.getMcpTools();for(let i of d)o.has(i.name)&&console.warn(`[MCP] Tool '${i.name}' from plugin overrides existing tool`),o.set(i.name,i),t&&console.log(`[MCP] Registered plugin tool: ${i.name}`);for(let i of n)o.set(i.name,i),t&&console.log(`[MCP] Registered additional tool: ${i.name}`);let p=t?(i,f)=>{console.log(`[MCP] ${i}`,f??"");}:()=>{};async function l(i,f){let M=o.get(i);if(!M)throw new Error(`Unknown tool: ${i}`);p(`Calling tool: ${i}`,f);let N={session:a,log:p};try{let g=await M.handler(f,N);return p(`Tool ${i} completed`,g),g}catch(g){throw p(`Tool ${i} failed`,g),g}}function y(){return Array.from(o.values()).map(i=>({name:i.name,description:i.description,inputSchema:z(i.inputSchema),category:i.annotations?.category}))}function L(){return {name:s,version:e,toolCount:o.size}}return {tools:o,session:a,handleToolCall:l,listTools:y,getInfo:L}}async function F(r,s){let{id:e,method:c,params:t}=s;try{switch(c){case "initialize":return {jsonrpc:"2.0",id:e,result:{protocolVersion:"2024-11-05",capabilities:{tools:{}},serverInfo:r.getInfo()}};case "tools/list":{let n=r.listTools();return {jsonrpc:"2.0",id:e,result:{tools:n.map(o=>({name:o.name,description:o.description,inputSchema:o.inputSchema}))}}}case "tools/call":{let{name:n,arguments:o}=t,a=await r.handleToolCall(n,o);return {jsonrpc:"2.0",id:e,result:a}}default:return {jsonrpc:"2.0",id:e,error:{code:-32601,message:`Method not found: ${c}`}}}}catch(n){return {jsonrpc:"2.0",id:e,error:{code:-32e3,message:n.message}}}}async function H(r={}){let s=q(r);r.debug&&(console.error(`[MCP] Server started: ${s.getInfo().name} v${s.getInfo().version}`),console.error(`[MCP] Tools registered: ${s.tools.size}`));let c=(await import('readline')).createInterface({input:process.stdin,output:process.stdout,terminal:false}),t="";c.on("line",async n=>{t+=n;try{let o=JSON.parse(t);t="";let a=await F(s,o);process.stdout.write(JSON.stringify(a)+`
16
+ `);}catch{}}),c.on("close",()=>{r.debug&&console.error("[MCP] Server closed"),process.exit(0);});}function z(r){return typeof r=="object"&&r!==null&&("type"in r||"properties"in r)?r:{type:"object",properties:{}}}exports.applyStyleTool=O;exports.closeDocumentTool=R;exports.coreMcpTools=T;exports.createMcpServer=q;exports.deleteTextTool=j;exports.formatTextTool=E;exports.getDocumentInfoTool=k;exports.getDocumentTextTool=$;exports.handleJsonRpcRequest=F;exports.insertTextTool=J;exports.loadDocumentTool=D;exports.replaceTextTool=v;exports.saveDocumentTool=C;exports.startStdioServer=H;
@@ -0,0 +1,16 @@
1
+ import {i,r}from'./chunk-37SLIJPH.mjs';import {a}from'./chunk-M5F4SK3W.mjs';import {n}from'./chunk-7MGFEP2R.mjs';import {b}from'./chunk-W53SI3XW.mjs';import'./chunk-LYBG4YI7.mjs';import'./chunk-WOHFANC5.mjs';import'./chunk-TAUMSKRE.mjs';var u={type:"string",description:"Document ID returned from docx_load"},x={type:"object",properties:{paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},offset:{type:"number",description:"Character offset within the paragraph",minimum:0}},required:["paragraphIndex","offset"]},h={type:"object",properties:{start:x,end:x},required:["start","end"]},D={name:"docx_load",description:`Load a DOCX document from base64-encoded content.
2
+ Returns a document ID that can be used with other tools.
3
+ The document remains in session memory until closed.`,inputSchema:{type:"object",properties:{content:{type:"string",description:"Base64-encoded DOCX file content"},source:{type:"string",description:"Optional source filename or identifier for reference"}},required:["content"]},handler:async(r,s)=>{let{content:e,source:c}=r;try{let t=atob(e),n$1=new Uint8Array(t.length);for(let l=0;l<t.length;l++)n$1[l]=t.charCodeAt(l);let o=n$1.buffer,a=await n(o),d=`doc_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;s.session.documents.set(d,{id:d,document:a,buffer:o,source:c,lastModified:Date.now()});let p=a.package.document.content.filter(l=>l.type==="paragraph").length;return {content:[{type:"text",text:JSON.stringify({documentId:d,source:c,paragraphCount:p,message:"Document loaded successfully"})}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to load document: ${t.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},C={name:"docx_save",description:`Export the document to base64-encoded DOCX format.
4
+ Returns the document as a base64 string that can be saved to a file.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r$1,s)=>{let{documentId:e}=r$1,c=s.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let t;c.buffer?t=await i(c.document):t=await r(c.document);let n=new Uint8Array(t),o="";for(let d=0;d<n.length;d++)o+=String.fromCharCode(n[d]);let a=btoa(o);return {content:[{type:"text",text:JSON.stringify({documentId:e,base64:a,size:t.byteLength,message:"Document exported successfully"})}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to save document: ${t.message}`}]}}},annotations:{category:"core",readOnly:true,complexity:"low"}},R={name:"docx_close",description:`Close a document and free its memory.
5
+ Use this when done working with a document.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r;return s.session.documents.has(e)?(s.session.documents.delete(e),{content:[{type:"text",text:JSON.stringify({documentId:e,message:"Document closed"})}]}):{isError:true,content:[{type:"text",text:`Document not found: ${e}`}]}},annotations:{category:"core",readOnly:false,complexity:"low"}},k={name:"docx_get_info",description:`Get metadata and statistics about a document.
6
+ Returns paragraph count, word count, table count, and other useful info.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r,c=s.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};let t=c.document,n=t.package.document,o=n.content.filter(p=>p.type==="paragraph"),a=n.content.filter(p=>p.type==="table"),d=0;for(let p of o)if(p.type==="paragraph"){let l=P(p);d+=l.split(/\s+/).filter(y=>y.length>0).length;}return {content:[{type:"text",text:JSON.stringify({documentId:e,paragraphCount:o.length,tableCount:a.length,wordCount:d,hasStyles:!!t.package.styles,hasTheme:!!t.package.theme,source:c.source,lastModified:c.lastModified})}]}},annotations:{category:"core",readOnly:true,complexity:"low"}},$={name:"docx_get_text",description:`Get the plain text content of the document.
7
+ Returns all text concatenated with paragraph breaks.
8
+ Useful for understanding document content before making edits.`,inputSchema:{type:"object",properties:{documentId:u,maxLength:{type:"number",description:"Maximum characters to return (default: 10000)",default:1e4}},required:["documentId"]},handler:async(r,s)=>{let{documentId:e,maxLength:c=1e4}=r,t=s.session.documents.get(e);if(!t)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};let n=t.document.package.document,o=[];for(let p of n.content)p.type==="paragraph"?o.push(P(p)):p.type==="table"&&o.push("[TABLE]");let a=o.join(`
9
+ `),d=a.length>c;return d&&(a=a.slice(0,c)+"..."),{content:[{type:"text",text:JSON.stringify({documentId:e,text:a,truncated:d,totalLength:d?o.join(`
10
+ `).length:a.length})}]}},annotations:{category:"core",readOnly:true,complexity:"low"}},J={name:"docx_insert_text",description:`Insert text at a specific position in the document.
11
+ Position is specified by paragraph index (0-indexed) and character offset.`,inputSchema:{type:"object",properties:{documentId:u,position:x,text:{type:"string",description:"Text to insert"}},required:["documentId","position","text"]},handler:async(r,s)=>{let{documentId:e,position:c,text:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"insertText",position:c,text:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,insertedLength:t.length,position:c})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to insert text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},v={name:"docx_replace_text",description:`Replace text in a range with new text.
12
+ Specify start and end positions to define the range to replace.`,inputSchema:{type:"object",properties:{documentId:u,range:h,text:{type:"string",description:"Replacement text"}},required:["documentId","range","text"]},handler:async(r,s)=>{let{documentId:e,range:c,text:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"replaceText",range:c,text:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedRange:c,newTextLength:t.length})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to replace text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},j={name:"docx_delete_text",description:`Delete text in a range.
13
+ Specify start and end positions to define the range to delete.`,inputSchema:{type:"object",properties:{documentId:u,range:h},required:["documentId","range"]},handler:async(r,s)=>{let{documentId:e,range:c}=r,t=s.session.documents.get(e);if(!t)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let n=a(t.document,{type:"deleteText",range:c});return t.document=n,t.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,deletedRange:c})}]}}catch(n){return {isError:true,content:[{type:"text",text:`Failed to delete text: ${n.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},E={name:"docx_format_text",description:`Apply formatting to text in a range.
14
+ Supports bold, italic, underline, font size, font family, color, and highlight.`,inputSchema:{type:"object",properties:{documentId:u,range:h,formatting:{type:"object",description:"Formatting options to apply",properties:{bold:{type:"boolean"},italic:{type:"boolean"},underline:{type:"boolean"},strikethrough:{type:"boolean"},fontSize:{type:"number",description:"Font size in points"},fontFamily:{type:"string"},color:{type:"string",description:'Hex color (e.g., "#FF0000")'},highlight:{type:"string",description:"Highlight color name"}}}},required:["documentId","range","formatting"]},handler:async(r,s)=>{let{documentId:e,range:c,formatting:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"formatText",range:c,formatting:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,range:c,appliedFormatting:t})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to format text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"medium"}},O={name:"docx_apply_style",description:`Apply a named style to a paragraph.
15
+ Use document styles like "Heading1", "Heading2", "Normal", etc.`,inputSchema:{type:"object",properties:{documentId:u,paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},styleId:{type:"string",description:'Style ID (e.g., "Heading1", "Normal")'}},required:["documentId","paragraphIndex","styleId"]},handler:async(r,s)=>{let{documentId:e,paragraphIndex:c,styleId:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"applyStyle",paragraphIndex:c,styleId:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,paragraphIndex:c,styleId:t})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to apply style: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}};function P(r){let s=[];for(let e of r.content)e.type==="run"?s.push(_(e)):e.type==="hyperlink"&&s.push(A(e));return s.join("")}function _(r){return r.content.filter(s=>s.type==="text").map(s=>s.text).join("")}function A(r){let s=[];for(let e of r.children)e.type==="run"&&s.push(_(e));return s.join("")}var T=[D,C,R,k,$,J,v,j,E,O];function q(r={}){let{name:s="docx-editor",version:e="0.1.0",includeCoreTools:c=true,debug:t=false,additionalTools:n=[]}=r,o=new Map,a={id:`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,documents:new Map,data:new Map};if(c)for(let i of T)o.set(i.name,i),t&&console.log(`[MCP] Registered core tool: ${i.name}`);let d=b.getMcpTools();for(let i of d)o.has(i.name)&&console.warn(`[MCP] Tool '${i.name}' from plugin overrides existing tool`),o.set(i.name,i),t&&console.log(`[MCP] Registered plugin tool: ${i.name}`);for(let i of n)o.set(i.name,i),t&&console.log(`[MCP] Registered additional tool: ${i.name}`);let p=t?(i,f)=>{console.log(`[MCP] ${i}`,f??"");}:()=>{};async function l(i,f){let M=o.get(i);if(!M)throw new Error(`Unknown tool: ${i}`);p(`Calling tool: ${i}`,f);let N={session:a,log:p};try{let g=await M.handler(f,N);return p(`Tool ${i} completed`,g),g}catch(g){throw p(`Tool ${i} failed`,g),g}}function y(){return Array.from(o.values()).map(i=>({name:i.name,description:i.description,inputSchema:z(i.inputSchema),category:i.annotations?.category}))}function L(){return {name:s,version:e,toolCount:o.size}}return {tools:o,session:a,handleToolCall:l,listTools:y,getInfo:L}}async function F(r,s){let{id:e,method:c,params:t}=s;try{switch(c){case "initialize":return {jsonrpc:"2.0",id:e,result:{protocolVersion:"2024-11-05",capabilities:{tools:{}},serverInfo:r.getInfo()}};case "tools/list":{let n=r.listTools();return {jsonrpc:"2.0",id:e,result:{tools:n.map(o=>({name:o.name,description:o.description,inputSchema:o.inputSchema}))}}}case "tools/call":{let{name:n,arguments:o}=t,a=await r.handleToolCall(n,o);return {jsonrpc:"2.0",id:e,result:a}}default:return {jsonrpc:"2.0",id:e,error:{code:-32601,message:`Method not found: ${c}`}}}}catch(n){return {jsonrpc:"2.0",id:e,error:{code:-32e3,message:n.message}}}}async function H(r={}){let s=q(r);r.debug&&(console.error(`[MCP] Server started: ${s.getInfo().name} v${s.getInfo().version}`),console.error(`[MCP] Tools registered: ${s.tools.size}`));let c=(await import('readline')).createInterface({input:process.stdin,output:process.stdout,terminal:false}),t="";c.on("line",async n=>{t+=n;try{let o=JSON.parse(t);t="";let a=await F(s,o);process.stdout.write(JSON.stringify(a)+`
16
+ `);}catch{}}),c.on("close",()=>{r.debug&&console.error("[MCP] Server closed"),process.exit(0);});}function z(r){return typeof r=="object"&&r!==null&&("type"in r||"properties"in r)?r:{type:"object",properties:{}}}export{O as applyStyleTool,R as closeDocumentTool,T as coreMcpTools,q as createMcpServer,j as deleteTextTool,E as formatTextTool,k as getDocumentInfoTool,$ as getDocumentTextTool,F as handleJsonRpcRequest,J as insertTextTool,D as loadDocumentTool,v as replaceTextTool,C as saveDocumentTool,H as startStdioServer};
@@ -0,0 +1 @@
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var chunkPB7VMDDP_js=require('./chunk-PB7VMDDP.js');require('./chunk-H5NTJZO4.js');Object.defineProperty(exports,"createTemplateProcessor",{enumerable:true,get:function(){return chunkPB7VMDDP_js.j}});Object.defineProperty(exports,"default",{enumerable:true,get:function(){return chunkPB7VMDDP_js.k}});Object.defineProperty(exports,"getMissingVariables",{enumerable:true,get:function(){return chunkPB7VMDDP_js.g}});Object.defineProperty(exports,"getTemplateTags",{enumerable:true,get:function(){return chunkPB7VMDDP_js.e}});Object.defineProperty(exports,"previewTemplate",{enumerable:true,get:function(){return chunkPB7VMDDP_js.h}});Object.defineProperty(exports,"processTemplate",{enumerable:true,get:function(){return chunkPB7VMDDP_js.a}});Object.defineProperty(exports,"processTemplateAdvanced",{enumerable:true,get:function(){return chunkPB7VMDDP_js.i}});Object.defineProperty(exports,"processTemplateAndDownload",{enumerable:true,get:function(){return chunkPB7VMDDP_js.d}});Object.defineProperty(exports,"processTemplateAsBlob",{enumerable:true,get:function(){return chunkPB7VMDDP_js.c}});Object.defineProperty(exports,"processTemplateDetailed",{enumerable:true,get:function(){return chunkPB7VMDDP_js.b}});Object.defineProperty(exports,"validateTemplate",{enumerable:true,get:function(){return chunkPB7VMDDP_js.f}});
@@ -0,0 +1 @@
1
+ export{j as createTemplateProcessor,k as default,g as getMissingVariables,e as getTemplateTags,h as previewTemplate,a as processTemplate,i as processTemplateAdvanced,d as processTemplateAndDownload,c as processTemplateAsBlob,b as processTemplateDetailed,f as validateTemplate}from'./chunk-DLVLK5FT.mjs';import'./chunk-TAUMSKRE.mjs';