efficient-office 0.5.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +17 -0
  2. package/dist/Documents-CVV64UEH.js +1 -0
  3. package/dist/Slides-JMP36AJH.js +1 -0
  4. package/dist/SlidesEditor-MZM7IR46.js +1 -0
  5. package/dist/Spreadsheet-55AVNUEA.js +1 -0
  6. package/dist/chunk-2AKHYM66.js +1 -0
  7. package/dist/chunk-2TZUCKZ7.js +1 -0
  8. package/dist/chunk-4NKXNXKY.js +1 -0
  9. package/dist/chunk-7K7AY3V3.js +1 -0
  10. package/dist/chunk-A5KQPSPX.js +1 -0
  11. package/dist/chunk-B32ASXHM.js +1 -0
  12. package/dist/chunk-B6JN7D6G.js +1 -0
  13. package/dist/chunk-COXKOQPZ.js +1 -0
  14. package/dist/chunk-GLT7O6TV.js +1 -0
  15. package/dist/chunk-HU4RI2OM.js +1 -0
  16. package/dist/chunk-I3AC6PYR.js +1 -0
  17. package/dist/chunk-JCSB2PHB.js +1 -0
  18. package/dist/chunk-JKYJGXJE.js +1 -0
  19. package/dist/chunk-N26CBJZA.js +1 -0
  20. package/dist/chunk-OB4MLAZC.js +1 -0
  21. package/dist/chunk-PWF37Y2N.js +1 -0
  22. package/dist/chunk-QFPW3KLL.js +1 -0
  23. package/dist/chunk-RHW2M2UY.js +1 -0
  24. package/dist/chunk-RLNXQG4T.js +1 -0
  25. package/dist/chunk-VKCG3LPQ.js +1 -0
  26. package/dist/chunk-X6F3Z4KZ.js +1 -0
  27. package/dist/chunk-XYVQTQ6N.js +1 -0
  28. package/dist/deckPdf-Y2RE7MFX.js +1 -0
  29. package/dist/documents/documents.css +4 -0
  30. package/dist/documents/index.d.ts +25 -6
  31. package/dist/documents/index.js +1 -1
  32. package/dist/docxPdf-EW5I5JR3.js +1 -0
  33. package/dist/importDocument-274VK7OM.js +1 -0
  34. package/dist/importSpreadsheet-4U3KEJ76.js +1 -0
  35. package/dist/pptxImport-STLMOUNE.js +1 -0
  36. package/dist/slides/index.d.ts +152 -53
  37. package/dist/slides/index.js +1 -1
  38. package/dist/slides/slides.css +23 -0
  39. package/dist/spreadsheet/index.d.ts +67 -43
  40. package/dist/spreadsheet/index.js +1 -1
  41. package/dist/spreadsheet/spreadsheet.css +4 -0
  42. package/dist/words-DK_ajpEa.d.ts +67 -0
  43. package/dist/workbookPdf-C5SSN226.js +1 -0
  44. package/dist/xlsxFile-B2JCZCOL.js +1 -0
  45. package/package.json +7 -2
  46. package/dist/Documents-XZ3AZVHI.js +0 -1
  47. package/dist/Slides-ILKPLYAJ.js +0 -1
  48. package/dist/SlidesEditor-44ITB7B2.js +0 -1
  49. package/dist/Spreadsheet-R5MYRMOF.js +0 -1
  50. package/dist/chunk-372GCYWH.js +0 -1
  51. package/dist/chunk-3JJCHWPJ.js +0 -1
  52. package/dist/chunk-3SRMKGQW.js +0 -1
  53. package/dist/chunk-BTDWPUTS.js +0 -1
  54. package/dist/chunk-CED4ECIS.js +0 -1
@@ -0,0 +1 @@
1
+ import{PptxPasswordError as t,PptxUnreadableError as e}from"./chunk-RLNXQG4T.js";import{DECK_FONT as n,MIN_SIZE as r,NO_FILL as a,SLIDE_H as o,SLIDE_W as s,newId as i,newSlide as l}from"./chunk-2TZUCKZ7.js";import{ENGLISH_WORDS as c}from"./chunk-X6F3Z4KZ.js";import"./chunk-B32ASXHM.js";import{child as p,childrenOf as f,descendants as u,openZip as d,parseXml as m,partText as h,readRels as y,readThemeFonts as g,resolveTarget as w}from"./chunk-RHW2M2UY.js";var x=2097152;function b(t){if(Array.isArray(t))return t.reduce((t,e)=>t+b(e)+2,t.length?0:2);if(t&&"object"==typeof t){const e=Object.entries(t).filter(([,t])=>void 0!==t);return e.reduce((t,[e,n])=>t+b(e)+2+b(n)+2,e.length?0:2)}const e=JSON.stringify(t)??"null";return e.length+5*(e.match(/[^\x20-\x7e]/g)?.length??0)}var v=[208,207,17,224],M=Array.from("EncryptedPackage").flatMap(t=>[t.charCodeAt(0),0]),k=4194304;function P(t){for(let e=t.indexOf(M[0]);e>=0;e=t.indexOf(M[0],e+1))if(M.every((n,r)=>t[e+r]===n))return!0;return!1}var S={black:"000000",white:"ffffff",red:"ff0000",green:"008000",blue:"0000ff",yellow:"ffff00",gray:"808080",grey:"808080"},N={bg1:"lt1",tx1:"dk1",bg2:"lt2",tx2:"dk2"};function C(t){const e=t.children[0];return e?.attrs.lastClr??e?.attrs.val}function A(t,e){const n=new Map,r=p(p(t,"a:themeElements"),"a:clrScheme")?.children??[];for(const t of r){const e=C(t);e&&n.set(t.name.replace(/^a:/,""),e)}return{scheme:n,map:{...N,...e?.attrs}}}function B(t,e){const n=p(p(e,"p:clrMapOvr"),"a:overrideClrMapping");return n?{...t,map:{...t.map,...n.attrs}}:t}var I=t=>[0,2,4].map(e=>parseInt(t.slice(e,e+2),16)),F=t=>t.map(t=>{return(e=t,Math.max(0,Math.min(255,Math.round(e)))).toString(16).padStart(2,"0");var e}).join("");function T(t,e,n){const[r,a,o]=function([t,e,n]){const[r,a,o]=[t/255,e/255,n/255],s=Math.max(r,a,o),i=Math.min(r,a,o),l=(s+i)/2;if(s===i)return[0,0,l];const c=s-i;return[(s===r?(a-o)/c+(a<o?6:0):s===a?(o-r)/c+2:(r-a)/c+4)/6,l>.5?c/(2-s-i):c/(s+i),l]}(I(t));return F(function([t,e,n]){if(0===e)return[255*n,255*n,255*n];const r=n<.5?n*(1+e):n+e-n*e,a=2*n-r,o=t=>{const e=(t+1)%1;return e<1/6?a+6*(r-a)*e:e<.5?r:e<2/3?a+(r-a)*(2/3-e)*6:a};return[o(t+1/3),o(t),o(t-1/3)].map(t=>255*t)}([r,a,Math.max(0,Math.min(1,o*e+n))]))}function j(t,e){const n=Number(e.attrs.val)/1e5;if(!Number.isFinite(n))return t;switch(e.name){case"a:lumMod":return T(t,n,0);case"a:lumOff":return T(t,1,n);case"a:tint":return F(I(t).map(t=>t+(255-t)*(1-n)));case"a:shade":return F(I(t).map(t=>t*n));default:return t}}function $(t,e){const n=e.scheme.get(e.map[t]??t);return n?`#${n.toLowerCase()}`:void 0}function z(t,e){const n=t&&function(t,e){switch(t.name){case"a:srgbClr":return t.attrs.val;case"a:sysClr":return t.attrs.lastClr;case"a:prstClr":return S[t.attrs.val];case"a:schemeClr":return e.scheme.get(e.map[t.attrs.val]??t.attrs.val);default:return}}(t,e);if(t&&n&&/^[0-9a-f]{6}$/i.test(n)&&"0"!==p(t,"a:alpha")?.attrs.val)return`#${t.children.reduce(j,n).toLowerCase()}`}function R(t,e){return z(p(t,"a:solidFill")?.children[0],e)}var O=t=>"1"===t||"true"===t,L=t=>Math.round(100*t)/100+0,H=(t,e)=>L(12700*t*e.scale),E=t=>t*Math.PI/180;function X(t){const e=p(t,"a:off")?.attrs,n=p(t,"a:ext")?.attrs;if(t&&e&&n)return{x:Number(e.x)||0,y:Number(e.y)||0,w:Number(n.cx)||0,h:Number(n.cy)||0,rotation:(Number(t.attrs.rot)||0)/6e4}}function D(t){const e=p(p(t,"p:grpSpPr"),"a:xfrm"),n=X(e),r=p(e,"a:chOff")?.attrs,a=p(e,"a:chExt")?.attrs;if(n&&r&&a)return{box:n,childX:Number(r.x)||0,childY:Number(r.y)||0,scaleX:Number(a.cx)?n.w/Number(a.cx):1,scaleY:Number(a.cy)?n.h/Number(a.cy):1,flipH:O(e?.attrs.flipH),flipV:O(e?.attrs.flipV)}}function V(t,e){const{box:n}=e,r=n.x+n.w/2,a=n.y+n.h/2;let o=n.x+(t.x-e.childX)*e.scaleX,s=n.y+(t.y-e.childY)*e.scaleY;e.flipH&&(o=2*r-o),e.flipV&&(s=2*a-s);const i=E(n.rotation),l=o-r,c=s-a;return{x:r+l*Math.cos(i)-c*Math.sin(i),y:a+l*Math.sin(i)+c*Math.cos(i)}}function W(t,e){const n=V({x:t.x+t.w/2,y:t.y+t.h/2},e),r=t.w*e.scaleX,a=t.h*e.scaleY,o=e.flipH!==e.flipV;return{x:n.x-r/2,y:n.y-a/2,w:r,h:a,rotation:(o?-t.rotation:t.rotation)+e.box.rotation}}var Y=t=>L((t%360+360)%360);function G(t,e,n){const r=e.reduce(W,t);return{id:i(),x:L(n.left+r.x*n.scale),y:L(n.top+r.y*n.scale),w:L(r.w*n.scale),h:L(r.h*n.scale),rotation:Y(r.rotation)}}function U(t,e,n,a){const o=t.x+t.w/2,s=t.y+t.h/2,l=E(t.rotation),c=r=>{const i=r*(e.flipH?-1:1)*t.w/2,c=r*(e.flipV?-1:1)*t.h/2,p={x:o+i*Math.cos(l)-c*Math.sin(l),y:s+i*Math.sin(l)+c*Math.cos(l)},f=n.reduce(V,p);return{x:a.left+f.x*a.scale,y:a.top+f.y*a.scale}},p=c(-1),f=c(1),u=Math.hypot(f.x-p.x,f.y-p.y);return{id:i(),x:L((p.x+f.x-u)/2),y:L((p.y+f.y-r)/2),w:L(u),h:r,rotation:Y(180*Math.atan2(f.y-p.y,f.x-p.x)/Math.PI)}}var Z={scheme:new Map,map:{}},q=(t,e)=>[...t.rels.values()].find(t=>t.type.endsWith(e)),K=t=>p(p(t,"p:cSld"),"p:spTree");function Q(t,e){const n=h(t,e);if(n)return{part:e,root:m(n),rels:new Map(y(t,e).map(t=>[t.id,t]))}}function J(t,e,n){const r=Q(t,e);if(!r)return;const a=q(r,"/slideMaster"),o=a&&w(e,a.target);return o&&!n.has(o)&&n.set(o,function(t,e){const n=Q(t,e);if(!n)return;const r=q(n,"/theme"),a=r?h(t,w(e,r.target)):void 0;return{...n,palette:A(a?m(a):void 0,p(n.root,"p:clrMap")),fonts:g(a)}}(t,o)),{...r,master:o?n.get(o):void 0}}var _={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",bmp:"image/bmp"};var tt=t=>p(p(p(t,"p:nvSpPr"),"p:nvPr"),"p:ph")??p(p(p(t,"p:nvPicPr"),"p:nvPr"),"p:ph"),et=t=>!!tt(t),nt=t=>(K(t.root)?.children??[]).filter(t=>"p:sp"===t.name&&tt(t)),rt=new Set(["title","ctrTitle"]),at=new Set(["dt","ftr","sldNum"]);function ot(t){return t&&rt.has(t)?"title":t&&at.has(t)?t:"body"}function st(t,e){const n=tt(t);if(!n)return{shapes:[],style:"p:otherStyle",isPlaceholder:!1};const r=e.layout&&function(t,e){const n=nt(t),{idx:r,type:a}=e.attrs;return(void 0!==r?n.find(t=>tt(t)?.attrs.idx===r):void 0)??(void 0!==a?n.find(t=>tt(t)?.attrs.type===a):void 0)}(e.layout,n),a=r?tt(r)??n:n,o=e.master&&function(t,e){const n=ot(e.attrs.type);return nt(t).find(t=>ot(tt(t)?.attrs.type)===n)}(e.master,a),s=ot(a.attrs.type);return{shapes:[r,o].filter(t=>!!t),style:"title"===s?"p:titleStyle":"body"===s?"p:bodyStyle":"p:otherStyle",isPlaceholder:!0}}function it(t,e,n,r){const a=t=>p(p(t,"p:txBody"),"a:lstStyle"),o=p(p(n.master?.root,"p:txStyles"),e.style),s=e.isPlaceholder?[o,r]:[r,o];return[a(t),...e.shapes.map(a),...s]}function lt(t,e,n){for(const r of[t,...e.shapes]){const t=p(p(r,"p:txBody"),"a:bodyPr")?.attrs[n];if(void 0!==t)return t}}var ct={l:"left",ctr:"center",r:"right"},pt=(t,e)=>t.lists.flatMap(t=>{const n=p(t,`a:lvl${e+1}pPr`);return n?[n]:[]});function ft(t,e){return"+mj-lt"===t?e.fonts.major:"+mn-lt"===t?e.fonts.minor:t}function ut(t,e,n,r){const a=[t,p(e,"a:defRPr"),...n.map(t=>p(t,"a:defRPr"))].filter(t=>!!t),o=t=>a.find(e=>void 0!==e.attrs[t])?.attrs[t],s=Number(o("sz")),i=o("b"),l=a.map(t=>R(t,r.palette)),c=a.map(t=>p(t,"a:latin")?.attrs.typeface).find(Boolean);return{sizePt:Number.isFinite(s)&&s>0?s/100:18,bold:"1"===i||"true"===i,colour:l.find(Boolean)??r.styleColour??$("tx1",r.palette)??"#000000",typeface:ft(c,r)??(r.isTitle?r.fonts.major:r.fonts.minor)}}function dt(t,e){for(const n of[t,...e]){if(p(n,"a:buNone"))return{kind:"none"};if(p(n,"a:buChar")||p(n,"a:buBlip"))return{kind:"bullet"};const t=p(n,"a:buAutoNum");if(t)return{kind:"number",startAt:Number(t.attrs.startAt)||1}}return{kind:"none"}}function mt(t,e){const n=[t,...e].map(t=>t?.attrs.algn).find(Boolean);return n&&ct[n]||"left"}function ht(t,e,n){const r=p(t,"a:pPr"),a=[];let o="";for(const s of t.children){if("a:br"===s.name&&(o+="\n"),"a:r"!==s.name&&"a:fld"!==s.name)continue;const t=p(s,"a:t")?.text??"";o+=t,t.trim()&&a.push({text:t,style:ut(p(s,"a:rPr"),r,e,n)})}return{text:o,runs:a}}var yt=(t,e)=>t.sizePt===e.sizePt&&t.bold===e.bold&&t.colour===e.colour;function gt(t,e){const n=[],r=[],a=function(){const t=[];return(e,n)=>"bullet"===e.kind?"• ":"none"===e.kind?(t.length=Math.min(t.length,n),""):(t.length=Math.min(t.length,n+1),t[n]=(t[n]??e.startAt-1)+1,`${t[n]}. `)}();let o;for(const s of f(t,"a:p")){const t=p(s,"a:pPr"),i=Number(t?.attrs.lvl)||0,l=pt(e,i),c=ht(s,l,e),f=dt(t,l),u=c.text.trim()?a(f,i):"";n.push(u?`${" ".repeat(i)}${u}${c.text}`:c.text),c.runs.length&&!o&&(o=mt(t,l)),r.push(...c.runs)}if(!r[0])return null;const s=function(t){const e=[];for(const n of t){const t=e.find(t=>yt(t.style,n.style));t?t.length+=n.text.length:e.push({style:n.style,length:n.text.length})}return e.reduce((t,e)=>e.length>t.length?e:t).style}(r),i=Number(p(p(t,"a:bodyPr"),"a:normAutofit")?.attrs.fontScale);return{text:n.join("\n").trimEnd(),sizePt:s.sizePt*(i>0?i/1e5:1),bold:s.bold,colour:s.colour,align:o??"left",mixed:r.some(t=>!yt(t.style,s)),typefaces:new Set(r.flatMap(t=>t.style.typeface?[t.style.typeface]:[]))}}function wt(t,e){const n=t.map(t=>t.map(e));return n.some(t=>t.some(Boolean))?n:void 0}var xt=t=>t.reduce((t,e)=>t+e,0);function bt(t,e,n,r){const o=X(p(t,"p:xfrm")),s=f(e,"a:tr");if(!o||!s.length)return void(n.tally.skipped+=1);const i=f(p(e,"a:tblGrid"),"a:gridCol").map(t=>Number(t.attrs.w)||0),l=s.map(t=>Number(t.attrs.h)||0),c=s.map(t=>f(t,"a:tc").map(t=>function(t,e){const n=p(t,"a:txBody"),r=gt(n,{palette:e.palette,fonts:e.master?.fonts??{},lists:[p(n,"a:lstStyle"),e.presentation.defaultTextStyle],isTitle:!1});for(const t of r?.typefaces??[])e.tally.typefaces.add(t);return{text:r?.text.replace(/\s*\n\s*/g," ")??"",block:r,fill:R(p(t,"a:tcPr"),e.palette)??null}}(t,n))),u=G({...o,w:xt(i)||o.w,h:xt(l)||o.h},r,n.frame),d=function(t){const e=new Map;for(const{block:n}of t)n&&e.set(n.sizePt,(e.get(n.sizePt)??0)+1);return[...e].sort((t,e)=>e[1]-t[1])[0]?.[0]}(c.flat()),m={...u,type:"table",rows:c.map(t=>t.map(t=>t.text)),headerFill:c[0].map(t=>t.fill).find(Boolean)??a,headerColor:c[0].map(t=>t.block?.colour).find(Boolean),fontSize:void 0===d?void 0:H(d,n.frame),columnWidths:xt(i)?i.map(t=>{return e=t,n=xt(i),Math.round(e/n*1e4)/1e4;var e,n}):void 0,rowHeights:xt(l)?l.map(t=>Math.round(t/xt(l)*u.h*100)/100):void 0,cellFills:wt(c,t=>t.fill),cellColors:wt(c,t=>t.block?.colour??null)};n.elements.push(m)}var vt={rect:"rect",ellipse:"ellipse",roundRect:"roundRect",diamond:"diamond",line:"line",straightConnector1:"line",flowChartProcess:"rect",flowChartAlternateProcess:"roundRect",flowChartDecision:"diamond",flowChartConnector:"ellipse"},Mt=new Set(["a:videoFile","a:audioFile","a:quickTimeFile","p14:media"]);function kt(t,e,n,r){const a=gt(p(t,"p:txBody"),function(t,e,n){const r=p(p(t,"p:style"),"a:fontRef")?.children[0];return{palette:n.palette,fonts:n.master?.fonts??{},lists:it(t,e,n,n.presentation.defaultTextStyle),isTitle:"p:titleStyle"===e.style,styleColour:z(r,n.palette)}}(t,n,r));if(!a)return;const{scale:o}=r.frame,s=(e,r)=>(Number(lt(t,n,e)??r)||0)*o,l=H(a.sizePt,r.frame),c=s("lIns",91440),f=s("tIns",45720),u=Math.max(e.w-c-s("rIns",91440),1),d=Math.max(e.h-f-s("bIns",45720),1),m=lt(t,n,"anchor"),h=Math.max(d-function(t,e,n){const r=Math.max(1,Math.floor(n/(.52*e)));return t.split("\n").reduce((t,e)=>t+Math.max(1,Math.ceil(e.length/r)),0)*e*1.25}(a.text,l,u),0),y="ctr"===m?h/2:"b"===m?h:0;r.elements.push({id:i(),type:"text",rotation:e.rotation,x:L(e.x+c),y:L(e.y+f+y),w:L(u),h:L(d-y),text:a.text,fontSize:l,bold:a.bold,color:a.colour,align:a.align});for(const t of a.typefaces)r.tally.typefaces.add(t);a.mixed&&(r.tally.mixedTextSimplified+=1)}function Pt(t,e){const n=p(t,"p:spPr");if(p(n,"a:noFill"))return{kind:"none"};if(p(n,"a:solidFill")){const t=R(n,e.palette);return t?{kind:"colour",colour:t}:{kind:"none"}}if(["a:gradFill","a:blipFill","a:pattFill","a:grpFill"].some(t=>p(n,t))){const t=function(t,e){const n=p(p(p(t,"a:gradFill"),"a:gsLst"),"a:gs")?.children[0],r=p(p(t,"a:pattFill"),"a:fgClr")?.children[0];return z(n??r,e.palette)}(n,e);return t?{kind:"colour",colour:t}:{kind:"undrawable"}}const r=p(p(t,"p:style"),"a:fillRef"),a=r&&"0"!==r.attrs.idx?z(r.children[0],e.palette):void 0;return a?{kind:"colour",colour:a}:{kind:"none"}}function St(t,e){const n=p(p(t,"p:spPr"),"a:ln");if(p(n,"a:noFill"))return;const r=p(p(t,"p:style"),"a:lnRef"),a=R(n,e.palette)??(r&&"0"!==r.attrs.idx?z(r.children[0],e.palette):void 0);return a?{stroke:a,strokeWidth:L((Number(n?.attrs.w)||9525)*e.frame.scale)}:void 0}function Nt(t,e){const n=p(p(p(t,"a:prstGeom"),"a:avLst"),"a:gd")?.attrs.fmla,r=Number(n?.replace("val ",""));return L((Number.isFinite(r)?r:16667)/1e5*Math.min(e.w,e.h))}var Ct=t=>!!t?.attrs.type&&"none"!==t.attrs.type;function At(t,e,n){const r=p(t,"p:spPr"),o=p(r,"a:xfrm"),s=X(o);if(!s)return void(e.tally.skipped+=1);const i=St(t,e);if(!i)return;const l=p(r,"a:ln");e.elements.push({...U(s,{flipH:O(o?.attrs.flipH),flipV:O(o?.attrs.flipV)},n,e.frame),type:"shape",shape:"line",fill:a,...i,...Ct(p(l,"a:tailEnd"))?{arrowEnd:!0}:{},...Ct(p(l,"a:headEnd"))?{arrowStart:!0}:{}})}function Bt(t,e,n){const r=st(t,e),o=p(t,"p:spPr"),s=function(t){return vt[p(t,"a:prstGeom")?.attrs.prst??"rect"]??"rect"}(o);if("line"===s)return void At(t,e,n);const i=X(p(o,"a:xfrm"))??r.shapes.map(t=>X(p(p(t,"p:spPr"),"a:xfrm"))).find(Boolean);if(!i)return void(p(t,"p:txBody")&&u(t,new Set(["a:t"])).length&&(e.tally.skipped+=1));const l=G(i,n,e.frame),c=Pt(t,e),f=St(t,e),d="colour"===c.kind||!!f;d&&function(t,e,n,r,o,s){s.elements.push({...t,type:"shape",shape:e,fill:"colour"===n.kind?n.colour:a,...r,..."roundRect"===e?{radius:Nt(o,t)}:{}})}(l,s,c,f,o,e),kt(t,l,r,e),"undrawable"!==c.kind||d||(e.tally.skipped+=1)}function It(t,e){const n=e.rels.get(t?.attrs["r:embed"]??"");return n&&!n.external?w(e.part,n.target):void 0}function Ft(t,e,n){const r=p(t,"p:nvPicPr"),a=st(t,e),o=X(p(p(t,"p:spPr"),"a:xfrm"))??a.shapes.map(t=>X(p(p(t,"p:spPr"),"a:xfrm"))).find(Boolean),s=p(t,"p:blipFill"),i=It(p(s,"a:blip"),e.slide),l=i&&!u(t,Mt).length?e.useImage(i,function(t){const e=e=>(Number(t?.attrs[e])||0)/1e5,n={left:e("l"),top:e("t"),right:e("r"),bottom:e("b")},r=Object.values(n);if(!r.every(t=>0===t)&&!r.some(t=>t<0))return n.left+n.right<1&&n.top+n.bottom<1?n:void 0}(p(s,"a:srcRect"))):void 0;o&&l?e.elements.push({...G(o,n,e.frame),type:"image",src:l,alt:p(r,"p:cNvPr")?.attrs.descr??""}):e.tally.skipped+=1}function Tt(t,e,n){const r=p(p(p(t,"a:graphic"),"a:graphicData"),"a:tbl");r?bt(t,r,e,n):e.tally.skipped+=1}function jt(t,e,n=[]){for(const r of t)switch(r.name){case"p:sp":Bt(r,e,n);break;case"p:pic":Ft(r,e,n);break;case"p:graphicFrame":Tt(r,e,n);break;case"p:cxnSp":At(r,e,n);break;case"p:contentPart":e.tally.skipped+=1;break;case"p:grpSp":{const t=D(r);jt(r.children,e,t?[t,...n]:n);break}case"mc:AlternateContent":jt(p(r,"mc:Fallback")?.children??[],e,n)}}function $t(t){const e=function(t){const e=h(t,"[Content_Types].xml"),n=e?m(e):void 0,r=new Map(f(n,"Override").map(t=>[t.attrs.PartName,t.attrs.ContentType])),a=new Map(f(n,"Default").map(t=>[t.attrs.Extension?.toLowerCase(),t.attrs.ContentType]));return t=>{const e=t.slice(t.lastIndexOf(".")+1).toLowerCase();return r.get(`/${t}`)??a.get(e)??_[e]??"application/octet-stream"}}(t),n=new Map;return{use:(t,r)=>{const a=e(t);if(!a.startsWith("image/"))return;const o=`${t}${function(t){return t?`#${t.left},${t.top},${t.right},${t.bottom}`:""}(r)}`;return n.has(o)||n.set(o,{key:o,part:t,contentType:a,crop:r}),o},uses:n}}function zt(t){return t.children.map(t=>"a:br"===t.name?"\n":"a:r"===t.name||"a:fld"===t.name?p(t,"a:t")?.text??"":"").join("")}function Rt(t,e){const n=q(e,"/notesSlide"),r=n&&Q(t,w(e.part,n.target)),a=((r&&K(r.root)?.children)??[]).find(t=>"body"===p(p(p(t,"p:nvSpPr"),"p:nvPr"),"p:ph")?.attrs.type);return f(p(a,"p:txBody"),"a:p").map(zt).join("\n").trim()}function Ot(t,e){const n=p(p(t.root,"p:cSld"),"p:bg");if(!n)return;const r=p(n,"p:bgPr"),a=R(r,e.palette)??z(p(n,"p:bgRef")?.children[0],e.palette);if(a)return{colour:a};const o=It(p(p(r,"a:blipFill"),"a:blip"),t);return o?{picture:o}:void 0}var Lt=t=>"0"===t.root.attrs.showMasterSp||"false"===t.root.attrs.showMasterSp;function Ht(t,e){const n=function(t){for(const e of[t.slide,t.layout,t.master]){const n=e&&Ot(e,t);if(n)return n}return{}}(t);return n.picture&&function(t,e){const n=e.useImage(t,void 0);if(!n)return void(e.tally.skipped+=1);const{left:r,top:a,width:o,height:s}=e.frame;e.elements.push({id:i(),type:"image",x:r,y:a,w:o,h:s,rotation:0,src:n,alt:""})}(n.picture,t),function(t){const{layout:e,master:n,slide:r}=t;if(!Lt(r))for(const r of[e&&Lt(e)?void 0:n,e]){const e=r?K(r.root)?.children??[]:[];r&&jt(e.filter(t=>!et(t)),{...t,slide:r})}}(t),jt(K(t.slide.root)?.children??[],t),{id:i(),background:n.colour??"#ffffff",notes:Rt(e,t.slide),elements:(r=t.elements,a=t.tally,a.skipped+=Math.max(r.length-200,0),r.slice(0,200))};var r,a}var Et=t=>"0"===t.root.attrs.show||"false"===t.root.attrs.show;function Xt(t){const n=function(t){const n=y(t,"").find(t=>t.type.endsWith("/officeDocument")),r=Q(t,n?w("",n.target):"ppt/presentation.xml");if(!r||"p:presentation"!==r.root.name)throw new e;const a=f(p(r.root,"p:sldIdLst"),"p:sldId").flatMap(t=>{const e=r.rels.get(t.attrs["r:id"]);return e?[w(r.part,e.target)]:[]}),o=p(r.root,"p:sldSz")?.attrs;return{width:Number(o?.cx)||9144e3,height:Number(o?.cy)||5143500,slides:a,defaultTextStyle:p(r.root,"p:defaultTextStyle")}}(t),r=function(t){const e=new Map,n=new Map;return r=>{const a=q(r,"/slideLayout"),o=a&&w(r.part,a.target);o&&!n.has(o)&&n.set(o,J(t,o,e));const s=o?n.get(o):void 0,i=s?.master,l=i?.palette??Z;return{slide:r,layout:s,master:i,palette:B(s?B(l,s.root):l,r.root)}}}(t),a=$t(t),i=function(t,e){const n=Math.min(s/t,o/e);return{scale:n,left:(s-t*n)/2,top:(o-e*n)/2,width:t*n,height:e*n}}(n.width,n.height),c={skipped:0,mixedTextSimplified:0,typefaces:new Set},u=[];let d=0;for(const e of n.slides){const o=Q(t,e);o&&!Et(o)&&(p(o.root,"p:timing")&&(d+=1),u.push(Ht({...r(o),presentation:n,frame:i,tally:c,elements:[],useImage:a.use},t)))}const m=new Set(u.flatMap(t=>t.elements.flatMap(t=>"image"===t.type?[t.src]:[])));return{document:{slides:u.length?u:[l()]},slideCount:u.length,images:[...a.uses.values()].filter(t=>m.has(t.key)),animationsDropped:d,tally:c}}var Dt=.15,Vt=1048576,Wt=/\.(xml|rels)$/i;async function Yt(n,r){if(await async function(t){const e=new Uint8Array(await t.slice(0,v.length).arrayBuffer());return v.every((t,n)=>e[n]===t)}(n))throw await async function(t,e){for(let n=0;n<t.size;n+=k-M.length)if(e?.throwIfAborted(),P(new Uint8Array(await t.slice(n,n+k).arrayBuffer())))return!0;return!1}(n,r)?new t:new e(c.pptxLegacyFormat)}function Gt(t){if(t.slides.length>300)throw new e(c.pptxTooManySlides(t.slides.length,300));const n=b(t);if(n>x)throw new e(c.pptxTooLarge((n/Vt).toFixed(1),2))}var Ut={"image/webp":"webp","image/png":"png","image/jpeg":"jpg","image/gif":"gif"};async function Zt(t,e,n){try{return await(n.prepareImage?n.prepareImage(e,t.contentType):async function(t,e,n){const r=await createImageBitmap(new Blob([t],{type:e}));try{const t=r.width*(n?.left??0),e=r.height*(n?.top??0),a=r.width-t-r.width*(n?.right??0),o=r.height-e-r.height*(n?.bottom??0),s=Math.min(1,1920/Math.max(a,o)),i=new OffscreenCanvas(Math.max(1,Math.round(a*s)),Math.max(1,Math.round(o*s))),l=i.getContext("2d");if(!l)throw new Error("No drawing context");return l.imageSmoothingQuality="high",l.drawImage(r,t,e,a,o,0,0,i.width,i.height),await i.convertToBlob({type:"image/webp",quality:.85})}finally{r.close()}}(e,t.contentType,t.crop))}catch(e){return n.signal?.throwIfAborted(),console.warn("A picture in the deck could not be read",t.part,e),null}}async function qt(t,e,n){const r={addresses:new Map,count:0,bytesBefore:0,bytesAfter:0},a=function(t,e){const n=new Map;for(const r of t){const t=e.prepareImage?r.part:r.key;n.set(t,[...n.get(t)??[],r])}return[...n.values()]}(t,n),o=new Map;let s=0;return await async function(t,e,n){let r=0,a=!1;await Promise.all(Array.from({length:Math.min(e,t.length)},async()=>{for(;!a&&r<t.length;){const e=t[r];r+=1;try{await n(e)}catch(t){throw a=!0,t}}}))}(a,4,async t=>{n.signal?.throwIfAborted();const[i]=t,l=o.get(i.part)??0;o.set(i.part,l+1);const c=await e.read(i.part).catch(()=>null),p=c&&await Zt(i,c,n);if(c&&p){n.signal?.throwIfAborted();const e=await n.storeImage(p,function(t,e,n){return`${t.slice(t.lastIndexOf("/")+1).replace(/\.[^.]*$/,"")}${n?`-${n}`:""}.${Ut[e.type]??"img"}`}(i.part,p,l));for(const{key:n}of t)r.addresses.set(n,e);r.count+=1,r.bytesBefore+=c.length,r.bytesAfter+=p.size}s+=1,n.onProgress?.(Dt+.85*s/a.length)}),r}async function Kt(t,r){r.signal?.throwIfAborted(),await Yt(t,r.signal);const a=await async function(t){try{return await d(t)}catch{throw new e}}(t),o=await async function(t,e){const n=new Map,r=t.names.filter(t=>Wt.test(t));for(const[a,o]of r.entries())e.signal?.throwIfAborted(),n.set(o,await t.read(o)),e.onProgress?.(Dt*(a+1)/r.length);return n}(a,r).catch(t=>{throw r.signal?.throwIfAborted(),t instanceof e?t:new e}),s=function(t){try{return Xt(t)}catch(t){if(t instanceof e)throw t;throw new e}}(o);Gt(s.document);const i=await qt(s.images,a,r),l=function(t,e,n){const r=t=>{if("image"!==t.type)return[t];const r=e.get(t.src);return void 0===r&&(n.skipped+=1),void 0===r?[]:[{...t,src:r}]};return{slides:t.slides.map(t=>({...t,elements:t.elements.flatMap(r)}))}}(s.document,i.addresses,s.tally);return Gt(l),r.onProgress?.(1),{document:l,notes:{slides:s.slideCount,images:i.count,imageBytesBefore:i.bytesBefore,imageBytesAfter:i.bytesAfter,fontsReplaced:[...s.tally.typefaces].filter(t=>t!==n).sort(),animationsDropped:s.animationsDropped,mixedTextSimplified:s.tally.mixedTextSimplified,skipped:s.tally.skipped}}}export{Kt as importPptx};
@@ -1,10 +1,118 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, ComponentType } from 'react';
3
+ import { F as FileWords, C as ChooseOfficeFile, P as PdfOptions } from '../words-DK_ajpEa.js';
4
+ export { E as ENGLISH_FILE_WORDS, O as OfficeFileChoice, a as OfficeFileRequest, Z as ZH_HANS_FILE_WORDS, h as hasExtension } from '../words-DK_ajpEa.js';
5
+
6
+ interface Box {
7
+ x: number;
8
+ y: number;
9
+ w: number;
10
+ h: number;
11
+ }
12
+ interface ElementBase extends Box {
13
+ id: string;
14
+ rotation: number;
15
+ }
16
+ interface TextElement extends ElementBase {
17
+ type: 'text';
18
+ text: string;
19
+ fontSize: number;
20
+ bold: boolean;
21
+ color: string;
22
+ align: 'left' | 'center' | 'right';
23
+ }
24
+ type ShapeKind = 'rect' | 'ellipse' | 'roundRect' | 'diamond' | 'line';
25
+ interface ShapeElement extends ElementBase {
26
+ type: 'shape';
27
+ /** A `line` runs left to right through the middle of its box; `rotation` turns it. */
28
+ shape: ShapeKind;
29
+ fill: string;
30
+ stroke?: string;
31
+ strokeWidth?: number;
32
+ /** A `roundRect`'s corners, in slide pixels. */
33
+ radius?: number;
34
+ arrowEnd?: boolean;
35
+ arrowStart?: boolean;
36
+ }
37
+ interface ImageElement extends ElementBase {
38
+ type: 'image';
39
+ src: string;
40
+ alt: string;
41
+ }
42
+ interface ChartPoint {
43
+ label: string;
44
+ value: number;
45
+ }
46
+ interface ChartElement extends ElementBase {
47
+ type: 'chart';
48
+ kind: 'bar' | 'line';
49
+ points: ChartPoint[];
50
+ color: string;
51
+ }
52
+ interface TableElement extends ElementBase {
53
+ type: 'table';
54
+ rows: string[][];
55
+ headerFill: string;
56
+ /** With none of these, a table draws at the standard size with even rows and columns. */
57
+ fontSize?: number;
58
+ headerColor?: string;
59
+ /** Each column's share of the width; together they make 1. */
60
+ columnWidths?: number[];
61
+ /** In slide pixels, drawn in proportion to the box. */
62
+ rowHeights?: number[];
63
+ /** By row and column; null takes the table's own look. */
64
+ cellFills?: (string | null)[][];
65
+ cellColors?: (string | null)[][];
66
+ }
67
+ type SlideElement = TextElement | ShapeElement | ImageElement | ChartElement | TableElement;
68
+ interface Slide {
69
+ id: string;
70
+ background: string;
71
+ notes: string;
72
+ elements: SlideElement[];
73
+ }
74
+ interface DeckDocument {
75
+ slides: Slide[];
76
+ }
77
+ /** A document that came back from the server with nothing in it yet. */
78
+ declare function asDocument(stored: unknown): DeckDocument;
79
+
80
+ interface PptxImportNotes {
81
+ slides: number;
82
+ images: number;
83
+ imageBytesBefore: number;
84
+ imageBytesAfter: number;
85
+ /** Typefaces in the file that are not the deck's font. */
86
+ fontsReplaced: string[];
87
+ /** Slides carrying `p:timing`. */
88
+ animationsDropped: number;
89
+ /** Text boxes whose runs had differing formats. */
90
+ mixedTextSimplified: number;
91
+ /** Shapes with no deck equivalent (charts, custom geometry, video). */
92
+ skipped: number;
93
+ }
94
+ interface PptxImportOptions {
95
+ /** Stores one prepared image, answering the address a deck image uses. */
96
+ storeImage: (image: Blob, name: string) => Promise<string>;
97
+ /** Called as work proceeds: 0..1. */
98
+ onProgress?: (fraction: number) => void;
99
+ signal?: AbortSignal;
100
+ /** Replaces the browser's canvas compression; tests and Node pass it. */
101
+ prepareImage?: (bytes: Uint8Array, contentType: string) => Promise<Blob>;
102
+ }
103
+
104
+ declare class PptxPasswordError extends Error {
105
+ constructor(message?: string);
106
+ }
107
+ declare class PptxUnreadableError extends Error {
108
+ constructor(message?: string);
109
+ }
3
110
 
4
111
  /**
5
112
  * The Slides app's words: its English, and each language this package carries. A
6
113
  * host hands a language in through `SlidesProvider`'s `words`.
7
114
  */
115
+
8
116
  interface SlidesWords {
9
117
  decks: string;
10
118
  newDeck: string;
@@ -76,6 +184,10 @@ interface SlidesWords {
76
184
  colour: string;
77
185
  rectangle: string;
78
186
  ellipse: string;
187
+ roundedRectangle: string;
188
+ diamond: string;
189
+ lineShape: string;
190
+ outlineColour: string;
79
191
  imageAddress: string;
80
192
  chooseImage: string;
81
193
  imageTitle: string;
@@ -89,6 +201,23 @@ interface SlidesWords {
89
201
  rows: string;
90
202
  rowsHint: string;
91
203
  headingColour: string;
204
+ pptxPasswordProtected: string;
205
+ pptxUnreadable: string;
206
+ pptxLegacyFormat: string;
207
+ pptxTooManySlides: (count: number, limit: number) => string;
208
+ pptxTooLarge: (size: string, limit: number) => string;
209
+ pdfSlideFailed: (slide: number) => string;
210
+ /** The file list's shared words: Open, Rename and the rest. */
211
+ files: FileWords;
212
+ /** The kind of file Open takes, as the drive names it. */
213
+ fileKind: string;
214
+ /** What a PowerPoint file had that its deck doesn't, or `null` when nothing is missing. */
215
+ importNotes: (left: {
216
+ skipped: number;
217
+ animations: number;
218
+ fonts: string[];
219
+ }) => string | null;
220
+ dismiss: string;
92
221
  }
93
222
  declare const ENGLISH_WORDS: SlidesWords;
94
223
  /** Machine-written and not yet reviewed. */
@@ -128,6 +257,12 @@ interface SlidesHost {
128
257
  /** Choose an image for a slide, answering its address. Absent: the image field
129
258
  * takes a typed address. */
130
259
  pickImage?: () => Promise<string | null>;
260
+ /** Keep one picture from an opened PowerPoint file, answering the address a slide
261
+ * names it by. Absent: pictures are kept in the deck itself, as data. */
262
+ storeImage?: (image: Blob, name: string) => Promise<string>;
263
+ /** Choose a PowerPoint file from the host's drive (../files/choose.ts). Absent:
264
+ * Open takes a file from this computer only. */
265
+ chooseFile?: ChooseOfficeFile;
131
266
  /** The app's words in the host's language. Absent: English. */
132
267
  words?: SlidesWords;
133
268
  }
@@ -139,61 +274,18 @@ declare function SlidesProvider({ value, children }: {
139
274
  children: ReactNode;
140
275
  }): react.JSX.Element;
141
276
 
142
- interface Box {
143
- x: number;
144
- y: number;
145
- w: number;
146
- h: number;
147
- }
148
- interface ElementBase extends Box {
277
+ interface ImportedDeck {
149
278
  id: string;
150
- rotation: number;
151
- }
152
- interface TextElement extends ElementBase {
153
- type: 'text';
154
- text: string;
155
- fontSize: number;
156
- bold: boolean;
157
- color: string;
158
- align: 'left' | 'center' | 'right';
159
- }
160
- interface ShapeElement extends ElementBase {
161
- type: 'shape';
162
- shape: 'rect' | 'ellipse';
163
- fill: string;
164
- }
165
- interface ImageElement extends ElementBase {
166
- type: 'image';
167
- src: string;
168
- alt: string;
169
- }
170
- interface ChartPoint {
171
- label: string;
172
- value: number;
173
- }
174
- interface ChartElement extends ElementBase {
175
- type: 'chart';
176
- kind: 'bar' | 'line';
177
- points: ChartPoint[];
178
- color: string;
179
- }
180
- interface TableElement extends ElementBase {
181
- type: 'table';
182
- rows: string[][];
183
- headerFill: string;
184
- }
185
- type SlideElement = TextElement | ShapeElement | ImageElement | ChartElement | TableElement;
186
- interface Slide {
187
- id: string;
188
- background: string;
189
- notes: string;
190
- elements: SlideElement[];
279
+ title: string;
280
+ notes: PptxImportNotes;
191
281
  }
192
- interface DeckDocument {
193
- slides: Slide[];
282
+ interface ImportDeckOptions {
283
+ /** Where each picture goes. Absent: kept in the deck as a data address. */
284
+ storeImage?: (image: Blob, name: string) => Promise<string>;
285
+ onProgress?: (fraction: number) => void;
286
+ signal?: AbortSignal;
194
287
  }
195
- /** A document that came back from the server with nothing in it yet. */
196
- declare function asDocument(stored: unknown): DeckDocument;
288
+ declare function importDeckFile(store: SlidesStore, file: File, options?: ImportDeckOptions): Promise<ImportedDeck>;
197
289
 
198
290
  /** The slide at `width` pixels. `editingId`'s element gives way to `editor`. */
199
291
  declare function SlideView({ slide, width, editingId, editor, }: {
@@ -219,5 +311,12 @@ declare const slidesApps: {
219
311
  readonly autoHeight: false;
220
312
  };
221
313
  };
314
+ /** Throws `PptxPasswordError` for an encrypted file, `PptxUnreadableError` for one that is not a pptx. */
315
+ declare function importPptx(file: Blob, options: PptxImportOptions): Promise<{
316
+ document: DeckDocument;
317
+ notes: PptxImportNotes;
318
+ }>;
319
+ /** A PDF with one page for each slide, drawn as `SlideView` draws it. */
320
+ declare function deckToPdf(document: DeckDocument, options?: PdfOptions): Promise<Blob>;
222
321
 
223
- export { DeckEditor, type DeckSummary, ENGLISH_WORDS, SlideView, Slides, SlidesConflict, type SlidesHost, SlidesProvider, type SlidesStore, type SlidesWords, type StoredDeck, ZH_HANS_WORDS, asDocument, browserSlidesStore, slidesApps };
322
+ export { ChooseOfficeFile, DeckEditor, type DeckSummary, ENGLISH_WORDS, FileWords, type ImportDeckOptions, type ImportedDeck, PdfOptions, type PptxImportNotes, type PptxImportOptions, PptxPasswordError, PptxUnreadableError, SlideView, Slides, SlidesConflict, type SlidesHost, SlidesProvider, type SlidesStore, type SlidesWords, type StoredDeck, ZH_HANS_WORDS, asDocument, browserSlidesStore, deckToPdf, importDeckFile, importPptx, slidesApps };
@@ -1 +1 @@
1
- import{SlideView as e,asDocument as o}from"../chunk-3JJCHWPJ.js";import{ENGLISH_WORDS as t,SlidesConflict as i,SlidesProvider as r,ZH_HANS_WORDS as s,browserSlidesStore as l}from"../chunk-BTDWPUTS.js";import{lazy as p}from"react";var m=p(()=>import("../Slides-ILKPLYAJ.js")),a=p(()=>import("../Slides-ILKPLYAJ.js").then(e=>({default:e.OpenDeck}))),d={"/slides":{component:m,label:"Slides",size:"3xl",appStyle:!0,flushBody:!0,autoHeight:!1}};export{a as DeckEditor,t as ENGLISH_WORDS,e as SlideView,m as Slides,i as SlidesConflict,r as SlidesProvider,s as ZH_HANS_WORDS,o as asDocument,l as browserSlidesStore,d as slidesApps};
1
+ import{importDeckFile as o}from"../chunk-QFPW3KLL.js";import{PptxPasswordError as t,PptxUnreadableError as r}from"../chunk-RLNXQG4T.js";import{SlidesConflict as m,SlidesProvider as i,browserSlidesStore as p}from"../chunk-OB4MLAZC.js";import{SlideView as s}from"../chunk-2AKHYM66.js";import{asDocument as n}from"../chunk-2TZUCKZ7.js";import{ENGLISH_WORDS as c,ZH_HANS_WORDS as e}from"../chunk-X6F3Z4KZ.js";import{ENGLISH_FILE_WORDS as f,ZH_HANS_FILE_WORDS as u}from"../chunk-B32ASXHM.js";import{hasExtension as a}from"../chunk-XYVQTQ6N.js";import{lazy as j}from"react";var h=j(()=>import("../Slides-JMP36AJH.js")),k=j(()=>import("../Slides-JMP36AJH.js").then(o=>({default:o.OpenDeck}))),d={"/slides":{component:h,label:"Slides",size:"3xl",appStyle:!0,flushBody:!0,autoHeight:!1}};async function l(o,t){const{importPptx:r}=await(import("../pptxImport-STLMOUNE.js"));return r(o,t)}async function M(o,t){const{deckToPdf:r}=await(import("../deckPdf-Y2RE7MFX.js"));return r(o,t)}export{k as DeckEditor,f as ENGLISH_FILE_WORDS,c as ENGLISH_WORDS,t as PptxPasswordError,r as PptxUnreadableError,s as SlideView,h as Slides,m as SlidesConflict,i as SlidesProvider,u as ZH_HANS_FILE_WORDS,e as ZH_HANS_WORDS,n as asDocument,p as browserSlidesStore,M as deckToPdf,a as hasExtension,o as importDeckFile,l as importPptx,d as slidesApps};
@@ -70,3 +70,26 @@
70
70
  .slides-list-rows { flex: 1; overflow-y: auto; margin: 0; padding: 0; list-style: none; }
71
71
  .slides-list-row { display: flex; align-items: center; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--line); }
72
72
  .slides-list-date { flex: 1; text-align: right; font-size: 14px; opacity: 0.7; }
73
+ /* A deck opened from a PowerPoint file says, once, what didn't come across. */
74
+ .slides-with-note { display: flex; flex-direction: column; height: 100%; }
75
+ .slides-with-note-body { flex: 1; min-height: 0; }
76
+ .slides-import-note { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px; color: var(--status-warning-text, var(--ink)); background: var(--status-warning-bg, var(--surface-raised)); border-bottom: 1px solid var(--line); }
77
+ .slides-import-note > span { flex: 1; }
78
+ /* The file list Documents and Spreadsheet share (./FileList.tsx), laid out as
79
+ Slides' deck list is. The build appends this to documents.css and
80
+ spreadsheet.css, so a host loads it with the app's own stylesheet. */
81
+ .office-filelist { display: flex; flex-direction: column; height: 100%; background: var(--surface); color: var(--ink); }
82
+ .office-filelist-head { display: flex; align-items: center; gap: 8px; padding: 16px; border-bottom: 1px solid var(--line); }
83
+ .office-filelist-head h2 { flex: 1; margin: 0; font-size: 16px; font-weight: 500; }
84
+ .office-filelist-empty { padding: 24px; }
85
+ .office-filelist-rows { flex: 1; overflow-y: auto; margin: 0; padding: 0; list-style: none; }
86
+ .office-filelist-row { display: flex; align-items: center; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--line); }
87
+ .office-filelist-date { flex: 1; text-align: right; font-size: 14px; opacity: 0.7; }
88
+ .office-filelist-input { display: none; }
89
+ .office-conflict { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; background: var(--status-warning-bg, var(--surface-raised)); border-bottom: 1px solid var(--line); font-size: 12px; }
90
+ .office-open-failed { padding: 24px; }
91
+ .office-save-state { margin-left: auto; }
92
+ .office-filelist-busy { padding: 8px 16px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--ink-muted, var(--ink)); background: var(--surface-sunken, var(--surface)); }
93
+ .office-filelist-rename { flex: 0 1 320px; min-width: 160px; }
94
+ .office-filelist-open { display: inline-flex; align-items: center; gap: 6px; }
95
+ .office-filelist:focus { outline: none; }
@@ -1,6 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, ComponentType } from 'react';
3
3
  import { SpreadsheetPreviewData } from 'efficient-shell/apps';
4
+ import { C as ChooseOfficeFile, F as FileWords, P as PdfOptions } from '../words-DK_ajpEa.js';
5
+ export { E as ENGLISH_FILE_WORDS, O as OfficeFileChoice, a as OfficeFileRequest, Z as ZH_HANS_FILE_WORDS, h as hasExtension } from '../words-DK_ajpEa.js';
4
6
 
5
7
  interface CellRange {
6
8
  r1: number;
@@ -180,6 +182,54 @@ declare function createSheetBridge(): {
180
182
  };
181
183
  type SheetBridge = ReturnType<typeof createSheetBridge>;
182
184
 
185
+ /** What a store holds for one spreadsheet. */
186
+ interface Workbook {
187
+ sheets: Sheet[];
188
+ }
189
+ interface SpreadsheetSummary {
190
+ id: string;
191
+ title: string;
192
+ updatedAt: string;
193
+ }
194
+ interface StoredSpreadsheet {
195
+ id: string;
196
+ title: string;
197
+ /** The workbook as stored. Null for a new spreadsheet, which opens on one blank sheet. */
198
+ workbook: Workbook | null;
199
+ /** The version this workbook was read at, opaque to this package. */
200
+ version: string;
201
+ }
202
+ /** A save refused because somebody saved since this editor read the spreadsheet. */
203
+ declare class SpreadsheetsConflict extends Error {
204
+ }
205
+ interface SpreadsheetsStore {
206
+ list: () => Promise<SpreadsheetSummary[]>;
207
+ get: (id: string) => Promise<StoredSpreadsheet>;
208
+ create: (title: string) => Promise<StoredSpreadsheet>;
209
+ rename: (id: string, title: string) => Promise<void>;
210
+ /** Writes the workbook whole, and answers its new version. Rejects with
211
+ * `SpreadsheetsConflict` when `version` is no longer the stored one. */
212
+ save: (id: string, workbook: Workbook, version: string) => Promise<string>;
213
+ remove: (id: string) => Promise<void>;
214
+ }
215
+ interface SpreadsheetsHost {
216
+ /** Absent: nothing saves by itself. */
217
+ store?: SpreadsheetsStore;
218
+ /** Absent: a person may. */
219
+ canCreate?: boolean;
220
+ canDelete?: boolean;
221
+ /** Choose a file from the host's drive (../files/choose.ts). Absent: Open takes
222
+ * a file from this computer only. */
223
+ chooseFile?: ChooseOfficeFile;
224
+ }
225
+ declare function SpreadsheetsProvider({ value, children }: {
226
+ value: SpreadsheetsHost;
227
+ children: ReactNode;
228
+ }): react.JSX.Element;
229
+
230
+ /** The files Spreadsheet opens, apart from the readers so the package entry can name them without loading one. */
231
+ declare const SPREADSHEET_EXTENSIONS: readonly string[];
232
+
183
233
  /**
184
234
  * The Spreadsheets app's words: its English, and each language this package carries. A
185
235
  * host hands a language in through `SpreadsheetWordsProvider`.
@@ -187,6 +237,7 @@ type SheetBridge = ReturnType<typeof createSheetBridge>;
187
237
  * The zh-Hans words for the file list and saving (`backToFiles` to
188
238
  * `deleteConfirm`) are machine-written, and no person has read them yet.
189
239
  */
240
+
190
241
  interface SpreadsheetWords {
191
242
  untitled: string;
192
243
  backToFiles: string;
@@ -333,6 +384,11 @@ interface SpreadsheetWords {
333
384
  deleteSheetMessage: (name: string) => string;
334
385
  /** One line about a formula function, by its name; the name itself for one it has none for. */
335
386
  functionHelp: (name: string) => string;
387
+ pdfPageFailed: (page: number) => string;
388
+ /** The file list's shared words: Open, Rename and the rest. */
389
+ files: FileWords;
390
+ /** The kind of file Open takes from the drive, as the drive names it. */
391
+ fileKind: string;
336
392
  }
337
393
  declare const ENGLISH_WORDS: SpreadsheetWords;
338
394
  declare const ZH_HANS_WORDS: SpreadsheetWords;
@@ -342,48 +398,6 @@ declare function SpreadsheetWordsProvider({ words, children }: {
342
398
  children: ReactNode;
343
399
  }): react.JSX.Element;
344
400
 
345
- /** What a store holds for one spreadsheet. */
346
- interface Workbook {
347
- sheets: Sheet[];
348
- }
349
- interface SpreadsheetSummary {
350
- id: string;
351
- title: string;
352
- updatedAt: string;
353
- }
354
- interface StoredSpreadsheet {
355
- id: string;
356
- title: string;
357
- /** The workbook as stored. Null for a new spreadsheet, which opens on one blank sheet. */
358
- workbook: Workbook | null;
359
- /** The version this workbook was read at, opaque to this package. */
360
- version: string;
361
- }
362
- /** A save refused because somebody saved since this editor read the spreadsheet. */
363
- declare class SpreadsheetsConflict extends Error {
364
- }
365
- interface SpreadsheetsStore {
366
- list: () => Promise<SpreadsheetSummary[]>;
367
- get: (id: string) => Promise<StoredSpreadsheet>;
368
- create: (title: string) => Promise<StoredSpreadsheet>;
369
- rename: (id: string, title: string) => Promise<void>;
370
- /** Writes the workbook whole, and answers its new version. Rejects with
371
- * `SpreadsheetsConflict` when `version` is no longer the stored one. */
372
- save: (id: string, workbook: Workbook, version: string) => Promise<string>;
373
- remove: (id: string) => Promise<void>;
374
- }
375
- interface SpreadsheetsHost {
376
- /** Absent: nothing saves by itself. */
377
- store?: SpreadsheetsStore;
378
- /** Absent: a person may. */
379
- canCreate?: boolean;
380
- canDelete?: boolean;
381
- }
382
- declare function SpreadsheetsProvider({ value, children }: {
383
- value: SpreadsheetsHost;
384
- children: ReactNode;
385
- }): react.JSX.Element;
386
-
387
401
  declare const Spreadsheet: ComponentType<{
388
402
  spreadsheetId?: string;
389
403
  onClose?: () => void;
@@ -416,5 +430,15 @@ declare const spreadsheetApp: {
416
430
  readonly multiInstance: true;
417
431
  };
418
432
  };
433
+ /** The sheets of an `.xlsx`, formulas and formatting kept. */
434
+ declare function readXlsx(bytes: Uint8Array): Promise<Sheet[]>;
435
+ /** A PDF of each sheet's displayed values, A4 landscape, its header row on every page. */
436
+ declare function workbookToPdf(sheets: readonly Sheet[], options?: PdfOptions): Promise<Blob>;
437
+ /** An Excel, OpenDocument or CSV file as a spreadsheet of its own in `store`, which
438
+ * then opens by id. The file stays as it was. */
439
+ declare function importSpreadsheetFile(store: SpreadsheetsStore, file: File): Promise<{
440
+ id: string;
441
+ title: string;
442
+ }>;
419
443
 
420
- export { ENGLISH_WORDS, type Sheet, type SheetBridge, type SheetBridgeState, type SheetEditFormat, type SheetEditOp, SheetEditRefused, type SheetEditResult, type SheetEditorPort, type SheetSnapshot, Spreadsheet, SpreadsheetEditor, SpreadsheetPane, type SpreadsheetSummary, type SpreadsheetWords, SpreadsheetWordsProvider, SpreadsheetsConflict, type SpreadsheetsHost, SpreadsheetsProvider, type SpreadsheetsStore, type StoredSpreadsheet, type Workbook, ZH_HANS_WORDS, applySheetOps, createSheetBridge, spreadsheetApp };
444
+ export { ChooseOfficeFile, ENGLISH_WORDS, FileWords, PdfOptions, SPREADSHEET_EXTENSIONS, type Sheet, type SheetBridge, type SheetBridgeState, type SheetEditFormat, type SheetEditOp, SheetEditRefused, type SheetEditResult, type SheetEditorPort, type SheetSnapshot, Spreadsheet, SpreadsheetEditor, SpreadsheetPane, type SpreadsheetSummary, type SpreadsheetWords, SpreadsheetWordsProvider, SpreadsheetsConflict, type SpreadsheetsHost, SpreadsheetsProvider, type SpreadsheetsStore, type StoredSpreadsheet, type Workbook, ZH_HANS_WORDS, applySheetOps, createSheetBridge, importSpreadsheetFile, readXlsx, spreadsheetApp, workbookToPdf };
@@ -1 +1 @@
1
- import{ENGLISH_WORDS as e,SpreadsheetWordsProvider as t,SpreadsheetsConflict as n,SpreadsheetsProvider as s,ZH_HANS_WORDS as r,cellDisplay as a,cellLabel as o,changeStructure as l,clearValues as c,colIndex as i,commitEntry as h,isFormula as u,makeEvaluator as p,newSheet as d,parseRangeLabel as m,rangeLabel as f,renameSheet as g,sortRange as w,updateFormats as b,usedBounds as S}from"../chunk-372GCYWH.js";import{lazy as M}from"react";var k=class extends Error{};function _(e,t,n){if(!t)return Math.min(n,e.length-1);const s=e.findIndex(e=>e.name.toLowerCase()===t.trim().toLowerCase());if(s<0)throw new k(`there is no sheet "${t}" any more`);return s}function v(e){const t=m(e);if(!t)throw new k(`"${e}" is not a range`);return t}function y(e,t,n){return e.map((e,s)=>s===t?n(e):e)}function R(e,t){const n={...e},s=(e,t)=>{void 0!==t&&(null===t||!1===t?delete n[e]:n[e]=t)};return s("bold",t.bold),s("italic",t.italic),s("underline",t.underline),s("align",t.align),s("fill",t.fill),s("color",t.color),s("numFmt",t.numFmt),n}function x(e,t,n){let s=e;for(const e of n)switch(e.op){case"add_sheet":if(s.some(t=>t.name.toLowerCase()===e.name.toLowerCase()))throw new k(`there is already a sheet "${e.name}"`);s=[...s,d(e.name)];break;case"rename_sheet":s=g(s,_(s,e.sheet,t),e.name);break;case"set_cells":{const n=_(s,e.sheet,t),r=v(e.start);s=y(s,n,t=>{let n=t;return e.values.forEach((e,t)=>e.forEach((e,s)=>{n=h(n,r.r1+t,r.c1+s,e)})),n});break}case"clear":s=y(s,_(s,e.sheet,t),t=>c(t,v(e.range)));break;case"insert_rows":case"delete_rows":{const n=_(s,e.sheet,t);s=l(s,n,"row",e.at-1,"insert_rows"===e.op?e.count:-e.count);break}case"insert_columns":case"delete_columns":{const n=_(s,e.sheet,t);s=l(s,n,"col",i(e.at),"insert_columns"===e.op?e.count:-e.count);break}case"sort":{const n=_(s,e.sheet,t),r=p(s);s=y(s,n,t=>w(t,n,r,v(e.range),i(e.by),!e.descending));break}case"format":s=y(s,_(s,e.sheet,t),t=>b(t,v(e.range),t=>R(t,e.format)));break;default:throw new k("this spreadsheet does not make that change")}return s}function C(){let e=null,t={open:!1,title:"",selection:null};const n=new Set,s=new Map,r=e=>{if(e.open!==t.open||e.title!==t.title||e.selection?.sheet!==t.selection?.sheet||e.selection?.range!==t.selection?.range){t=e;for(const e of n)e()}};return{getState:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)}),attach:t=>(e=t,s.clear(),()=>{e===t&&(e=null,s.clear(),r({open:!1,title:"",selection:null}))}),changed(){if(!e)return;const t=e.sheets(),n=e.selection();r({open:!0,title:e.title(),selection:n&&t[n.sheet]?{sheet:t[n.sheet].name,range:f(n.range)}:null})},snapshot:()=>e?function(e,t,n,s){const r=p(t);return{title:e,sheets:t.map((e,t)=>{const n=S(e),s=[],l={};if(n)for(let c=0;c<=Math.min(n.row,4999);c++){const n=[],i=Math.min(e.cells[c]?.length??0,200);for(let s=0;s<i;s++){const i=e.cells[c][s]??"";""!==i?(n.push(a(e,t,r,c,s).text),u(i)&&(l[o(c,s)]=i)):n.push("")}s.push(n)}return{name:e.name,rows:s,formulas:l}}),activeSheet:Math.min(n,t.length-1),selection:s?{sheet:s.sheet,range:f(s.range)}:null}}(e.title(),e.sheets(),e.activeSheet(),e.selection()):null,apply(t,n){if(!e)return{applied:!1,reason:"the spreadsheet is closed"};if(s.has(t))return{applied:!0};const r=e.sheets();let a;try{a=x(r,e.activeSheet(),n)}catch(e){return{applied:!1,reason:e instanceof k?e.message:"it no longer fits the sheet"}}return e.commit(a),s.set(t,{before:r,after:a}),{applied:!0}},undo(t){const n=s.get(t);return e&&n?e.sheets()!==n.after?{applied:!1,reason:"the sheet has changed since"}:(e.undoLast(),s.delete(t),{applied:!0}):{applied:!1,reason:"the spreadsheet has been closed since"}}}}var F=M(()=>import("../Spreadsheet-R5MYRMOF.js")),L=M(()=>import("../Spreadsheet-R5MYRMOF.js").then(e=>({default:e.SpreadsheetById}))),j=M(()=>import("../Spreadsheet-R5MYRMOF.js").then(e=>({default:e.SpreadsheetPane}))),Y={"/spreadsheet":{component:F,label:"Spreadsheets",size:"2xl",appStyle:!0,multiInstance:!0}};export{e as ENGLISH_WORDS,k as SheetEditRefused,F as Spreadsheet,L as SpreadsheetEditor,j as SpreadsheetPane,t as SpreadsheetWordsProvider,n as SpreadsheetsConflict,s as SpreadsheetsProvider,r as ZH_HANS_WORDS,x as applySheetOps,C as createSheetBridge,Y as spreadsheetApp};
1
+ import{SPREADSHEET_EXTENSIONS as e,SpreadsheetWordsProvider as t,SpreadsheetsConflict as n,SpreadsheetsProvider as s}from"../chunk-GLT7O6TV.js";import{ENGLISH_WORDS as r,ZH_HANS_WORDS as o}from"../chunk-7K7AY3V3.js";import{cellDisplay as a,cellLabel as i,changeStructure as l,clearValues as c,colIndex as h,commitEntry as u,isFormula as p,makeEvaluator as m,newSheet as d,parseRangeLabel as f,rangeLabel as w,renameSheet as g,sortRange as b,updateFormats as k,usedBounds as S}from"../chunk-VKCG3LPQ.js";import{ENGLISH_FILE_WORDS as j,ZH_HANS_FILE_WORDS as y}from"../chunk-B32ASXHM.js";import{hasExtension as _}from"../chunk-XYVQTQ6N.js";import{lazy as x}from"react";var A=class extends Error{};function C(e,t,n){if(!t)return Math.min(n,e.length-1);const s=e.findIndex(e=>e.name.toLowerCase()===t.trim().toLowerCase());if(s<0)throw new A(`there is no sheet "${t}" any more`);return s}function L(e){const t=f(e);if(!t)throw new A(`"${e}" is not a range`);return t}function v(e,t,n){return e.map((e,s)=>s===t?n(e):e)}function E(e,t){const n={...e},s=(e,t)=>{void 0!==t&&(null===t||!1===t?delete n[e]:n[e]=t)};return s("bold",t.bold),s("italic",t.italic),s("underline",t.underline),s("align",t.align),s("fill",t.fill),s("color",t.color),s("numFmt",t.numFmt),n}function V(e,t,n){let s=e;for(const e of n)switch(e.op){case"add_sheet":if(s.some(t=>t.name.toLowerCase()===e.name.toLowerCase()))throw new A(`there is already a sheet "${e.name}"`);s=[...s,d(e.name)];break;case"rename_sheet":s=g(s,C(s,e.sheet,t),e.name);break;case"set_cells":{const n=C(s,e.sheet,t),r=L(e.start);s=v(s,n,t=>{let n=t;return e.values.forEach((e,t)=>e.forEach((e,s)=>{n=u(n,r.r1+t,r.c1+s,e)})),n});break}case"clear":s=v(s,C(s,e.sheet,t),t=>c(t,L(e.range)));break;case"insert_rows":case"delete_rows":{const n=C(s,e.sheet,t);s=l(s,n,"row",e.at-1,"insert_rows"===e.op?e.count:-e.count);break}case"insert_columns":case"delete_columns":{const n=C(s,e.sheet,t);s=l(s,n,"col",h(e.at),"insert_columns"===e.op?e.count:-e.count);break}case"sort":{const n=C(s,e.sheet,t),r=m(s);s=v(s,n,t=>b(t,n,r,L(e.range),h(e.by),!e.descending));break}case"format":s=v(s,C(s,e.sheet,t),t=>k(t,L(e.range),t=>E(t,e.format)));break;default:throw new A("this spreadsheet does not make that change")}return s}function M(){let e=null,t={open:!1,title:"",selection:null};const n=new Set,s=new Map,r=e=>{if(e.open!==t.open||e.title!==t.title||e.selection?.sheet!==t.selection?.sheet||e.selection?.range!==t.selection?.range){t=e;for(const e of n)e()}};return{getState:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)}),attach:t=>(e=t,s.clear(),()=>{e===t&&(e=null,s.clear(),r({open:!1,title:"",selection:null}))}),changed(){if(!e)return;const t=e.sheets(),n=e.selection();r({open:!0,title:e.title(),selection:n&&t[n.sheet]?{sheet:t[n.sheet].name,range:w(n.range)}:null})},snapshot:()=>e?function(e,t,n,s){const r=m(t);return{title:e,sheets:t.map((e,t)=>{const n=S(e),s=[],o={};if(n)for(let l=0;l<=Math.min(n.row,4999);l++){const n=[],c=Math.min(e.cells[l]?.length??0,200);for(let s=0;s<c;s++){const c=e.cells[l][s]??"";""!==c?(n.push(a(e,t,r,l,s).text),p(c)&&(o[i(l,s)]=c)):n.push("")}s.push(n)}return{name:e.name,rows:s,formulas:o}}),activeSheet:Math.min(n,t.length-1),selection:s?{sheet:s.sheet,range:w(s.range)}:null}}(e.title(),e.sheets(),e.activeSheet(),e.selection()):null,apply(t,n){if(!e)return{applied:!1,reason:"the spreadsheet is closed"};if(s.has(t))return{applied:!0};const r=e.sheets();let o;try{o=V(r,e.activeSheet(),n)}catch(e){return{applied:!1,reason:e instanceof A?e.message:"it no longer fits the sheet"}}return e.commit(o),s.set(t,{before:r,after:o}),{applied:!0}},undo(t){const n=s.get(t);return e&&n?e.sheets()!==n.after?{applied:!1,reason:"the sheet has changed since"}:(e.undoLast(),s.delete(t),{applied:!0}):{applied:!1,reason:"the spreadsheet has been closed since"}}}}var N=x(()=>import("../Spreadsheet-55AVNUEA.js")),F=x(()=>import("../Spreadsheet-55AVNUEA.js").then(e=>({default:e.SpreadsheetById}))),P=x(()=>import("../Spreadsheet-55AVNUEA.js").then(e=>({default:e.SpreadsheetPane}))),T={"/spreadsheet":{component:N,label:"Spreadsheets",size:"2xl",appStyle:!0,multiInstance:!0}};async function U(e){const{readXlsx:t}=await(import("../xlsxFile-B2JCZCOL.js"));return t(e)}async function B(e,t){const{workbookToPdf:n}=await(import("../workbookPdf-C5SSN226.js"));return n(e,t)}async function I(e,t){const{importSpreadsheetFile:n}=await(import("../importSpreadsheet-4U3KEJ76.js"));return n(e,t)}export{j as ENGLISH_FILE_WORDS,r as ENGLISH_WORDS,e as SPREADSHEET_EXTENSIONS,A as SheetEditRefused,N as Spreadsheet,F as SpreadsheetEditor,P as SpreadsheetPane,t as SpreadsheetWordsProvider,n as SpreadsheetsConflict,s as SpreadsheetsProvider,y as ZH_HANS_FILE_WORDS,o as ZH_HANS_WORDS,V as applySheetOps,M as createSheetBridge,_ as hasExtension,I as importSpreadsheetFile,U as readXlsx,T as spreadsheetApp,B as workbookToPdf};
@@ -12,3 +12,7 @@
12
12
  .office-conflict { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; background: var(--status-warning-bg, var(--surface-raised)); border-bottom: 1px solid var(--line); font-size: 12px; }
13
13
  .office-open-failed { padding: 24px; }
14
14
  .office-save-state { margin-left: auto; }
15
+ .office-filelist-busy { padding: 8px 16px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--ink-muted, var(--ink)); background: var(--surface-sunken, var(--surface)); }
16
+ .office-filelist-rename { flex: 0 1 320px; min-width: 160px; }
17
+ .office-filelist-open { display: inline-flex; align-items: center; gap: 6px; }
18
+ .office-filelist:focus { outline: none; }
@@ -0,0 +1,67 @@
1
+ /** How any of the three apps makes a PDF. */
2
+ interface PdfOptions {
3
+ /** Called after each page. */
4
+ onProgress?: (done: number, total: number) => void;
5
+ signal?: AbortSignal;
6
+ /** JPEG quality of each page, 0..1. */
7
+ quality?: number;
8
+ }
9
+
10
+ /**
11
+ * A file from the host's own drive, for the Open menu on each app's file list
12
+ * (./FileList.tsx). This package has no drive: a host that keeps people's files
13
+ * (EFFICIENT's Files window, say) hands in `chooseFile`, and the list's Open menu
14
+ * gains "From Efficient Drive" beside "From this computer". The host chooses in
15
+ * its own window, so there is never a second copy of it here.
16
+ *
17
+ * What comes back is opened as a copy in the app's own store: the original stays
18
+ * as it was. `place` puts that copy beside the original, and `location` says where
19
+ * that is, for the message the person reads once it is saved.
20
+ */
21
+ interface OfficeFileRequest {
22
+ /** What the host shows while it chooses: "Choosing a PowerPoint file for Slides". */
23
+ title: string;
24
+ /** The extensions the app opens, lower case, without the dot. */
25
+ extensions: readonly string[];
26
+ }
27
+ interface OfficeFileChoice {
28
+ file: File;
29
+ /** Where the original is, as the person reads it: "My files › Sales". Said only
30
+ * once `place` put the copy there. */
31
+ location?: string;
32
+ /** Puts the app's new copy (by its id in the app's store) beside the original. */
33
+ place?: (id: string) => Promise<void>;
34
+ }
35
+ type ChooseOfficeFile = (request: OfficeFileRequest) => Promise<OfficeFileChoice | null>;
36
+ /** Whether `name` ends in one of `extensions`. */
37
+ declare function hasExtension(name: string, extensions: readonly string[]): boolean;
38
+
39
+ /**
40
+ * The words every app's file list shares (./FileList.tsx): the Open menu, the
41
+ * right-click menu, renaming in the row, and the message once a file from
42
+ * elsewhere is saved as a copy. Each app carries one of these in its own words
43
+ * (`files`), so a host's language reaches them the way it reaches the rest.
44
+ *
45
+ * The zh-Hans words are machine-written, and no person has read them yet.
46
+ */
47
+ interface FileWords {
48
+ open: string;
49
+ fromComputer: string;
50
+ fromDrive: string;
51
+ rename: string;
52
+ delete: string;
53
+ /** The name field's label while a row is renamed. */
54
+ name: string;
55
+ renameFailed: string;
56
+ /** "Choosing a PowerPoint file for Slides". */
57
+ choosing: (kind: string, app: string) => string;
58
+ /** While a file is read and saved. */
59
+ opening: (name: string) => string;
60
+ openFailed: (name: string) => string;
61
+ /** Once a file from elsewhere is saved as a copy; `location` when it came from the drive. */
62
+ savedCopy: (title: string, original: string, location?: string) => string;
63
+ }
64
+ declare const ENGLISH_FILE_WORDS: FileWords;
65
+ declare const ZH_HANS_FILE_WORDS: FileWords;
66
+
67
+ export { type ChooseOfficeFile as C, ENGLISH_FILE_WORDS as E, type FileWords as F, type OfficeFileChoice as O, type PdfOptions as P, ZH_HANS_FILE_WORDS as Z, type OfficeFileRequest as a, hasExtension as h };
@@ -0,0 +1 @@
1
+ import{rowPageStarts as t}from"./chunk-PWF37Y2N.js";import{ENGLISH_WORDS as e}from"./chunk-7K7AY3V3.js";import{DEFAULT_COL_WIDTH as o,cellDisplay as n,filteredRows as r,formatKey as s,makeEvaluator as a,usedBounds as i}from"./chunk-VKCG3LPQ.js";import{drawJpeg as c,embeddedFonts as l,jpegPdf as d,openStage as p,settled as h}from"./chunk-JKYJGXJE.js";import"./chunk-B32ASXHM.js";var m=t=>t*(4/3),f=m(842),u=m(595),w=f-2*m(36),g=u-2*m(36),y="Calibri,Carlito,Arial,sans-serif",b=t=>Array.from({length:t},(t,e)=>e);function x(t,e,a){const c=i(t);if(!c)return{name:t.name,widths:[],rows:[],headerRows:0};const l=new Set([...t.hiddenRows,...r(t,e,a)]),d=new Set(t.hiddenCols),p=b(c.col+1).filter(t=>!d.has(t)),h=b(c.row+1).filter(t=>!l.has(t)).map(o=>p.map(r=>{const{text:i,align:c,color:l}=n(t,e,a,o,r),d=t.formats[s(o,r)];return{text:i,align:d?.align??c,color:d?.color??l,format:d}}));return{name:t.name,widths:p.map(e=>t.colWidths[e]??o),rows:h,headerRows:Math.min(Math.max(t.frozenRows,1),h.length)}}function R(t){const e=document.createElement("td");e.textContent=t.text;const{format:o}=t;return e.style.cssText=`border:.5pt solid #bbb;padding:1pt 3pt;vertical-align:top;overflow-wrap:anywhere;white-space:pre-wrap;text-align:${t.align}`,t.color&&(e.style.color=t.color),o?.fill&&(e.style.background=o.fill),o?.bold&&(e.style.fontWeight="700"),o?.italic&&(e.style.fontStyle="italic"),o?.fontSize&&(e.style.fontSize=`${o.fontSize}pt`),e}function v(t){const e=document.createElement("tr");return e.append(...t.map(R)),e}function E(t,e){const o=document.createElement("table"),n=t.widths.reduce((t,e)=>t+e,0);o.style.cssText=`border-collapse:collapse;table-layout:fixed;width:${n}px;font:10pt ${y};color:#000`;const r=document.createElement("colgroup");r.append(...t.widths.map(t=>Object.assign(document.createElement("col"),{style:`width:${t}px`})));const s=document.createElement("tbody");return s.append(...e.map(v)),o.append(r,s),o}function $(t){const e=document.createElement("div");return e.textContent=t,e.style.cssText=`font:600 13pt ${y};color:#000;margin-bottom:6pt`,e}function C({table:t,scale:e,starts:o},n){const r=document.createElement("div");if(r.style.cssText=`position:relative;overflow:hidden;background:#fff;width:${f}px;height:${u}px;padding:${m(36)}px;box-sizing:border-box`,r.append($(t.name)),t.rows.length){const s=o[n+1]??t.rows.length,a=E(t,[...t.rows.slice(0,t.headerRows),...t.rows.slice(o[n],s)]);a.style.transform=`scale(${e})`,a.style.transformOrigin="0 0",r.append(a)}return r}async function k(t,e,o,n){e.append(t);try{await h(t);return{jpeg:await c(t,{width:f,height:u,pixelRatio:2,quality:n,fontCss:o}),width:842,height:595}}finally{t.remove()}}async function A(o,n={}){const{signal:r,onProgress:s,quality:i}=n;r?.throwIfAborted();const c=p();try{const n=a(o),p=o.map((e,o)=>function(e,o){const n=e.widths.reduce((t,e)=>t+e,0),r=n>w?w/n:1,s=$(e.name),a=E(e,e.rows);o.append(s,a);const i=s.getBoundingClientRect().height+m(6),c=Array.from(a.querySelectorAll("tr"),t=>t.getBoundingClientRect().height);s.remove(),a.remove();const l=c.slice(0,e.headerRows).reduce((t,e)=>t+e,0),d=(g-i)/r,p=t(c.slice(e.headerRows),d,l).map(t=>t+e.headerRows);return{table:e,scale:r,starts:p}}(x(e,o,n),c.root)),h=p.reduce((t,e)=>t+e.starts.length,0),f=await l(c.root),u=[];for(const t of p)for(const o of t.starts.keys())r?.throwIfAborted(),u.push(await k(C(t,o),c.root,f,i).catch(t=>{throw new Error(e.pdfPageFailed(u.length+1),{cause:t})})),s?.(u.length,h);return d(u)}finally{c.close()}}export{x as sheetTable,A as workbookToPdf};
@@ -0,0 +1 @@
1
+ import{readXlsx as o,unzip as r,writeXlsx as m,zip as p}from"./chunk-N26CBJZA.js";import"./chunk-VKCG3LPQ.js";export{o as readXlsx,r as unzip,m as writeXlsx,p as zip};