@betteroffice/pptx 0.5.1 → 0.6.1
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/LICENSES/MIT-ruzstd.txt +21 -0
- package/LICENSES/MIT-twox-hash.txt +21 -0
- package/LICENSES/MIT-wuff.txt +20 -0
- package/README.md +24 -5
- package/dist/chunk-2XA2UH2O.js +1 -0
- package/dist/chunk-4WP5ZWYV.js +1 -0
- package/dist/chunk-65A2TX24.js +1 -0
- package/dist/chunk-663FARNX.js +1 -0
- package/dist/chunk-AYLLA7XR.js +1 -0
- package/dist/chunk-AZDGFDN2.js +1 -0
- package/dist/chunk-CCVGR3MS.js +1 -0
- package/dist/chunk-COS6CTH7.js +2 -0
- package/dist/chunk-G54T5CXF.js +1 -0
- package/dist/chunk-GAM2OAAP.js +2 -0
- package/dist/chunk-GHET7GIK.js +1 -0
- package/dist/chunk-GR7EGQ2Z.js +1 -0
- package/dist/chunk-HZODDD5T.js +1 -0
- package/dist/chunk-J54GRQWZ.js +1 -0
- package/dist/chunk-JJV35WHH.js +2 -0
- package/dist/chunk-KGEED2XY.js +1 -0
- package/dist/chunk-OUNTNO7R.js +1 -0
- package/dist/chunk-QRAGGQDN.js +1 -0
- package/dist/chunk-QWRXUT7T.js +1 -0
- package/dist/chunk-RNJM2LKC.js +3 -0
- package/dist/chunk-S6HKAO2F.js +1 -0
- package/dist/chunk-S6UYP4BX.js +1 -0
- package/dist/chunk-T6VUFMNC.js +1 -0
- package/dist/chunk-TRT2B252.js +10 -0
- package/dist/collaboration.js +1 -1
- package/dist/{editorSession-Cl_EWgAi.d.ts → editorSession-qQaVvMVR.d.ts} +346 -6
- package/dist/generated/metafile_svg_wasm_bg.wasm +0 -0
- package/dist/generated/pptx_wasm_bg.wasm +0 -0
- package/dist/generated/pptx_wasm_lean_bg.wasm +0 -0
- package/dist/generated/preflight/pptx_preflight_bg.wasm +0 -0
- package/dist/index.d.ts +21 -18
- package/dist/index.js +1 -1
- package/dist/pptxSessionWorker.mjs +13 -9
- package/dist/pptxSessionWorker.node.mjs +1 -0
- package/dist/pptxWorkerStart.d.ts +5 -0
- package/dist/pptxWorkerStart.js +1 -0
- package/dist/sessionWorker.missing.d.ts +3 -0
- package/dist/sessionWorker.missing.js +1 -0
- package/dist/sessionWorker.node.d.ts +3 -0
- package/dist/sessionWorker.node.js +1 -0
- package/dist/transport-BcduBS8X.d.ts +16 -0
- package/dist/wasm-preflight.d.ts +26 -0
- package/dist/wasm-preflight.js +1 -0
- package/dist/worker.d.ts +122 -22
- package/dist/worker.js +1 -1
- package/package.json +18 -5
- package/dist/chunk-2CPM3HRW.js +0 -1
- package/dist/chunk-3TTZUGDD.js +0 -1
- package/dist/chunk-B6OFSXHM.js +0 -1
- package/dist/chunk-DDNX2Z7E.js +0 -1
- package/dist/chunk-JZOLK2OC.js +0 -1
- package/dist/chunk-NWXUJY6L.js +0 -3
- /package/dist/{pptxSessionWorker.d.ts → pptxSessionWorker.node.d.ts} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { B as BlipEffect, a as CaretStop, b as
|
|
1
|
+
import { P as PresentationImageDecodeOptions } from './editorSession-qQaVvMVR.js';
|
|
2
|
+
export { B as BlipEffect, C as CanvasImageResolver, a as CaretStop, b as ChartData, c as ChartDataSeries, d as ColorTransform, e as ColorValue, f as CommentFlavor, g as CommentReceipt, h as CommentSnapshot, D as DeckSnapshot, E as EditProfile, i as EditSuccess, j as ExportCompletion, k as ExportDiagnostic, l as ExportSeverity, G as GeometryPathCommand, H as HeaderFooterSettings, m as HistoryProfile, n as HistoryResult, o as HitTestResult, I as ImageCrop, p as ImageEffect, q as ImagePrimitive, r as InheritedGeometry, s as InspectPresentationOptions, L as LayoutProfile, M as MarkdownAnchor, O as OpenPresentationOptions, t as OperationFailure, u as OperationRefusal, v as Paint, w as PaintFontCoverage, x as PaintSlideOptions, y as ParagraphAlignment, z as ParagraphSnapshot, A as PictureDraft, F as PlaceholderPrimitive, J as PositionedGlyph, K as PositionedTextLine, N as PositionedTextRun, Q as PptxAnchor, R as PptxAnchorScope, S as PptxCaretAnchor, T as PptxEditFailure, U as PptxEditFailureCode, V as PptxEditHistory, W as PptxEditPreview, X as PptxEditReceipt, Y as PptxEditRefusal, Z as PptxEditRequest, _ as PptxEditResult, $ as PptxEditSource, a0 as PptxEditStep, a1 as PptxEditTarget, a2 as PptxExportComment, a3 as PptxExportDiagnostic, a4 as PptxExportDiagnosticCode, a5 as PptxExportError, a6 as PptxExportFailure, a7 as PptxExportFailureCode, a8 as PptxExportList, a9 as PptxExportMark, aa as PptxExportNotes, ab as PptxExportObject, ac as PptxExportObjectKind, ad as PptxExportOptions, ae as PptxExportParagraph, af as PptxExportRefusal, ag as PptxExportResult, ah as PptxExportRun, ai as PptxExportShape, aj as PptxExportShapeKind, ak as PptxExportSlide, al as PptxExportStory, am as PptxExportTable, an as PptxExportTableCell, ao as PptxFindMatch, ap as PptxFindRequest, aq as PptxFindResult, ar as PptxFindScope, as as PptxFontFace, at as PptxMarkdownContent, au as PptxMarkdownOptions, av as PptxParagraphText, aw as PptxPeerNotReadyError, ax as PptxPngOptions, ay as PptxPngTarget, az as PptxReadRequest, aA as PptxReadResult, aB as PptxShapeTarget, aC as PptxSlideTarget, aD as PptxSourceProvenance, aE as PptxStoryTarget, aF as PptxStoryText, aG as PptxStructuredContent, aH as PptxTextField, aI as PptxTextGuard, aJ as PptxTextMatch, aK as PptxTextRange, aL as PptxTextSearchOptions, aM as PptxTextSpan, aN as PptxTextTarget, aO as PptxValidationResult, aP as PptxWorkerEditorDisposedError, aQ as PresentationHandle, aR as PresetShapeDraft, aS as PrimitiveTransform, aT as Profiled, aU as ProfiledLayout, aV as Proposal, aW as ProposalAcceptance, aX as ProposalChange, aY as ProposalDiffSlide, aZ as ProposalEdit, a_ as ProposalPictureMediaTooLargeError, a$ as ProposalPreview, b0 as ProposalShapeChange, b1 as ProposalStripEntry, b2 as ProposalTextChange, b3 as SavePresentationOptions, b4 as ShapeAdjustReceipt, b5 as ShapeAltText, b6 as ShapeDraft, b7 as ShapeFill, b8 as ShapeFillReceipt, b9 as ShapeGradient, ba as ShapeKind, bb as ShapeLineEnd, bc as ShapeOutline, bd as ShapePrimitive, be as ShapeReceipt, bf as ShapeRect, bg as ShapeSnapshot, bh as ShapeStroke, bi as ShapeStrokeReceipt, bj as ShapeZOrderReceipt, bk as SlideCanvasLike, bl as SlideDateText, bm as SlideDisplayList, bn as SlideHeaderFooter, bo as SlideHeaderFooterText, bp as SlideLayoutSnapshot, bq as SlidePrimitive, br as SlideReceipt, bs as SlideSnapshot, bt as StaleProposalError, bu as StorySnapshot, bv as Stroke, bw as StrokeEnd, bx as TableGrid, by as TableGridCell, bz as TableReceipt, bA as TextBoxPrimitive, bB as TextLanguage, bC as TextLink, bD as TextLinkTarget, bE as TextParagraphDraft, bF as TextReceipt, bG as TextRunSnapshot, bH as TextStyle, bI as TextStylePatch, bJ as TextStyleSnapshot, bK as TransformReceipt, bL as UndoCaptureMode, bM as UpdateEvent, bN as ValidationSuccess, bO as WasmInitInput, bP as createPptxWorkerEditorSession, bQ as decodeFontFace, bR as exportPptxMarkdown, bS as exportPptxStructured, bT as initWasm, bU as inspectPresentation, bV as isProposalsAvailable, bW as isWasmAvailable, bX as metafileImageBytes, bY as needsElementDecode, bZ as openPresentation, b_ as openPresentationSession, b$ as paintSlide, c0 as renderPptxMarkdown, c1 as sizeCanvasForSlide, c2 as wasmVersion } from './editorSession-qQaVvMVR.js';
|
|
3
3
|
export { C as CollaborationProvider, P as PRESENCE_LABEL_DURATION_MS, p as presenceColorForClientId } from './presence-C1o8TDwu.js';
|
|
4
4
|
export { A as AsyncCollaborationReplica, b as CollaborationError, c as CollaborationErrorCode, d as CollaborationErrorListener, e as CollaborationProviderOptions, C as CollaborationReplica, f as CollaborationStatus, g as CollaborationStatusChange, h as CollaborationStatusListener, i as CollaborationTransport, j as CollaborationTransportEvent, k as CollaborationUpdateOrigin, l as CollaborationUser, m as PptxPresence, P as PptxPresenceCursor, n as PptxPresenceListener, a as PptxPresencePeer, o as PptxPresenceState, p as PptxPresenceUser } from './types-ui_ARP0o.js';
|
|
5
|
-
|
|
6
|
-
interface PresentationImageDecodeOptions {
|
|
7
|
-
maxDimension?: number;
|
|
8
|
-
}
|
|
9
|
-
declare function needsElementDecode(blob: Blob): boolean;
|
|
5
|
+
export { FontPreflight, FontPreflightFace, fontPreflight, preloadPreflightWasm } from './wasm-preflight.js';
|
|
10
6
|
|
|
11
7
|
declare function presentationImageBlob(bytes: Uint8Array): Blob;
|
|
12
8
|
declare function decodePresentationImage(bytes: Uint8Array, errorMessage: string, options?: PresentationImageDecodeOptions): Promise<CanvasImageSource>;
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
type PngExportCode = 'canvas-unavailable' | 'canvas-too-large' | 'font-unavailable' | 'picture-unavailable';
|
|
11
|
+
declare class PngExportError extends Error {
|
|
12
|
+
readonly code: PngExportCode;
|
|
13
|
+
constructor(code: PngExportCode, message: string);
|
|
18
14
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Rasterize one slide to a PNG blob through the same canvas painter the editor
|
|
21
|
-
* draws with, so an export matches what is on screen. The server-side twin is
|
|
22
|
-
* the `betteroffice-pptx-raster` crate.
|
|
23
|
-
*/
|
|
24
|
-
declare function slideToPng(list: SlideDisplayList, options?: SlideToPngOptions): Promise<Blob>;
|
|
25
15
|
|
|
26
|
-
|
|
16
|
+
/** An installed font pack that cannot be used, so its faces are substituted. */
|
|
17
|
+
interface FontPackDiagnostic {
|
|
18
|
+
/** The add-on package: `@betteroffice/fonts-latin`, `-intl` or `-cjk`. */
|
|
19
|
+
pack: 'latin' | 'intl' | 'cjk';
|
|
20
|
+
/** `version-mismatch`: another release is installed; `missing-file`: files are absent; `invalid-manifest`: its manifest cannot be read. */
|
|
21
|
+
reason: 'version-mismatch' | 'missing-file' | 'invalid-manifest';
|
|
22
|
+
/** A sentence naming the package and what is wrong. */
|
|
23
|
+
detail: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The installed font add-on packages that cannot be used, and why; their faces are substituted. */
|
|
27
|
+
declare function fontPackDiagnostics(): Promise<FontPackDiagnostic[]>;
|
|
28
|
+
|
|
29
|
+
export { type FontPackDiagnostic, type PngExportCode, PngExportError, PresentationImageDecodeOptions, decodePresentationImage, fontPackDiagnostics, presentationImageBlob };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a,b,c,f}from'./chunk-B6OFSXHM.js';export{j as createPptxWorkerEditorSession,d as needsElementDecode,i as openPresentationSession}from'./chunk-B6OFSXHM.js';import'./chunk-YMIVEAXD.js';import {a as a$1,z}from'./chunk-DDNX2Z7E.js';export{d as PptxExportError,C as PptxPeerNotReadyError,E as PptxWorkerEditorDisposedError,c as StaleProposalError,x as exportPptxMarkdown,w as exportPptxStructured,s as initWasm,v as inspectPresentation,r as isProposalsAvailable,t as isWasmAvailable,A as openPresentation,y as renderPptxMarkdown,u as wasmVersion}from'./chunk-DDNX2Z7E.js';export{c as CollaborationError,f as CollaborationProvider}from'./chunk-JZOLK2OC.js';export{a as PRESENCE_LABEL_DURATION_MS,b as presenceColorForClientId}from'./chunk-2CPM3HRW.js';import'./chunk-O2XFH626.js';var Te=import('./chunk-3TTZUGDD.js'),Me=134217728;function H(e,t,n=1){return {width:Math.ceil(e.width*n*t),height:Math.ceil(e.height*n*t)}}function _(e,t,n,o=1){let i=H(t,n,o);e.width=i.width,e.height=i.height,e.style.width=`${t.width*o}px`,e.style.height=`${t.height*o}px`;}async function N(e,t,n=1,o=1,i={}){let r=await Te,a={remaining:i.maxShadowPixels??Me};if(!Number.isSafeInteger(a.remaining)||a.remaining<0)throw new Error("invalid shadow pixel budget");let s=i.resolveImage?.acquire?.()??i.resolveImage,l={...i,resolveImage:s};try{e.save(),e.setTransform(n*o,0,0,n*o,0,0),e.clearRect(0,0,t.width,t.height),t.background&&(e.fillStyle=O(e,t.background,0,0,t.width,t.height),e.fillRect(0,0,t.width,t.height));for(let h of t.primitives)await ee(e,h,l,n*o,a,r);}finally{try{e.restore();}finally{s?.release?.();}}}async function ee(e,t,n,o,i,r){e.save();try{switch(Re(e,t),t.kind){case "shape":te(e,t,o,i);break;case "image":await _e(e,t,n.resolveImage,o,i);break;case "textBox":Je(e,t,r,n.textChanges);break;case "placeholder":Qe(e,t);break;case "chart":case "table":await ke(e,t,n,o,i,r);break}}finally{e.restore();}}async function ke(e,t,n,o,i,r){e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip();for(let a of t.primitives)await ee(e,a,n,o,i,r);}function Re(e,t){let n=t.transform;if(!n)return;let o=t.x+t.w/2,i=t.y+t.h/2;e.translate(o,i),e.rotate((n.rotationDeg??0)*Math.PI/180),e.scale(n.flipH?-1:1,n.flipV?-1:1),e.translate(-o,-i);}function te(e,t,n,o){t.clip&&(W(e,t.clip,t.x,t.y,t.w,t.h),e.clip()),t.shadow&&(t.fill||t.stroke||t.shadow.paths?.some(i=>i.stroke))&&De(e,t,n,o),W(e,t.path,t.x,t.y,t.w,t.h),t.fill&&(e.fillStyle=O(e,t.fill,t.x,t.y,t.w,t.h),e.fill(t.evenOdd?"evenodd":"nonzero")),t.stroke&&(ie(e,t.stroke,t.x,t.y,t.w,t.h),Ae(e,t));}function De(e,t,n,o){let i=t.shadow?.paths?.length?t.shadow.paths.map(r=>({...t,path:r.path,fill:r.fill?t.fill:void 0,stroke:r.stroke,shadow:void 0})):[{...t,shadow:void 0}];ne(e,t.shadow,i.flatMap(r=>X(r.path,r)),i.reduce((r,a)=>Math.max(r,a.stroke?.width??0),0),n,o,r=>{for(let a of i)te(r,a,n,o);});}function ne(e,t,n,o,i,r,a){let s=t.scaleX??1,l=t.scaleY??1,h=e.getTransform(),d={a:h.a*s,b:h.b*l,c:h.c*s,d:h.d*l,e:h.e*s,f:h.f*l};if(!n.length)return;let p=1/0,u=1/0,f=-1/0,m=-1/0;for(let[I,Y]of n){let j=d.a*I+d.c*Y+d.e,G=d.b*I+d.d*Y+d.f;p=Math.min(p,j),u=Math.min(u,G),f=Math.max(f,j),m=Math.max(m,G);}let P=Math.min(Math.max(t.blur??0,0)*i/2,128),b=P*3+1,c=o*i*Math.max(Math.abs(s),Math.abs(l))*2,E=(t.dx??0)*i,T=(t.dy??0)*i,v=Math.floor(Math.max(p-c,-b-E)),S=Math.floor(Math.max(u-c,-b-T)),M=Math.ceil(Math.min(f+c,e.canvas.width+b-E)),k=Math.ceil(Math.min(m+c,e.canvas.height+b-T));if(M<=v||k<=S)return;let L=(M-v)*(k-S);if(!Number.isSafeInteger(L)||L>r.remaining)return;r.remaining-=L;let w=typeof OffscreenCanvas<"u"?new OffscreenCanvas(M-v,k-S):Object.assign(document.createElement("canvas"),{width:M-v,height:k-S}),C=w.getContext("2d");if(C){C.setTransform(d.a,d.b,d.c,d.d,d.e-v,d.f-S),a(C),e.save();try{if(e.resetTransform(),typeof e.filter=="string")C.setTransform(1,0,0,1,0,0),C.globalCompositeOperation="source-in",C.fillStyle=t.color,C.fillRect(0,0,w.width,w.height),e.filter=`blur(${P}px)`,e.drawImage(w,v+E,S+T);else {let I=e.canvas.width+1;e.shadowColor=t.color,e.shadowBlur=P*2,e.shadowOffsetX=v+E-I,e.shadowOffsetY=T,e.drawImage(w,I,S);}}finally{e.restore();}}}function X(e,t){let n=[];for(let o of e)o.type!=="close"&&(o.type==="quad"?n.push([t.x+o.cpx*t.w,t.y+o.cpy*t.h]):o.type==="cubic"&&(n.push([t.x+o.cp1x*t.w,t.y+o.cp1y*t.h]),n.push([t.x+o.cp2x*t.w,t.y+o.cp2y*t.h])),n.push([t.x+o.x*t.w,t.y+o.y*t.h]));return n.filter((o,i)=>i===0||o[0]!==n[i-1][0]||o[1]!==n[i-1][1])}function Oe(e){return e.path?X(e.path,e):[[e.x,e.y],[e.x+e.w,e.y],[e.x+e.w,e.y+e.h],[e.x,e.y+e.h]]}var Le=new Set(["triangle","stealth","arrow","diamond","oval"]);function Ae(e,t){let n=t.stroke;if(!n||!n.headEnd&&!n.tailEnd)return;let o=X(t.path,t);if(o.length<2)return;let i=[[n.headEnd,o[1],o[0]],[n.tailEnd,o[o.length-2],o[o.length-1]]];e.save(),e.setLineDash([]);let r=n.paint?O(e,n.paint,t.x,t.y,t.w,t.h):n.color;e.fillStyle=r,e.strokeStyle=r,e.lineWidth=n.width,e.lineJoin="miter";for(let[a,s,l]of i){if(!a||!Le.has(a.kind))continue;let[h,d]=[l[0]-s[0],l[1]-s[1]],p=Math.hypot(h,d);p<1e-6||Fe(e,a,l,h/p,d/p);}e.restore();}function Fe(e,t,[n,o],i,r){let a=t.width/2,[s,l]=[-r*a,i*a],[h,d]=[n-i*t.length,o-r*t.length];switch(e.beginPath(),t.kind){case "triangle":e.moveTo(n,o),e.lineTo(h+s,d+l),e.lineTo(h-s,d-l),e.closePath(),e.fill();break;case "stealth":e.moveTo(n,o),e.lineTo(h+s,d+l),e.lineTo(n-i*t.length*.6,o-r*t.length*.6),e.lineTo(h-s,d-l),e.closePath(),e.fill();break;case "arrow":e.moveTo(h+s,d+l),e.lineTo(n,o),e.lineTo(h-s,d-l),e.stroke();break;case "diamond":{let[p,u]=[i*t.length/2,r*t.length/2];e.moveTo(n+p,o+u),e.lineTo(n+s,o+l),e.lineTo(n-p,o-u),e.lineTo(n-s,o-l),e.closePath(),e.fill();break}case "oval":e.ellipse(n,o,t.length/2,a,Math.atan2(r,i),0,Math.PI*2),e.fill();break}}function We(e,t,n){if(n.tile){Be(e,t,n,n.tile);return}let o=n.crop,i=g(o?.left),r=g(o?.top),a=1-i-g(o?.right),s=1-r-g(o?.bottom),l=n.path!==void 0||a!==1||s!==1;if(a<=0||s<=0)return;l&&(e.save(),U(e,n),e.clip());let h=oe(t),d=re(t),p=n.destination??n;h>0&&d>0?e.drawImage(t,i*h,r*d,a*h,s*d,p.x,p.y,p.w,p.h):e.drawImage(t,p.x,p.y,p.w,p.h),l&&e.restore();}function Be(e,t,n,o){let i=oe(t),r=re(t);if(i<=0||r<=0)return;let a$1=a(t),s=i*a$1.x,l=r*a$1.y,h=Math.round(g(n.crop?.left)*s)/a$1.x,d=Math.round(g(n.crop?.top)*l)/a$1.y,p=(s-Math.round(g(n.crop?.right)*s))/a$1.x,u=(l-Math.round(g(n.crop?.bottom)*l))/a$1.y;if(p<=h||u<=d)return;let m=h>0||d>0||p<i||u<r?He(t,h,d,p-h,u-d):t,P=e.createPattern(m,"repeat");if(!P)return;e.save(),U(e,n),e.clip();let b=a(m),c=n.destination??n;P.setTransform(new DOMMatrix().translateSelf(c.x,c.y).scaleSelf(o.scaleX*b.x,o.scaleY*b.y)),e.fillStyle=P,e.fillRect(c.x,c.y,c.w,c.h),e.restore();}function He(e,t,n,o,i){try{let r=ae(Math.max(1,Math.ceil(o)),Math.max(1,Math.ceil(i))),a$1=r?.getContext("2d");if(!r||!a$1)return e;a$1.drawImage(e,t,n,o,i,0,0,r.width,r.height);let s=a(e);return b(r,{x:s.x*o/r.width,y:s.y*i/r.height}),r}catch{return e}}function U(e,t){t.path?W(e,t.path,t.x,t.y,t.w,t.h):(e.beginPath(),e.rect(t.x,t.y,t.w,t.h));}function g(e){return e===void 0||!Number.isFinite(e)?0:Math.min(Math.max(e,0),1)}function oe(e){return "naturalWidth"in e&&typeof e.naturalWidth=="number"?e.naturalWidth:"width"in e&&typeof e.width=="number"?e.width:0}function re(e){return "naturalHeight"in e&&typeof e.naturalHeight=="number"?e.naturalHeight:"height"in e&&typeof e.height=="number"?e.height:0}function W(e,t,n,o,i,r){e.beginPath();for(let a of t)switch(a.type){case "move":e.moveTo(n+a.x*i,o+a.y*r);break;case "line":e.lineTo(n+a.x*i,o+a.y*r);break;case "quad":e.quadraticCurveTo(n+a.cpx*i,o+a.cpy*r,n+a.x*i,o+a.y*r);break;case "cubic":e.bezierCurveTo(n+a.cp1x*i,o+a.cp1y*r,n+a.cp2x*i,o+a.cp2y*r,n+a.x*i,o+a.y*r);break;case "close":e.closePath();break}}function ie(e,t,n,o,i,r){e.strokeStyle=t.paint?O(e,t.paint,n,o,i,r):t.color,e.lineWidth=t.width,e.setLineDash(t.dashed?[Math.max(3,t.width*2),Math.max(2,t.width)]:[]),e.lineJoin=t.join??"miter",e.stroke();}function O(e,t,n,o,i,r){if(t.kind==="solid")return t.color;let a=(t.angleDeg??0)*Math.PI/180,s=n+i/2,l=o+r/2,h=Math.hypot(i,r)/2,d=t.gradientType==="linear"?e.createLinearGradient(s-Math.cos(a)*h,l-Math.sin(a)*h,s+Math.cos(a)*h,l+Math.sin(a)*h):e.createRadialGradient(s,l,0,s,l,h);for(let p of t.stops)d.addColorStop(Math.max(0,Math.min(1,p.position)),p.color);return d}async function _e(e,t,n,o,i){let r;if(t.assetId&&n){let a=await Ne(n,t.assetId);a&&(r=t.effects?.length?ze(a,t.effects):a);}if(t.shadow&&(r||t.stroke||t.shadow.paths?.some(a=>a.stroke))){let a=t.shadow.paths?.length?t.shadow.paths.map(s=>({image:{...t,path:s.path,stroke:s.stroke},source:s.fill?r:void 0})):[{image:t,source:r}];ne(e,t.shadow,a.flatMap(s=>Oe(s.image)),a.reduce((s,l)=>Math.max(s,l.image.stroke?.width??0),0),o,i,s=>{for(let l of a)K(s,l.image,l.source);});}K(e,t,r);}async function Ne(e,t){try{return await e(t)}catch{return null}}function K(e,t,n){n&&We(e,n,t),t.stroke&&(U(e,t),ie(e,t.stroke,t.x,t.y,t.w,t.h));}var Z=33554432,Xe=67108864;function Ue(e){let t=e,n=t.naturalWidth??t.videoWidth??t.displayWidth??(typeof t.width=="number"?t.width:0),o=t.naturalHeight??t.videoHeight??t.displayHeight??(typeof t.height=="number"?t.height:0);return n>0&&o>0?{width:n,height:o}:null}function Ye(e){let t=e.width*e.height;if(t<=Z)return e;let n=Math.sqrt(Z/t);return {width:Math.max(1,Math.floor(e.width*n)),height:Math.max(1,Math.floor(e.height*n))}}var B=new WeakMap,y=[],A=0;function je(e){let t=e;return "videoWidth"in t||"displayWidth"in t||typeof t.getContext=="function"}function Ge(e,t){let n=B.get(e),o=n?.get(t);if(!n||!o)return;let i=y.findIndex(r=>r.entries===n&&r.key===t);return i>=0&&y.push(...y.splice(i,1)),o}function qe(e,t,n,o){let i=B.get(e);for(i||(i=new Map,B.set(e,i)),i.set(t,n),y.push({entries:i,key:t,pixels:o}),A+=o;A>Xe&&y.length>1;){let r=y.shift();if(!r)break;r.entries.delete(r.key),A-=r.pixels;}}function ae(e,t){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(e,t);if(typeof document>"u")return null;let n=document.createElement("canvas");return n.width=e,n.height=t,n}function ze(e,t){let n=Ue(e);if(!n)return e;let o=JSON.stringify(t),i=!je(e);if(i){let a=Ge(e,o);if(a)return a}let r=Ye(n);try{let a$1=ae(r.width,r.height),s=a$1?.getContext("2d");if(!a$1||!s)return e;s.drawImage(e,0,0,r.width,r.height);let l=s.getImageData(0,0,r.width,r.height);Ve(l.data,t),s.putImageData(l,0,0);let h=a$1,d=a(e);return b(h,{x:d.x*n.width/r.width,y:d.y*n.height/r.height}),i&&qe(e,o,h,r.width*r.height),h}catch{return e}}function F(e,t){return .299*e[t]+.587*e[t+1]+.114*e[t+2]}function $e(e,t){let n=Math.min(Math.max(t,-1),1),o=n>=0?128/(128-127*n):(128+127*n)/128,i=128-128*o+255*Math.min(Math.max(e,-1),1)*(1+o)/2,r=new Uint8ClampedArray(256);for(let a=0;a<256;a+=1)r[a]=Math.round(o*a+i);return r}function D(e){let t=e.startsWith("#")?e.slice(1):e,n=t.length===3||t.length===4?[...t].map(r=>r+r).join(""):t;if(n.length!==6&&n.length!==8)return null;let o=r=>Number.parseInt(n.slice(r,r+2),16),i=[o(0),o(2),o(4),n.length===8?o(6):255];return i.some(Number.isNaN)?null:i}function Ve(e,t){for(let n of t)switch(n.kind){case "biLevel":{let o=Math.min(Math.max(n.threshold,0),1)*255;for(let i=0;i<e.length;i+=4){let r=F(e,i)<o?0:255;e[i]=r,e[i+1]=r,e[i+2]=r;}break}case "alpha":{let o=Math.min(Math.max(n.amount,0),1);for(let i=3;i<e.length;i+=4)e[i]=Math.round(e[i]*o);break}case "grayscale":{for(let o=0;o<e.length;o+=4){let i=Math.round(F(e,o));e[o]=i,e[o+1]=i,e[o+2]=i;}break}case "luminance":{let o=$e(n.brightness,n.contrast);for(let i=0;i<e.length;i+=4)e[i]=o[e[i]],e[i+1]=o[e[i+1]],e[i+2]=o[e[i+2]];break}case "duotone":{let o=D(n.shadow),i=D(n.highlight);if(!o||!i)break;for(let r=0;r<e.length;r+=4){let a=F(e,r)/255;for(let l=0;l<3;l+=1)e[r+l]=Math.round(o[l]*(1-a)+i[l]*a);let s=o[3]*(1-a)+i[3]*a;e[r+3]=Math.round(e[r+3]*s/255);}break}case "colorChange":{let o=D(n.from),i=D(n.to);if(!o||!i)break;for(let r=0;r<e.length;r+=4)e[r]!==o[0]||e[r+1]!==o[1]||e[r+2]!==o[2]||n.useAlpha!==false&&e[r+3]!==o[3]||(e[r]=i[0],e[r+1]=i[1],e[r+2]=i[2],n.useAlpha!==false&&(e[r+3]=i[3]));break}}}function Je(e,t,n,o=[]){t.overflow||(e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip()),e.textAlign="left",e.textBaseline="alphabetic";let i=o.filter(a=>a.storyId===t.storyId);Q(e,t,i,false);let r=t.textShadow;r&&(e.save(),e.shadowColor=r.color,e.shadowBlur=Math.max(r.blur??0,0),e.shadowOffsetX=r.dx??0,e.shadowOffsetY=r.dy??0);for(let a of t.lines)for(let s of a.runs)Ke(e,s,a.baseline,n);r&&e.restore(),Q(e,t,i,true);}function Q(e,t,n,o){if(n.length!==0)for(let i of t.lines)for(let r of i.runs)for(let a of n){let s=Math.max(r.start,a.start),l=Math.min(r.end,a.end);if(s>=l)continue;let h=i.caretStops.filter(f=>f.position>=s&&f.position<=l),d=h.length>1?Math.max(r.x,Math.min(...h.map(f=>f.x))):r.x,p=h.length>1?Math.min(r.x+r.width,Math.max(...h.map(f=>f.x))):r.x+r.width;if(p<=d)continue;let u=a.kind==="insertion";if(o){e.fillStyle=u?"#166534":"#b91c1c";let m=i.baseline-(r.baselineOffsetPx??0)+r.fontSizePx*(u?.08:-0.3);e.fillRect(d,m,p-d,Math.max(1,r.fontSizePx*.05));}else e.fillStyle=u?"#dcfce7cc":"#fee2e2cc",e.fillRect(d,i.y,p-d,i.height);}}function Ke(e,t,n,o){let i=t.italic?"italic ":"",r=t.bold?"bold ":"";e.font=`${i}${r}${t.fontSizePx}px ${Ze(t.fontFamily)}`,e.fillStyle=t.color;let a=t.letterSpacingPx??0;e.letterSpacing=a===0?"0px":`${a}px`;let s="textRendering"in e?e.textRendering:void 0;s!==void 0&&(e.textRendering="geometricPrecision");let l=n-(t.baselineOffsetPx??0);o.paintTextChunks(e,t,l,a),e.letterSpacing="0px",s!==void 0&&(e.textRendering=s),t.underline&&e.fillRect(t.x,l+t.fontSizePx*.08,t.width,Math.max(1,t.fontSizePx*.05));}function Ze(e){return e.includes(" ")?JSON.stringify(e):e}function Qe(e,t){e.strokeStyle="#8a94a6",e.lineWidth=1,e.setLineDash([5,4]),e.strokeRect(t.x,t.y,t.w,t.h),t.label&&(e.setLineDash([]),e.fillStyle="#5d6675",e.font="12px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(t.label,t.x+t.w/2,t.y+t.h/2,Math.max(0,t.w-12)));}function se(e){if(a$1(e)){if(e.byteLength>33554432)throw new Error("TIFF image exceeds the browser transfer budget");return new Blob([z(e).slice()],{type:"image/png"})}return c(e)}async function tt(e,t,n={}){let o=n.maxDimension;if(o!=null&&(!Number.isSafeInteger(o)||o<1))throw new Error("invalid image dimension limit");return f(se(e),t,n)}async function nt(e,t={}){let{scale:n=1,resolveImage:o}=t;if(!Number.isFinite(n)||n<=0)throw new Error("scale must be finite and positive");let i=ot(e,n),r=i.getContext("2d");if(!r)throw new Error("2d canvas context unavailable");return await N(r,e,1,n,{resolveImage:o}),rt(i)}function ot(e,t){if(typeof OffscreenCanvas=="function"){let{width:o,height:i}=H(e,1,t);return new OffscreenCanvas(o,i)}if(typeof document>"u")throw new Error("no canvas backend in this environment");let n=document.createElement("canvas");return _(n,e,1,t),n}function rt(e){return "convertToBlob"in e?e.convertToBlob({type:"image/png"}):new Promise((t,n)=>{e.toBlob(o=>{o?t(o):n(new Error("canvas produced no png"));},"image/png");})}export{tt as decodePresentationImage,N as paintSlide,se as presentationImageBlob,_ as sizeCanvasForSlide,nt as slideToPng};
|
|
1
|
+
export{c as fontPreflight,b as preloadPreflightWasm}from'./chunk-AYLLA7XR.js';export{f as createPptxWorkerEditorSession,e as openPresentationSession}from'./chunk-QRAGGQDN.js';import'./chunk-YMIVEAXD.js';export{b as PptxPeerNotReadyError,d as PptxWorkerEditorDisposedError}from'./chunk-KGEED2XY.js';import'./chunk-T6VUFMNC.js';import {a,ca,b,e,o}from'./chunk-COS6CTH7.js';export{G as PptxExportError,F as ProposalPictureMediaTooLargeError,E as StaleProposalError,H as decodeFontFace,aa as exportPptxMarkdown,$ as exportPptxStructured,X as initWasm,_ as inspectPresentation,W as isProposalsAvailable,Y as isWasmAvailable,f as metafileImageBytes,c as needsElementDecode,da as openPresentation,h as paintSlide,ba as renderPptxMarkdown,g as sizeCanvasForSlide,Z as wasmVersion}from'./chunk-COS6CTH7.js';export{a as PngExportError}from'./chunk-CCVGR3MS.js';import'./chunk-S6UYP4BX.js';export{c as CollaborationError,f as CollaborationProvider}from'./chunk-HZODDD5T.js';import'./chunk-GHET7GIK.js';export{a as PRESENCE_LABEL_DURATION_MS,b as presenceColorForClientId}from'./chunk-65A2TX24.js';import'./chunk-OUNTNO7R.js';import'./chunk-O2XFH626.js';function P(e){if(a(e)){if(e.byteLength>33554432)throw new Error("TIFF image exceeds the browser transfer budget");return new Blob([ca(e).slice()],{type:"image/png"})}return b(e)}async function G(e$1,l,o={}){let t=o.maxDimension;if(t!=null&&(!Number.isSafeInteger(t)||t<1))throw new Error("invalid image dimension limit");return e(P(e$1),l,o)}function W(){return o()}export{G as decodePresentationImage,W as fontPackDiagnostics,P as presentationImageBlob};
|