efficient-office 0.12.0 → 0.14.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.
- package/dist/Documents-4L3242LJ.js +1 -0
- package/dist/Slides-JLWEMUXJ.js +1 -0
- package/dist/SlidesEditor-DGK4W6W4.js +1 -0
- package/dist/Spreadsheet-WQOZPWY5.js +1 -0
- package/dist/chunk-5K2D7PBJ.js +1 -0
- package/dist/chunk-7B4B25DB.js +1 -0
- package/dist/chunk-AJTH75FI.js +1 -0
- package/dist/chunk-BDVKNU3U.js +1 -0
- package/dist/chunk-CEVQKZ66.js +1 -0
- package/dist/chunk-EDJRXJNE.js +1 -0
- package/dist/chunk-EP3ZNVDB.js +1 -0
- package/dist/{chunk-DG4VDXLL.js → chunk-HQM2HX4V.js} +1 -1
- package/dist/{chunk-HNNYUGDU.js → chunk-JI56OCIU.js} +1 -1
- package/dist/{chunk-O35VT6BD.js → chunk-LGY776XE.js} +1 -1
- package/dist/chunk-PX4QOBHF.js +1 -0
- package/dist/{chunk-MDG2ADZ7.js → chunk-R2CXMNZL.js} +1 -1
- package/dist/{chunk-EC6D54MM.js → chunk-SDLOT5Z5.js} +1 -1
- package/dist/chunk-T2TZ7HF5.js +1 -0
- package/dist/chunk-VMUUFEWS.js +1 -0
- package/dist/chunk-VYLIT7NN.js +1 -0
- package/dist/{chunk-MR7ZWQHF.js → chunk-WAB44FLE.js} +1 -1
- package/dist/{chunk-NRGUS5QY.js → chunk-XENQLN5I.js} +1 -1
- package/dist/deckPdf-KZFS4CTF.js +1 -0
- package/dist/documents/documents.css +43 -1
- package/dist/documents/index.d.ts +154 -2
- package/dist/documents/index.js +1 -1
- package/dist/docxPdf-LO2VPZSJ.js +1 -0
- package/dist/importDocument-C5L275FU.js +1 -0
- package/dist/importSpreadsheet-L5FJGRUV.js +1 -0
- package/dist/{pptxImport-OACGHWQ6.js → pptxImport-UQQXZUQL.js} +1 -1
- package/dist/slides/index.d.ts +213 -17
- package/dist/slides/index.js +1 -1
- package/dist/slides/slides.css +53 -0
- package/dist/spreadsheet/index.d.ts +2 -1
- package/dist/spreadsheet/index.js +1 -1
- package/dist/workbookPdf-K65CQX4K.js +1 -0
- package/dist/xlsxFile-3GXD4KW5.js +1 -0
- package/package.json +1 -1
- package/dist/Documents-2ZU5D3ZI.js +0 -1
- package/dist/Slides-YZQXZJX4.js +0 -1
- package/dist/SlidesEditor-ETCUQVJ7.js +0 -1
- package/dist/Spreadsheet-VWRRB6FE.js +0 -1
- package/dist/chunk-3RFDQOTI.js +0 -1
- package/dist/chunk-ADXHTZ3Q.js +0 -1
- package/dist/chunk-B2X3NIQR.js +0 -1
- package/dist/chunk-BGAR3P46.js +0 -1
- package/dist/chunk-JKYJGXJE.js +0 -1
- package/dist/chunk-POH6OTTR.js +0 -1
- package/dist/chunk-PXOQN7D6.js +0 -1
- package/dist/chunk-Q7NVDOCX.js +0 -1
- package/dist/chunk-UKGIT2RS.js +0 -1
- package/dist/chunk-YKQ5UKYZ.js +0 -1
- package/dist/chunk-ZS45QEF4.js +0 -1
- package/dist/deckPdf-4RC7QJ45.js +0 -1
- package/dist/docxPdf-QSMEFCUF.js +0 -1
- package/dist/importDocument-34WALCTG.js +0 -1
- package/dist/importSpreadsheet-IRN32JON.js +0 -1
- package/dist/workbookPdf-CQTTURQ5.js +0 -1
- package/dist/xlsxFile-SX767BIH.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PptxPasswordError as t,PptxUnreadableError as e}from"./chunk-MDG2ADZ7.js";import{DECK_FONT as n,ENGLISH_WORDS as r,MIN_SIZE as a,NO_FILL as o,SLIDE_H as s,SLIDE_W as i,newId as l,newSlide as c}from"./chunk-PXOQN7D6.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-D3JKD7KW.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 $(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 j(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($,n).toLowerCase()}`}function O(t,e){return z(p(t,"a:solidFill")?.children[0],e)}var D=t=>"1"===t||"true"===t,R=t=>Math.round(100*t)/100+0,L=(t,e)=>R(12700*t*e.scale),E=t=>t*Math.PI/180;function H(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 V(t){const e=p(p(t,"p:grpSpPr"),"a:xfrm"),n=H(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:D(e?.attrs.flipH),flipV:D(e?.attrs.flipV)}}function X(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=X({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=>R((t%360+360)%360);function G(t,e,n){const r=e.reduce(W,t);return{id:l(),x:R(n.left+r.x*n.scale),y:R(n.top+r.y*n.scale),w:R(r.w*n.scale),h:R(r.h*n.scale),rotation:Y(r.rotation)}}function q(t,e,n,r){const o=t.x+t.w/2,s=t.y+t.h/2,i=E(t.rotation),c=a=>{const l=a*(e.flipH?-1:1)*t.w/2,c=a*(e.flipV?-1:1)*t.h/2,p={x:o+l*Math.cos(i)-c*Math.sin(i),y:s+l*Math.sin(i)+c*Math.cos(i)},f=n.reduce(X,p);return{x:r.left+f.x*r.scale,y:r.top+f.y*r.scale}},p=c(-1),f=c(1),u=Math.hypot(f.x-p.x,f.y-p.y);return{id:l(),x:R((p.x+f.x-u)/2),y:R((p.y+f.y-a)/2),w:R(u),h:a,rotation:Y(180*Math.atan2(f.y-p.y,f.x-p.x)/Math.PI)}}var J={scheme:new Map,map:{}},K=(t,e)=>[...t.rels.values()].find(t=>t.type.endsWith(e)),Q=t=>p(p(t,"p:cSld"),"p:spTree");function U(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 Z(t,e,n){const r=U(t,e);if(!r)return;const a=K(r,"/slideMaster"),o=a&&w(e,a.target);return o&&!n.has(o)&&n.set(o,function(t,e){const n=U(t,e);if(!n)return;const r=K(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=>(Q(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=>O(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??j("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 a=H(p(t,"p:xfrm")),s=f(e,"a:tr");if(!a||!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:O(p(t,"a:tcPr"),e.palette)??null}}(t,n))),u=G({...a,w:xt(i)||a.w,h:xt(l)||a.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)??o,headerColor:c[0].map(t=>t.block?.colour).find(Boolean),fontSize:void 0===d?void 0:L(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,i=L(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,i,u),0),y="ctr"===m?h/2:"b"===m?h:0;r.elements.push({id:l(),type:"text",rotation:e.rotation,x:R(e.x+c),y:R(e.y+f+y),w:R(u),h:R(d-y),text:a.text,fontSize:i,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=O(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=O(n,e.palette)??(r&&"0"!==r.attrs.idx?z(r.children[0],e.palette):void 0);return a?{stroke:a,strokeWidth:R((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 R((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"),a=p(r,"a:xfrm"),s=H(a);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({...q(s,{flipH:D(a?.attrs.flipH),flipV:D(a?.attrs.flipV)},n,e.frame),type:"shape",shape:"line",fill:o,...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),a=p(t,"p:spPr"),s=function(t){return vt[p(t,"a:prstGeom")?.attrs.prst??"rect"]??"rect"}(a);if("line"===s)return void At(t,e,n);const i=H(p(a,"a:xfrm"))??r.shapes.map(t=>H(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,a,s){s.elements.push({...t,type:"shape",shape:e,fill:"colour"===n.kind?n.colour:o,...r,..."roundRect"===e?{radius:Nt(a,t)}:{}})}(l,s,c,f,a,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=H(p(p(t,"p:spPr"),"a:xfrm"))??a.shapes.map(t=>H(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 $t(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=V(r);$t(r.children,e,t?[t,...n]:n);break}case"mc:AlternateContent":$t(p(r,"mc:Fallback")?.children??[],e,n)}}function jt(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 Ot(t,e){const n=K(e,"/notesSlide"),r=n&&U(t,w(e.part,n.target)),a=((r&&Q(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 Dt(t,e){const n=p(p(t.root,"p:cSld"),"p:bg");if(!n)return;const r=p(n,"p:bgPr"),a=O(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 Rt=t=>"0"===t.root.attrs.showMasterSp||"false"===t.root.attrs.showMasterSp;function Lt(t,e){const n=function(t){for(const e of[t.slide,t.layout,t.master]){const n=e&&Dt(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:l(),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(!Rt(r))for(const r of[e&&Rt(e)?void 0:n,e]){const e=r?Q(r.root)?.children??[]:[];r&&$t(e.filter(t=>!et(t)),{...t,slide:r})}}(t),$t(Q(t.slide.root)?.children??[],t),{id:l(),background:n.colour??"#ffffff",notes:Ot(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 Ht(t){const n=function(t){const n=y(t,"").find(t=>t.type.endsWith("/officeDocument")),r=U(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=K(r,"/slideLayout"),o=a&&w(r.part,a.target);o&&!n.has(o)&&n.set(o,Z(t,o,e));const s=o?n.get(o):void 0,i=s?.master,l=i?.palette??J;return{slide:r,layout:s,master:i,palette:B(s?B(l,s.root):l,r.root)}}}(t),a=jt(t),o=function(t,e){const n=Math.min(i/t,s/e);return{scale:n,left:(i-t*n)/2,top:(s-e*n)/2,width:t*n,height:e*n}}(n.width,n.height),l={skipped:0,mixedTextSimplified:0,typefaces:new Set},u=[];let d=0;for(const e of n.slides){const s=U(t,e);s&&!Et(s)&&(p(s.root,"p:timing")&&(d+=1),u.push(Lt({...r(s),presentation:n,frame:o,tally:l,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:[c()]},slideCount:u.length,images:[...a.uses.values()].filter(t=>m.has(t.key)),animationsDropped:d,tally:l}}var Vt=.15,Xt=1048576,Wt=/\.(xml|rels)$/i;async function Yt(n,a){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,a)?new t:new e(r.pptxLegacyFormat)}function Gt(t){if(t.slides.length>300)throw new e(r.pptxTooManySlides(t.slides.length,300));const n=b(t);if(n>x)throw new e(r.pptxTooLarge((n/Xt).toFixed(1),2))}var qt={"image/webp":"webp","image/png":"png","image/jpeg":"jpg","image/gif":"gif"};async function Jt(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 Kt(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 Jt(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}`:""}.${qt[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?.(Vt+.85*s/a.length)}),r}async function Qt(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?.(Vt*(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 Ht(t)}catch(t){if(t instanceof e)throw t;throw new e}}(o);Gt(s.document);const i=await Kt(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{Qt as importPptx};
|
|
1
|
+
import{PptxPasswordError as t,PptxUnreadableError as e}from"./chunk-R2CXMNZL.js";import{DECK_FONT as n,ENGLISH_WORDS as r,MIN_SIZE as a,NO_FILL as o,SLIDE_H as s,SLIDE_W as i,newId as l,newSlide as c}from"./chunk-AJTH75FI.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-D3JKD7KW.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 I(t,e){const n=p(p(e,"p:clrMapOvr"),"a:overrideClrMapping");return n?{...t,map:{...t.map,...n.attrs}}:t}var B=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]}(B(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 $(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(B(t).map(t=>t+(255-t)*(1-n)));case"a:shade":return F(B(t).map(t=>t*n));default:return t}}function j(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($,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),D=t=>t*Math.PI/180;function E(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 V(t){const e=p(p(t,"p:grpSpPr"),"a:xfrm"),n=E(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 X(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=D(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=X({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:l(),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 J(t,e,n,r){const o=t.x+t.w/2,s=t.y+t.h/2,i=D(t.rotation),c=a=>{const l=a*(e.flipH?-1:1)*t.w/2,c=a*(e.flipV?-1:1)*t.h/2,p={x:o+l*Math.cos(i)-c*Math.sin(i),y:s+l*Math.sin(i)+c*Math.cos(i)},f=n.reduce(X,p);return{x:r.left+f.x*r.scale,y:r.top+f.y*r.scale}},p=c(-1),f=c(1),u=Math.hypot(f.x-p.x,f.y-p.y);return{id:l(),x:L((p.x+f.x-u)/2),y:L((p.y+f.y-a)/2),w:L(u),h:a,rotation:Y(180*Math.atan2(f.y-p.y,f.x-p.x)/Math.PI)}}var q={scheme:new Map,map:{}},K=(t,e)=>[...t.rels.values()].find(t=>t.type.endsWith(e)),U=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 Z(t,e,n){const r=Q(t,e);if(!r)return;const a=K(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=K(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=>(U(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??j("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 a=E(p(t,"p:xfrm")),s=f(e,"a:tr");if(!a||!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({...a,w:xt(i)||a.w,h:xt(l)||a.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)??o,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,i=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,i,u),0),y="ctr"===m?h/2:"b"===m?h:0;r.elements.push({id:l(),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:i,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"),a=p(r,"a:xfrm"),s=E(a);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({...J(s,{flipH:O(a?.attrs.flipH),flipV:O(a?.attrs.flipV)},n,e.frame),type:"shape",shape:"line",fill:o,...i,...Ct(p(l,"a:tailEnd"))?{arrowEnd:!0}:{},...Ct(p(l,"a:headEnd"))?{arrowStart:!0}:{}})}function It(t,e,n){const r=st(t,e),a=p(t,"p:spPr"),s=function(t){return vt[p(t,"a:prstGeom")?.attrs.prst??"rect"]??"rect"}(a);if("line"===s)return void At(t,e,n);const i=E(p(a,"a:xfrm"))??r.shapes.map(t=>E(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,a,s){s.elements.push({...t,type:"shape",shape:e,fill:"colour"===n.kind?n.colour:o,...r,..."roundRect"===e?{radius:Nt(a,t)}:{}})}(l,s,c,f,a,e),kt(t,l,r,e),"undrawable"!==c.kind||d||(e.tally.skipped+=1)}function Bt(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=E(p(p(t,"p:spPr"),"a:xfrm"))??a.shapes.map(t=>E(p(p(t,"p:spPr"),"a:xfrm"))).find(Boolean),s=p(t,"p:blipFill"),i=Bt(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 $t(t,e,n=[]){for(const r of t)switch(r.name){case"p:sp":It(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=V(r);$t(r.children,e,t?[t,...n]:n);break}case"mc:AlternateContent":$t(p(r,"mc:Fallback")?.children??[],e,n)}}function jt(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=K(e,"/notesSlide"),r=n&&Q(t,w(e.part,n.target)),a=((r&&U(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=Bt(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:l(),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?U(r.root)?.children??[]:[];r&&$t(e.filter(t=>!et(t)),{...t,slide:r})}}(t),$t(U(t.slide.root)?.children??[],t),{id:l(),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 Dt=t=>"0"===t.root.attrs.show||"false"===t.root.attrs.show;function Et(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=K(r,"/slideLayout"),o=a&&w(r.part,a.target);o&&!n.has(o)&&n.set(o,Z(t,o,e));const s=o?n.get(o):void 0,i=s?.master,l=i?.palette??q;return{slide:r,layout:s,master:i,palette:I(s?I(l,s.root):l,r.root)}}}(t),a=jt(t),o=function(t,e){const n=Math.min(i/t,s/e);return{scale:n,left:(i-t*n)/2,top:(s-e*n)/2,width:t*n,height:e*n}}(n.width,n.height),l={skipped:0,mixedTextSimplified:0,typefaces:new Set},u=[];let d=0;for(const e of n.slides){const s=Q(t,e);s&&!Dt(s)&&(p(s.root,"p:timing")&&(d+=1),u.push(Ht({...r(s),presentation:n,frame:o,tally:l,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:[c()]},slideCount:u.length,images:[...a.uses.values()].filter(t=>m.has(t.key)),animationsDropped:d,tally:l}}var Vt=.15,Xt=1048576,Wt=/\.(xml|rels)$/i;async function Yt(n,a){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,a)?new t:new e(r.pptxLegacyFormat)}function Gt(t){if(t.slides.length>300)throw new e(r.pptxTooManySlides(t.slides.length,300));const n=b(t);if(n>x)throw new e(r.pptxTooLarge((n/Xt).toFixed(1),2))}var Jt={"image/webp":"webp","image/png":"png","image/jpeg":"jpg","image/gif":"gif"};async function qt(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 Kt(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 qt(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}`:""}.${Jt[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?.(Vt+.85*s/a.length)}),r}async function Ut(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?.(Vt*(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 Et(t)}catch(t){if(t instanceof e)throw t;throw new e}}(o);Gt(s.document);const i=await Kt(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{Ut as importPptx};
|
package/dist/slides/index.d.ts
CHANGED
|
@@ -32,6 +32,10 @@ interface TextRun {
|
|
|
32
32
|
font?: string;
|
|
33
33
|
/** `https://`, `http://`, `mailto:`, or `#slide=<id>` for another slide. */
|
|
34
34
|
link?: string;
|
|
35
|
+
/** Raised or lowered, smaller, as in H₂O or 10³ (0.11). */
|
|
36
|
+
script?: 'super' | 'sub';
|
|
37
|
+
/** Extra room between letters, in ems (0.11). */
|
|
38
|
+
spacing?: number;
|
|
35
39
|
}
|
|
36
40
|
interface Paragraph {
|
|
37
41
|
runs: TextRun[];
|
|
@@ -41,6 +45,11 @@ interface Paragraph {
|
|
|
41
45
|
level?: number;
|
|
42
46
|
/** A multiple of the font size. */
|
|
43
47
|
lineHeight?: number;
|
|
48
|
+
/** Room above and below the paragraph, in slide pixels (0.11). */
|
|
49
|
+
spaceBefore?: number;
|
|
50
|
+
spaceAfter?: number;
|
|
51
|
+
/** A bulleted paragraph's mark, one of `BULLET_GLYPHS` (0.11). */
|
|
52
|
+
bullet?: string;
|
|
44
53
|
}
|
|
45
54
|
/** What a layout's text box is for, so a theme can restyle it. */
|
|
46
55
|
type PlaceholderRole = 'title' | 'subtitle' | 'body';
|
|
@@ -61,10 +70,22 @@ interface TextElement extends ElementBase {
|
|
|
61
70
|
/** Shrink the type until the words fit the box. */
|
|
62
71
|
autofit?: boolean;
|
|
63
72
|
placeholder?: PlaceholderRole;
|
|
73
|
+
/** The words flow through this many columns (0.11). */
|
|
74
|
+
columns?: number;
|
|
75
|
+
}
|
|
76
|
+
/** The words a shape holds (0.11): a text box's own fields, all optional, so an
|
|
77
|
+
* older shape is a shape with none (./shapeText). */
|
|
78
|
+
type ShapeWords = Partial<Pick<TextElement, 'text' | 'paragraphs' | 'fontSize' | 'bold' | 'color' | 'align' | 'font' | 'anchor' | 'autofit'>>;
|
|
79
|
+
declare const SHAPE_KINDS: readonly ["rect", "roundRect", "ellipse", "triangle", "rightTriangle", "diamond", "pentagon", "hexagon", "octagon", "star", "heart", "cloud", "bolt", "parallelogram", "trapezoid", "cylinder", "plus", "arrowRight", "arrowLeft", "arrowUp", "arrowDown", "arrowLeftRight", "chevron", "callout", "calloutRound", "line", "freeform", "curve"];
|
|
80
|
+
type StrokeDash = 'solid' | 'dash' | 'dot';
|
|
81
|
+
/** Two colours across a fill, turned by `angle` degrees (0 runs left to right). */
|
|
82
|
+
interface Gradient {
|
|
83
|
+
from: string;
|
|
84
|
+
to: string;
|
|
85
|
+
angle: number;
|
|
64
86
|
}
|
|
65
|
-
declare const SHAPE_KINDS: readonly ["rect", "roundRect", "ellipse", "triangle", "rightTriangle", "diamond", "pentagon", "hexagon", "octagon", "star", "heart", "cloud", "bolt", "parallelogram", "trapezoid", "cylinder", "plus", "arrowRight", "arrowLeft", "arrowUp", "arrowDown", "arrowLeftRight", "chevron", "callout", "calloutRound", "line"];
|
|
66
87
|
type ShapeKind = (typeof SHAPE_KINDS)[number];
|
|
67
|
-
interface ShapeElement extends ElementBase {
|
|
88
|
+
interface ShapeElement extends ElementBase, ShapeWords {
|
|
68
89
|
type: 'shape';
|
|
69
90
|
/** A `line` runs left to right through the middle of its box; `rotation` turns it. */
|
|
70
91
|
shape: ShapeKind;
|
|
@@ -75,6 +96,14 @@ interface ShapeElement extends ElementBase {
|
|
|
75
96
|
radius?: number;
|
|
76
97
|
arrowEnd?: boolean;
|
|
77
98
|
arrowStart?: boolean;
|
|
99
|
+
dash?: StrokeDash;
|
|
100
|
+
/** Drawn over `fill`, which stays as the colour an older reader shows. */
|
|
101
|
+
gradient?: Gradient;
|
|
102
|
+
/** A soft shadow below and to the right. */
|
|
103
|
+
shadow?: boolean;
|
|
104
|
+
/** A drawn shape's outline, each point a share of its box's width and height
|
|
105
|
+
* (0 to 1), so it stretches as the box is resized (`DRAWN_SHAPES`). */
|
|
106
|
+
points?: [number, number][];
|
|
78
107
|
}
|
|
79
108
|
/** A share of each side cut away, each 0 to below 1. */
|
|
80
109
|
interface Crop {
|
|
@@ -90,12 +119,24 @@ interface ImageElement extends ElementBase {
|
|
|
90
119
|
crop?: Crop;
|
|
91
120
|
/** 0 to 1; absent is 1. */
|
|
92
121
|
opacity?: number;
|
|
122
|
+
/** Drawn inside this shape's outline instead of its box (0.11). */
|
|
123
|
+
mask?: Exclude<ShapeKind, 'line' | 'freeform' | 'curve'>;
|
|
124
|
+
/** 1 is as taken; 0.5 to 1.5. */
|
|
125
|
+
brightness?: number;
|
|
126
|
+
contrast?: number;
|
|
127
|
+
recolour?: 'greyscale' | 'sepia';
|
|
93
128
|
}
|
|
94
129
|
interface VideoElement extends ElementBase {
|
|
95
130
|
type: 'video';
|
|
96
131
|
/** A YouTube or Vimeo page, or a video file's address. */
|
|
97
132
|
src: string;
|
|
98
133
|
alt: string;
|
|
134
|
+
/** Seconds into the video it starts and stops (0.11). */
|
|
135
|
+
start?: number;
|
|
136
|
+
end?: number;
|
|
137
|
+
/** Plays as the slide is shown. */
|
|
138
|
+
autoplay?: boolean;
|
|
139
|
+
mute?: boolean;
|
|
99
140
|
}
|
|
100
141
|
type ConnectorSide = 'n' | 'e' | 's' | 'w';
|
|
101
142
|
interface ConnectorEnd {
|
|
@@ -165,6 +206,10 @@ interface TableElement extends ElementBase {
|
|
|
165
206
|
borderColor?: string;
|
|
166
207
|
/** In slide pixels; 0 draws none. */
|
|
167
208
|
borderWidth?: number;
|
|
209
|
+
/** Room inside each cell, in slide pixels (0.11); absent scales with the type. */
|
|
210
|
+
cellPadding?: number;
|
|
211
|
+
cellAlign?: TextAlign;
|
|
212
|
+
cellAnchor?: 'top' | 'middle' | 'bottom';
|
|
168
213
|
}
|
|
169
214
|
type SlideElement = TextElement | ShapeElement | ImageElement | VideoElement | ConnectorElement | ChartElement | TableElement;
|
|
170
215
|
type TransitionKind = 'fade' | 'slide' | 'push' | 'zoom' | 'flip';
|
|
@@ -173,12 +218,13 @@ interface Transition {
|
|
|
173
218
|
/** Seconds. */
|
|
174
219
|
duration: number;
|
|
175
220
|
}
|
|
176
|
-
|
|
221
|
+
declare const ANIMATION_EFFECTS: readonly ["appear", "fadeIn", "flyIn", "zoomIn", "wipeIn", "spin", "pulse", "fadeOut", "flyOut", "zoomOut", "wipeOut"];
|
|
222
|
+
type AnimationEffect = (typeof ANIMATION_EFFECTS)[number];
|
|
177
223
|
interface Animation {
|
|
178
224
|
id: string;
|
|
179
225
|
elementId: string;
|
|
180
226
|
effect: AnimationEffect;
|
|
181
|
-
/** Where a fly-in comes from. */
|
|
227
|
+
/** Where a fly-in comes from, a fly-out goes, or a wipe starts. */
|
|
182
228
|
from?: 'left' | 'right' | 'top' | 'bottom';
|
|
183
229
|
start: 'click' | 'withPrevious' | 'afterPrevious';
|
|
184
230
|
/** Seconds. */
|
|
@@ -187,17 +233,36 @@ interface Animation {
|
|
|
187
233
|
byParagraph?: boolean;
|
|
188
234
|
}
|
|
189
235
|
type LayoutId = 'title' | 'titleBody' | 'section' | 'twoColumns' | 'titleOnly' | 'blank';
|
|
236
|
+
/** A picture behind a slide's objects (0.11), named by address like an image. */
|
|
237
|
+
interface BackgroundImage {
|
|
238
|
+
src: string;
|
|
239
|
+
fit: 'fill' | 'fit' | 'tile';
|
|
240
|
+
/** 0 to 0.8: a black veil over the picture, so words on it read. */
|
|
241
|
+
dim?: number;
|
|
242
|
+
}
|
|
190
243
|
interface Slide {
|
|
191
244
|
id: string;
|
|
192
245
|
background: string;
|
|
193
246
|
notes: string;
|
|
194
247
|
elements: SlideElement[];
|
|
195
|
-
|
|
248
|
+
/** A built-in `LayoutId`, or the id of one of the deck's own `layouts`. */
|
|
249
|
+
layout?: LayoutId | (string & {});
|
|
196
250
|
/** Left out of the show, kept in the deck. */
|
|
197
251
|
skip?: boolean;
|
|
198
252
|
transition?: Transition;
|
|
199
253
|
/** In the order they play. */
|
|
200
254
|
animations?: Animation[];
|
|
255
|
+
/** Drawn over `background`, which stays as an older reader's colour (0.11). */
|
|
256
|
+
backgroundImage?: BackgroundImage;
|
|
257
|
+
backgroundGradient?: Gradient;
|
|
258
|
+
}
|
|
259
|
+
/** A layout the deck keeps of its own (0.11): a built-in one restyled (same `id`),
|
|
260
|
+
* or a new one. Its elements are a new slide's, given new ids each time. */
|
|
261
|
+
interface DeckLayout {
|
|
262
|
+
id: string;
|
|
263
|
+
name: string;
|
|
264
|
+
background?: string;
|
|
265
|
+
elements: SlideElement[];
|
|
201
266
|
}
|
|
202
267
|
interface DeckTheme {
|
|
203
268
|
id: string;
|
|
@@ -214,6 +279,7 @@ interface DeckDocument {
|
|
|
214
279
|
slides: Slide[];
|
|
215
280
|
theme?: DeckTheme;
|
|
216
281
|
slideNumbers?: boolean;
|
|
282
|
+
layouts?: DeckLayout[];
|
|
217
283
|
}
|
|
218
284
|
/** A document that came back from the server with nothing in it yet. */
|
|
219
285
|
declare function asDocument(stored: unknown): DeckDocument;
|
|
@@ -559,6 +625,125 @@ interface SlidesWords {
|
|
|
559
625
|
commentCount: (n: number) => string;
|
|
560
626
|
restoreConfirm: (when: string) => string;
|
|
561
627
|
shapeName: (kind: ShapeKind) => string;
|
|
628
|
+
effectFlyOut: string;
|
|
629
|
+
effectZoomOut: string;
|
|
630
|
+
effectSpin: string;
|
|
631
|
+
effectWipeIn: string;
|
|
632
|
+
effectWipeOut: string;
|
|
633
|
+
effectPulse: string;
|
|
634
|
+
assignTo: (name: string) => string;
|
|
635
|
+
assignedTo: (name: string) => string;
|
|
636
|
+
assignedDone: (name: string) => string;
|
|
637
|
+
unassign: string;
|
|
638
|
+
findReplace: string;
|
|
639
|
+
find: string;
|
|
640
|
+
replaceWith: string;
|
|
641
|
+
matchCase: string;
|
|
642
|
+
wholeWords: string;
|
|
643
|
+
matchesOf: (n: number, total: number, slides: number) => string;
|
|
644
|
+
noMatches: string;
|
|
645
|
+
findHint: string;
|
|
646
|
+
previousMatch: string;
|
|
647
|
+
nextMatch: string;
|
|
648
|
+
replace: string;
|
|
649
|
+
replaceAll: string;
|
|
650
|
+
gridView: string;
|
|
651
|
+
slidesPicked: (n: number) => string;
|
|
652
|
+
duplicateSlides: (n: number) => string;
|
|
653
|
+
deleteSlides: (n: number) => string;
|
|
654
|
+
outlineStyle: string;
|
|
655
|
+
dashSolid: string;
|
|
656
|
+
dashDashed: string;
|
|
657
|
+
dashDotted: string;
|
|
658
|
+
fillSolid: string;
|
|
659
|
+
fillGradient: string;
|
|
660
|
+
gradientFrom: string;
|
|
661
|
+
gradientTo: string;
|
|
662
|
+
shadow: string;
|
|
663
|
+
videoStart: string;
|
|
664
|
+
videoEnd: string;
|
|
665
|
+
autoplay: string;
|
|
666
|
+
mute: string;
|
|
667
|
+
mask: string;
|
|
668
|
+
maskNone: string;
|
|
669
|
+
brightness: string;
|
|
670
|
+
contrast: string;
|
|
671
|
+
recolour: string;
|
|
672
|
+
recolourNone: string;
|
|
673
|
+
greyscale: string;
|
|
674
|
+
sepia: string;
|
|
675
|
+
backgroundKind: string;
|
|
676
|
+
backgroundFit: string;
|
|
677
|
+
fitFill: string;
|
|
678
|
+
fitFit: string;
|
|
679
|
+
fitTile: string;
|
|
680
|
+
dim: string;
|
|
681
|
+
reset: string;
|
|
682
|
+
cellPadding: string;
|
|
683
|
+
cellAlign: string;
|
|
684
|
+
evenRows: string;
|
|
685
|
+
evenColumns: string;
|
|
686
|
+
superscript: string;
|
|
687
|
+
subscript: string;
|
|
688
|
+
letterSpacing: string;
|
|
689
|
+
normal: string;
|
|
690
|
+
bulletStyle: string;
|
|
691
|
+
bulletAuto: string;
|
|
692
|
+
spaceBefore: string;
|
|
693
|
+
spaceAfter: string;
|
|
694
|
+
columns: string;
|
|
695
|
+
importSlides: string;
|
|
696
|
+
importCount: (n: number) => string;
|
|
697
|
+
importFrom: string;
|
|
698
|
+
importPptxFile: string;
|
|
699
|
+
selectAll: string;
|
|
700
|
+
keepTheirTheme: string;
|
|
701
|
+
useThisTheme: string;
|
|
702
|
+
sameTheme: string;
|
|
703
|
+
print: string;
|
|
704
|
+
printLayout: string;
|
|
705
|
+
printSlides: string;
|
|
706
|
+
printNotes: string;
|
|
707
|
+
printHandouts: (n: number) => string;
|
|
708
|
+
includeSkipped: string;
|
|
709
|
+
printHint: string;
|
|
710
|
+
presentOptions: string;
|
|
711
|
+
fromStart: string;
|
|
712
|
+
autoAdvance: string;
|
|
713
|
+
everySeconds: (seconds: number) => string;
|
|
714
|
+
off: string;
|
|
715
|
+
loopAtEnd: string;
|
|
716
|
+
loop: string;
|
|
717
|
+
laserPointer: string;
|
|
718
|
+
advancingEvery: (seconds: number) => string;
|
|
719
|
+
thisSlide: string;
|
|
720
|
+
plainText: string;
|
|
721
|
+
makeCopy: string;
|
|
722
|
+
copyOf: (title: string) => string;
|
|
723
|
+
copyMade: (title: string) => string;
|
|
724
|
+
copyFailed: string;
|
|
725
|
+
drawFreeform: string;
|
|
726
|
+
drawCurve: string;
|
|
727
|
+
drawFreeformHint: string;
|
|
728
|
+
drawCurveHint: string;
|
|
729
|
+
zoom: string;
|
|
730
|
+
zoomIn: string;
|
|
731
|
+
zoomOut: string;
|
|
732
|
+
fit: string;
|
|
733
|
+
rulers: string;
|
|
734
|
+
onEverySlide: string;
|
|
735
|
+
editLayouts: string;
|
|
736
|
+
saveAsLayout: string;
|
|
737
|
+
layoutNamePrompt: string;
|
|
738
|
+
myLayout: string;
|
|
739
|
+
layoutSaved: string;
|
|
740
|
+
newLayout: string;
|
|
741
|
+
replaceLayout: (name: string) => string;
|
|
742
|
+
resetLayout: string;
|
|
743
|
+
deleteLayout: string;
|
|
744
|
+
layoutHint: string;
|
|
745
|
+
importTheme: string;
|
|
746
|
+
themeImported: string;
|
|
562
747
|
starterName: (id: StarterId) => string;
|
|
563
748
|
themeName: (id: string) => string;
|
|
564
749
|
presenterStep: (n: number, total: number) => string;
|
|
@@ -609,20 +794,29 @@ interface DeckComment {
|
|
|
609
794
|
createdAt: string;
|
|
610
795
|
resolvedAt: string | null;
|
|
611
796
|
resolvedByName: string;
|
|
797
|
+
/** Whose action item the thread is (a thread's first comment only, 0.11). */
|
|
798
|
+
assigneeId?: string | null;
|
|
799
|
+
assigneeName?: string;
|
|
800
|
+
}
|
|
801
|
+
interface NewDeckComment {
|
|
802
|
+
slideId: string;
|
|
803
|
+
elementId: string;
|
|
804
|
+
body: string;
|
|
805
|
+
parent: string | null;
|
|
806
|
+
mentions: string[];
|
|
807
|
+
/** A person to hand the thread to, by id (0.11). A host that can't assign ignores it. */
|
|
808
|
+
assignee?: string;
|
|
809
|
+
}
|
|
810
|
+
interface DeckCommentChange {
|
|
811
|
+
body?: string;
|
|
812
|
+
resolved?: boolean;
|
|
813
|
+
/** Hand the thread to somebody, or null to take it back (0.11). */
|
|
814
|
+
assignee?: string | null;
|
|
612
815
|
}
|
|
613
816
|
interface CommentsStore {
|
|
614
817
|
list: (deckId: string) => Promise<DeckComment[]>;
|
|
615
|
-
add: (deckId: string, comment:
|
|
616
|
-
|
|
617
|
-
elementId: string;
|
|
618
|
-
body: string;
|
|
619
|
-
parent: string | null;
|
|
620
|
-
mentions: string[];
|
|
621
|
-
}) => Promise<DeckComment>;
|
|
622
|
-
update: (deckId: string, id: string, change: {
|
|
623
|
-
body?: string;
|
|
624
|
-
resolved?: boolean;
|
|
625
|
-
}) => Promise<DeckComment>;
|
|
818
|
+
add: (deckId: string, comment: NewDeckComment) => Promise<DeckComment>;
|
|
819
|
+
update: (deckId: string, id: string, change: DeckCommentChange) => Promise<DeckComment>;
|
|
626
820
|
remove: (deckId: string, id: string) => Promise<void>;
|
|
627
821
|
}
|
|
628
822
|
interface DeckVersionSummary {
|
|
@@ -773,6 +967,8 @@ interface ElementBodyOptions {
|
|
|
773
967
|
onLink?: (href: string) => void;
|
|
774
968
|
/** A table cell's editor, in place of its words. */
|
|
775
969
|
cellEditor?: (row: number, col: number) => ReactNode;
|
|
970
|
+
/** The words editor of the shape being typed in, drawn over the shape. */
|
|
971
|
+
shapeEditor?: ReactNode;
|
|
776
972
|
}
|
|
777
973
|
interface SlideMotion {
|
|
778
974
|
hidden: ReadonlySet<string>;
|
|
@@ -814,4 +1010,4 @@ declare function importPptx(file: Blob, options: PptxImportOptions): Promise<{
|
|
|
814
1010
|
/** A PDF with one page for each slide, drawn as `SlideView` draws it. */
|
|
815
1011
|
declare function deckToPdf(document: DeckDocument, options?: PdfOptions): Promise<Blob>;
|
|
816
1012
|
|
|
817
|
-
export { ChooseOfficeFile, type CommentsStore, type DeckComment, DeckEditor, type DeckSummary, type DeckVersionSummary, ENGLISH_WORDS, FileWords, type ImportDeckOptions, type ImportedDeck, type LiveChannel, type LiveEvent, PdfOptions, type Person, type PptxImportNotes, type PptxImportOptions, PptxPasswordError, PptxUnreadableError, SlideView, Slides, SlidesConflict, type SlidesHost, SlidesProvider, type SlidesStore, type SlidesWords, type StoredDeck, type VersionsStore, ZH_HANS_WORDS, asDocument, browserSlidesStore, deckToPdf, importDeckFile, importPptx, mergeDecks, slidesApps };
|
|
1013
|
+
export { ChooseOfficeFile, type CommentsStore, type DeckComment, type DeckCommentChange, DeckEditor, type DeckSummary, type DeckVersionSummary, ENGLISH_WORDS, FileWords, type ImportDeckOptions, type ImportedDeck, type LiveChannel, type LiveEvent, type NewDeckComment, PdfOptions, type Person, type PptxImportNotes, type PptxImportOptions, PptxPasswordError, PptxUnreadableError, SlideView, Slides, SlidesConflict, type SlidesHost, SlidesProvider, type SlidesStore, type SlidesWords, type StoredDeck, type VersionsStore, ZH_HANS_WORDS, asDocument, browserSlidesStore, deckToPdf, importDeckFile, importPptx, mergeDecks, slidesApps };
|
package/dist/slides/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{mergeDecks as o}from"../chunk-
|
|
1
|
+
import{mergeDecks as o}from"../chunk-EDJRXJNE.js";import{PptxPasswordError as t,PptxUnreadableError as r}from"../chunk-R2CXMNZL.js";import{SlidesConflict as i,SlidesProvider as m,browserSlidesStore as p,importDeckFile as s}from"../chunk-T2TZ7HF5.js";import{SlideView as n}from"../chunk-EP3ZNVDB.js";import{ENGLISH_WORDS as e,ZH_HANS_WORDS as c,asDocument as f}from"../chunk-AJTH75FI.js";import{ENGLISH_FILE_WORDS as u,ZH_HANS_FILE_WORDS as a}from"../chunk-B32ASXHM.js";import{hasExtension as j}from"../chunk-XYVQTQ6N.js";import{lazy as d}from"react";var h=d(()=>import("../Slides-JLWEMUXJ.js")),k=d(()=>import("../Slides-JLWEMUXJ.js").then(o=>({default:o.OpenDeck}))),l={"/slides":{component:h,label:"Slides",size:"3xl",appStyle:!0,flushBody:!0,autoHeight:!1}};async function J(o,t){const{importPptx:r}=await(import("../pptxImport-UQQXZUQL.js"));return r(o,t)}async function X(o,t){const{deckToPdf:r}=await(import("../deckPdf-KZFS4CTF.js"));return r(o,t)}export{k as DeckEditor,u as ENGLISH_FILE_WORDS,e as ENGLISH_WORDS,t as PptxPasswordError,r as PptxUnreadableError,n as SlideView,h as Slides,i as SlidesConflict,m as SlidesProvider,a as ZH_HANS_FILE_WORDS,c as ZH_HANS_WORDS,f as asDocument,p as browserSlidesStore,X as deckToPdf,j as hasExtension,s as importDeckFile,J as importPptx,o as mergeDecks,l as slidesApps};
|
package/dist/slides/slides.css
CHANGED
|
@@ -153,6 +153,59 @@
|
|
|
153
153
|
.slides-starter:hover { border-color: var(--slides-accent); }
|
|
154
154
|
.slides-starter-thumb { display: block; width: 128px; height: 72px; overflow: hidden; border-radius: 3px; }
|
|
155
155
|
.slides-starter-blank { display: block; width: 100%; height: 100%; background: #ffffff; border: 1px solid var(--line); box-sizing: border-box; }
|
|
156
|
+
|
|
157
|
+
/* 0.11: the Tier 1 and 2 additions (mockup approved 2026-11-16). */
|
|
158
|
+
.slides-pane[data-zoomed] { overflow: auto; align-items: flex-start; justify-content: flex-start; }
|
|
159
|
+
.slides-pane[data-zoomed] .slides-stage-frame { margin: 24px; }
|
|
160
|
+
.slides-stage-frame { position: relative; flex: none; }
|
|
161
|
+
.slides-stage-frame[data-rulers] { padding: 20px 0 0 20px; }
|
|
162
|
+
.slides-ruler { position: absolute; background: var(--surface); color: var(--ink); opacity: 0.85; font-size: 9px; overflow: hidden; pointer-events: none; }
|
|
163
|
+
.slides-ruler-top { top: 0; left: 20px; border-bottom: 1px solid var(--line); }
|
|
164
|
+
.slides-ruler-left { top: 20px; left: 0; border-right: 1px solid var(--line); }
|
|
165
|
+
.slides-ruler span { position: absolute; }
|
|
166
|
+
.slides-ruler-top span { bottom: 0; height: 5px; border-left: 1px solid var(--line); padding-left: 2px; line-height: 1; }
|
|
167
|
+
.slides-ruler-top span[data-major] { height: 14px; }
|
|
168
|
+
.slides-ruler-left span { right: 0; width: 5px; border-top: 1px solid var(--line); writing-mode: vertical-rl; transform: rotate(180deg); line-height: 1; }
|
|
169
|
+
.slides-ruler-left span[data-major] { width: 14px; }
|
|
170
|
+
.slides-stage[data-drawing] { cursor: crosshair; }
|
|
171
|
+
.slides-drawn { position: absolute; left: 0; top: 0; color: var(--slides-accent); pointer-events: none; }
|
|
172
|
+
.slides-zoom { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 4px 12px; font-size: 12px; background: var(--surface-raised); border-top: 1px solid var(--line); }
|
|
173
|
+
.slides-zoom-value { min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; }
|
|
174
|
+
.slides-present { display: inline-flex; align-items: center; gap: 2px; }
|
|
175
|
+
|
|
176
|
+
.slides-segmented { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
|
|
177
|
+
.slides-segmented button { flex: 1; padding: 4px 8px; font-size: 12px; background: transparent; color: inherit; border: 0; border-left: 1px solid var(--line); cursor: pointer; }
|
|
178
|
+
.slides-segmented button:first-child { border-left: 0; }
|
|
179
|
+
.slides-segmented button[aria-checked='true'] { background: var(--slides-accent); color: var(--submit-fg, #fff); }
|
|
180
|
+
.slides-segmented-wrap { flex-wrap: wrap; }
|
|
181
|
+
.slides-segmented-wrap button { flex: 1 1 45%; border-top: 1px solid var(--line); }
|
|
182
|
+
|
|
183
|
+
.slides-sorter-pane { flex-direction: column; align-items: stretch; justify-content: flex-start; }
|
|
184
|
+
.slides-sorter-bar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 12px; background: var(--surface); }
|
|
185
|
+
.slides-sorter { flex: 1; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 16px; padding: 16px; align-content: start; }
|
|
186
|
+
.slides-sorter-tile { display: flex; flex-direction: column; gap: 4px; width: fit-content; cursor: pointer; border-radius: 4px; outline: none; }
|
|
187
|
+
.slides-sorter-tile > div:first-child { border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
|
|
188
|
+
.slides-sorter-tile[data-picked] > div:first-child { outline: 2px solid var(--slides-accent); outline-offset: 1px; }
|
|
189
|
+
.slides-sorter-tile[data-skipped] > div:first-child { opacity: 0.5; }
|
|
190
|
+
.slides-sorter-tile[data-drop] { box-shadow: -4px 0 0 var(--slides-accent); }
|
|
191
|
+
.slides-sorter-tile:focus-visible > div:first-child { outline: 2px solid var(--slides-accent); }
|
|
192
|
+
.slides-sorter-number { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; opacity: 0.7; }
|
|
193
|
+
.slides-thumb[data-picked] .slides-thumb-image { outline: 2px solid var(--slides-accent); outline-offset: 1px; opacity: 0.85; }
|
|
194
|
+
|
|
195
|
+
.slides-import { display: flex; flex-direction: column; gap: 12px; }
|
|
196
|
+
.slides-import-source { flex: 1; min-width: 0; }
|
|
197
|
+
.slides-import-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 10px; max-height: 360px; overflow: auto; }
|
|
198
|
+
.slides-import-tile { padding: 0; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; background: transparent; cursor: pointer; width: fit-content; }
|
|
199
|
+
.slides-import-tile[aria-selected='true'] { outline: 2px solid var(--slides-accent); outline-offset: 1px; }
|
|
200
|
+
.slides-print { display: flex; flex-direction: column; gap: 12px; }
|
|
201
|
+
|
|
202
|
+
.slides-layouts { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; }
|
|
203
|
+
.slides-layout-row { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 8px; font-size: 12px; }
|
|
204
|
+
.slides-layout-row > div:first-child { border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
|
|
205
|
+
|
|
206
|
+
.slides-assigned { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 0 4px; color: var(--slides-accent); }
|
|
207
|
+
.slides-link-button { margin-left: auto; padding: 0; border: 0; background: none; color: inherit; font-size: 12px; text-decoration: underline; cursor: pointer; }
|
|
208
|
+
.slides-presenter-current[data-laser] { cursor: none; }
|
|
156
209
|
/* The file list Documents and Spreadsheet share (./FileList.tsx), laid out as
|
|
157
210
|
Slides' deck list is. The build appends this to documents.css and
|
|
158
211
|
spreadsheet.css, so a host loads it with the app's own stylesheet. */
|
|
@@ -240,7 +240,8 @@ declare const SPREADSHEET_EXTENSIONS: readonly string[];
|
|
|
240
240
|
* SUBTOTAL: CHAR, CLEAN, CODE, ISERR, ISEVEN, ISODD, MAXIFS, MINIFS, MROUND,
|
|
241
241
|
* PERCENTILE, QUARTILE, QUOTIENT, the three REGEX functions and SUBTOTAL), and of
|
|
242
242
|
* its date functions (DATEVALUE, ISOWEEKNUM, NETWORKDAYS.INTL, TIMEVALUE, WEEKNUM,
|
|
243
|
-
* WORKDAY, WORKDAY.INTL and YEARFRAC)
|
|
243
|
+
* WORKDAY, WORKDAY.INTL and YEARFRAC), and of its finance functions and HYPERLINK
|
|
244
|
+
* (HYPERLINK, IPMT, IRR, NPER, PPMT, RATE, XIRR and XNPV).
|
|
244
245
|
*/
|
|
245
246
|
|
|
246
247
|
interface SpreadsheetWords {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SPREADSHEET_EXTENSIONS as e,SpreadsheetWordsProvider as t,SpreadsheetsConflict as n,SpreadsheetsProvider as s}from"../chunk-
|
|
1
|
+
import{SPREADSHEET_EXTENSIONS as e,SpreadsheetWordsProvider as t,SpreadsheetsConflict as n,SpreadsheetsProvider as s}from"../chunk-XENQLN5I.js";import{ENGLISH_WORDS as r,ZH_HANS_WORDS as o}from"../chunk-BDVKNU3U.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-5K2D7PBJ.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 v=class extends Error{};function L(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 v(`there is no sheet "${t}" any more`);return s}function P(e){const t=f(e);if(!t)throw new v(`"${e}" is not a range`);return t}function Q(e,t,n){return e.map((e,s)=>s===t?n(e):e)}function W(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 M(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 v(`there is already a sheet "${e.name}"`);s=[...s,d(e.name)];break;case"rename_sheet":s=g(s,L(s,e.sheet,t),e.name);break;case"set_cells":{const n=L(s,e.sheet,t),r=P(e.start);s=Q(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=Q(s,L(s,e.sheet,t),t=>c(t,P(e.range)));break;case"insert_rows":case"delete_rows":{const n=L(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=L(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=L(s,e.sheet,t),r=m(s);s=Q(s,n,t=>b(t,n,r,P(e.range),h(e.by),!e.descending));break}case"format":s=Q(s,L(s,e.sheet,t),t=>k(t,P(e.range),t=>W(t,e.format)));break;default:throw new v("this spreadsheet does not make that change")}return s}function X(){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=M(r,e.activeSheet(),n)}catch(e){return{applied:!1,reason:e instanceof v?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 C=x(()=>import("../Spreadsheet-WQOZPWY5.js")),F=x(()=>import("../Spreadsheet-WQOZPWY5.js").then(e=>({default:e.SpreadsheetById}))),K=x(()=>import("../Spreadsheet-WQOZPWY5.js").then(e=>({default:e.SpreadsheetPane}))),B={"/spreadsheet":{component:C,label:"Spreadsheets",size:"2xl",appStyle:!0,multiInstance:!0}};async function E(e){const{readXlsx:t}=await(import("../xlsxFile-3GXD4KW5.js"));return t(e)}async function I(e,t){const{workbookToPdf:n}=await(import("../workbookPdf-K65CQX4K.js"));return n(e,t)}async function N(e,t){const{importSpreadsheetFile:n}=await(import("../importSpreadsheet-L5FJGRUV.js"));return n(e,t)}export{j as ENGLISH_FILE_WORDS,r as ENGLISH_WORDS,e as SPREADSHEET_EXTENSIONS,v as SheetEditRefused,C as Spreadsheet,F as SpreadsheetEditor,K as SpreadsheetPane,t as SpreadsheetWordsProvider,n as SpreadsheetsConflict,s as SpreadsheetsProvider,y as ZH_HANS_FILE_WORDS,o as ZH_HANS_WORDS,M as applySheetOps,X as createSheetBridge,_ as hasExtension,N as importSpreadsheetFile,E as readXlsx,B as spreadsheetApp,I as workbookToPdf};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{rowPageStarts as t}from"./chunk-PWF37Y2N.js";import{ENGLISH_WORDS as e}from"./chunk-BDVKNU3U.js";import{DEFAULT_COL_WIDTH as o,cellDisplay as n,filteredRows as r,formatKey as s,makeEvaluator as a,usedBounds as i}from"./chunk-5K2D7PBJ.js";import{jpegPdf as c}from"./chunk-CEVQKZ66.js";import{drawJpeg as l,embeddedFonts as d,openStage as p,settled as h}from"./chunk-PX4QOBHF.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 k({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 C(t,e,o,n){e.append(t);try{await h(t);return{jpeg:await l(t,{width:f,height:u,pixelRatio:2,quality:n,fontCss:o}),width:842,height:595}}finally{t.remove()}}async function j(o,n={}){const{signal:r,onProgress:s,quality:i}=n;r?.throwIfAborted();const l=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),l.root)),h=p.reduce((t,e)=>t+e.starts.length,0),f=await d(l.root),u=[];for(const t of p)for(const o of t.starts.keys())r?.throwIfAborted(),u.push(await C(k(t,o),l.root,f,i).catch(t=>{throw new Error(e.pdfPageFailed(u.length+1),{cause:t})})),s?.(u.length,h);return c(u)}finally{l.close()}}export{x as sheetTable,j as workbookToPdf};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readXlsx as o,unzip as r,writeXlsx as m,zip as p}from"./chunk-WAB44FLE.js";import"./chunk-5K2D7PBJ.js";export{o as readXlsx,r as unzip,m as writeXlsx,p as zip};
|