@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/chunk-VBOTMRXV.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {b}from'./chunk-TTRUPDAB.mjs';var a=class{constructor(){b(this,"plugins",new Map);b(this,"commandHandlers",new Map);b(this,"eventListeners",new Set);b(this,"initialized",new Set);}register(e,r){let t=[];if(!e.id)return {success:false,error:"Plugin must have an id"};if(this.plugins.has(e.id))return {success:false,error:`Plugin '${e.id}' is already registered`};if(e.dependencies){for(let i of e.dependencies)if(!this.plugins.has(i))return {success:false,error:`Plugin '${e.id}' requires '${i}' which is not registered`}}if(e.commandHandlers)for(let[i,o]of Object.entries(e.commandHandlers)){if(this.commandHandlers.has(i)){let d=this.commandHandlers.get(i);t.push(`Command '${i}' from '${e.id}' overrides handler from '${d.pluginId}'`);}this.commandHandlers.set(i,{pluginId:e.id,handler:o});}if(this.plugins.set(e.id,e),e.initialize&&!this.initialized.has(e.id))try{let i=e.initialize();i instanceof Promise?i.then(()=>{this.initialized.add(e.id);}).catch(o=>{this.emit({type:"error",pluginId:e.id,error:o});}):this.initialized.add(e.id);}catch(i){this.emit({type:"error",pluginId:e.id,error:i});}return r?.debug&&console.log(`[PluginRegistry] Registered plugin: ${e.id}`),this.emit({type:"registered",plugin:e}),{success:true,plugin:e,warnings:t.length>0?t:void 0}}unregister(e){let r=this.plugins.get(e);if(!r)return false;for(let[t,i]of this.plugins)if(i.dependencies?.includes(e))return console.warn(`Cannot unregister '${e}': '${t}' depends on it`),false;for(let[t,{pluginId:i}]of this.commandHandlers)i===e&&this.commandHandlers.delete(t);if(r.destroy)try{let t=r.destroy();t instanceof Promise&&t.catch(i=>{this.emit({type:"error",pluginId:e,error:i});});}catch(t){this.emit({type:"error",pluginId:e,error:t});}return this.plugins.delete(e),this.initialized.delete(e),this.emit({type:"unregistered",pluginId:e}),true}get(e){return this.plugins.get(e)}getAll(){return Array.from(this.plugins.values())}has(e){return this.plugins.has(e)}get size(){return this.plugins.size}getCommandHandler(e){return this.commandHandlers.get(e)?.handler}getCommandTypes(){return Array.from(this.commandHandlers.keys())}hasCommandHandler(e){return this.commandHandlers.has(e)}getMcpTools(){let e=[];for(let r of this.plugins.values())r.mcpTools&&e.push(...r.mcpTools);return e}getMcpToolsForPlugin(e){return this.plugins.get(e)?.mcpTools||[]}getMcpTool(e){for(let r of this.plugins.values())if(r.mcpTools){let t=r.mcpTools.find(i=>i.name===e);if(t)return t}}addEventListener(e){this.eventListeners.add(e);}removeEventListener(e){this.eventListeners.delete(e);}emit(e){for(let r of this.eventListeners)try{r(e);}catch(t){console.error("[PluginRegistry] Event listener error:",t);}}clear(){for(let e of this.plugins.values())if(e.destroy)try{e.destroy();}catch{}this.plugins.clear(),this.commandHandlers.clear(),this.initialized.clear();}getDebugInfo(){return {plugins:Array.from(this.plugins.keys()),commandTypes:Array.from(this.commandHandlers.keys()),mcpTools:this.getMcpTools().map(e=>e.name),initialized:Array.from(this.initialized)}}},l=new a;function u(s,e){return s.map(r=>l.register(r,e))}function m(s){return e=>l.register(e,s)}export{a,l as b,u as c,m as d};
|
package/dist/chunk-VCER63GQ.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a}from'./chunk-BI3B33LI.mjs';import {b}from'./chunk-TTRUPDAB.mjs';var v="docx-editor-autosave",d=3e4,m=1440*60*1e3,S=2e3,c=1;function h(){try{let t="__docx_editor_test__";return localStorage.setItem(t,"test"),localStorage.removeItem(t),!0}catch{return false}}function l(t){return JSON.stringify({...t,originalBuffer:null})}function f(t){try{let s=JSON.parse(t);return !s||typeof s!="object"||!s.document||!s.savedAt?null:(s.version!==c&&console.warn("Auto-save data version mismatch, may need migration"),s)}catch{return null}}function g(t,s){let e=new Date(t).getTime();return Date.now()-e>s}var u=class extends a{constructor(e={}){super({status:"idle",lastSaveTime:null,hasRecoveryData:false,isEnabled:true});b(this,"storageKey");b(this,"interval");b(this,"maxAge");b(this,"saveOnChange");b(this,"debounceDelay");b(this,"onSaveCallback");b(this,"onErrorCallback");b(this,"onRecoveryAvailableCallback");b(this,"storageAvailable");b(this,"currentDocument",null);b(this,"lastSavedJson",null);b(this,"intervalTimer",null);b(this,"debounceTimer",null);b(this,"status","idle");b(this,"lastSaveTime",null);b(this,"_hasRecoveryData",false);b(this,"_isEnabled");this.storageKey=e.storageKey??v,this.interval=e.interval??d,this.maxAge=e.maxAge??m,this.saveOnChange=e.saveOnChange??true,this.debounceDelay=e.debounceDelay??S,this.onSaveCallback=e.onSave,this.onErrorCallback=e.onError,this.onRecoveryAvailableCallback=e.onRecoveryAvailable,this._isEnabled=true,this.storageAvailable=h(),this.checkRecoveryData();}onDocumentChanged(e){this.currentDocument=e,this._isEnabled&&this.saveOnChange&&e&&this.storageAvailable&&this.debounceSave();}async save(){if(!this.storageAvailable)return this.onErrorCallback?.(new Error("localStorage is not available")),false;let e=this.currentDocument;if(!e)return false;this.updateStatus("saving");try{let r=l(e);if(r===this.lastSavedJson)return this.updateStatus("saved"),!0;this.persistToStorage(r),this.lastSavedJson=r;let i=new Date;return this.lastSaveTime=i,this.updateStatus("saved"),this.onSaveCallback?.(i),!0}catch(r){return console.error("Auto-save failed:",r),this.updateStatus("error"),this.onErrorCallback?.(r),false}}clear(){if(this.storageAvailable)try{localStorage.removeItem(this.storageKey),this._hasRecoveryData=!1,this.lastSavedJson=null,this.emitSnapshot();}catch(e){console.error("Failed to clear auto-save:",e);}}getRecoveryData(){if(!this.storageAvailable)return null;try{let e=localStorage.getItem(this.storageKey);if(!e)return null;let r=f(e);return r?g(r.savedAt,this.maxAge)?(this.clear(),null):r:null}catch{return null}}acceptRecovery(){let e=this.getRecoveryData();return e?(this._hasRecoveryData=false,this.emitSnapshot(),e.document):null}dismissRecovery(){this.clear(),this._hasRecoveryData=false,this.emitSnapshot();}enable(){this._isEnabled=true,this.startInterval(),this.emitSnapshot();}disable(){this._isEnabled=false,this.stopTimers(),this.emitSnapshot();}startInterval(){this.stopTimers(),!(!this._isEnabled||!this.storageAvailable)&&(this.intervalTimer=setInterval(()=>{this.save();},this.interval));}destroy(){if(this.stopTimers(),this._isEnabled&&this.currentDocument&&this.storageAvailable)try{this.persistToStorage(l(this.currentDocument));}catch(e){console.error("Failed to save on destroy:",e);}}checkRecoveryData(){if(!this.storageAvailable)return;let e=this.getRecoveryData();e&&(this._hasRecoveryData=true,this.emitSnapshot(),this.onRecoveryAvailableCallback?.(e));}persistToStorage(e){let r={document:JSON.parse(e),savedAt:new Date().toISOString(),version:c};localStorage.setItem(this.storageKey,JSON.stringify(r));}debounceSave(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.save();},this.debounceDelay);}stopTimers(){this.intervalTimer&&(clearInterval(this.intervalTimer),this.intervalTimer=null),this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null);}updateStatus(e){this.status=e,this.emitSnapshot();}emitSnapshot(){this.setSnapshot({status:this.status,lastSaveTime:this.lastSaveTime,hasRecoveryData:this._hasRecoveryData,isEnabled:this._isEnabled});}};function y(t){if(!t)return "Never";let e=new Date().getTime()-t.getTime(),r=Math.floor(e/1e3),i=Math.floor(r/60),o=Math.floor(i/60);return r<10?"Just now":r<60?`${r} seconds ago`:i<60?`${i} minute${i===1?"":"s"} ago`:o<24?`${o} hour${o===1?"":"s"} ago`:t.toLocaleDateString()}function A(t){return {idle:"Ready",saving:"Saving...",saved:"Saved",error:"Save failed"}[t]}function T(t=v){try{let s=localStorage.getItem(t);return s?new Blob([s]).size:0}catch{return 0}}function E(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function _(){return h()}export{u as a,y as b,A as c,T as d,E as e,_ as f};
|
package/dist/chunk-WAUF2UC7.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {a}from'./chunk-BIQWVK5P.mjs';function E(t){let o=t?.package.headers;if(o){for(let n of o.values())if(n.watermark)return n.watermark}}function R(t){let o=t.package.headers;if(!o||o.size===0)return t;let n=false,s=new Map;for(let[a,i]of o)if(i.watermark){let{watermark:d,...u}=i;s.set(a,u),n=true;}else s.set(a,i);return n?{...t,package:{...t.package,headers:s}}:t}function y(t,o){let n=t.package.headers;if(!n||n.size===0)return t;let s=new Map;for(let[a,i]of n)s.set(a,{...i,watermark:{...o}});return {...t,package:{...t.package,headers:s}}}function $(t){let o=t.package.document,n=[];if(o.sections)for(let s of o.sections)s.properties&&n.push(s.properties);return o.finalSectionProperties&&n.push(o.finalSectionProperties),n}function M(t,o){let n=t.package,s=n.document,a$1=n.headers,i=$(t),d=new Set;if(a$1)for(let e of a$1.values())d.add(e.hdrFtrType);let u=!a$1||a$1.size===0,F=i.some(e=>e.titlePg),D=i.some(e=>e.evenAndOddHeaders),h=u,g=F&&!d.has("first"),k=D&&!d.has("even");if(!h&&!g&&!k)return t;let f=n.relationships?new Map(n.relationships):new Map,H=new Map(a$1??[]),p=new Set;for(let e of f.values())e.target&&p.add(e.target.replace(/^\/?word\//,"").toLowerCase());function T(){let e=1;for(;p.has(`header${e}.xml`);)e++;let r=`header${e}.xml`;return p.add(r.toLowerCase()),r}function v(e){let r=`rIdWmHdr${e[0].toUpperCase()}${e.slice(1)}`,c=1;for(;f.has(r);)r=`rIdWmHdr${e[0].toUpperCase()}${e.slice(1)}${c++}`;return f.set(r,{id:r,type:a.header,target:T()}),H.set(r,{type:"header",hdrFtrType:e,content:[],watermark:{...o}}),r}let l={};function x(e){return l[e]??(l[e]=v(e))}function m(e,r){let c=e?.headerReferences?[...e.headerReferences]:[];return c.some(I=>I.type===r)?e??{}:(c.push({type:r,rId:x(r)}),{...e??{},headerReferences:c})}function P(e){let r=e;return h&&(r=m(r,"default")),g&&r?.titlePg&&(r=m(r,"first")),k&&r?.evenAndOddHeaders&&(r=m(r,"even")),r}let W=P(s.finalSectionProperties),w=s.sections?.map(e=>({...e,properties:P(e.properties)??e.properties}));return {...t,package:{...n,relationships:f,headers:H,document:{...s,finalSectionProperties:W,...w?{sections:w}:{}}}}}function z(t,o){if(!o)return R(t);let n=y(t,o);return M(n,o)}
|
|
2
|
-
export{E as a,z as b};
|
package/dist/chunk-X4XDO3LZ.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {b as b$1,c as c$1}from'./chunk-OBQGPMPQ.mjs';import {b}from'./chunk-3UBMCDME.mjs';var c={top:4,bottom:4,left:7,right:7},h=200;function y(e,r){let o=e.kind??"<unknown>";throw new Error(`${r}: unhandled LayoutBlock kind "${o}". Add the case alongside the other LayoutBlock switches (see types.ts).`)}function x(e){return {pageWidth:e.size.w,pageHeight:e.size.h,marginLeft:e.margins.left,marginTop:e.margins.top,contentWidth:e.size.w-e.margins.left-e.margins.right,contentHeight:e.size.h-e.margins.top-e.margins.bottom}}function f(e,r,o){return u(e,r,o)}function u(e,r,o){let n=e.position?.vertical;if(!n)return r;let t=p(n.relativeTo,r,o);return n.align==="top"?t.base:n.align==="center"?t.size?t.base+(t.size-e.height)/2:r:n.align==="bottom"?t.size?t.base+t.size-e.height:r:n.posOffset!==void 0?t.base+b(n.posOffset):n.relativeTo==="paragraph"||n.relativeTo==="line"?r:t.base}function p(e,r,o){let n=o?.pageHeight??0,t=o?.marginTop??0,a=o?.contentHeight??0;switch(e){case "paragraph":case "line":return {base:r,size:0};case "page":return {base:-t,size:n};case "topMargin":return {base:-t,size:t};case "bottomMargin":return {base:a,size:t};default:return {base:0,size:a}}}function k(e){return b$1(e.wrapType)||e.wrapType==="topAndBottom"?false:c$1(e.wrapType)?true:e.displayMode==="float"&&e.cssFloat!=="none"}export{c as a,h as b,y as c,x as d,f as e,k as f};
|
package/dist/chunk-XQBCCJBO.mjs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-UIEJWORW.mjs';import {b as b$1,a as a$3}from'./chunk-6PW4CWUG.mjs';import {a as a$2}from'./chunk-OJOHXQNQ.mjs';import {h as h$1,s}from'./chunk-KVKLLTDP.mjs';import {a}from'./chunk-LDUWIM7M.mjs';import {b}from'./chunk-TTRUPDAB.mjs';var P=class o{constructor(t){b(this,"_document");b(this,"_pendingVariables");t instanceof ArrayBuffer||ArrayBuffer.isView(t)?this._document={package:{document:{content:[]}},originalBuffer:t instanceof ArrayBuffer?t:t.buffer}:this._document=t,this._pendingVariables={};}static async fromBuffer(t){let e=await a(t);return new o(e)}static fromDocument(t){return new o(t)}getDocument(){return this._document}getText(){let t=this._document.package.document;return this._getBodyText(t)}getFormattedText(){let t=[],e=this._document.package.document;for(let n of e.content)n.type==="paragraph"&&this._extractParagraphSegments(n,t);return t}getVariables(){return a$1(this._document)}getStyles(){let t=this._document.package.styles;if(!t?.styles)return [];let e=[];for(let[n,r]of Object.entries(t.styles))if(typeof r=="object"&&r!==null){let a=r;e.push({id:n,name:a.name||n,type:a.type==="numbering"?"paragraph":a.type||"paragraph",builtIn:a.default});}return e}getPageCount(){let t=this.getWordCount();return Math.max(1,Math.ceil(t/500))}getWordCount(){return this.getText().split(/\s+/).filter(n=>n.length>0).length}getCharacterCount(t=true){let e=this.getText();return t?e.length:e.replace(/\s/g,"").length}getParagraphCount(){return this._document.package.document.content.filter(t=>t.type==="paragraph").length}getTableCount(){return this._document.package.document.content.filter(t=>t.type==="table").length}getAgentContext(t=100){let e=this._document.package.document,n=e.content.filter(i=>i.type==="paragraph"),r=n.map((i,s)=>{let c=this._getParagraphText(i),p=i.formatting?.styleId;return {index:s,preview:c.slice(0,t),style:p,isHeading:p?.toLowerCase().includes("heading")||false,headingLevel:this._parseHeadingLevel(p),isListItem:!!i.listRendering,isEmpty:c.trim().length===0}}),a=(e.sections||[]).map((i,s)=>({index:s,paragraphCount:i.content?.length||0,pageSize:i.properties?.pageWidth&&i.properties?.pageHeight?{width:i.properties.pageWidth,height:i.properties.pageHeight}:void 0,isLandscape:i.properties?.orientation==="landscape",hasHeader:!!i.properties?.headerReferences?.length,hasFooter:!!i.properties?.footerReferences?.length}));return {paragraphCount:n.length,wordCount:this.getWordCount(),characterCount:this.getCharacterCount(),variables:this.getVariables(),variableCount:this.getVariables().length,availableStyles:this.getStyles(),outline:r,sections:a,hasTables:this.getTableCount()>0,hasImages:this._hasImages(),hasHyperlinks:this._hasHyperlinks()}}insertText(t,e,n={}){let r={type:"insertText",position:t,text:e,formatting:n.formatting};return this._executeCommand(r)}replaceRange(t,e,n={}){let r={type:"replaceText",range:t,text:e,formatting:n.formatting};return this._executeCommand(r)}deleteRange(t){let e={type:"deleteText",range:t};return this._executeCommand(e)}applyFormatting(t,e){let n={type:"formatText",range:t,formatting:e};return this._executeCommand(n)}applyStyle(t,e){let n={type:"applyStyle",paragraphIndex:t,styleId:e};return this._executeCommand(n)}applyParagraphFormatting(t,e){let n={type:"formatParagraph",paragraphIndex:t,formatting:e};return this._executeCommand(n)}insertTable(t,e,n,r={}){let a={type:"insertTable",position:t,rows:e,columns:n,data:r.data,hasHeader:r.hasHeader};return this._executeCommand(a)}insertImage(t,e,n={}){let r={type:"insertImage",position:t,src:e,width:n.width,height:n.height,alt:n.alt};return this._executeCommand(r)}insertHyperlink(t,e,n={}){let r={type:"insertHyperlink",range:t,url:e,displayText:n.displayText,tooltip:n.tooltip};return this._executeCommand(r)}removeHyperlink(t){let e={type:"removeHyperlink",range:t};return this._executeCommand(e)}insertParagraphBreak(t){let e={type:"insertParagraphBreak",position:t};return this._executeCommand(e)}mergeParagraphs(t,e){let n={type:"mergeParagraphs",paragraphIndex:t,count:e};return this._executeCommand(n)}setVariable(t,e){return this._pendingVariables[t]=e,this}setVariables(t){for(let[e,n]of Object.entries(t))this._pendingVariables[e]=n;return this}getPendingVariables(){return {...this._pendingVariables}}clearPendingVariables(){return this._pendingVariables={},this}async applyVariables(t){let e={...this._pendingVariables,...t};if(Object.keys(e).length===0)return this;let n=this._document.originalBuffer;if(!n)throw new Error("Cannot apply variables: no original buffer for processing");let{processTemplate:r}=await import('./processTemplate-HDUIZFJ5.mjs'),a$1=r(n,e),i=await a(a$1),s=new o(i);return s._pendingVariables={},s}async toBuffer(t){if(this._document.originalBuffer){if(t?.selective){let n=await a$2(this._document,this._document.originalBuffer,t.selective);if(n)return this._document.originalBuffer=n,n}let e=await h$1(this._document);return this._document.originalBuffer=e,e}return s(this._document)}async toBlob(t="application/vnd.openxmlformats-officedocument.wordprocessingml.document"){let e=await this.toBuffer();return new Blob([e],{type:t})}executeCommands(t){return new o(b$1(this._document,t))}_executeCommand(t){let e=new o(a$3(this._document,t));return e._pendingVariables={...this._pendingVariables},e}_getBodyText(t){let e=[];for(let n of t.content)n.type==="paragraph"?e.push(this._getParagraphText(n)):n.type==="table"&&e.push(this._getTableText(n));return e.join(`
|
|
2
|
-
`)}_getParagraphText(t){let e=[];for(let n of t.content)n.type==="run"?e.push(this._getRunText(n)):n.type==="hyperlink"&&e.push(this._getHyperlinkText(n));return e.join("")}_getRunText(t){return t.content.filter(e=>e.type==="text").map(e=>e.text).join("")}_getHyperlinkText(t){let e=[];for(let n of t.children)n.type==="run"&&e.push(this._getRunText(n));return e.join("")}_getTableText(t){let e=[];for(let n of t.rows)for(let r of n.cells)for(let a of r.content)a.type==="paragraph"&&e.push(this._getParagraphText(a));return e.join(" ")}_extractParagraphSegments(t,e){for(let n of t.content)if(n.type==="run"){let r=this._getRunText(n);r&&e.push({text:r,formatting:n.formatting});}else if(n.type==="hyperlink"){let r=n.href||"";for(let a of n.children)if(a.type==="run"){let i=this._getRunText(a);i&&e.push({text:i,formatting:a.formatting,isHyperlink:true,hyperlinkUrl:r});}}}_parseHeadingLevel(t){if(!t)return;let e=t.match(/heading\s*(\d)/i);if(e)return parseInt(e[1],10)}_hasImages(){let t=this._document.package.document;for(let e of t.content)if(e.type==="paragraph"){for(let n of e.content)if(n.type==="run"){for(let r of n.content)if(r.type==="drawing")return true}}return false}_hasHyperlinks(){let t=this._document.package.document;for(let e of t.content)if(e.type==="paragraph"){for(let n of e.content)if(n.type==="hyperlink")return true}return false}};async function Pt(o){return P.fromBuffer(o)}function Tt(o){return P.fromDocument(o)}function W(o,t={}){let{outlineMaxChars:e=100,maxOutlineParagraphs:n=50}=t,r=o.package.document,a=r.content.filter(y=>y.type==="paragraph"),i=$(a,e,n),s=a$1(o),c=U(o),p=G(r),u=q(r),d=J(r),f=r.content.some(y=>y.type==="table"),x=Q(r),l=X(r);return {paragraphCount:a.length,wordCount:u,characterCount:d,variables:s,variableCount:s.length,availableStyles:c,outline:i,sections:p,hasTables:f,hasImages:x,hasHyperlinks:l}}function wt(o,t,e={}){let{contextChars:n=200,includeSuggestions:r=true}=e,i=o.package.document.content.filter(m=>m.type==="paragraph"),s=i[t.start.paragraphIndex];if(!s)throw new Error(`Paragraph not found at index ${t.start.paragraphIndex}`);let c=g(s),p="";if(t.start.paragraphIndex===t.end.paragraphIndex)p=c.slice(t.start.offset,t.end.offset);else {let m=[];for(let b=t.start.paragraphIndex;b<=t.end.paragraphIndex;b++){let H=i[b];if(!H)continue;let _=g(H);b===t.start.paragraphIndex?m.push(_.slice(t.start.offset)):b===t.end.paragraphIndex?m.push(_.slice(0,t.end.offset)):m.push(_);}p=m.join(`
|
|
3
|
-
`);}let u=tt(i,t.start.paragraphIndex,t.start.offset,n),d=et(i,t.end.paragraphIndex,t.end.offset,n),f=nt(s,t.start.offset),x=s.formatting||{},l={index:t.start.paragraphIndex,fullText:c,style:s.formatting?.styleId,wordCount:v(c)},y=false,A=rt(s,t.start.offset),S=r?ot(p):[];return {selectedText:p,range:t,formatting:f,paragraphFormatting:x,textBefore:u,textAfter:d,paragraph:l,inTable:y,inHyperlink:A,suggestedActions:S}}function z(o){let t=W(o,{outlineMaxChars:50,maxOutlineParagraphs:10}),e=[`Document with ${t.paragraphCount} paragraphs, ${t.wordCount} words.`];t.hasTables&&e.push("Contains tables."),t.hasImages&&e.push("Contains images."),t.hasHyperlinks&&e.push("Contains hyperlinks."),t.variableCount>0&&e.push(`Has ${t.variableCount} template variables: ${t.variables.join(", ")}`);let n=t.outline.filter(r=>r.isHeading);if(n.length>0){e.push(`
|
|
4
|
-
Headings:`);for(let r of n.slice(0,5)){let a=r.headingLevel||1;e.push(`${" ".repeat(a-1)}- ${r.preview}`);}n.length>5&&e.push(` ... and ${n.length-5} more headings`);}return e.join(" ")}function $(o,t,e){let n=[];for(let r=0;r<Math.min(o.length,e);r++){let a=o[r],i=g(a),s=a.formatting?.styleId;n.push({index:r,preview:i.slice(0,t),style:s,isHeading:Y(s),headingLevel:Z(s),isListItem:!!a.listRendering,isEmpty:i.trim().length===0});}return n}function U(o){let t=o.package.styles;if(!t?.styles)return [];let e=[];for(let[n,r]of Object.entries(t.styles))if(typeof r=="object"&&r!==null){let a=r;e.push({id:n,name:a.name||n,type:a.type==="numbering"?"paragraph":a.type||"paragraph",builtIn:a.default});}return e}function G(o){return o.sections?o.sections.map((t,e)=>({index:e,paragraphCount:t.content?.length||0,pageSize:t.properties?.pageWidth&&t.properties?.pageHeight?{width:t.properties.pageWidth,height:t.properties.pageHeight}:void 0,isLandscape:t.properties?.orientation==="landscape",hasHeader:!!t.properties?.headerReferences?.length,hasFooter:!!t.properties?.footerReferences?.length})):[]}function q(o){let t=0;for(let e of o.content)if(e.type==="paragraph"){let n=g(e);t+=v(n);}else e.type==="table"&&(t+=K(e));return t}function v(o){return o.split(/\s+/).filter(e=>e.length>0).length}function J(o){let t=0;for(let e of o.content)if(e.type==="paragraph"){let n=g(e);t+=n.length;}else e.type==="table"&&(t+=N(e));return t}function K(o){let t=0;for(let e of o.rows)for(let n of e.cells)for(let r of n.content)if(r.type==="paragraph"){let a=g(r);t+=v(a);}return t}function N(o){let t=0;for(let e of o.rows)for(let n of e.cells)for(let r of n.content)if(r.type==="paragraph"){let a=g(r);t+=a.length;}return t}function g(o){let t=[];for(let e of o.content)e.type==="run"?t.push(T(e)):e.type==="hyperlink"&&t.push(F(e));return t.join("")}function T(o){return o.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function F(o){let t=[];for(let e of o.children)e.type==="run"&&t.push(T(e));return t.join("")}function Q(o){for(let t of o.content)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="run"){for(let n of e.content)if(n.type==="drawing")return true}}return false}function X(o){for(let t of o.content)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="hyperlink")return true}return false}function Y(o){return o?o.toLowerCase().includes("heading"):false}function Z(o){if(!o)return;let t=o.match(/heading\s*(\d)/i);if(t)return parseInt(t[1],10)}function tt(o,t,e,n){let r=[],a=0,i=o[t];if(i){let p=g(i).slice(0,e);r.unshift(p),a+=p.length;}for(let c=t-1;c>=0&&a<n;c--){let p=o[c];if(!p)continue;let u=g(p);r.unshift(u),a+=u.length;}let s=r.join(`
|
|
5
|
-
`);return s.length>n?"..."+s.slice(-n):s}function et(o,t,e,n){let r=[],a=0,i=o[t];if(i){let p=g(i).slice(e);r.push(p),a+=p.length;}for(let c=t+1;c<o.length&&a<n;c++){let p=o[c];if(!p)continue;let u=g(p);r.push(u),a+=u.length;}let s=r.join(`
|
|
6
|
-
`);return s.length>n?s.slice(0,n)+"...":s}function nt(o,t){let e=0;for(let n of o.content)if(n.type==="run"){let r=T(n),a=e,i=e+r.length;if(t>=a&&t<i)return n.formatting||{};e=i;}else if(n.type==="hyperlink"){let r=F(n),a=e,i=e+r.length;if(t>=a&&t<i){for(let s of n.children)if(s.type==="run")return s.formatting||{}}e=i;}return {}}function rt(o,t){let e=0;for(let n of o.content)if(n.type==="run"){let r=T(n);e+=r.length;}else if(n.type==="hyperlink"){let r=F(n),a=e,i=e+r.length;if(t>=a&&t<i)return true;e=i;}return false}function ot(o,t,e){let n=[];return o.length>0&&(n.push({id:"rewrite",label:"Rewrite",description:"Rewrite this text",priority:10},{id:"summarize",label:"Summarize",description:"Summarize this text",priority:9}),o.length>200&&n.push({id:"summarize",label:"Summarize",description:"Create a shorter version",priority:8}),o.length<50&&o.split(/\s+/).length<10&&n.push({id:"expand",label:"Expand",description:"Add more details",priority:8}),n.push({id:"fixGrammar",label:"Fix Grammar",description:"Fix grammar and spelling",priority:7}),n.push({id:"translate",label:"Translate",description:"Translate to another language",priority:6}),n.push({id:"makeFormal",label:"Make Formal",description:"Use formal tone",priority:5},{id:"makeCasual",label:"Make Casual",description:"Use casual tone",priority:4})),n.sort((r,a)=>(a.priority||0)-(r.priority||0)),n}function at(o,t,e={}){let{contextCharsBefore:n=200,contextCharsAfter:r=200,includeSuggestions:a=true}=e,i=o.package.document,s=i.content.filter(m=>m.type==="paragraph");if(t.start.paragraphIndex>=s.length)throw new Error(`Invalid start paragraph index: ${t.start.paragraphIndex}`);let c=s[t.start.paragraphIndex],p=it(s,t),u=st(s,t.start,n),d=ct(s,t.end,r),f=pt(c,t.start.offset),x=c.formatting||{},l={index:t.start.paragraphIndex,fullText:h(c),style:c.formatting?.styleId,wordCount:R(h(c))},y=lt(i,t.start),A=gt(c,t.start.offset),S=a?ft(p):[];return {selectedText:p,range:t,formatting:f,paragraphFormatting:x,textBefore:u,textAfter:d,paragraph:l,inTable:y,inHyperlink:A,suggestedActions:S}}function Rt(o,t,e={}){let n=at(o,t,e),{includeDocumentSummary:r=true}=e,i=o.package.document.content.filter(l=>l.type==="paragraph"),s=R(n.selectedText),c=n.selectedText.length,p=t.start.paragraphIndex!==t.end.paragraphIndex,u=[];for(let l=t.start.paragraphIndex;l<=t.end.paragraphIndex;l++)u.push(l);let d=mt(i,t),f=r?z(o):void 0,x=ht(n.selectedText);return {...n,documentSummary:f,wordCount:s,characterCount:c,isMultiParagraph:p,paragraphIndices:u,detectedLanguage:x,contentType:d}}function Ht(o,t){let n=o.package.document.content.filter(s=>s.type==="paragraph"),r=[];for(let s=t.start.paragraphIndex;s<=t.end.paragraphIndex;s++){let c=n[s];if(!c)continue;let p=s===t.start.paragraphIndex?t.start.offset:0,u=s===t.end.paragraphIndex?t.end.offset:1/0;ut(c,p,u,r);}let a=r.length<=1||r.every(s=>dt(s,r[0]));return {predominant:r.length>0?r[0]:{},isConsistent:a,allFormatting:r}}function it(o,t){if(t.start.paragraphIndex===t.end.paragraphIndex){let n=o[t.start.paragraphIndex];return n?h(n).slice(t.start.offset,t.end.offset):""}let e=[];for(let n=t.start.paragraphIndex;n<=t.end.paragraphIndex;n++){let r=o[n];if(!r)continue;let a=h(r);n===t.start.paragraphIndex?e.push(a.slice(t.start.offset)):n===t.end.paragraphIndex?e.push(a.slice(0,t.end.offset)):e.push(a);}return e.join(`
|
|
7
|
-
`)}function st(o,t,e){let n=[],r=0,a=o[t.paragraphIndex];if(a){let c=h(a).slice(0,t.offset);n.unshift(c),r+=c.length;}for(let s=t.paragraphIndex-1;s>=0&&r<e;s--){let c=o[s];if(!c)continue;let p=h(c);n.unshift(p),r+=p.length;}let i=n.join(`
|
|
8
|
-
`);return i.length>e?"..."+i.slice(-e):i}function ct(o,t,e){let n=[],r=0,a=o[t.paragraphIndex];if(a){let c=h(a).slice(t.offset);n.push(c),r+=c.length;}for(let s=t.paragraphIndex+1;s<o.length&&r<e;s++){let c=o[s];if(!c)continue;let p=h(c);n.push(p),r+=p.length;}let i=n.join(`
|
|
9
|
-
`);return i.length>e?i.slice(0,e)+"...":i}function pt(o,t){let e=0;for(let n of o.content)if(n.type==="run"){let r=C(n),a=e+r.length;if(t>=e&&t<a)return n.formatting||{};e=a;}else if(n.type==="hyperlink"){let r=I(n),a=e+r.length;if(t>=e&&t<a){for(let i of n.children)if(i.type==="run")return i.formatting||{}}e=a;}return {}}function ut(o,t,e,n){let r=0;for(let a of o.content)if(a.type==="run"){let i=C(a),s=r,c=r+i.length;c>t&&s<e&&a.formatting&&n.push({...a.formatting}),r=c;}else if(a.type==="hyperlink"){let i=I(a),s=r,c=r+i.length;if(c>t&&s<e)for(let p of a.children)p.type==="run"&&p.formatting&&n.push({...p.formatting});r=c;}}function lt(o,t){return false}function gt(o,t){let e=0;for(let n of o.content)if(n.type==="run"){let r=C(n);e+=r.length;}else if(n.type==="hyperlink"){let r=I(n),a=e,i=e+r.length;if(t>=a&&t<i)return true;e=i;}return false}function ft(o,t,e){let n=[];if(!o||o.trim().length===0)return n;n.push({id:"askAI",label:"Ask AI",description:"Ask AI about this text",priority:11},{id:"rewrite",label:"Rewrite",description:"Rewrite this text differently",priority:10});let r=R(o);return r>50&&n.push({id:"summarize",label:"Summarize",description:"Create a shorter version",priority:9}),r<20&&n.push({id:"expand",label:"Expand",description:"Add more details",priority:9}),n.push({id:"fixGrammar",label:"Fix Grammar",description:"Fix grammar and spelling",priority:7},{id:"translate",label:"Translate",description:"Translate to another language",priority:6},{id:"explain",label:"Explain",description:"Explain what this means",priority:5}),n.push({id:"makeFormal",label:"Make Formal",description:"Use formal tone",priority:4},{id:"makeCasual",label:"Make Casual",description:"Use casual tone",priority:3}),n.sort((a,i)=>(i.priority||0)-(a.priority||0)),n}function mt(o,t){let e=new Set;for(let n=t.start.paragraphIndex;n<=t.end.paragraphIndex;n++){let r=o[n];r&&(r.listRendering?e.add("list"):r.formatting?.styleId?.toLowerCase().includes("heading")?e.add("heading"):e.add("prose"));}return e.size>1?"mixed":e.has("list")?"list":e.has("heading")?"heading":"prose"}function ht(o){return /[а-яА-ЯёЁ]/.test(o)?"ru":/[一-龯]/.test(o)?"zh":/[ひらがなカタカナ]/.test(o)||/[\u3040-\u309F\u30A0-\u30FF]/.test(o)?"ja":/[가-힣]/.test(o)?"ko":/[àâäéèêëïîôùûüç]/i.test(o)?"fr":/[äöüß]/i.test(o)?"de":/[áéíóúñ]/i.test(o)?"es":"en"}function h(o){let t=[];for(let e of o.content)e.type==="run"?t.push(C(e)):e.type==="hyperlink"&&t.push(I(e));return t.join("")}function C(o){return o.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function I(o){let t=[];for(let e of o.children)e.type==="run"&&t.push(C(e));return t.join("")}function R(o){return o.split(/\s+/).filter(t=>t.length>0).length}function dt(o,t){let e=Object.keys(o),n=Object.keys(t);return e.length!==n.length?false:e.every(r=>{let a=o[r],i=t[r];return a===i})}export{P as a,Pt as b,Tt as c,W as d,wt as e,z as f,at as g,Rt as h,Ht as i};
|
package/dist/chunk-XWUOLYRQ.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {a}from'./chunk-FPZBTOD6.mjs';import {c as c$1}from'./chunk-H3JCIGWK.mjs';var m=new TextEncoder;function I(e){if(!e)return d({abstractNums:[],nums:[]});let t=c$1({"[Content_Types].xml":m.encode('<?xml version="1.0" encoding="UTF-8"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/><Override PartName="/word/numbering.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"/></Types>'),"word/document.xml":m.encode('<?xml version="1.0" encoding="UTF-8"?><w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body><w:p/></w:body></w:document>'),"word/_rels/document.xml.rels":m.encode('<?xml version="1.0" encoding="UTF-8"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering" Target="numbering.xml"/></Relationships>'),"word/numbering.xml":m.encode(e)}),r=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),n=a(r,{parseHeadersFooters:false,parseNotes:false,detectVariables:false}).document.package.numbering??{abstractNums:[],nums:[]};return d(n)}var b=new WeakMap;function T(e){let t=b.get(e);return t||(t=d(e),b.set(e,t)),t}function d(e){let t=new Map;for(let n of e.abstractNums)t.set(n.abstractNumId,n);let r=new Map;for(let n of e.nums)r.set(n.numId,n);return {definitions:e,getLevel(n,i){let s=r.get(n);if(!s)return null;if(s.levelOverrides){let o=s.levelOverrides.find(l=>l.ilvl===i);if(o){if(o.lvl)return o.lvl;let l=t.get(s.abstractNumId);if(l){let u=l.levels.find(x=>x.ilvl===i);if(u&&o.startOverride!==void 0)return {...u,start:o.startOverride}}}}let a=t.get(s.abstractNumId);if(!a)return null;if(a.numStyleLink&&a.levels.length===0){for(let o of t.values())if(o.styleLink===a.numStyleLink&&o.levels.length>0){a=o;break}}return a.levels.find(o=>o.ilvl===i)??null},getAbstract(n){return t.get(n)??null},getInstance(n){return r.get(n)??null},hasNumbering(n){return r.has(n)}}}function k(e,t){let{numId:r,ilvl:n=0}=e;if(r===void 0||r===0)return null;let i=t.getLevel(r,n);if(!i)return null;let s=[];for(let l=0;l<=n;l+=1){let u=t.getLevel(r,l);s.push(u?.numFmt??"decimal");}let a=t.getInstance(r),o=a?.levelOverrides?.find(l=>l.ilvl===n);return {level:n,numId:r,marker:i.lvlText,isBullet:i.numFmt==="bullet",numFmt:i.numFmt,markerHidden:i.rPr?.hidden||void 0,markerFontFamily:i.rPr?.fontFamily?.ascii||i.rPr?.fontFamily?.hAnsi||void 0,markerFontSize:i.rPr?.fontSize?i.rPr.fontSize/2:void 0,markerSuffix:i.suffix,levelNumFmts:s,abstractNumId:a?.abstractNumId,startOverride:o?.startOverride}}function N(e,t){switch(t){case "decimal":return e.toString();case "decimalZero":return c(e,2);case "decimalZero3":return c(e,3);case "decimalZero4":return c(e,4);case "decimalZero5":return c(e,5);case "upperRoman":return g(e).toUpperCase();case "lowerRoman":return g(e).toLowerCase();case "upperLetter":return v(e).toUpperCase();case "lowerLetter":return v(e).toLowerCase();case "ordinal":return h(e);case "bullet":return "\u2022";case "none":return "";case "decimalEnclosedParen":return `(${e})`;case "numberInDash":return `-${e}-`;default:return e.toString()}}function c(e,t){return e<0?e.toString():e.toString().padStart(t,"0")}function g(e){if(e<=0||e>3999)return e.toString();let t=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],r="",n=e;for(let[i,s]of t)for(;n>=i;)r+=s,n-=i;return r}function v(e){if(e<=0)return "";let t="",r=e;for(;r>0;)r--,t=String.fromCharCode(97+r%26)+t,r=Math.floor(r/26);return t}function h(e){let t=["th","st","nd","rd"],r=e%100;return e+(t[(r-20)%10]||t[r]||t[0])}function C(e,t,r){let n=e;for(let i=1;i<=9;i++){let s=`%${i}`;if(n.includes(s)){let a=i-1,o=t[a]??1,l=r[a]??"decimal",u=N(o,l);n=n.replace(s,u);}}return n}function M(e){if(e.lvlText)return e.lvlText;let t=e.rPr?.fontFamily?.ascii||e.rPr?.fontFamily?.hAnsi;if(t){let r=t.toLowerCase();if(r==="symbol")return "\u2022";if(r.includes("wingding"))return "\u2751"}return "\u2022"}function S(e){return e.numFmt==="bullet"||e.numFmt==="none"}
|
|
2
|
-
export{I as a,T as b,d as c,k as d,N as e,c as f,C as g,M as h,S as i};
|
package/dist/chunk-XYH6XWP3.mjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import {b as b$1,f as f$1}from'./chunk-O2QSE2I7.mjs';import {b}from'./chunk-UIEJWORW.mjs';import {a}from'./chunk-LDUWIM7M.mjs';function D(o){return typeof o=="object"&&o!==null&&("_def"in o||"parse"in o||"safeParse"in o)}function C(o,i){let s=i,{position:n,variableName:t}=s,e=JSON.parse(JSON.stringify(o)),a=e.package.document.content.filter(m=>m.type==="paragraph");if(n.paragraphIndex>=a.length)throw new Error(`Paragraph index ${n.paragraphIndex} out of bounds`);let l=a[n.paragraphIndex],p=`{${t}}`;return M(l,n.offset,p),e.templateVariables||(e.templateVariables=[]),e.templateVariables.includes(t)||e.templateVariables.push(t),e}function P(o,i){let s=i,{range:n,variableName:t}=s,e=JSON.parse(JSON.stringify(o)),a=e.package.document.content.filter(m=>m.type==="paragraph");if(n.start.paragraphIndex!==n.end.paragraphIndex)throw new Error("Template variable replacement cannot span multiple paragraphs");if(n.start.paragraphIndex>=a.length)throw new Error(`Paragraph index ${n.start.paragraphIndex} out of bounds`);let l=a[n.start.paragraphIndex];V(l,n.start.offset,n.end.offset);let p=`{${t}}`;return M(l,n.start.offset,p),e.templateVariables||(e.templateVariables=[]),e.templateVariables.includes(t)||e.templateVariables.push(t),e}function M(o,i,s){let n=0,t=false;for(let e=0;e<o.content.length;e++){let r=o.content[e];if(r.type==="run"){let a=x(r),l=n,p=n+a.length;if(!t&&i>=l&&i<=p){let m=i-l,b=a.slice(0,m),y=a.slice(m),d=[];for(let c=0;c<e;c++)d.push(o.content[c]);b&&d.push({type:"run",formatting:r.formatting,content:[{type:"text",text:b}]}),d.push({type:"run",formatting:r.formatting,content:[{type:"text",text:s}]}),y&&d.push({type:"run",formatting:r.formatting,content:[{type:"text",text:y}]});for(let c=e+1;c<o.content.length;c++)d.push(o.content[c]);o.content=d,t=true;break}n=p;}else if(r.type==="hyperlink")for(let a of r.children)a.type==="run"&&(n+=x(a).length);}t||o.content.push({type:"run",content:[{type:"text",text:s}]});}function V(o,i,s){let n=[],t=0;for(let e of o.content)if(e.type==="run"){let r=x(e),a=t,l=t+r.length;if(l<=i||a>=s)n.push(e);else {let p="";a<i&&(p+=r.slice(0,i-a)),l>s&&(p+=r.slice(s-a)),p.length>0&&n.push({type:"run",formatting:e.formatting,content:[{type:"text",text:p}]});}t=l;}else n.push(e);o.content=n;}function x(o){return o.content.filter(i=>i.type==="text").map(i=>i.text).join("")}var f={type:"string",description:"Document ID from a previous docx_load call"},R={type:"object",properties:{paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)"},offset:{type:"number",description:"Character offset within the paragraph"}},required:["paragraphIndex","offset"]},S={name:"docx_get_variables",description:`List all template variables ({name} format) found in the document.
|
|
2
|
-
Returns variable names without braces, along with their locations (body, headers, footers, etc.).
|
|
3
|
-
Use this to discover what data fields a template document expects.`,inputSchema:{type:"object",properties:{documentId:f},required:["documentId"]},handler:async(o,i)=>{let{documentId:s}=o,n=i.session.documents.get(s);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};try{let t=b(n.document);return {content:[{type:"text",text:JSON.stringify({variables:t.variables,count:t.variables.length,totalOccurrences:t.totalOccurrences,byLocation:t.byLocation},null,2)}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to detect variables: ${t.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low",examples:[{description:"Get all variables from a loaded document",input:{documentId:"doc_123"},output:'{"variables": ["customer_name", "invoice_date"], "count": 2}'}]}},k={name:"docx_insert_variable",description:`Insert a template variable placeholder ({name}) at a specific position in the document.
|
|
4
|
-
The variable can later be substituted with actual values using docx_apply_template.
|
|
5
|
-
Variable names should follow the pattern: letters, numbers, underscores, starting with a letter.`,inputSchema:{type:"object",properties:{documentId:f,position:R,variableName:{type:"string",description:'Variable name without braces (e.g., "customer_name"). Will be inserted as {customer_name}',pattern:"^[a-zA-Z_][a-zA-Z0-9_]*$"}},required:["documentId","position","variableName"]},handler:async(o,i)=>{let{documentId:s,position:n,variableName:t}=o,e=i.session.documents.get(s);if(!e)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};if(!/^[a-zA-Z_][a-zA-Z0-9_\-.]*$/.test(t))return {isError:true,content:[{type:"text",text:`Invalid variable name: ${t}. Must start with letter/underscore and contain only alphanumeric, underscore, hyphen, or dot.`}]};try{let{executeCommand:r}=await import('./executor-7O2RBJ2B.mjs'),a=r(e.document,{type:"insertText",position:n,text:`{${t}}`});return e.document=a,e.lastModified=Date.now(),a.templateVariables||(a.templateVariables=[]),a.templateVariables.includes(t)||a.templateVariables.push(t),{content:[{type:"text",text:JSON.stringify({success:!0,variable:t,insertedAs:`{${t}}`,position:n})}]}}catch(r){return {isError:true,content:[{type:"text",text:`Failed to insert variable: ${r.message}`}]}}},annotations:{category:"template",readOnly:false,complexity:"low",examples:[{description:"Insert customer name variable at start of first paragraph",input:{documentId:"doc_123",position:{paragraphIndex:0,offset:0},variableName:"customer_name"}}]}},E={name:"docx_apply_template",description:`Substitute template variables with actual values in the document.
|
|
6
|
-
Replaces all {variable} placeholders with the corresponding values provided.
|
|
7
|
-
Preserves all formatting (fonts, styles, colors, tables).
|
|
8
|
-
Use docx_get_variables first to discover what variables exist in the document.`,inputSchema:{type:"object",properties:{documentId:f,variables:{type:"object",description:'Map of variable names to values (e.g., {"customer_name": "John Doe", "date": "2024-01-15"})',additionalProperties:{type:"string"}},keepUnmatchedVariables:{type:"boolean",description:"If true, keep {variable} placeholders for variables not in the map. If false, replace with empty string. Default: true",default:true}},required:["documentId","variables"]},handler:async(o,i)=>{let{documentId:s,variables:n,keepUnmatchedVariables:t=true}=o,e=i.session.documents.get(s);if(!e)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};if(!e.buffer)return {isError:true,content:[{type:"text",text:"Cannot apply template: document was not loaded from a DOCX buffer"}]};try{let r=b$1(e.buffer,n,{nullGetter:t?"keep":"empty"}),a$1=await a(r.buffer);return e.document=a$1,e.buffer=r.buffer,e.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedVariables:r.replacedVariables,unreplacedVariables:r.unreplacedVariables,warnings:r.warnings})}]}}catch(r){return {isError:true,content:[{type:"text",text:`Failed to apply template: ${r.message}`}]}}},annotations:{category:"template",readOnly:false,complexity:"medium",examples:[{description:"Fill in customer and date values",input:{documentId:"doc_123",variables:{customer_name:"Jane Smith",invoice_date:"2024-02-15",amount:"$1,234.56"}}}]}},_={name:"docx_validate_template",description:`Validate that a document is a valid docxtemplater template.
|
|
9
|
-
Checks for syntax errors like unclosed braces, invalid tag names, etc.
|
|
10
|
-
Returns validation result with any errors found and list of valid tags.`,inputSchema:{type:"object",properties:{documentId:f},required:["documentId"]},handler:async(o,i)=>{let{documentId:s}=o,n=i.session.documents.get(s);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};if(!n.buffer)return {isError:true,content:[{type:"text",text:"Cannot validate template: document was not loaded from a DOCX buffer"}]};try{let t=f$1(n.buffer);return {content:[{type:"text",text:JSON.stringify({valid:t.valid,tags:t.tags,errors:t.errors.map(e=>({message:e.message,variable:e.variable,type:e.type}))},null,2)}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to validate template: ${t.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low"}},I=[S,k,E,_];var J={id:"docxtemplater",name:"Docxtemplater",version:"1.0.0",description:"Template variable support using standard docxtemplater syntax ({variable})",commandHandlers:{insertTemplateVariable:C,replaceWithTemplateVariable:P},mcpTools:I};export{D as a,J as b};
|
package/dist/chunk-YBIM6UJV.mjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
function d(t){let e=[];for(let n of t.content)n.type==="run"?e.push(g(n)):n.type==="hyperlink"&&e.push(y(n));return e.join("")}function g(t){return t.content.filter(e=>e.type==="text").map(e=>e.text).join("")}function y(t){let e=[];for(let n of t.children)n.type==="run"&&e.push(g(n));return e.join("")}function B(t){let e=[];for(let n of t.rows)for(let o of n.cells)for(let r of o.content)r.type==="paragraph"&&e.push(d(r));return e.join(" ")}function Ct(t){let e=[];for(let n of t.content)n.type==="paragraph"?e.push(d(n)):n.type==="table"&&e.push(B(n));return e.join(`
|
|
2
|
-
`)}function A(t){return t.split(/\s+/).filter(n=>n.length>0).length}function mt(t,e=true){return e?t.length:t.replace(/\s/g,"").length}function kt(t){let e=0;for(let n of t.content)n.type==="paragraph"?e+=A(d(n)):n.type==="table"&&(e+=J(n));return e}function J(t){let e=0;for(let n of t.rows)for(let o of n.cells)for(let r of o.content)r.type==="paragraph"&&(e+=A(d(r)));return e}function xt(t){let e=0;for(let n of t.content)n.type==="paragraph"?e+=d(n).length:n.type==="table"&&(e+=G(n));return e}function G(t){let e=0;for(let n of t.rows)for(let o of n.cells)for(let r of o.content)r.type==="paragraph"&&(e+=d(r).length);return e}function bt(t,e,n){let o=[],r=0,a=t[e.paragraphIndex];if(a){let s=d(a).slice(0,e.offset);o.unshift(s),r+=s.length;}for(let c=e.paragraphIndex-1;c>=0&&r<n;c--){let s=t[c];if(!s)continue;let l=d(s);o.unshift(l),r+=l.length;}let i=o.join(`
|
|
3
|
-
`);return i.length>n?"..."+i.slice(-n):i}function wt(t,e,n){let o=[],r=0,a=t[e.paragraphIndex];if(a){let s=d(a).slice(e.offset);o.push(s),r+=s.length;}for(let c=e.paragraphIndex+1;c<t.length&&r<n;c++){let s=t[c];if(!s)continue;let l=d(s);o.push(l),r+=l.length;}let i=o.join(`
|
|
4
|
-
`);return i.length>n?i.slice(0,n)+"...":i}function St(t,e){let n=0;for(let o of t.content)if(o.type==="run"){let r=g(o),a=n+r.length;if(e>=n&&e<a)return o.formatting||{};n=a;}else if(o.type==="hyperlink"){let r=y(o),a=n+r.length;if(e>=n&&e<a){for(let i of o.children)if(i.type==="run")return i.formatting||{}}n=a;}return {}}function Tt(t,e){let n=0;for(let o of t.content)if(o.type==="run"){let r=g(o);n+=r.length;}else if(o.type==="hyperlink"){let r=y(o),a=n,i=n+r.length;if(e>=a&&e<i)return true;n=i;}return false}function Pt(t,e){let n=0;for(let o of t.content)if(o.type==="run"){let r=g(o);n+=r.length;}else if(o.type==="hyperlink"){let r=y(o),a=n,i=n+r.length;if(e>=a&&e<i)return o;n=i;}}function Bt(t){return t?t.toLowerCase().includes("heading"):false}function It(t){if(!t)return;let e=t.match(/heading\s*(\d)/i);if(e)return parseInt(e[1],10)}function Ft(t){for(let e of t.content)if(e.type==="paragraph"){for(let n of e.content)if(n.type==="run"){for(let o of n.content)if(o.type==="drawing")return true}}return false}function Dt(t){for(let e of t.content)if(e.type==="paragraph"){for(let n of e.content)if(n.type==="hyperlink")return true}return false}function Ot(t){return t.content.some(e=>e.type==="table")}function K(t){return t.content.filter(e=>e.type==="paragraph")}function Mt(t,e){return K(t)[e]}function Et(t,e){let n=0;for(let o=0;o<t.content.length;o++)if(t.content[o].type==="paragraph"){if(n===e)return o;n++;}return -1}function Q(t){return "package"in t?t.package.document:t}function tt(t){return t.type==="inlineSdt"?Y(t.content):q(t.content)}function q(t){let e=[];for(let n of t)n.type==="paragraph"?e.push(d(n)):n.type==="table"?e.push(B(n)):n.type==="blockSdt"&&e.push(q(n.content));return e.join(`
|
|
5
|
-
`)}function Y(t){let e=[];for(let n of t)switch(n.type){case "run":e.push(g(n));break;case "hyperlink":e.push(y(n));break;case "simpleField":for(let o of n.content)e.push(o.type==="run"?g(o):y(o));break;case "complexField":for(let o of n.fieldResult)e.push(g(o));break;case "inlineSdt":e.push(Y(n.content));break;case "mathEquation":n.plainText&&e.push(n.plainText);break}return e.join("")}function x(t,e){return !(e.tag!==void 0&&t.tag!==e.tag||e.alias!==void 0&&t.alias!==e.alias||e.id!==void 0&&t.id!==e.id||e.type!==void 0&&t.sdtType!==e.type)}function W(t,e,n,o){let r=t.properties;return {tag:r.tag,alias:r.alias,id:r.id,sdtType:r.sdtType,lock:r.lock,listItems:r.listItems,placeholder:r.placeholder,showingPlaceholder:r.showingPlaceholder,checked:r.checked,dateFormat:r.dateFormat,dataBinding:r.dataBinding,text:tt(t),path:e,depth:n,kind:t.type==="inlineSdt"?"inline":"block",location:o}}function et(t,e={},n={}){let o=[],r=(i,c,s,l)=>{for(let p of i)p.type==="inlineSdt"&&(x(p.properties,e)&&o.push(W(p,s,l,c)),r(p.content,c,s,l+1));},a=(i,c,s,l)=>{for(let p=0;p<i.length;p++){let u=i[p],f=[...s,p];if(u.type==="blockSdt")x(u.properties,e)&&o.push(W(u,f,l,c)),a(u.content,c,f,l+1);else if(u.type==="table")for(let k of u.rows)for(let w of k.cells)a(w.content,c,f,l);else u.type==="paragraph"&&r(u.content,c,f,l);}};if(a(Q(t).content,{part:"body"},[],0),n.includeHeadersFooters&&"package"in t){let i=(c,s)=>{if(c)for(let l of [...c.keys()].sort())a(c.get(l).content,{part:s,rId:l},[],0);};i(t.package.headers,"header"),i(t.package.footers,"footer");}return o}function Lt(t,e,n={}){return et(t,e,n)[0]}var I=class extends Error{constructor(e){super(`No content control matched ${JSON.stringify(e)}`),this.name="ContentControlNotFoundError";}},m=class extends Error{constructor(e,n){super(`Content control is ${e}; cannot ${n} it without { force: true }`),this.name="ContentControlLockedError";}},F=class extends Error{constructor(e){super(`Content control is a '${e}' control; replacing its content with free text would desync it. Use a type-specific value setter or pass { force: true }.`),this.name="ContentControlTypeError";}},b=class extends Error{constructor(){super("Content control is data-bound (w:dataBinding); its content is driven by the Custom XML store and a direct write will not persist. Update the store, or pass { force: true }."),this.name="ContentControlBoundError";}},nt=new Set(["richText","plainText","unknown"]);function ot(t){return nt.has(t)}function O(t){return t==="contentLocked"||t==="sdtContentLocked"}function rt(t){return t==="sdtLocked"||t==="sdtContentLocked"}function it(t){return /<w15:repeatingSection(Item)?[\s/>]/.test(t.rawPropertiesXml??"")}function M(t){return t.dataBinding!=null}function E(t){return t&&t.replace(/<w:showingPlcHdr\b[^>]*\/>/g,"").replace(/<w:showingPlcHdr\b[^>]*>[\s\S]*?<\/w:showingPlcHdr>/g,"")}function X(t){if(!t.showingPlaceholder&&!/showingPlcHdr/.test(t.rawPropertiesXml??""))return t;let e={...t,showingPlaceholder:false},n=E(t.rawPropertiesXml);return n!==void 0&&(e.rawPropertiesXml=n),e}function V(t){return {type:"paragraph",content:t?[{type:"run",content:[{type:"text",text:t}]}]:[]}}function ct(t,e={}){return typeof t!="string"?structuredClone(t):e.singleParagraph?[V(t)]:t.split(`
|
|
6
|
-
`).map(V)}function at(t,e,n,o){let r=[];for(let a of t){if(o.done){r.push(a);continue}if(a.type==="blockSdt"){if(x(a.properties,e)){r.push(...n(a)),o.done=true;continue}r.push({...a,content:at(a.content,e,n,o)});}else r.push(a);}return r}function st(t,e){return {...t,package:{...t.package,document:{...t.package.document,content:e}}}}var D=class extends Error{constructor(e){super(e),this.name="ContentControlKindError";}};function lt(t){switch(t.type){case "run":case "hyperlink":case "simpleField":case "complexField":case "inlineSdt":case "mathEquation":return true;default:return false}}function ut(t){let e=t.content.find(n=>n.type==="run");return e?.formatting?structuredClone(e.formatting):void 0}function j(t){let e={type:"text",text:t};return /^\s|\s$/.test(t)&&(e.preserveSpace=true),e}function pt(t,e){if(typeof t!="string"){if(t.length===1&&t[0].type==="paragraph"&&t[0].content.every(lt))return structuredClone(t[0].content);throw new D("Cannot place block content (paragraphs/tables) inside an inline content control. Pass a string, or a single paragraph whose content is entirely inline.")}if(t==="")return [];let n=ut(e),o=e.properties.sdtType==="plainText",r=[];o||!t.includes(`
|
|
7
|
-
`)?r.push(j(t)):t.split(`
|
|
8
|
-
`).forEach((i,c)=>{c>0&&r.push({type:"break",breakType:"textWrapping"}),i&&r.push(j(i));});let a={type:"run",content:r};return n&&(a.formatting=n),[a]}var C=t=>t.stopAtFirst&&t.matched>0;function Z(t,e,n,o){let r=false,a=[];for(let i of t){if(C(o)||i.type!=="inlineSdt"){a.push(i);continue}if(x(i.properties,e)){a.push(...n(i)),o.matched+=1,r=true;continue}let c=i.content,s=Z(c,e,n,o);s!==c?(a.push({...i,content:s}),r=true):a.push(i);}return r?a:t}function dt(t,e,n,o,r){if(C(r))return t;let a=false,i=t.rows.map(c=>{if(C(r))return c;let s=false,l=c.cells.map(p=>{if(C(r))return p;let u=p.content,f=S(u,e,n,o,r);return f!==u?(s=true,{...p,content:f}):p});return s?(a=true,{...c,cells:l}):c});return a?{...t,rows:i}:t}function S(t,e,n,o,r){let a=false,i=[];for(let c of t){if(C(r)){i.push(c);continue}if(c.type==="blockSdt"){if(x(c.properties,e)){i.push(...n(c)),r.matched+=1,a=true;continue}let s=S(c.content,e,n,o,r);s!==c.content?(i.push({...c,content:s}),a=true):i.push(c);}else if(c.type==="table"){let s=dt(c,e,n,o,r);s!==c?(i.push(s),a=true):i.push(c);}else if(c.type==="paragraph"){let s=Z(c.content,e,o,r);s!==c.content?(i.push({...c,content:s}),a=true):i.push(c);}else i.push(c);}return a?i:t}function ft(t,e,n,o){let r=e==="header"?"headers":"footers",a=new Map(t.package[r]);return a.set(n,o),{...t,package:{...t.package,[r]:a}}}function T(t,e,n,o,r,a=c=>c,i=false){let c={matched:0,stopAtFirst:!i},s=t,l=S(t.package.document.content,e,n,o,c);if(l!==t.package.document.content&&(s=st(s,a(l))),C(c))return s;if(r)for(let p of ["header","footer"]){let u=p==="header"?s.package.headers:s.package.footers;if(u)for(let f of [...u.keys()].sort()){let k=u.get(f),w=S(k.content,e,n,o,c);if(w!==k.content&&(s=ft(s,p,f,{...k,content:w})),C(c))return s}}if(c.matched===0)throw new I(e);return s}function U(t,e){if(!e&&O(t.lock))throw new m(t.lock,"edit");if(!e&&!ot(t.sdtType))throw new F(t.sdtType);if(!e&&M(t))throw new b}function N(t,e){if(!e.force&&rt(t.lock))throw new m(t.lock,"remove");if(e.keepContent&&!e.force&&it(t))throw new m(t.lock,"remove")}function vt(t,e,n,o={}){return T(t,e,i=>(U(i.properties,o.force),[{...i,properties:X(i.properties),content:ct(n,{singleParagraph:i.properties.sdtType==="plainText"})}]),i=>(U(i.properties,o.force),[{...i,properties:X(i.properties),content:pt(n,i)}]),o.includeHeadersFooters??false,void 0,o.all??false)}function At(t,e,n={}){let o=i=>(N(i.properties,n),n.keepContent?i.content:[]),r=i=>(N(i.properties,n),n.keepContent?i.content:[]),a=i=>i.length>0?i:[{type:"paragraph",content:[]}];return T(t,e,o,r,n.includeHeadersFooters??false,a,n.all??false)}var h=class extends Error{constructor(e){super(e),this.name="ContentControlValueError";}};function P(t,e,n){let o=new RegExp(`<${e}\\b[^>]*>`).exec(t);if(!o)return;let r=new RegExp(`\\b${n}="([^"]*)"`).exec(o[0]);return r?r[1]:void 0}function H(t,e,n,o){let a=new RegExp(`<${e}\\b[^>]*?(/?)>`).exec(t);if(!a)return t;let i=a[0],c=a[1]==="/",s=i.slice(1,c?-2:-1),p=new RegExp(`\\b${n}="[^"]*"`).test(s)?s.replace(new RegExp(`\\b${n}="[^"]*"`),()=>`${n}="${o}"`):`${s} ${n}="${o}"`;return t.replace(i,()=>`<${p}${c?"/>":">"}`)}function gt(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function ht(t,e){if(!t)return e;let n=parseInt(t,16);return Number.isNaN(n)||n<0||n>1114111||n>=55296&&n<=57343?e:String.fromCodePoint(n)}function yt(t,e,n){let[o,r,a]=t.slice(0,10).split("-").map(u=>parseInt(u,10));if(!z(o,r,a))return t;let i=e&&e.trim()?e:"M/d/yyyy",c=u=>String(u).padStart(2,"0"),s=new Date(Date.UTC(o,r-1,a)),l=u=>{try{return new Intl.DateTimeFormat(n||"en",{month:u,timeZone:"UTC"}).format(s)}catch{return new Intl.DateTimeFormat("en",{month:u,timeZone:"UTC"}).format(s)}},p={yyyy:String(o),yy:String(o).slice(-2),MMMM:l("long"),MMM:l("short"),MM:c(r),M:String(r),dd:c(a),d:String(a)};return i.replace(/yyyy|yy|MMMM|MMM|MM|M|dd|d/g,u=>p[u])}function z(t,e,n){if(!t||!e||!n)return false;let o=new Date(Date.UTC(t,e-1,n));return o.getUTCFullYear()===t&&o.getUTCMonth()===e-1&&o.getUTCDate()===n}function R(t,e){return t?{type:"paragraph",content:[{type:"run",content:[{type:"text",text:t}],...e?{formatting:{fontFamily:{ascii:e,hAnsi:e,eastAsia:e,cs:e}}}:{}}]}:{type:"paragraph",content:[]}}function $(t,e){let n=E(e);return {...t,showingPlaceholder:false,rawPropertiesXml:(n??e)||void 0}}function _(t,e){let n=t.rawPropertiesXml??"";switch(e.kind){case "dropdown":{if(t.sdtType!=="dropDownList"&&t.sdtType!=="comboBox")throw new h(`Control is '${t.sdtType}', not a dropdown/combo box.`);let o=t.listItems?.find(l=>l.value===e.value||l.displayText===e.value);if(!o&&t.sdtType==="dropDownList")throw new h(`'${e.value}' is not one of the control's list items.`);let r=o?.value??e.value,a=o?.displayText??e.value,i=o?t.listItems?.indexOf(o):void 0,c=t.sdtType==="comboBox"?"w:comboBox":"w:dropDownList",s=H(n,c,"w:lastValue",gt(r));return {properties:{...$(t,s),listLastValue:r,controlState:{...t.controlState,value:a,selectedValue:r,selectedIndex:i,placeholder:false}},content:[R(a)]}}case "checkbox":{if(t.sdtType!=="checkbox")throw new h(`Control is '${t.sdtType}', not a checkbox.`);if(P(n,"w14:checked","w14:val")==null)throw new h("Checkbox control has no <w14:checked> state to update (not a Word checkbox).");let o=e.checked?"w14:checkedState":"w14:uncheckedState",r=ht(P(n,o,"w14:val"),e.checked?"\u2612":"\u2610"),a=P(n,o,"w14:font"),i=H(n,"w14:checked","w14:val",e.checked?"1":"0");return {properties:{...$(t,i),checked:e.checked,controlState:{...t.controlState,checked:e.checked,value:r,placeholder:false}},content:[R(r,a)]}}case "date":{if(t.sdtType!=="date")throw new h(`Control is '${t.sdtType}', not a date control.`);let o=e.date.slice(0,10),[r,a,i]=/^\d{4}-\d{2}-\d{2}$/.test(o)?o.split("-").map(Number):[];if(!z(r,a,i))throw new h(`Date must be ISO yyyy-mm-dd, got '${e.date}'.`);let c=`${o}T00:00:00`,s=H(n,"w:date","w:fullDate",c),l=t.dateState?.format??t.dateFormat??P(n,"w:dateFormat","w:val"),p=t.dateState?.language,u=yt(o,l,p);return {properties:{...$(t,s),dateFormat:l,dateState:{...t.dateState,fullDate:c,format:l},controlState:{...t.controlState,value:o,placeholder:false}},content:[R(u)]}}}}function jt(t,e,n,o={}){let r=c=>{if(!o.force&&O(c.lock))throw new m(c.lock,"edit");if(!o.force&&M(c))throw new b};return T(t,e,c=>{r(c.properties);let{properties:s,content:l}=_(c.properties,n);return [{...c,properties:s,content:l}]},c=>{r(c.properties);let{properties:s,content:l}=_(c.properties,n),p=l[0],u=p&&p.type==="paragraph"?p.content:[];return [{...c,properties:s,content:u}]},o.includeHeadersFooters??false,void 0,o.all??false)}export{m as A,F as B,b as C,at as D,st as E,D as F,lt as G,vt as H,At as I,h as J,yt as K,_ as L,jt as M,d as a,g as b,y as c,B as d,Ct as e,A as f,mt as g,kt as h,xt as i,bt as j,wt as k,St as l,Tt as m,Pt as n,Bt as o,It as p,Ft as q,Dt as r,Ot as s,K as t,Mt as u,Et as v,tt as w,et as x,Lt as y,I as z};
|
package/dist/chunk-YCIH2Q3E.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var F={FFFF00:"yellow","00FF00":"green","00FFFF":"cyan",FF00FF:"magenta","0000FF":"blue",FF0000:"red","00008B":"darkBlue","008080":"darkCyan","008000":"darkGreen",800080:"darkMagenta","8B0000":"darkRed",808e3:"darkYellow",808080:"darkGray",C0C0C0:"lightGray","000000":"black",FFFFFF:"white"};function t(e){let r=e.replace(/^#/,"").toUpperCase();return F[r]||null}export{F as a,t as b};
|
package/dist/chunk-ZOV5KL7C.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t=/^[a-z][a-z0-9+.-]*:/i,i=/^(https?|mailto|tel|ftp):/i;function d(n){if(!n)return;let e=n.replace(/[\t\n\r]/g,"").replace(/^[\x00-\x20]+/,"");if(e)return t.test(e)?i.test(e)?n:void 0:n}export{d as a};
|
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
import { Document } from './types/document.mjs';
|
|
2
|
-
import { C as ColorValue, a as Theme, z as ThemeColorSlot } from './formatting-DoL7KBSL.mjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Template Processing Utility
|
|
6
|
-
*
|
|
7
|
-
* Uses docxtemplater to substitute template variables in DOCX documents:
|
|
8
|
-
* - Processes {variable_name} patterns (docxtemplater default syntax)
|
|
9
|
-
* - Preserves all formatting (fonts, styles, colors, tables)
|
|
10
|
-
* - Error handling with useful messages
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* Options for template processing
|
|
14
|
-
*/
|
|
15
|
-
interface ProcessTemplateOptions {
|
|
16
|
-
/** How to handle undefined variables */
|
|
17
|
-
nullGetter?: 'keep' | 'empty' | 'error';
|
|
18
|
-
/** Custom parser for variable names */
|
|
19
|
-
parser?: (tag: string) => {
|
|
20
|
-
get: (scope: Record<string, unknown>) => unknown;
|
|
21
|
-
};
|
|
22
|
-
/** Line breaks: keep raw \n or convert to w:br */
|
|
23
|
-
linebreaks?: boolean;
|
|
24
|
-
/** Delimiter settings */
|
|
25
|
-
delimiters?: {
|
|
26
|
-
start?: string;
|
|
27
|
-
end?: string;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Result of template processing
|
|
32
|
-
*/
|
|
33
|
-
interface ProcessTemplateResult {
|
|
34
|
-
/** The processed document buffer */
|
|
35
|
-
buffer: ArrayBuffer;
|
|
36
|
-
/** Variables that were found and replaced */
|
|
37
|
-
replacedVariables: string[];
|
|
38
|
-
/** Variables that were not replaced (no value provided) */
|
|
39
|
-
unreplacedVariables: string[];
|
|
40
|
-
/** Any warnings during processing */
|
|
41
|
-
warnings: string[];
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Error details from template processing
|
|
45
|
-
*/
|
|
46
|
-
interface TemplateError {
|
|
47
|
-
/** Error message */
|
|
48
|
-
message: string;
|
|
49
|
-
/** Variable name that caused the error (if applicable) */
|
|
50
|
-
variable?: string;
|
|
51
|
-
/** Error type */
|
|
52
|
-
type: 'parse' | 'render' | 'undefined' | 'unknown';
|
|
53
|
-
/** Original error */
|
|
54
|
-
originalError?: Error;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Process a DOCX template with variable substitution
|
|
58
|
-
*
|
|
59
|
-
* @param buffer - The DOCX file as ArrayBuffer
|
|
60
|
-
* @param variables - Map of variable names to values
|
|
61
|
-
* @param options - Processing options
|
|
62
|
-
* @returns Processed DOCX as ArrayBuffer
|
|
63
|
-
*/
|
|
64
|
-
declare function processTemplate(buffer: ArrayBuffer, variables: Record<string, string>, options?: ProcessTemplateOptions): ArrayBuffer;
|
|
65
|
-
/**
|
|
66
|
-
* Process template with detailed result
|
|
67
|
-
*
|
|
68
|
-
* @param buffer - The DOCX file as ArrayBuffer
|
|
69
|
-
* @param variables - Map of variable names to values
|
|
70
|
-
* @param options - Processing options
|
|
71
|
-
* @returns Detailed processing result
|
|
72
|
-
*/
|
|
73
|
-
declare function processTemplateDetailed(buffer: ArrayBuffer, variables: Record<string, string>, options?: ProcessTemplateOptions): ProcessTemplateResult;
|
|
74
|
-
/**
|
|
75
|
-
* Process template and return as Blob
|
|
76
|
-
*
|
|
77
|
-
* @param buffer - The DOCX file as ArrayBuffer
|
|
78
|
-
* @param variables - Map of variable names to values
|
|
79
|
-
* @param options - Processing options
|
|
80
|
-
* @returns Processed DOCX as Blob
|
|
81
|
-
*/
|
|
82
|
-
declare function processTemplateAsBlob(buffer: ArrayBuffer, variables: Record<string, string>, options?: ProcessTemplateOptions): Blob;
|
|
83
|
-
/**
|
|
84
|
-
* Process template and trigger download
|
|
85
|
-
*
|
|
86
|
-
* @param buffer - The DOCX file as ArrayBuffer
|
|
87
|
-
* @param variables - Map of variable names to values
|
|
88
|
-
* @param filename - Output filename (without extension)
|
|
89
|
-
* @param options - Processing options
|
|
90
|
-
*/
|
|
91
|
-
declare function processTemplateAndDownload(buffer: ArrayBuffer, variables: Record<string, string>, filename?: string, options?: ProcessTemplateOptions): void;
|
|
92
|
-
/**
|
|
93
|
-
* Get all template tags in a document without processing
|
|
94
|
-
*
|
|
95
|
-
* @param buffer - The DOCX file as ArrayBuffer
|
|
96
|
-
* @returns List of tag names found
|
|
97
|
-
*/
|
|
98
|
-
declare function getTemplateTags(buffer: ArrayBuffer): string[];
|
|
99
|
-
/**
|
|
100
|
-
* Validate that a document is a valid docxtemplater template
|
|
101
|
-
*
|
|
102
|
-
* @param buffer - The DOCX file as ArrayBuffer
|
|
103
|
-
* @returns Validation result
|
|
104
|
-
*/
|
|
105
|
-
declare function validateTemplate(buffer: ArrayBuffer): {
|
|
106
|
-
valid: boolean;
|
|
107
|
-
errors: TemplateError[];
|
|
108
|
-
tags: string[];
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* Check if all required variables have values
|
|
112
|
-
*
|
|
113
|
-
* @param tags - List of template tags
|
|
114
|
-
* @param variables - Provided variable values
|
|
115
|
-
* @returns Missing variable names
|
|
116
|
-
*/
|
|
117
|
-
declare function getMissingVariables(tags: string[], variables: Record<string, string>): string[];
|
|
118
|
-
/**
|
|
119
|
-
* Preview what the document will look like after processing
|
|
120
|
-
* Returns the document text with variables replaced (for preview purposes)
|
|
121
|
-
*
|
|
122
|
-
* @param buffer - The DOCX file as ArrayBuffer
|
|
123
|
-
* @param variables - Map of variable names to values
|
|
124
|
-
* @returns Preview text
|
|
125
|
-
*/
|
|
126
|
-
declare function previewTemplate(buffer: ArrayBuffer, variables: Record<string, string>): string;
|
|
127
|
-
/**
|
|
128
|
-
* Process template with conditional sections
|
|
129
|
-
* Supports #if, #unless, #each loops
|
|
130
|
-
*
|
|
131
|
-
* @param buffer - The DOCX file as ArrayBuffer
|
|
132
|
-
* @param data - Full data object (can include arrays, nested objects)
|
|
133
|
-
* @param options - Processing options
|
|
134
|
-
* @returns Processed DOCX as ArrayBuffer
|
|
135
|
-
*/
|
|
136
|
-
declare function processTemplateAdvanced(buffer: ArrayBuffer, data: Record<string, unknown>, options?: ProcessTemplateOptions): ArrayBuffer;
|
|
137
|
-
/**
|
|
138
|
-
* Create a template processor with preset options
|
|
139
|
-
*/
|
|
140
|
-
declare function createTemplateProcessor(defaultOptions?: ProcessTemplateOptions): (buffer: ArrayBuffer, variables: Record<string, string>) => ArrayBuffer;
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Create Document Utility
|
|
144
|
-
*
|
|
145
|
-
* Provides functions to create new documents programmatically.
|
|
146
|
-
*/
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Options for creating an empty document
|
|
150
|
-
*/
|
|
151
|
-
interface CreateEmptyDocumentOptions {
|
|
152
|
-
/** Page width in twips (default: 12240 = 8.5 inches) */
|
|
153
|
-
pageWidth?: number;
|
|
154
|
-
/** Page height in twips (default: 15840 = 11 inches) */
|
|
155
|
-
pageHeight?: number;
|
|
156
|
-
/** Page orientation (default: 'portrait') */
|
|
157
|
-
orientation?: 'portrait' | 'landscape';
|
|
158
|
-
/** Top margin in twips (default: 1440 = 1 inch) */
|
|
159
|
-
marginTop?: number;
|
|
160
|
-
/** Bottom margin in twips (default: 1440 = 1 inch) */
|
|
161
|
-
marginBottom?: number;
|
|
162
|
-
/** Left margin in twips (default: 1440 = 1 inch) */
|
|
163
|
-
marginLeft?: number;
|
|
164
|
-
/** Right margin in twips (default: 1440 = 1 inch) */
|
|
165
|
-
marginRight?: number;
|
|
166
|
-
/** Initial text content (default: empty string) */
|
|
167
|
-
initialText?: string;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Create an empty document with a single paragraph
|
|
171
|
-
*
|
|
172
|
-
* @param options - Optional configuration for the document
|
|
173
|
-
* @returns A new empty Document object
|
|
174
|
-
*
|
|
175
|
-
* @example
|
|
176
|
-
* ```ts
|
|
177
|
-
* // Create a blank document
|
|
178
|
-
* const doc = createEmptyDocument();
|
|
179
|
-
*
|
|
180
|
-
* // Create with custom margins
|
|
181
|
-
* const doc = createEmptyDocument({
|
|
182
|
-
* marginTop: 720, // 0.5 inch
|
|
183
|
-
* marginBottom: 720,
|
|
184
|
-
* });
|
|
185
|
-
*
|
|
186
|
-
* // Create with initial text
|
|
187
|
-
* const doc = createEmptyDocument({
|
|
188
|
-
* initialText: 'Hello, World!'
|
|
189
|
-
* });
|
|
190
|
-
* ```
|
|
191
|
-
*/
|
|
192
|
-
declare function createEmptyDocument(options?: CreateEmptyDocumentOptions): Document;
|
|
193
|
-
/**
|
|
194
|
-
* Create a document with a single paragraph containing the given text
|
|
195
|
-
*
|
|
196
|
-
* @param text - The text content for the document
|
|
197
|
-
* @param options - Optional configuration for the document
|
|
198
|
-
* @returns A new Document object with the specified text
|
|
199
|
-
*/
|
|
200
|
-
declare function createDocumentWithText(text: string, options?: Omit<CreateEmptyDocumentOptions, 'initialText'>): Document;
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Color Resolver - Convert OOXML colors to CSS
|
|
204
|
-
*
|
|
205
|
-
* The generic color machinery (theme slots, tint/shade math, blending, the
|
|
206
|
-
* picker matrix) is re-exported here. This module keeps the WordprocessingML-
|
|
207
|
-
* specific pieces: w:highlight named colors, w:shd shading semantics, and
|
|
208
|
-
* ColorValue construction helpers.
|
|
209
|
-
*
|
|
210
|
-
* OOXML Color References:
|
|
211
|
-
* - w:color/@w:val - RGB hex or "auto"
|
|
212
|
-
* - w:color/@w:themeColor - Theme color slot
|
|
213
|
-
* - w:color/@w:themeTint - Tint modifier (0-255, hex)
|
|
214
|
-
* - w:color/@w:themeShade - Shade modifier (0-255, hex)
|
|
215
|
-
*/
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Resolve a highlight color name to CSS
|
|
219
|
-
*
|
|
220
|
-
* @param highlight - Highlight color name (e.g., "yellow", "cyan")
|
|
221
|
-
* @returns CSS color string or empty string for "none"
|
|
222
|
-
*/
|
|
223
|
-
declare function resolveHighlightColor(highlight: string | undefined): string;
|
|
224
|
-
/**
|
|
225
|
-
* Resolve a shading fill or pattern color to CSS
|
|
226
|
-
*
|
|
227
|
-
* @param color - ColorValue for fill
|
|
228
|
-
* @param theme - Theme for resolving theme colors
|
|
229
|
-
* @returns CSS color string
|
|
230
|
-
*/
|
|
231
|
-
declare function resolveShadingColor(color: ColorValue | undefined | null, theme: Theme | null | undefined): string;
|
|
232
|
-
/**
|
|
233
|
-
* Check if a color is effectively black
|
|
234
|
-
*
|
|
235
|
-
* @param color - ColorValue object
|
|
236
|
-
* @param theme - Theme for resolving theme colors
|
|
237
|
-
* @returns True if color resolves to black or very dark
|
|
238
|
-
*/
|
|
239
|
-
declare function isBlack(color: ColorValue | undefined | null, theme: Theme | null | undefined): boolean;
|
|
240
|
-
/**
|
|
241
|
-
* Check if a color is effectively white
|
|
242
|
-
*
|
|
243
|
-
* @param color - ColorValue object
|
|
244
|
-
* @param theme - Theme for resolving theme colors
|
|
245
|
-
* @returns True if color resolves to white or very light
|
|
246
|
-
*/
|
|
247
|
-
declare function isWhite(color: ColorValue | undefined | null, theme: Theme | null | undefined): boolean;
|
|
248
|
-
/**
|
|
249
|
-
* Parse a color string (various formats) to ColorValue
|
|
250
|
-
*
|
|
251
|
-
* @param colorString - Color string like "FF0000", "auto", or theme color name
|
|
252
|
-
* @returns ColorValue object
|
|
253
|
-
*/
|
|
254
|
-
declare function parseColorString(colorString: string | undefined): ColorValue | undefined;
|
|
255
|
-
/**
|
|
256
|
-
* Create a ColorValue from theme color reference
|
|
257
|
-
*
|
|
258
|
-
* @param themeColor - Theme color slot name
|
|
259
|
-
* @param tint - Optional tint modifier
|
|
260
|
-
* @param shade - Optional shade modifier
|
|
261
|
-
* @returns ColorValue object
|
|
262
|
-
*/
|
|
263
|
-
declare function createThemeColor(themeColor: ThemeColorSlot, tint?: number, shade?: number): ColorValue;
|
|
264
|
-
/**
|
|
265
|
-
* Create a ColorValue from RGB hex
|
|
266
|
-
*
|
|
267
|
-
* @param hex - 6-character hex color (no #)
|
|
268
|
-
* @returns ColorValue object
|
|
269
|
-
*/
|
|
270
|
-
declare function createRgbColor(hex: string): ColorValue;
|
|
271
|
-
/**
|
|
272
|
-
* Ensure a hex color string has a '#' prefix.
|
|
273
|
-
*/
|
|
274
|
-
declare function ensureHexPrefix(hex: string): string;
|
|
275
|
-
/**
|
|
276
|
-
* Resolve a highlight color value to a CSS-ready string.
|
|
277
|
-
* Tries OOXML named highlight first, then ensures hex prefix.
|
|
278
|
-
*/
|
|
279
|
-
declare function resolveHighlightToCss(value: string): string;
|
|
280
|
-
/**
|
|
281
|
-
* Check if two colors are equal
|
|
282
|
-
*
|
|
283
|
-
* @param color1 - First color
|
|
284
|
-
* @param color2 - Second color
|
|
285
|
-
* @param theme - Theme for resolving
|
|
286
|
-
* @returns True if colors resolve to the same value
|
|
287
|
-
*/
|
|
288
|
-
declare function colorsEqual(color1: ColorValue | undefined | null, color2: ColorValue | undefined | null, theme: Theme | null | undefined): boolean;
|
|
289
|
-
|
|
290
|
-
export { type CreateEmptyDocumentOptions as C, type ProcessTemplateOptions as P, type TemplateError as T, type ProcessTemplateResult as a, createDocumentWithText as b, colorsEqual as c, createEmptyDocument as d, createRgbColor as e, createTemplateProcessor as f, createThemeColor as g, getMissingVariables as h, getTemplateTags as i, isBlack as j, isWhite as k, previewTemplate as l, processTemplate as m, processTemplateAdvanced as n, processTemplateAsBlob as o, parseColorString as p, processTemplateDetailed as q, resolveHighlightColor as r, resolveShadingColor as s, ensureHexPrefix as t, resolveHighlightToCss as u, validateTemplate as v, processTemplateAndDownload as w };
|
package/dist/core-plugins.d.mts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { b as CorePlugin } from './types-dYdjUZMo.mjs';
|
|
2
|
-
export { C as CommandHandler, a as CommandResult, E as ExtractCommand, J as JsonSchema, L as LoadedDocument, M as McpSession, c as McpToolAnnotations, d as McpToolContent, e as McpToolContext, f as McpToolDefinition, n as McpToolExample, g as McpToolHandler, h as McpToolResult, P as PluginCommand, C as PluginCommandHandler, i as PluginEvent, j as PluginEventListener, k as PluginOptions, l as PluginRegistrationResult, f as ToolDefinition, g as ToolHandler, h as ToolResult, T as TypedCommandHandler, Z as ZodSchemaLike, m as isZodSchema } from './types-dYdjUZMo.mjs';
|
|
3
|
-
export { P as PluginRegistry, c as createPluginRegistrar, p as pluginRegistry, r as registerPlugins } from './registry-DMM5VTdT.mjs';
|
|
4
|
-
import './types/document.mjs';
|
|
5
|
-
import './content-sSHuWw49.mjs';
|
|
6
|
-
import './formatting-DoL7KBSL.mjs';
|
|
7
|
-
import './docx/wrapTypes.mjs';
|
|
8
|
-
import './styles-VxNcXLdi.mjs';
|
|
9
|
-
import './settingsParser-CcGvtmCK.mjs';
|
|
10
|
-
import './types/agentApi.mjs';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Docxtemplater Plugin
|
|
14
|
-
*
|
|
15
|
-
* Core plugin for template variable functionality using docxtemplater.
|
|
16
|
-
*
|
|
17
|
-
* **Command handlers** — `insertTemplateVariable` and `replaceWithTemplateVariable`
|
|
18
|
-
* allow DocumentAgent to programmatically insert `{variable}` placeholders.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```ts
|
|
22
|
-
* import { pluginRegistry } from '@betteroffice/docx/core-plugins';
|
|
23
|
-
* import { docxtemplaterPlugin } from '@betteroffice/docx/core-plugins/docxtemplater';
|
|
24
|
-
*
|
|
25
|
-
* pluginRegistry.register(docxtemplaterPlugin);
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Docxtemplater plugin for template variable functionality.
|
|
31
|
-
*
|
|
32
|
-
* Dependency validation is handled lazily by `processTemplate` at call time,
|
|
33
|
-
* so no eager `initialize()` is needed.
|
|
34
|
-
*/
|
|
35
|
-
declare const docxtemplaterPlugin: CorePlugin;
|
|
36
|
-
|
|
37
|
-
export { CorePlugin, CorePlugin as Plugin, docxtemplaterPlugin };
|
package/dist/core-plugins.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{b as docxtemplaterPlugin,a as isZodSchema}from'./chunk-XYH6XWP3.mjs';import'./chunk-O2QSE2I7.mjs';import'./chunk-UIEJWORW.mjs';export{a as PluginRegistry,d as createPluginRegistrar,b as pluginRegistry,c as registerPlugins}from'./chunk-VBOTMRXV.mjs';import'./chunk-LDUWIM7M.mjs';import'./chunk-DXKG3HQ5.mjs';import'./chunk-FPZBTOD6.mjs';import'./chunk-H3JCIGWK.mjs';import'./chunk-SINEY6ZF.mjs';import'./chunk-T4EZMUXM.mjs';import'./chunk-TTRUPDAB.mjs';
|
package/dist/docx/parser.d.mts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Document } from '../types/document.mjs';
|
|
2
|
-
import { D as DocxInput } from '../docxInput-DTbCa48g.mjs';
|
|
3
|
-
import '../content-sSHuWw49.mjs';
|
|
4
|
-
import '../formatting-DoL7KBSL.mjs';
|
|
5
|
-
import './wrapTypes.mjs';
|
|
6
|
-
import '../styles-VxNcXLdi.mjs';
|
|
7
|
-
import '../settingsParser-CcGvtmCK.mjs';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Public DOCX parser facade.
|
|
11
|
-
*
|
|
12
|
-
* Rust S9 owns ZIP/XML parsing. TypeScript only normalizes host inputs,
|
|
13
|
-
* rehydrates the public `Document`, reports progress, and registers fonts.
|
|
14
|
-
* @packageDocumentation
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
type ProgressCallback = (stage: string, percent: number) => void;
|
|
19
|
-
interface ParseOptions {
|
|
20
|
-
onProgress?: ProgressCallback;
|
|
21
|
-
preloadFonts?: boolean;
|
|
22
|
-
parseHeadersFooters?: boolean;
|
|
23
|
-
parseNotes?: boolean;
|
|
24
|
-
detectVariables?: boolean;
|
|
25
|
-
}
|
|
26
|
-
declare function parseDocx(input: DocxInput, options?: ParseOptions): Promise<Document>;
|
|
27
|
-
declare function quickParseDocx(buffer: ArrayBuffer): Promise<Document>;
|
|
28
|
-
declare function fullParseDocx(buffer: ArrayBuffer, onProgress?: ProgressCallback): Promise<Document>;
|
|
29
|
-
declare function getDocxVariables(buffer: ArrayBuffer): Promise<string[]>;
|
|
30
|
-
declare function getDocxSummary(buffer: ArrayBuffer): Promise<{
|
|
31
|
-
hasDocument: boolean;
|
|
32
|
-
hasStyles: boolean;
|
|
33
|
-
hasTheme: boolean;
|
|
34
|
-
hasNumbering: boolean;
|
|
35
|
-
headerCount: number;
|
|
36
|
-
footerCount: number;
|
|
37
|
-
mediaCount: number;
|
|
38
|
-
variableCount: number;
|
|
39
|
-
}>;
|
|
40
|
-
|
|
41
|
-
export { type ParseOptions, type ProgressCallback, fullParseDocx, getDocxSummary, getDocxVariables, parseDocx, quickParseDocx };
|
package/dist/docx/parser.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{c as fullParseDocx,e as getDocxSummary,d as getDocxVariables,a as parseDocx,b as quickParseDocx}from'../chunk-LDUWIM7M.mjs';import'../chunk-DXKG3HQ5.mjs';import'../chunk-FPZBTOD6.mjs';import'../chunk-H3JCIGWK.mjs';import'../chunk-SINEY6ZF.mjs';import'../chunk-T4EZMUXM.mjs';import'../chunk-TTRUPDAB.mjs';
|