@betteroffice/docx 0.0.1 → 0.0.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.
- package/README.md +19 -0
- package/dist/chunk-AEQOEQJ7.mjs +57 -0
- package/dist/chunk-AZ52IWB6.mjs +16 -0
- package/dist/{chunk-SINEY6ZF.mjs → chunk-B4IR6YP4.mjs} +1 -1
- package/dist/chunk-IFT6DUJX.mjs +1 -0
- package/dist/{chunk-H3JCIGWK.mjs → chunk-NJHOPXZW.mjs} +1 -1
- package/dist/chunk-NTQM4EYN.mjs +1 -0
- package/dist/{chunk-KXNZFTTK.mjs → chunk-WBH3SXI6.mjs} +1 -1
- package/dist/collaboration/index.d.mts +64 -0
- package/dist/collaboration/index.mjs +1 -0
- package/dist/{content-sSHuWw49.d.mts → content-DLFHRQav.d.mts} +8 -8
- package/dist/core.d.mts +148 -341
- package/dist/core.mjs +1 -1
- package/dist/{displayListQueries-p-ijSzdh.d.mts → displayListQueries-UGc_XBUv.d.mts} +1 -1
- package/dist/docx/index.d.mts +40 -520
- package/dist/docx/index.mjs +2 -2
- package/dist/editor/index.d.mts +35 -151
- package/dist/editor/index.mjs +1 -1
- package/dist/{fontLoader-Bx6DK6-2.d.mts → fontLoader-aSewHMKF.d.mts} +65 -63
- package/dist/{formatting-DoL7KBSL.d.mts → formatting-D1EPSaJP.d.mts} +1 -1
- package/dist/generated/edit/docx_edit_bg.wasm +0 -0
- package/dist/generated/layout/docx_layout_bg.wasm +0 -0
- package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
- package/dist/generated/parse/docx_parse_bg.wasm +0 -0
- package/dist/index-Bwxm3oiC.d.mts +934 -0
- package/dist/layout/index.d.mts +18 -240
- package/dist/layout/index.mjs +1 -1
- package/dist/layout/pagination/index.d.mts +10 -58
- package/dist/layout/pagination/index.mjs +1 -1
- package/dist/layout/render/index.d.mts +10 -11
- package/dist/layout/render/index.mjs +1 -1
- package/dist/plugin-api/RenderedDomContext.d.mts +8 -9
- package/dist/plugin-api/index.d.mts +191 -6
- package/dist/plugin-api/resolveItemPositions.d.mts +4 -5
- package/dist/{rustDisplayList-dqunvwxH.d.mts → rustDisplayList-CX78djsZ.d.mts} +5 -5
- package/dist/rustMeasureSource-D1KsQvVC.d.mts +106 -0
- package/dist/selectiveSave-CVoajSKE.d.mts +56 -0
- package/dist/styles/index.d.mts +4 -39
- package/dist/styles/index.mjs +1 -1
- package/dist/{styles-VxNcXLdi.d.mts → styles-Dn_o3Vo5.d.mts} +2 -2
- package/dist/types/content.d.mts +2 -2
- package/dist/types/document.d.mts +40 -14
- package/dist/{types-DNrYr6yQ.d.mts → types-DMkDbvEu.d.mts} +3 -71
- package/dist/utils/comments.d.mts +2 -2
- package/dist/utils/index.d.mts +110 -576
- package/dist/utils/index.mjs +1 -84
- package/dist/utils/stylePreview.d.mts +2 -2
- package/dist/utils/units.d.mts +33 -2
- package/dist/wasm-BGQBTR2J.mjs +1 -0
- package/dist/wasm-edit.d.mts +13 -5
- package/dist/wasm-edit.mjs +1 -1
- package/dist/wasm-opc.mjs +1 -1
- package/dist/wasm-parse.mjs +1 -1
- package/dist/yrs/index.d.mts +5 -881
- package/dist/yrs/index.mjs +1 -1
- package/dist/yrs/residentEngineWorker.mjs +1 -1
- package/package.json +16 -139
- package/dist/Subscribable-DOz6Ohoo.d.mts +0 -33
- package/dist/agent/index.d.mts +0 -531
- package/dist/agent/index.mjs +0 -1
- package/dist/chunk-34K66SY4.mjs +0 -1
- package/dist/chunk-4RCISPPE.mjs +0 -1
- package/dist/chunk-52GB3Y42.mjs +0 -1
- package/dist/chunk-6PW4CWUG.mjs +0 -1
- package/dist/chunk-7DEIW7FL.mjs +0 -1
- package/dist/chunk-7PCO5I2O.mjs +0 -1
- package/dist/chunk-BI3B33LI.mjs +0 -1
- package/dist/chunk-BIQWVK5P.mjs +0 -2
- package/dist/chunk-DXKG3HQ5.mjs +0 -16
- package/dist/chunk-FPZBTOD6.mjs +0 -1
- package/dist/chunk-FZIA7OFY.mjs +0 -1
- package/dist/chunk-GWKJ2Y4Y.mjs +0 -1
- package/dist/chunk-HJGAQIU7.mjs +0 -2
- package/dist/chunk-I6KKMUUC.mjs +0 -1
- package/dist/chunk-IL5JZJT7.mjs +0 -1
- package/dist/chunk-JY6ILTNS.mjs +0 -1
- package/dist/chunk-KEE52TT5.mjs +0 -1
- package/dist/chunk-KVKLLTDP.mjs +0 -58
- package/dist/chunk-L5ISVQ3W.mjs +0 -1
- package/dist/chunk-LDUWIM7M.mjs +0 -1
- package/dist/chunk-N5Q3YN64.mjs +0 -1
- package/dist/chunk-NEWOMDTX.mjs +0 -1
- package/dist/chunk-O2QSE2I7.mjs +0 -1
- package/dist/chunk-OJOHXQNQ.mjs +0 -1
- package/dist/chunk-OMR3TWCD.mjs +0 -2
- package/dist/chunk-P3KDV4M2.mjs +0 -1
- package/dist/chunk-Q7PO7V73.mjs +0 -1
- package/dist/chunk-QOUFE3VX.mjs +0 -1
- package/dist/chunk-TYHI7RAD.mjs +0 -1
- package/dist/chunk-UIEJWORW.mjs +0 -1
- package/dist/chunk-VAOUFAUH.mjs +0 -1
- package/dist/chunk-VBOTMRXV.mjs +0 -1
- package/dist/chunk-VCER63GQ.mjs +0 -1
- package/dist/chunk-WAUF2UC7.mjs +0 -2
- package/dist/chunk-X4XDO3LZ.mjs +0 -1
- package/dist/chunk-XQBCCJBO.mjs +0 -9
- package/dist/chunk-XWUOLYRQ.mjs +0 -2
- package/dist/chunk-XYH6XWP3.mjs +0 -10
- package/dist/chunk-YBIM6UJV.mjs +0 -8
- package/dist/chunk-YCIH2Q3E.mjs +0 -1
- package/dist/chunk-ZOV5KL7C.mjs +0 -1
- package/dist/colorResolver-n0o7H7ep.d.mts +0 -290
- package/dist/core-plugins.d.mts +0 -37
- package/dist/core-plugins.mjs +0 -1
- package/dist/docx/parser.d.mts +0 -41
- package/dist/docx/parser.mjs +0 -1
- package/dist/docx/rezip.d.mts +0 -148
- package/dist/docx/rezip.mjs +0 -1
- package/dist/docx/serializer/index.d.mts +0 -42
- package/dist/docx/serializer/index.mjs +0 -1
- package/dist/editorTree-DO5PyDK8.d.mts +0 -37
- package/dist/executor-7O2RBJ2B.mjs +0 -1
- package/dist/headerFooterLayout-0zPT64Qc.d.mts +0 -316
- package/dist/headless.d.mts +0 -69
- package/dist/headless.mjs +0 -1
- package/dist/layout/flow/index.d.mts +0 -149
- package/dist/layout/flow/index.mjs +0 -1
- package/dist/layout/measure/index.d.mts +0 -324
- package/dist/layout/measure/index.mjs +0 -1
- package/dist/layout/pagination/types.d.mts +0 -4
- package/dist/layout/pagination/types.mjs +0 -1
- package/dist/managers/AutoSaveManager.d.mts +0 -81
- package/dist/managers/AutoSaveManager.mjs +0 -1
- package/dist/managers/TableSelectionManager.d.mts +0 -74
- package/dist/managers/TableSelectionManager.mjs +0 -1
- package/dist/managers/types.d.mts +0 -113
- package/dist/managers/types.mjs +0 -0
- package/dist/mcp-cli.mjs +0 -142
- package/dist/mcp.d.mts +0 -162
- package/dist/mcp.mjs +0 -16
- package/dist/measureBlocksPipeline-Df0Bbrwy.d.mts +0 -109
- package/dist/measuredBlock-DZwz8zhD.d.mts +0 -26
- package/dist/plugin-api/types.d.mts +0 -193
- package/dist/plugin-api/types.mjs +0 -0
- package/dist/processTemplate-HDUIZFJ5.mjs +0 -1
- package/dist/registry-DMM5VTdT.d.mts +0 -165
- package/dist/rustPagination-Bj2hq013.d.mts +0 -106
- package/dist/sectionConfigs-DW3J8q0X.d.mts +0 -55
- package/dist/selectionContext-Buc9BCU1.d.mts +0 -570
- package/dist/selectiveSave-oFBJ1n71.d.mts +0 -16
- package/dist/selectiveXmlPatch-ypkxlTD_.d.mts +0 -23
- package/dist/settingsParser-CcGvtmCK.d.mts +0 -33
- package/dist/types/agentApi.d.mts +0 -456
- package/dist/types/agentApi.mjs +0 -1
- package/dist/types-dYdjUZMo.d.mts +0 -311
- package/dist/units-O5Y02RKQ.d.mts +0 -34
- package/dist/utils/headingCollector.d.mts +0 -28
- package/dist/utils/headingCollector.mjs +0 -1
- package/dist/utils/highlightColors.d.mts +0 -14
- package/dist/utils/highlightColors.mjs +0 -1
- package/dist/utils/textSelection.d.mts +0 -92
- package/dist/utils/textSelection.mjs +0 -1
- package/dist/variableDetector-Borj29SF.d.mts +0 -115
- package/dist/wasm-FZQ5XB2Y.mjs +0 -1
- package/dist/watermarkApi-DCxjutkg.d.mts +0 -38
package/dist/mcp.mjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-6PW4CWUG.mjs';import'./chunk-KXNZFTTK.mjs';import {b}from'./chunk-VBOTMRXV.mjs';import {h as h$1,s}from'./chunk-KVKLLTDP.mjs';import'./chunk-BIQWVK5P.mjs';import'./chunk-3UBMCDME.mjs';import {a}from'./chunk-LDUWIM7M.mjs';import'./chunk-DXKG3HQ5.mjs';import'./chunk-FPZBTOD6.mjs';import'./chunk-H3JCIGWK.mjs';import'./chunk-N5Q3YN64.mjs';import'./chunk-SINEY6ZF.mjs';import'./chunk-T4EZMUXM.mjs';import'./chunk-TTRUPDAB.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"]},R={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$1=await a(o),d=`doc_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;s.session.documents.set(d,{id:d,document:a$1,buffer:o,source:c,lastModified:Date.now()});let p=a$1.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"}},k={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$1)=>{let{documentId:e}=r,c=s$1.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let t;c.buffer?t=await h$1(c.document):t=await s(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"}},$={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"}},J={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=q(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"}},v={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(q(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$1(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"}},E={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$1(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"}},O={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$1(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"}},P={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$1(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"}},_={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$1(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 q(r){let s=[];for(let e of r.content)e.type==="run"?s.push(F(e)):e.type==="hyperlink"&&s.push(z(e));return s.join("")}function F(r){return r.content.filter(s=>s.type==="text").map(s=>s.text).join("")}function z(r){let s=[];for(let e of r.children)e.type==="run"&&s.push(F(e));return s.join("")}var T=[R,k,$,J,v,j,E,O,P,_];function L(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 H={session:a,log:p};try{let g=await M.handler(f,H);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:B(i.inputSchema),category:i.annotations?.category}))}function A(){return {name:s,version:e,toolCount:o.size}}return {tools:o,session:a,handleToolCall:l,listTools:y,getInfo:A}}async function N(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 U(r={}){let s=L(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 N(s,o);process.stdout.write(JSON.stringify(a)+`
|
|
16
|
-
`);}catch{}}),c.on("close",()=>{r.debug&&console.error("[MCP] Server closed"),process.exit(0);});}function B(r){return typeof r=="object"&&r!==null&&("type"in r||"properties"in r)?r:{type:"object",properties:{}}}export{_ as applyStyleTool,$ as closeDocumentTool,T as coreMcpTools,L as createMcpServer,O as deleteTextTool,P as formatTextTool,J as getDocumentInfoTool,v as getDocumentTextTool,N as handleJsonRpcRequest,j as insertTextTool,R as loadDocumentTool,E as replaceTextTool,k as saveDocumentTool,U as startStdioServer};
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { W as WrapTextDirection, i as PageGeometry, e as LayoutBlock, B as BlockExtent } from './types-DNrYr6yQ.mjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Clamp floating-wrap margins so at least a usable strip of the line
|
|
5
|
-
* remains. Unchecked margins from near-full-width tables/images can exceed
|
|
6
|
-
* contentWidth and collapse every line to ~1 glyph (the "single character
|
|
7
|
-
* per line after a wide floating table" bug).
|
|
8
|
-
*
|
|
9
|
-
* Returned margins are zeroed when:
|
|
10
|
-
* - either side alone is >= contentWidth (no strip on that side at all), or
|
|
11
|
-
* - their sum is >= contentWidth (no strip exists between the two sides).
|
|
12
|
-
*/
|
|
13
|
-
declare function clampFloatingWrapMargins(leftMargin: number, rightMargin: number, contentWidth: number): {
|
|
14
|
-
leftMargin: number;
|
|
15
|
-
rightMargin: number;
|
|
16
|
-
};
|
|
17
|
-
interface FloatingExclusionRect {
|
|
18
|
-
/** which margin absorbs the exclusion when wrapText alone doesn't pick a side. */
|
|
19
|
-
side: 'left' | 'right';
|
|
20
|
-
/** object's left edge in content-area px. */
|
|
21
|
-
x: number;
|
|
22
|
-
/** object's top edge in content-area px. */
|
|
23
|
-
y: number;
|
|
24
|
-
width: number;
|
|
25
|
-
height: number;
|
|
26
|
-
distTop: number;
|
|
27
|
-
distBottom: number;
|
|
28
|
-
distLeft: number;
|
|
29
|
-
distRight: number;
|
|
30
|
-
wrapText?: WrapTextDirection;
|
|
31
|
-
wrapType?: string;
|
|
32
|
-
}
|
|
33
|
-
interface FloatingImageZone {
|
|
34
|
-
leftMargin: number;
|
|
35
|
-
rightMargin: number;
|
|
36
|
-
topY: number;
|
|
37
|
-
bottomY: number;
|
|
38
|
-
segments?: FloatingLineSegmentZone[];
|
|
39
|
-
/**
|
|
40
|
-
* Full-width vertical band (OOXML `topAndBottom` wrap): no text fits beside
|
|
41
|
-
* it, so any line overlapping `[topY, bottomY]` is pushed below the band.
|
|
42
|
-
*/
|
|
43
|
-
fullWidthBlock?: boolean;
|
|
44
|
-
}
|
|
45
|
-
interface FloatingLineSegmentZone {
|
|
46
|
-
leftOffset: number;
|
|
47
|
-
availableWidth: number;
|
|
48
|
-
}
|
|
49
|
-
interface FloatingLineMargins {
|
|
50
|
-
leftMargin: number;
|
|
51
|
-
rightMargin: number;
|
|
52
|
-
segments?: FloatingLineSegmentZone[];
|
|
53
|
-
}
|
|
54
|
-
declare function rectsToFloatingZones(rects: FloatingExclusionRect[], contentWidth: number): FloatingImageZone[];
|
|
55
|
-
declare function getFloatingMargins(lineY: number, lineHeight: number, zones: FloatingImageZone[] | undefined, paragraphYOffset: number): FloatingLineMargins;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Floating-aware block measurement pipeline.
|
|
59
|
-
*
|
|
60
|
-
* Pre-scans a block list to extract exclusion zones from anchored images,
|
|
61
|
-
* floating tables, and floating text boxes; groups co-located floats so
|
|
62
|
-
* their combined exclusion applies starting from the earliest anchor; then
|
|
63
|
-
* walks the blocks calling the caller-supplied `measureBlock` with the
|
|
64
|
-
* active zones and cumulative Y at each step.
|
|
65
|
-
*
|
|
66
|
-
* Adapters (React, Vue) provide their own `measureBlock` so they can
|
|
67
|
-
* decide e.g. whether to cache paragraph measures. The orchestration,
|
|
68
|
-
* extraction, and grouping live here so both adapters stay in lockstep.
|
|
69
|
-
*
|
|
70
|
-
* @packageDocumentation
|
|
71
|
-
* @public
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Block-measurement callback shape passed to {@link measureBlocksWithFloats}.
|
|
76
|
-
* Adapters (React, Vue) supply this so they can decide platform-specific
|
|
77
|
-
* concerns (e.g. paragraph-measure caching, per-section width) while
|
|
78
|
-
* sharing the floating-zone orchestration. This is adapter-author API,
|
|
79
|
-
* not end-consumer API.
|
|
80
|
-
*
|
|
81
|
-
* @public
|
|
82
|
-
*/
|
|
83
|
-
type MeasureBlockFn = (block: LayoutBlock, contentWidth: number, floatingZones?: FloatingImageZone[], cumulativeY?: number) => BlockExtent;
|
|
84
|
-
/**
|
|
85
|
-
* Page geometry (CSS px) used to resolve page/margin-relative anchored objects
|
|
86
|
-
* into content-area coordinates — currently the vertical anchor of a top-pinned
|
|
87
|
-
* `topAndBottom` band. Same shape the painter uses (see `pageGeometryFromPage`),
|
|
88
|
-
* so both paths resolve to identical positions.
|
|
89
|
-
*
|
|
90
|
-
* @public
|
|
91
|
-
*/
|
|
92
|
-
type FloatPageGeometry = PageGeometry;
|
|
93
|
-
/**
|
|
94
|
-
* Walk `blocks` and produce one `BlockExtent` per block. Before measuring, this
|
|
95
|
-
* extracts floating exclusion zones (images / floating tables / floating
|
|
96
|
-
* textboxes), groups overlapping co-located floats, and threads the active
|
|
97
|
-
* zones plus cumulative Y into each `measureBlock` call.
|
|
98
|
-
*
|
|
99
|
-
* Pass `pageGeometry` whenever the document may contain page/margin-anchored
|
|
100
|
-
* `topAndBottom` text boxes (e.g. a title banner pinned to the page top):
|
|
101
|
-
* without it their reserved band falls back to flow-relative Y and the band
|
|
102
|
-
* won't line up with where the painter places the box. Build it with the
|
|
103
|
-
* shared `pageGeometryFromPage` helper.
|
|
104
|
-
*
|
|
105
|
-
* @public
|
|
106
|
-
*/
|
|
107
|
-
declare function measureBlocksWithFloats(blocks: LayoutBlock[], contentWidth: number | number[], measureBlock: MeasureBlockFn, pageGeometry?: FloatPageGeometry): BlockExtent[];
|
|
108
|
-
|
|
109
|
-
export { type FloatPageGeometry as F, type MeasureBlockFn as M, type FloatingExclusionRect as a, type FloatingImageZone as b, type FloatingLineSegmentZone as c, clampFloatingWrapMargins as d, getFloatingMargins as g, measureBlocksWithFloats as m, rectsToFloatingZones as r };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { e as LayoutBlock, B as BlockExtent } from './types-DNrYr6yQ.mjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The colocated block+measure unit consumed by the paginator.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* A flow block paired with its measurement. The paginator consumes
|
|
9
|
-
* `MeasuredBlock[]` instead of two parallel `LayoutBlock[]` + `BlockExtent[]`
|
|
10
|
-
* arrays kept in lockstep by index — colocating the pair makes a misaligned
|
|
11
|
-
* block/measure unrepresentable.
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
type MeasuredBlock = {
|
|
15
|
-
block: LayoutBlock;
|
|
16
|
-
measure: BlockExtent;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Zip aligned `blocks` and `measures` into `MeasuredBlock[]`. This is the one
|
|
20
|
-
* place a length assumption is localized — the pervasive per-index coupling it
|
|
21
|
-
* replaces is what the measured-block model removes.
|
|
22
|
-
* @public
|
|
23
|
-
*/
|
|
24
|
-
declare function toMeasuredBlocks(blocks: LayoutBlock[], measures: BlockExtent[]): MeasuredBlock[];
|
|
25
|
-
|
|
26
|
-
export { type MeasuredBlock as M, toMeasuredBlocks as t };
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { Document } from '../types/document.mjs';
|
|
2
|
-
import '../content-sSHuWw49.mjs';
|
|
3
|
-
import '../formatting-DoL7KBSL.mjs';
|
|
4
|
-
import '../docx/wrapTypes.mjs';
|
|
5
|
-
import '../styles-VxNcXLdi.mjs';
|
|
6
|
-
import '../settingsParser-CcGvtmCK.mjs';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Framework-Agnostic Plugin Interface for the DOCX Editor
|
|
10
|
-
*
|
|
11
|
-
* Core plugin types that can be used by any framework (React, Vue, etc.).
|
|
12
|
-
* Framework-specific adapters extend EditorPluginCore with their own
|
|
13
|
-
* UI rendering capabilities (e.g., ReactEditorPlugin, VueEditorPlugin).
|
|
14
|
-
* @packageDocumentation
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Coordinates returned by position lookup in the rendered DOM.
|
|
20
|
-
*/
|
|
21
|
-
interface PositionCoordinates {
|
|
22
|
-
x: number;
|
|
23
|
-
y: number;
|
|
24
|
-
height: number;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Context for accessing rendered-page geometry in the paged editor.
|
|
28
|
-
*
|
|
29
|
-
* Provides position mapping over the canvas renderer's output (Rust
|
|
30
|
-
* display-list queries, with the accessibility mirror's DOM as fallback).
|
|
31
|
-
* Use this for rendering overlays, annotations, and other visual elements
|
|
32
|
-
* positioned relative to rendered content.
|
|
33
|
-
*
|
|
34
|
-
* The mirror DOM uses data-doc-start/data-doc-end attributes on spans
|
|
35
|
-
* to map between display positions and DOM elements.
|
|
36
|
-
*/
|
|
37
|
-
interface RenderedDomContext {
|
|
38
|
-
/** The container element holding all rendered pages. */
|
|
39
|
-
pagesContainer: HTMLElement;
|
|
40
|
-
/**
|
|
41
|
-
* Get pixel coordinates for a display position in the rendered DOM.
|
|
42
|
-
* Returns null if the position cannot be found.
|
|
43
|
-
*/
|
|
44
|
-
getCoordinatesForPosition(position: number): PositionCoordinates | null;
|
|
45
|
-
/**
|
|
46
|
-
* Find DOM elements that overlap with a display-position range.
|
|
47
|
-
*/
|
|
48
|
-
findElementsForRange(from: number, to: number): Element[];
|
|
49
|
-
/**
|
|
50
|
-
* Get bounding rectangles for a range of text, accounting for line wraps.
|
|
51
|
-
* Returns rects relative to the pages container.
|
|
52
|
-
*/
|
|
53
|
-
getRectsForRange(from: number, to: number): Array<{
|
|
54
|
-
x: number;
|
|
55
|
-
y: number;
|
|
56
|
-
width: number;
|
|
57
|
-
height: number;
|
|
58
|
-
}>;
|
|
59
|
-
/** Query-backed caret coordinates for one explicit header/footer page. */
|
|
60
|
-
getCoordinatesForHfPosition(region: 'header' | 'footer', rId: string, position: number, pageIndex: number): PositionCoordinates | null;
|
|
61
|
-
/** Query-backed range rectangles for one explicit header/footer page. */
|
|
62
|
-
getRectsForHfRange(region: 'header' | 'footer', rId: string, from: number, to: number, pageIndex: number): Array<{
|
|
63
|
-
x: number;
|
|
64
|
-
y: number;
|
|
65
|
-
width: number;
|
|
66
|
-
height: number;
|
|
67
|
-
}>;
|
|
68
|
-
/** Bounds of one rendered page relative to the pages container. */
|
|
69
|
-
getPageBounds(pageIndex: number): {
|
|
70
|
-
x: number;
|
|
71
|
-
y: number;
|
|
72
|
-
width: number;
|
|
73
|
-
height: number;
|
|
74
|
-
} | null;
|
|
75
|
-
/** Current zoom level (1 = 100%). */
|
|
76
|
-
zoom: number;
|
|
77
|
-
/**
|
|
78
|
-
* Offset of the pages container from its parent viewport.
|
|
79
|
-
*/
|
|
80
|
-
getContainerOffset(): {
|
|
81
|
-
x: number;
|
|
82
|
-
y: number;
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Props passed to plugin panel components (framework-agnostic base).
|
|
87
|
-
*/
|
|
88
|
-
interface PluginPanelProps<TState = unknown> {
|
|
89
|
-
/** Current serializer-facing document snapshot. */
|
|
90
|
-
document: Document | null;
|
|
91
|
-
/** Scroll editor to a specific position */
|
|
92
|
-
scrollToPosition: (pos: number) => void;
|
|
93
|
-
/** Select a range in the editor */
|
|
94
|
-
selectRange: (from: number, to: number) => void;
|
|
95
|
-
/** Plugin-specific state (managed by the plugin) */
|
|
96
|
-
pluginState: TState;
|
|
97
|
-
/** Width of the panel in pixels */
|
|
98
|
-
panelWidth: number;
|
|
99
|
-
/**
|
|
100
|
-
* Context for the rendered pages (canvas renderer output).
|
|
101
|
-
* May be null if layout hasn't completed yet.
|
|
102
|
-
*/
|
|
103
|
-
renderedDomContext: RenderedDomContext | null;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Configuration for plugin panel rendering.
|
|
107
|
-
*/
|
|
108
|
-
interface PanelConfig {
|
|
109
|
-
/** Where to render the panel */
|
|
110
|
-
position: 'left' | 'right' | 'bottom';
|
|
111
|
-
/** Default width/height of the panel */
|
|
112
|
-
defaultSize: number;
|
|
113
|
-
/** Minimum size */
|
|
114
|
-
minSize?: number;
|
|
115
|
-
/** Maximum size */
|
|
116
|
-
maxSize?: number;
|
|
117
|
-
/** Whether the panel is resizable */
|
|
118
|
-
resizable?: boolean;
|
|
119
|
-
/** Whether the panel can be collapsed */
|
|
120
|
-
collapsible?: boolean;
|
|
121
|
-
/** Initial collapsed state */
|
|
122
|
-
defaultCollapsed?: boolean;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Framework-agnostic core plugin interface.
|
|
126
|
-
*
|
|
127
|
-
* Contains all non-UI plugin capabilities:
|
|
128
|
-
* - State management (initialize, onStateChange, destroy)
|
|
129
|
-
* - CSS injection
|
|
130
|
-
* - Panel configuration
|
|
131
|
-
*
|
|
132
|
-
* Framework adapters (ReactEditorPlugin, VueEditorPlugin) extend this
|
|
133
|
-
* with their own Panel component type and renderOverlay function.
|
|
134
|
-
*/
|
|
135
|
-
interface EditorPluginCore<TState = any> {
|
|
136
|
-
/** Unique plugin identifier */
|
|
137
|
-
id: string;
|
|
138
|
-
/** Display name for the plugin */
|
|
139
|
-
name: string;
|
|
140
|
-
/**
|
|
141
|
-
* Configuration for the panel (position, size, etc.)
|
|
142
|
-
*/
|
|
143
|
-
panelConfig?: PanelConfig;
|
|
144
|
-
/**
|
|
145
|
-
* Called when the projected document changes.
|
|
146
|
-
* Use this to update plugin-specific state based on document changes.
|
|
147
|
-
*/
|
|
148
|
-
onStateChange?: (document: Document) => TState | undefined;
|
|
149
|
-
/**
|
|
150
|
-
* Initialize plugin state when the plugin is first loaded.
|
|
151
|
-
*/
|
|
152
|
-
initialize?: (document: Document | null) => TState;
|
|
153
|
-
/**
|
|
154
|
-
* Called when the plugin is being destroyed.
|
|
155
|
-
* Use this for cleanup (subscriptions, timers, etc.)
|
|
156
|
-
*/
|
|
157
|
-
destroy?: () => void;
|
|
158
|
-
/**
|
|
159
|
-
* CSS styles to inject for this plugin.
|
|
160
|
-
* Can be a string of CSS or a URL to a stylesheet.
|
|
161
|
-
*/
|
|
162
|
-
styles?: string;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* A sidebar item anchored to a document position.
|
|
166
|
-
* Framework adapters extend this with rendering capabilities.
|
|
167
|
-
*/
|
|
168
|
-
interface SidebarItem {
|
|
169
|
-
/** Unique ID for this item (used as React key and for overlap resolution). */
|
|
170
|
-
id: string;
|
|
171
|
-
/** Display position this item anchors to. */
|
|
172
|
-
anchorPos: number;
|
|
173
|
-
/** Optional key into the anchorPositions Map (e.g. "comment-42", "revision-7"). */
|
|
174
|
-
anchorKey?: string;
|
|
175
|
-
/** Sort priority within items at the same anchor Y. Lower = first. Default: 0. */
|
|
176
|
-
priority?: number;
|
|
177
|
-
/** Temporary items (e.g. "add comment" input) skip entrance animation. */
|
|
178
|
-
isTemporary?: boolean;
|
|
179
|
-
/** Pre-computed Y position (scroll-container coords, pre-zoom). Overrides anchor resolution. */
|
|
180
|
-
fixedY?: number;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Context provided to plugins when computing sidebar items.
|
|
184
|
-
*/
|
|
185
|
-
interface SidebarItemContext {
|
|
186
|
-
document: Document | null;
|
|
187
|
-
renderedDomContext: RenderedDomContext | null;
|
|
188
|
-
/** Pre-computed Y positions from layout engine (keys like "comment-{id}"). */
|
|
189
|
-
anchorPositions: Map<string, number>;
|
|
190
|
-
zoom: number;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export type { EditorPluginCore, PanelConfig, PluginPanelProps, PositionCoordinates, RenderedDomContext, SidebarItem, SidebarItemContext };
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
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-O2QSE2I7.mjs';import'./chunk-TTRUPDAB.mjs';
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { b as CorePlugin, k as PluginOptions, l as PluginRegistrationResult, C as CommandHandler, f as McpToolDefinition, j as PluginEventListener } from './types-dYdjUZMo.mjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Plugin Registry
|
|
5
|
-
*
|
|
6
|
-
* Central registry for core plugins. Manages plugin lifecycle,
|
|
7
|
-
* collects command handlers from all plugins, and aggregates
|
|
8
|
-
* MCP tool definitions for the MCP server.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Plugin Registry - manages core plugins
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* import { pluginRegistry, docxtemplaterPlugin } from '@betteroffice/docx/core-plugins';
|
|
17
|
-
*
|
|
18
|
-
* // Register plugins
|
|
19
|
-
* pluginRegistry.register(docxtemplaterPlugin);
|
|
20
|
-
*
|
|
21
|
-
* // Get all MCP tools for MCP server
|
|
22
|
-
* const tools = pluginRegistry.getMcpTools();
|
|
23
|
-
*
|
|
24
|
-
* // Get command handler for executor
|
|
25
|
-
* const handler = pluginRegistry.getCommandHandler('insertTemplateVariable');
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
declare class PluginRegistry {
|
|
29
|
-
private plugins;
|
|
30
|
-
private commandHandlers;
|
|
31
|
-
private eventListeners;
|
|
32
|
-
private initialized;
|
|
33
|
-
/**
|
|
34
|
-
* Register a plugin
|
|
35
|
-
*
|
|
36
|
-
* @param plugin - The plugin to register
|
|
37
|
-
* @param options - Optional configuration
|
|
38
|
-
* @returns Registration result
|
|
39
|
-
*/
|
|
40
|
-
register(plugin: CorePlugin, options?: PluginOptions): PluginRegistrationResult;
|
|
41
|
-
/**
|
|
42
|
-
* Unregister a plugin
|
|
43
|
-
*
|
|
44
|
-
* @param pluginId - ID of the plugin to unregister
|
|
45
|
-
* @returns Whether unregistration succeeded
|
|
46
|
-
*/
|
|
47
|
-
unregister(pluginId: string): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Get a registered plugin by ID
|
|
50
|
-
*
|
|
51
|
-
* @param id - Plugin ID
|
|
52
|
-
* @returns The plugin or undefined
|
|
53
|
-
*/
|
|
54
|
-
get(id: string): CorePlugin | undefined;
|
|
55
|
-
/**
|
|
56
|
-
* Get all registered plugins
|
|
57
|
-
*
|
|
58
|
-
* @returns Array of all plugins
|
|
59
|
-
*/
|
|
60
|
-
getAll(): CorePlugin[];
|
|
61
|
-
/**
|
|
62
|
-
* Check if a plugin is registered
|
|
63
|
-
*
|
|
64
|
-
* @param id - Plugin ID
|
|
65
|
-
* @returns Whether the plugin is registered
|
|
66
|
-
*/
|
|
67
|
-
has(id: string): boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Get number of registered plugins
|
|
70
|
-
*/
|
|
71
|
-
get size(): number;
|
|
72
|
-
/**
|
|
73
|
-
* Get a command handler for a command type
|
|
74
|
-
*
|
|
75
|
-
* @param commandType - The command type
|
|
76
|
-
* @returns The handler or undefined
|
|
77
|
-
*/
|
|
78
|
-
getCommandHandler(commandType: string): CommandHandler | undefined;
|
|
79
|
-
/**
|
|
80
|
-
* Get all registered command types
|
|
81
|
-
*
|
|
82
|
-
* @returns Array of command type strings
|
|
83
|
-
*/
|
|
84
|
-
getCommandTypes(): string[];
|
|
85
|
-
/**
|
|
86
|
-
* Check if a command type has a handler
|
|
87
|
-
*
|
|
88
|
-
* @param commandType - The command type
|
|
89
|
-
* @returns Whether a handler exists
|
|
90
|
-
*/
|
|
91
|
-
hasCommandHandler(commandType: string): boolean;
|
|
92
|
-
/**
|
|
93
|
-
* Get all MCP tools from all registered plugins
|
|
94
|
-
*
|
|
95
|
-
* @returns Array of MCP tool definitions
|
|
96
|
-
*/
|
|
97
|
-
getMcpTools(): McpToolDefinition[];
|
|
98
|
-
/**
|
|
99
|
-
* Get MCP tools from a specific plugin
|
|
100
|
-
*
|
|
101
|
-
* @param pluginId - Plugin ID
|
|
102
|
-
* @returns Array of MCP tool definitions
|
|
103
|
-
*/
|
|
104
|
-
getMcpToolsForPlugin(pluginId: string): McpToolDefinition[];
|
|
105
|
-
/**
|
|
106
|
-
* Get an MCP tool by name
|
|
107
|
-
*
|
|
108
|
-
* @param toolName - Tool name
|
|
109
|
-
* @returns The tool definition or undefined
|
|
110
|
-
*/
|
|
111
|
-
getMcpTool(toolName: string): McpToolDefinition | undefined;
|
|
112
|
-
/**
|
|
113
|
-
* Add an event listener
|
|
114
|
-
*
|
|
115
|
-
* @param listener - Event listener function
|
|
116
|
-
*/
|
|
117
|
-
addEventListener(listener: PluginEventListener): void;
|
|
118
|
-
/**
|
|
119
|
-
* Remove an event listener
|
|
120
|
-
*
|
|
121
|
-
* @param listener - Event listener function
|
|
122
|
-
*/
|
|
123
|
-
removeEventListener(listener: PluginEventListener): void;
|
|
124
|
-
/**
|
|
125
|
-
* Emit an event to all listeners
|
|
126
|
-
*/
|
|
127
|
-
private emit;
|
|
128
|
-
/**
|
|
129
|
-
* Clear all registered plugins
|
|
130
|
-
*
|
|
131
|
-
* Useful for testing or resetting state.
|
|
132
|
-
*/
|
|
133
|
-
clear(): void;
|
|
134
|
-
/**
|
|
135
|
-
* Get registry state for debugging
|
|
136
|
-
*/
|
|
137
|
-
getDebugInfo(): {
|
|
138
|
-
plugins: string[];
|
|
139
|
-
commandTypes: string[];
|
|
140
|
-
mcpTools: string[];
|
|
141
|
-
initialized: string[];
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Global plugin registry instance
|
|
146
|
-
*
|
|
147
|
-
* Use this for registering plugins and accessing their capabilities.
|
|
148
|
-
*/
|
|
149
|
-
declare const pluginRegistry: PluginRegistry;
|
|
150
|
-
/**
|
|
151
|
-
* Register multiple plugins at once
|
|
152
|
-
*
|
|
153
|
-
* @param plugins - Array of plugins to register
|
|
154
|
-
* @returns Array of registration results
|
|
155
|
-
*/
|
|
156
|
-
declare function registerPlugins(plugins: CorePlugin[], options?: PluginOptions): PluginRegistrationResult[];
|
|
157
|
-
/**
|
|
158
|
-
* Create a plugin registration helper with options pre-configured
|
|
159
|
-
*
|
|
160
|
-
* @param options - Default options for plugin registration
|
|
161
|
-
* @returns Registration function
|
|
162
|
-
*/
|
|
163
|
-
declare function createPluginRegistrar(options: PluginOptions): (plugin: CorePlugin) => PluginRegistrationResult;
|
|
164
|
-
|
|
165
|
-
export { PluginRegistry as P, createPluginRegistrar as c, pluginRegistry as p, registerPlugins as r };
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { L as LayoutOptions, a as Layout } from './types-DNrYr6yQ.mjs';
|
|
2
|
-
import { M as MeasuredBlock } from './measuredBlock-DZwz8zhD.mjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The mandatory Rust pagination source — the seam through which EVERY
|
|
6
|
-
* pagination pass (full, incremental-trigger, footnote pass 1, and each
|
|
7
|
-
* footnote-stabilization iteration in `layout/regions/footnoteLayout.ts`)
|
|
8
|
-
* runs the wasm `docx-layout` engine. There is no TypeScript pagination
|
|
9
|
-
* kernel anymore; this seam is the only way a `Layout` is produced.
|
|
10
|
-
*
|
|
11
|
-
* Contract (pinned by the golden corpus — `__golden__/rustParity.test.ts`
|
|
12
|
-
* proves the engine reproduces every golden byte-for-byte, and
|
|
13
|
-
* `__golden__/rustPaginationSeam.test.ts` proves this seam adds zero drift
|
|
14
|
-
* on top):
|
|
15
|
-
* - Input marshaling is exactly the golden convention:
|
|
16
|
-
* `JSON.stringify({ measured, options }, mapReplacer)` where the replacer
|
|
17
|
-
* turns `Map`s (`options.footnoteReservedHeights`) into plain objects
|
|
18
|
-
* keyed by decimal page number — the shape the Rust `LayoutOptions`
|
|
19
|
-
* deserializer expects.
|
|
20
|
-
* - `layout_document_json` in, `Layout` JSON out. Engine failures THROW —
|
|
21
|
-
* the layout pipeline surfaces the error (`onError` / console) and keeps
|
|
22
|
-
* the previous committed layout; nothing falls back to a hidden kernel.
|
|
23
|
-
* - The wasm engine is synchronous once loaded. Adapters gate layout passes
|
|
24
|
-
* on {@link RustPaginationSource.isReady} / `whenReady()` (the same
|
|
25
|
-
* defer-and-rerun pattern as the Rust measurement readiness gate), so
|
|
26
|
-
* `paginate` never runs against an unloaded engine. The wasm module is
|
|
27
|
-
* shared with the measurement engine, so in practice it is already
|
|
28
|
-
* resolved by the time the first measured pass reaches pagination.
|
|
29
|
-
*
|
|
30
|
-
* @packageDocumentation
|
|
31
|
-
* @public
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* The narrow seam `editor/computeLayout.ts` consumes: a synchronous
|
|
36
|
-
* pagination call over the measured blocks + options, plus the readiness
|
|
37
|
-
* surface adapters use to defer layout passes until the wasm engine has
|
|
38
|
-
* loaded. `paginate` throws if called before readiness or when the engine
|
|
39
|
-
* rejects the input — there is no fallback engine.
|
|
40
|
-
*
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
43
|
-
interface LayoutPaginationSource {
|
|
44
|
-
/** Paginate through the loaded Rust engine. Throws when not ready or on engine failure. */
|
|
45
|
-
paginate(measured: MeasuredBlock[], options: LayoutOptions): Layout;
|
|
46
|
-
/** Whether the wasm engine has finished its lazy load. */
|
|
47
|
-
isReady(): boolean;
|
|
48
|
-
/** Resolves when the engine is loaded; rejects if the load failed. */
|
|
49
|
-
whenReady(): Promise<void>;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Thin sync facade over the wasm pagination export (`layout_document_json`).
|
|
53
|
-
* Injectable so unit tests can script responses without loading wasm — the
|
|
54
|
-
* same pattern as the measurement seam's `RustTextEngine`.
|
|
55
|
-
*
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
58
|
-
interface RustLayoutEngine {
|
|
59
|
-
/** `{ measured, options }` JSON in, `Layout` JSON out. Throws on any input the engine rejects. */
|
|
60
|
-
layoutDocumentJson(input: string): string;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Lazily load the embedded wasm module and expose its pagination surface as
|
|
64
|
-
* a {@link RustLayoutEngine}. The dynamic `import()` keeps the ~800KB base64
|
|
65
|
-
* module out of the synchronous require graph; the module — and therefore
|
|
66
|
-
* the wasm instantiation — is shared with the measurement seam
|
|
67
|
-
* (`getRustTextEngine`), so only one load happens per session.
|
|
68
|
-
*
|
|
69
|
-
* @public
|
|
70
|
-
*/
|
|
71
|
-
declare function getRustLayoutEngine(): Promise<RustLayoutEngine>;
|
|
72
|
-
/** Counters for observability (passes paginated / engine errors). @public */
|
|
73
|
-
interface RustPaginationStats {
|
|
74
|
-
/** Layout passes paginated by the Rust engine. */
|
|
75
|
-
rustPaginated: number;
|
|
76
|
-
/** Passes where the engine threw (the pass produced no layout). */
|
|
77
|
-
engineErrors: number;
|
|
78
|
-
}
|
|
79
|
-
/** Options for {@link createRustPaginationSource}. @public */
|
|
80
|
-
interface RustPaginationSourceOptions {
|
|
81
|
-
/** Pre-loaded engine (tests). When set, the source is ready immediately. */
|
|
82
|
-
engine?: RustLayoutEngine;
|
|
83
|
-
/** Engine loader override (tests). Defaults to {@link getRustLayoutEngine}. */
|
|
84
|
-
loadEngine?: () => Promise<RustLayoutEngine>;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* The mandatory pagination source. Create with
|
|
88
|
-
* {@link createRustPaginationSource}; see the module doc for the contract.
|
|
89
|
-
*
|
|
90
|
-
* @public
|
|
91
|
-
*/
|
|
92
|
-
interface RustPaginationSource extends LayoutPaginationSource {
|
|
93
|
-
/** Snapshot of the pagination counters (never reset implicitly). */
|
|
94
|
-
getStats(): RustPaginationStats;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Build a {@link RustPaginationSource}. The wasm load starts immediately at
|
|
98
|
-
* construction; adapters defer layout passes until `isReady()` and re-run
|
|
99
|
-
* the pipeline off `whenReady()` — mirroring the Rust measurement readiness
|
|
100
|
-
* gate, and sharing the same underlying wasm module load.
|
|
101
|
-
*
|
|
102
|
-
* @public
|
|
103
|
-
*/
|
|
104
|
-
declare function createRustPaginationSource(opts?: RustPaginationSourceOptions): RustPaginationSource;
|
|
105
|
-
|
|
106
|
-
export { type LayoutPaginationSource as L, type RustLayoutEngine as R, type RustPaginationSource as a, type RustPaginationSourceOptions as b, type RustPaginationStats as c, createRustPaginationSource as d, getRustLayoutEngine as g };
|