@imgly/plugin-print-ready-pdfs-web 1.1.0 → 1.1.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/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.1.1] - 2025-12-18
9
+
10
+ ### Fixed
11
+
12
+ - Fixed Webpack 5 compatibility issue where Node.js module imports (`module`, `path`, `fs`, `url`) caused build failures in Angular 17+ and other Webpack 5 environments ([#11471](https://github.com/imgly/ubq/issues/11471))
13
+
8
14
  ## [1.1.0] - 2025-12-03
9
15
 
10
16
  ### Added
package/README.md CHANGED
@@ -334,7 +334,7 @@ Text and vector graphics are preserved in their original vector format during co
334
334
 
335
335
  ### Transparency Handling
336
336
 
337
- **Important:** PDF/X-3:2003 does not support transparency. By default, the plugin flattens all transparency to ensure compliance:
337
+ **Important:** PDF/X-3:2003 is based on PDF 1.3 which does not support transparency. By default, the plugin flattens all transparency to ensure compliance:
338
338
 
339
339
  ```javascript
340
340
  // Default behavior - flattens transparency (PDF/X-3 compliant)
@@ -350,30 +350,50 @@ const printReadyPDF = await convertToPDFX3(pdfBlob, {
350
350
  - **Pages without transparency** → Preserved as vectors (text, shapes remain editable)
351
351
  - **Mixed content** → Only transparent elements are rasterized
352
352
 
353
- **For Maximum Quality:**
353
+ **Why Flattening is Required:**
354
354
 
355
- If your CE.SDK exports contain no transparency, you can disable flattening to preserve all vectors:
355
+ PDF/X-3 is based on PDF 1.3, which predates PDF transparency features (introduced in PDF 1.4). Therefore, **transparency flattening is mandatory** for PDF/X-3 compliance—this is a requirement of the standard itself, not a limitation of the tooling. Any PDF with transparency must have those elements composited into opaque equivalents before it can be a valid PDF/X-3 file.
356
+
357
+ **⚠️ Known Issue: Black Backgrounds During Flattening**
358
+
359
+ During the flattening process, certain elements with transparency may render with black backgrounds instead of their intended appearance. Affected elements include:
360
+
361
+ - Gradients that fade to transparent
362
+ - PNG images with alpha channels (e.g., stickers, icons)
363
+ - Text with emoji characters
364
+ - Overlapping semi-transparent elements
365
+
366
+ **Workaround - Preserve Transparency:**
367
+
368
+ If visual fidelity is more important than strict PDF/X-3 compliance, you can disable transparency flattening:
356
369
 
357
370
  ```javascript
358
- // Disable flattening for transparent-free PDFs (best quality)
371
+ // Preserve transparency for better visual fidelity
359
372
  const printReadyPDF = await convertToPDFX3(pdfBlob, {
360
373
  outputProfile: 'fogra39',
361
- title: 'Vector Preserved',
362
- flattenTransparency: false, // Preserves vectors, but may not be PDF/X-3 compliant if transparency exists
374
+ title: 'Visual Fidelity Preserved',
375
+ flattenTransparency: false, // Preserves appearance but may not be strictly PDF/X-3 compliant
363
376
  });
364
377
  ```
365
378
 
366
- **⚠️ Important:** Only disable `flattenTransparency` if you're certain your PDFs contain no transparency. PDFs with transparency and `flattenTransparency: false` will fail PDF/X-3 validation.
379
+ **Trade-offs:**
380
+ | Setting | Visual Fidelity | PDF/X-3 Compliance |
381
+ |---------|----------------|-------------------|
382
+ | `flattenTransparency: true` (default) | May have artifacts | Strictly compliant |
383
+ | `flattenTransparency: false` | Preserved | May not validate if transparency exists |
384
+
385
+ **Avoiding Transparency Issues in CE.SDK:**
367
386
 
368
- **Avoiding Transparency in CE.SDK:**
387
+ To ensure best results with PDF/X-3, design without transparency:
369
388
  - Use 100% opacity for all elements
370
- - Avoid alpha channel PNG images
389
+ - Avoid PNG images with alpha channels
371
390
  - Use solid fills instead of gradient opacity
391
+ - Avoid gradients that fade to transparent
372
392
  - Export without blend modes
373
393
 
374
394
  ## Known Limitations
375
395
 
376
- - **Transparency**: PDF/X-3:2003 does not support transparency. Pages containing transparency (alpha channels, soft masks, opacity < 1.0) will be rasterized to bitmaps during conversion to ensure compliance. To preserve vectors, avoid transparency in your CE.SDK designs.
396
+ - **Transparency Flattening Required**: PDF/X-3 is based on PDF 1.3 which does not support transparency. Transparency flattening is mandatory for compliance. During flattening, elements with transparency may render with black backgrounds (affects gradients with alpha, PNGs with transparency, emojis). Use `flattenTransparency: false` as a workaround if visual fidelity is more important than strict compliance. See [Transparency Handling](#transparency-handling) for details.
377
397
  - **Spot Colors**: Currently, spot colors (Pantone, custom inks) are converted to CMYK during the PDF/X-3 conversion process. This is a limitation of the current Ghostscript WASM implementation. If preserving spot colors is critical for your workflow, consider server-side PDF processing solutions.
378
398
  - **PDF/X Versions**: Only supports PDF/X-3:2003 (not X-1a or X-4 yet)
379
399
 
package/dist/gs.js CHANGED
@@ -18,7 +18,7 @@ if (f.ENVIRONMENT) {
18
18
  throw Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)");
19
19
  }
20
20
  if (fa) {
21
- const {createRequire:a} = await import("module");
21
+ const {createRequire:a} = await import(/* webpackIgnore: true */ "module");
22
22
  var require = a(import.meta.url);
23
23
  }
24
24
  f.noInitialRun = !0;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var f=class o{constructor(t){this.component=t}static globalLogLevel="warn";static logs=[];static maxLogs=1e3;static setLogLevel(t){o.globalLogLevel=t}static getLogs(){return[...o.logs]}static clearLogs(){o.logs=[]}debug(t,e){this.log("debug",t,e)}info(t,e){this.log("info",t,e)}warn(t,e){this.log("warn",t,e)}error(t,e){this.log("error",t,e)}log(t,e,i){let r={debug:0,info:1,warn:2,error:3};if(r[t]<r[o.globalLogLevel])return;let s={timestamp:Date.now(),level:t,component:this.component,message:e,data:i};o.logs.push(s),o.logs.length>o.maxLogs&&(o.logs=o.logs.slice(-o.maxLogs));let n=`[${new Date().toISOString()}] [${t.toUpperCase()}] [${this.component}]`,l=i?`${e} ${JSON.stringify(i)}`:e;switch(t){case"debug":console.debug(n,l);break;case"info":console.info(n,l);break;case"warn":console.warn(n,l);break;case"error":console.error(n,l);break;default:break}}};var P=class{supportsWebAssembly(){try{return typeof WebAssembly=="object"&&typeof WebAssembly.instantiate=="function"}catch{return!1}}};async function D(o={}){let{silent:t=!0}=o,e=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,i,r;if(e){let{createRequire:c}=await import("module"),{dirname:h,join:d}=await import("path"),u=c(import.meta.url).resolve("./gs.js"),y=h(u);r=d(y,"gs.wasm"),i=await import(u)}else i=await import(new URL("./gs.js",import.meta.url).href),r=new URL("./gs.wasm",import.meta.url).href;let s=i.default||i,n={locateFile:c=>c==="gs.wasm"?r:c};return t&&(n.print=()=>{},n.printErr=()=>{}),await s(n)}var F=class{static instance=null;static TIMEOUT_MS=3e4;static async load(t={}){return this.instance?this.instance:(this.instance=this.loadInternal(t),this.instance)}static async loadInternal(t){let e=new f("GhostscriptLoader");if(!new P().supportsWebAssembly())throw new Error("WebAssembly not supported in this browser");let r=t.timeout||this.TIMEOUT_MS;try{return e.info("Loading bundled Ghostscript (AGPL-3.0 licensed)"),e.info("Source available at: https://github.com/imgly/plugins"),await this.loadWithTimeout(()=>this.loadFromBundle(),r)}catch(s){throw e.error("Ghostscript loading failed",{error:s.message}),new Error(`Failed to load Ghostscript: ${s.message}`)}}static async loadFromBundle(){let t=new f("GhostscriptInit");try{t.info("Initializing Ghostscript module");let e=await D();return t.info("Ghostscript module initialized successfully",{version:e.version||"unknown",hasFS:!!e.FS,hasCallMain:!!e.callMain}),e}catch(e){throw t.error("Ghostscript initialization failed",{error:e}),new Error(`Ghostscript initialization failed: ${e.message}`)}}static async loadWithTimeout(t,e){return Promise.race([t(),new Promise((i,r)=>{setTimeout(()=>r(new Error(`Loading timeout after ${e}ms`)),e)})])}static reset(){this.instance=null}};var p=class{static async toUint8Array(t){if(t.arrayBuffer){let e=await t.arrayBuffer();return new Uint8Array(e)}return new Promise((e,i)=>{let r=new FileReader;r.onload=()=>{r.result instanceof ArrayBuffer?e(new Uint8Array(r.result)):i(new Error("Failed to read blob as ArrayBuffer"))},r.onerror=()=>i(r.error),r.readAsArrayBuffer(t)})}static async validatePDF(t){try{let e=await this.toUint8Array(t),i=new Uint8Array([37,80,68,70]);if(e.length<4)return!1;for(let r=0;r<4;r++)if(e[r]!==i[r])return!1;return!0}catch{return!1}}};var b=class{constructor(t,e="/tmp/pdfx"){this.module=t;this.fs=t.FS,this.logger=new f("VirtualFileSystem"),this.workingDir=e,this.initialize()}fs;logger;managedFiles=new Set;workingDir;initialize(){try{this.createDirIfNotExists(this.workingDir),this.createDirIfNotExists(`${this.workingDir}/input`),this.createDirIfNotExists(`${this.workingDir}/output`),this.createDirIfNotExists(`${this.workingDir}/profiles`),this.createDirIfNotExists(`${this.workingDir}/temp`),this.logger.info("Virtual filesystem initialized",{workingDir:this.workingDir})}catch(t){throw this.logger.error("Failed to initialize virtual filesystem",{error:t}),new Error(`VFS initialization failed: ${t}`)}}createDirIfNotExists(t){try{this.fs.mkdir(t)}catch(e){if(e.code!=="EEXIST")throw e}}async writeBlob(t,e,i=!0){try{let r=await p.toUint8Array(e);this.fs.writeFile(t,r),i&&this.managedFiles.add(t),this.logger.debug("File written",{path:t,size:r.length})}catch(r){throw this.logger.error("Failed to write blob",{path:t,error:r}),new Error(`Failed to write file ${t}: ${r}`)}}writeText(t,e,i=!0){try{this.fs.writeFile(t,e),i&&this.managedFiles.add(t),this.logger.debug("Text file written",{path:t,length:e.length})}catch(r){throw this.logger.error("Failed to write text",{path:t,error:r}),new Error(`Failed to write text file ${t}: ${r}`)}}readFile(t){try{let e=this.fs.readFile(t);return this.logger.debug("File read",{path:t,size:e.length}),e}catch(e){throw this.logger.error("Failed to read file",{path:t,error:e}),new Error(`Failed to read file ${t}: ${e}`)}}exists(t){try{return this.fs.stat(t),!0}catch{return!1}}cleanup(){let t=0;for(let e of this.managedFiles)try{this.fs.unlink(e),t++}catch(i){this.logger.warn("Failed to cleanup file",{path:e,error:i})}this.managedFiles.clear(),this.logger.info("Filesystem cleanup completed",{cleanedCount:t})}};async function z(o,t){if(Array.isArray(o)){if(o.length===0)return[];let e=[];for(let i=0;i<o.length;i++)try{let r=await x(o[i],t);e.push(r)}catch(r){throw new Error(`Failed to convert PDF ${i+1} of ${o.length}: ${r instanceof Error?r.message:String(r)}`)}return e}return x(o,t)}async function x(o,t){if(!(o instanceof Blob))throw new Error("Input must be a Blob");if(o.size===0)throw new Error("Input PDF is empty");if(o.size>100*1024*1024)throw new Error(`Input PDF too large (${o.size} bytes). Maximum: 100MB`);if(!t.outputProfile)throw new Error('outputProfile is required. Must be one of: "gracol", "fogra39", "srgb", "custom"');let e=["gracol","fogra39","srgb","custom"];if(!e.includes(t.outputProfile))throw new Error(`Invalid outputProfile "${t.outputProfile}". Must be one of: ${e.join(", ")}`);if(t.outputProfile==="custom"&&!t.customProfile)throw new Error('customProfile Blob is required when outputProfile is "custom"');if(t.customProfile&&!(t.customProfile instanceof Blob))throw new Error("customProfile must be a Blob");if(!await p.validatePDF(o))throw new Error("Invalid PDF format");let r=await F.load(),s=new b(r);try{let n="/tmp/input.pdf",l="/tmp/output.pdf",c="/tmp/pdfx_def.ps",h="/tmp/custom.icc";if(await s.writeBlob(n,o),t.outputProfile==="custom"&&t.customProfile)await s.writeBlob(h,t.customProfile);else if(t.outputProfile!=="custom"){let a=S[t.outputProfile],A=`/tmp/${a.file}`,G=typeof process<"u"&&process.versions?.node!=null,v;if(G){let{readFileSync:E}=await import("fs"),{fileURLToPath:g}=await import("url"),{dirname:k,join:X}=await import("path"),R=k(g(import.meta.url)),U=X(R,a.file),N=E(U);v=new Blob([N],{type:"application/vnd.iccprofile"})}else{let E=new URL(a.file,import.meta.url).href,g=await fetch(E);if(!g.ok)throw new Error(`Failed to load ICC profile ${a.file}: ${g.statusText}`);v=await g.blob()}await s.writeBlob(A,v)}let d,w,u;if(t.outputProfile==="custom")d=h,w=t.outputConditionIdentifier||"Custom Profile",u=t.outputCondition||"Custom ICC Profile";else{let a=S[t.outputProfile];d=`/tmp/${a.file}`,w=t.outputConditionIdentifier||a.identifier,u=t.outputCondition||a.info}let y=s.readFile(d),L=Array.from(y).map(a=>a.toString(16).padStart(2,"0")).join(""),I=y.slice(16,20),B=String.fromCharCode(...I).trim()==="CMYK",T=_(t,L,w,u);s.writeText(c,T);let m=["-dBATCH","-dNOPAUSE","-sDEVICE=pdfwrite","-dCompatibilityLevel=1.4","-dWriteObjStms=false","-dWriteXRefStm=false","-dPDFSETTINGS=/prepress","-dSetPageSize=false","-dAutoRotatePages=/None"];t.flattenTransparency!==!1&&m.push("-dHaveTransparency=false"),B?m.push("-sColorConversionStrategy=CMYK","-dProcessColorModel=/DeviceCMYK","-dConvertCMYKImagesToRGB=false"):m.push("-sColorConversionStrategy=RGB"),m.push(`-sOutputFile=${l}`,c,n);let C=await r.callMain(m);if(C!==0)throw new Error(`Ghostscript conversion failed with exit code ${C}`);let O=s.readFile(l),M=new Uint8Array(O),$=new Blob([M],{type:"application/pdf"});return s.cleanup(),$}catch(n){throw s.cleanup(),n}}var S={gracol:{file:"GRACoL2013_CRPC6.icc",identifier:"CGATS 21.2",info:"GRACoL 2013 CRPC6"},fogra39:{file:"ISOcoated_v2_eci.icc",identifier:"FOGRA39",info:"ISO Coated v2 (ECI)"},srgb:{file:"sRGB_IEC61966-2-1.icc",identifier:"sRGB IEC61966-2.1",info:"sRGB IEC61966-2.1"}};function _(o,t,e,i){return`%!
1
+ var f=class o{constructor(t){this.component=t}static globalLogLevel="warn";static logs=[];static maxLogs=1e3;static setLogLevel(t){o.globalLogLevel=t}static getLogs(){return[...o.logs]}static clearLogs(){o.logs=[]}debug(t,e){this.log("debug",t,e)}info(t,e){this.log("info",t,e)}warn(t,e){this.log("warn",t,e)}error(t,e){this.log("error",t,e)}log(t,e,i){let r={debug:0,info:1,warn:2,error:3};if(r[t]<r[o.globalLogLevel])return;let s={timestamp:Date.now(),level:t,component:this.component,message:e,data:i};o.logs.push(s),o.logs.length>o.maxLogs&&(o.logs=o.logs.slice(-o.maxLogs));let n=`[${new Date().toISOString()}] [${t.toUpperCase()}] [${this.component}]`,l=i?`${e} ${JSON.stringify(i)}`:e;switch(t){case"debug":console.debug(n,l);break;case"info":console.info(n,l);break;case"warn":console.warn(n,l);break;case"error":console.error(n,l);break;default:break}}};var F=class{supportsWebAssembly(){try{return typeof WebAssembly=="object"&&typeof WebAssembly.instantiate=="function"}catch{return!1}}};async function L(o={}){let{silent:t=!0}=o,e=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,i,r;if(e){let c=typeof process<"u"&&(process.env.VITEST==="true"||!1),w=new Function("s","return import(s)"),u=c?p=>import(p):w,g=await u("module"),d=await u("path"),y=g.createRequire,v=d.dirname,D=d.join,P=y(import.meta.url).resolve("./gs.js"),C=v(P);r=D(C,"gs.wasm"),i=await u(P)}else i=await import(new URL("./gs.js",import.meta.url).href),r=new URL("./gs.wasm",import.meta.url).href;let s=i.default||i,n={locateFile:c=>c==="gs.wasm"?r:c};return t&&(n.print=()=>{},n.printErr=()=>{}),await s(n)}var b=class{static instance=null;static TIMEOUT_MS=3e4;static async load(t={}){return this.instance?this.instance:(this.instance=this.loadInternal(t),this.instance)}static async loadInternal(t){let e=new f("GhostscriptLoader");if(!new F().supportsWebAssembly())throw new Error("WebAssembly not supported in this browser");let r=t.timeout||this.TIMEOUT_MS;try{return e.info("Loading bundled Ghostscript (AGPL-3.0 licensed)"),e.info("Source available at: https://github.com/imgly/plugins"),await this.loadWithTimeout(()=>this.loadFromBundle(),r)}catch(s){throw e.error("Ghostscript loading failed",{error:s.message}),new Error(`Failed to load Ghostscript: ${s.message}`)}}static async loadFromBundle(){let t=new f("GhostscriptInit");try{t.info("Initializing Ghostscript module");let e=await L();return t.info("Ghostscript module initialized successfully",{version:e.version||"unknown",hasFS:!!e.FS,hasCallMain:!!e.callMain}),e}catch(e){throw t.error("Ghostscript initialization failed",{error:e}),new Error(`Ghostscript initialization failed: ${e.message}`)}}static async loadWithTimeout(t,e){return Promise.race([t(),new Promise((i,r)=>{setTimeout(()=>r(new Error(`Loading timeout after ${e}ms`)),e)})])}static reset(){this.instance=null}};var m=class{static async toUint8Array(t){if(t.arrayBuffer){let e=await t.arrayBuffer();return new Uint8Array(e)}return new Promise((e,i)=>{let r=new FileReader;r.onload=()=>{r.result instanceof ArrayBuffer?e(new Uint8Array(r.result)):i(new Error("Failed to read blob as ArrayBuffer"))},r.onerror=()=>i(r.error),r.readAsArrayBuffer(t)})}static async validatePDF(t){try{let e=await this.toUint8Array(t),i=new Uint8Array([37,80,68,70]);if(e.length<4)return!1;for(let r=0;r<4;r++)if(e[r]!==i[r])return!1;return!0}catch{return!1}}};var E=class{constructor(t,e="/tmp/pdfx"){this.module=t;this.fs=t.FS,this.logger=new f("VirtualFileSystem"),this.workingDir=e,this.initialize()}fs;logger;managedFiles=new Set;workingDir;initialize(){try{this.createDirIfNotExists(this.workingDir),this.createDirIfNotExists(`${this.workingDir}/input`),this.createDirIfNotExists(`${this.workingDir}/output`),this.createDirIfNotExists(`${this.workingDir}/profiles`),this.createDirIfNotExists(`${this.workingDir}/temp`),this.logger.info("Virtual filesystem initialized",{workingDir:this.workingDir})}catch(t){throw this.logger.error("Failed to initialize virtual filesystem",{error:t}),new Error(`VFS initialization failed: ${t}`)}}createDirIfNotExists(t){try{this.fs.mkdir(t)}catch(e){if(e.code!=="EEXIST")throw e}}async writeBlob(t,e,i=!0){try{let r=await m.toUint8Array(e);this.fs.writeFile(t,r),i&&this.managedFiles.add(t),this.logger.debug("File written",{path:t,size:r.length})}catch(r){throw this.logger.error("Failed to write blob",{path:t,error:r}),new Error(`Failed to write file ${t}: ${r}`)}}writeText(t,e,i=!0){try{this.fs.writeFile(t,e),i&&this.managedFiles.add(t),this.logger.debug("Text file written",{path:t,length:e.length})}catch(r){throw this.logger.error("Failed to write text",{path:t,error:r}),new Error(`Failed to write text file ${t}: ${r}`)}}readFile(t){try{let e=this.fs.readFile(t);return this.logger.debug("File read",{path:t,size:e.length}),e}catch(e){throw this.logger.error("Failed to read file",{path:t,error:e}),new Error(`Failed to read file ${t}: ${e}`)}}exists(t){try{return this.fs.stat(t),!0}catch{return!1}}cleanup(){let t=0;for(let e of this.managedFiles)try{this.fs.unlink(e),t++}catch(i){this.logger.warn("Failed to cleanup file",{path:e,error:i})}this.managedFiles.clear(),this.logger.info("Filesystem cleanup completed",{cleanedCount:t})}};async function q(o,t){if(Array.isArray(o)){if(o.length===0)return[];let e=[];for(let i=0;i<o.length;i++)try{let r=await B(o[i],t);e.push(r)}catch(r){throw new Error(`Failed to convert PDF ${i+1} of ${o.length}: ${r instanceof Error?r.message:String(r)}`)}return e}return B(o,t)}async function B(o,t){if(!(o instanceof Blob))throw new Error("Input must be a Blob");if(o.size===0)throw new Error("Input PDF is empty");if(o.size>100*1024*1024)throw new Error(`Input PDF too large (${o.size} bytes). Maximum: 100MB`);if(!t.outputProfile)throw new Error('outputProfile is required. Must be one of: "gracol", "fogra39", "srgb", "custom"');let e=["gracol","fogra39","srgb","custom"];if(!e.includes(t.outputProfile))throw new Error(`Invalid outputProfile "${t.outputProfile}". Must be one of: ${e.join(", ")}`);if(t.outputProfile==="custom"&&!t.customProfile)throw new Error('customProfile Blob is required when outputProfile is "custom"');if(t.customProfile&&!(t.customProfile instanceof Blob))throw new Error("customProfile must be a Blob");if(!await m.validatePDF(o))throw new Error("Invalid PDF format");let r=await b.load(),s=new E(r);try{let n="/tmp/input.pdf",l="/tmp/output.pdf",c="/tmp/pdfx_def.ps",w="/tmp/custom.icc";if(await s.writeBlob(n,o),t.outputProfile==="custom"&&t.customProfile)await s.writeBlob(w,t.customProfile);else if(t.outputProfile!=="custom"){let a=O[t.outputProfile],k=`/tmp/${a.file}`,X=typeof process<"u"&&process.versions?.node!=null,I;if(X){let S=process.env.VITEST==="true"||!1,h=new Function("s","return import(s)"),x=S?W=>import(W):h,{readFileSync:R}=await x("fs"),{fileURLToPath:U}=await x("url"),{dirname:N,join:z}=await x("path"),_=N(U(import.meta.url)),V=z(_,a.file),j=R(V);I=new Blob([j],{type:"application/vnd.iccprofile"})}else{let S=new URL(a.file,import.meta.url).href,h=await fetch(S);if(!h.ok)throw new Error(`Failed to load ICC profile ${a.file}: ${h.statusText}`);I=await h.blob()}await s.writeBlob(k,I)}let u,g,d;if(t.outputProfile==="custom")u=w,g=t.outputConditionIdentifier||"Custom Profile",d=t.outputCondition||"Custom ICC Profile";else{let a=O[t.outputProfile];u=`/tmp/${a.file}`,g=t.outputConditionIdentifier||a.identifier,d=t.outputCondition||a.info}let y=s.readFile(u),v=Array.from(y).map(a=>a.toString(16).padStart(2,"0")).join(""),D=y.slice(16,20),P=String.fromCharCode(...D).trim()==="CMYK",C=K(t,v,g,d);s.writeText(c,C);let p=["-dBATCH","-dNOPAUSE","-sDEVICE=pdfwrite","-dCompatibilityLevel=1.4","-dWriteObjStms=false","-dWriteXRefStm=false","-dPDFSETTINGS=/prepress","-dSetPageSize=false","-dAutoRotatePages=/None"];t.flattenTransparency!==!1&&p.push("-dHaveTransparency=false"),P?p.push("-sColorConversionStrategy=CMYK","-dProcessColorModel=/DeviceCMYK","-dConvertCMYKImagesToRGB=false"):p.push("-sColorConversionStrategy=RGB"),p.push(`-sOutputFile=${l}`,c,n);let T=await r.callMain(p);if(T!==0)throw new Error(`Ghostscript conversion failed with exit code ${T}`);let $=s.readFile(l),A=new Uint8Array($),G=new Blob([A],{type:"application/pdf"});return s.cleanup(),G}catch(n){throw s.cleanup(),n}}var O={gracol:{file:"GRACoL2013_CRPC6.icc",identifier:"CGATS 21.2",info:"GRACoL 2013 CRPC6"},fogra39:{file:"ISOcoated_v2_eci.icc",identifier:"FOGRA39",info:"ISO Coated v2 (ECI)"},srgb:{file:"sRGB_IEC61966-2-1.icc",identifier:"sRGB IEC61966-2.1",info:"sRGB IEC61966-2.1"}};function K(o,t,e,i){return`%!
2
2
  % PDF/X-3 Definition File
3
3
  [ /Title (${o.title||"Untitled"}) /DOCINFO pdfmark
4
4
  [ /Trapped /False /DOCINFO pdfmark
@@ -26,5 +26,5 @@ var f=class o{constructor(t){this.component=t}static globalLogLevel="warn";stati
26
26
  >> /PUT pdfmark
27
27
 
28
28
  % Add OutputIntent to Catalog
29
- [{Catalog} <</OutputIntents [{OutputIntent_PDFX}]>> /PUT pdfmark`}export{f as Logger,z as convertToPDFX3};
29
+ [{Catalog} <</OutputIntents [{OutputIntent_PDFX}]>> /PUT pdfmark`}export{f as Logger,q as convertToPDFX3};
30
30
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/utils/logger.ts", "../src/utils/browser-detection.ts", "../src/wasm/ghostscript-module.ts", "../src/core/ghostscript-loader.ts", "../src/utils/blob-utils.ts", "../src/core/virtual-filesystem.ts", "../src/pdfx.ts"],
4
- "sourcesContent": ["/* eslint-disable no-console */\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\nexport interface LogEntry {\n timestamp: number;\n level: LogLevel;\n component: string;\n message: string;\n data?: any;\n}\n\nexport class Logger {\n private static globalLogLevel: LogLevel = 'warn';\n\n private static logs: LogEntry[] = [];\n\n private static maxLogs = 1000;\n\n constructor(private component: string) {}\n\n static setLogLevel(level: LogLevel): void {\n Logger.globalLogLevel = level;\n }\n\n static getLogs(): LogEntry[] {\n return [...Logger.logs];\n }\n\n static clearLogs(): void {\n Logger.logs = [];\n }\n\n debug(message: string, data?: any): void {\n this.log('debug', message, data);\n }\n\n info(message: string, data?: any): void {\n this.log('info', message, data);\n }\n\n warn(message: string, data?: any): void {\n this.log('warn', message, data);\n }\n\n error(message: string, data?: any): void {\n this.log('error', message, data);\n }\n\n private log(level: LogLevel, message: string, data?: any): void {\n const levelOrder: Record<LogLevel, number> = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3,\n };\n\n if (levelOrder[level] < levelOrder[Logger.globalLogLevel]) {\n return;\n }\n\n const entry: LogEntry = {\n timestamp: Date.now(),\n level,\n component: this.component,\n message,\n data,\n };\n\n Logger.logs.push(entry);\n\n // Keep logs under the limit\n if (Logger.logs.length > Logger.maxLogs) {\n Logger.logs = Logger.logs.slice(-Logger.maxLogs);\n }\n\n // Console output\n const prefix = `[${new Date().toISOString()}] [${level.toUpperCase()}] [${\n this.component\n }]`;\n const logMessage = data ? `${message} ${JSON.stringify(data)}` : message;\n\n switch (level) {\n case 'debug':\n console.debug(prefix, logMessage);\n break;\n case 'info':\n console.info(prefix, logMessage);\n break;\n case 'warn':\n console.warn(prefix, logMessage);\n break;\n case 'error':\n console.error(prefix, logMessage);\n break;\n default:\n // All log levels handled above\n break;\n }\n }\n}\n", "export class BrowserDetection {\n supportsWebAssembly(): boolean {\n try {\n return (\n typeof WebAssembly === 'object' &&\n typeof WebAssembly.instantiate === 'function'\n );\n } catch {\n return false;\n }\n }\n}\n", "// Wrapper for the Ghostscript WASM module to ensure proper loading\nimport type {\n EmscriptenModule,\n GhostscriptModuleFactory,\n} from '../types/ghostscript';\n\nexport interface GhostscriptModuleOptions {\n /**\n * Whether to suppress Ghostscript's stdout/stderr output.\n * Default: true (silent mode)\n */\n silent?: boolean;\n}\n\nexport default async function createGhostscriptModule(\n options: GhostscriptModuleOptions = {}\n): Promise<EmscriptenModule> {\n const { silent = true } = options;\n // Check if we're in Node.js\n const isNode =\n typeof process !== 'undefined' &&\n process.versions != null &&\n process.versions.node != null;\n\n let GhostscriptModule: any;\n let wasmPath: string;\n\n if (isNode) {\n // Node.js: Use require.resolve to find gs.js relative to this module\n const { createRequire } = await import('module');\n const { dirname, join } = await import('path');\n\n const requireForESM = createRequire(import.meta.url);\n\n // Resolve gs.js directly (it's copied to dist/ alongside the bundle)\n const gsPath = requireForESM.resolve('./gs.js');\n const moduleDir = dirname(gsPath);\n wasmPath = join(moduleDir, 'gs.wasm');\n\n GhostscriptModule = await import(gsPath);\n } else {\n // Browser: Use URL-based imports\n const moduleUrl = new URL('./gs.js', import.meta.url).href;\n GhostscriptModule = await import(/* webpackIgnore: true */ moduleUrl);\n wasmPath = new URL('./gs.wasm', import.meta.url).href;\n }\n\n const factory = (GhostscriptModule.default ||\n GhostscriptModule) as GhostscriptModuleFactory;\n\n // Configure the module to load WASM from the bundled location\n const moduleConfig: Record<string, unknown> = {\n locateFile: (filename: string) => {\n if (filename === 'gs.wasm') {\n return wasmPath;\n }\n return filename;\n },\n };\n\n // Suppress Ghostscript stdout/stderr output in silent mode\n if (silent) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n moduleConfig.print = () => {};\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n moduleConfig.printErr = () => {};\n }\n\n const module = await factory(moduleConfig);\n\n return module;\n}\n", "import type { EmscriptenModule } from '../types/ghostscript';\nimport { Logger } from '../utils/logger';\nimport { BrowserDetection } from '../utils/browser-detection';\nimport createGhostscriptModule from '../wasm/ghostscript-module';\n\nexport interface LoaderOptions {\n timeout?: number;\n}\n\nexport class GhostscriptLoader {\n private static instance: Promise<EmscriptenModule> | null = null;\n\n private static readonly TIMEOUT_MS = 30000;\n\n static async load(options: LoaderOptions = {}): Promise<EmscriptenModule> {\n if (this.instance) {\n return this.instance;\n }\n\n this.instance = this.loadInternal(options);\n return this.instance;\n }\n\n private static async loadInternal(\n options: LoaderOptions\n ): Promise<EmscriptenModule> {\n const logger = new Logger('GhostscriptLoader');\n const browser = new BrowserDetection();\n\n // Check browser compatibility\n if (!browser.supportsWebAssembly()) {\n throw new Error('WebAssembly not supported in this browser');\n }\n\n const timeout = options.timeout || this.TIMEOUT_MS;\n\n try {\n logger.info('Loading bundled Ghostscript (AGPL-3.0 licensed)');\n logger.info('Source available at: https://github.com/imgly/plugins');\n return await this.loadWithTimeout(() => this.loadFromBundle(), timeout);\n } catch (error) {\n logger.error('Ghostscript loading failed', {\n error: (error as Error).message,\n });\n throw new Error(\n `Failed to load Ghostscript: ${(error as Error).message}`\n );\n }\n }\n\n private static async loadFromBundle(): Promise<EmscriptenModule> {\n // Use the bundled WASM module with proper configuration\n const logger = new Logger('GhostscriptInit');\n\n try {\n logger.info('Initializing Ghostscript module');\n\n const module = await createGhostscriptModule();\n\n logger.info('Ghostscript module initialized successfully', {\n version: module.version || 'unknown',\n hasFS: !!module.FS,\n hasCallMain: !!module.callMain,\n });\n\n return module;\n } catch (error) {\n logger.error('Ghostscript initialization failed', { error });\n throw new Error(\n `Ghostscript initialization failed: ${(error as Error).message}`\n );\n }\n }\n\n private static async loadWithTimeout<T>(\n operation: () => Promise<T>,\n timeoutMs: number\n ): Promise<T> {\n return Promise.race([\n operation(),\n new Promise<never>((_, reject) => {\n setTimeout(\n () => reject(new Error(`Loading timeout after ${timeoutMs}ms`)),\n timeoutMs\n );\n }),\n ]);\n }\n\n static reset(): void {\n this.instance = null;\n }\n}\n", "export class BlobUtils {\n static async toUint8Array(blob: Blob): Promise<Uint8Array> {\n if (blob.arrayBuffer) {\n const buffer = await blob.arrayBuffer();\n return new Uint8Array(buffer);\n }\n\n // Fallback for older browsers\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () => {\n if (reader.result instanceof ArrayBuffer) {\n resolve(new Uint8Array(reader.result));\n } else {\n reject(new Error('Failed to read blob as ArrayBuffer'));\n }\n };\n reader.onerror = () => reject(reader.error);\n reader.readAsArrayBuffer(blob);\n });\n }\n\n static async validatePDF(blob: Blob): Promise<boolean> {\n try {\n const data = await this.toUint8Array(blob);\n\n // Check PDF magic number\n const pdfHeader = new Uint8Array([0x25, 0x50, 0x44, 0x46]); // %PDF\n\n if (data.length < 4) {\n return false;\n }\n\n for (let i = 0; i < 4; i++) {\n if (data[i] !== pdfHeader[i]) {\n return false;\n }\n }\n\n return true;\n } catch {\n return false;\n }\n }\n}\n", "import type { EmscriptenModule, EmscriptenFS } from '../types/ghostscript';\nimport { Logger } from '../utils/logger';\nimport { BlobUtils } from '../utils/blob-utils';\n\nexport interface FileEntry {\n path: string;\n data: Uint8Array;\n cleanup: boolean;\n}\n\nexport class VirtualFileSystem {\n private readonly fs: EmscriptenFS;\n\n private readonly logger: Logger;\n\n private readonly managedFiles: Set<string> = new Set();\n\n private readonly workingDir: string;\n\n constructor(\n private readonly module: EmscriptenModule,\n workingDir = '/tmp/pdfx'\n ) {\n this.fs = module.FS;\n this.logger = new Logger('VirtualFileSystem');\n this.workingDir = workingDir;\n this.initialize();\n }\n\n private initialize(): void {\n try {\n // Create working directory structure (handle existing directories gracefully)\n this.createDirIfNotExists(this.workingDir);\n this.createDirIfNotExists(`${this.workingDir}/input`);\n this.createDirIfNotExists(`${this.workingDir}/output`);\n this.createDirIfNotExists(`${this.workingDir}/profiles`);\n this.createDirIfNotExists(`${this.workingDir}/temp`);\n\n this.logger.info('Virtual filesystem initialized', {\n workingDir: this.workingDir,\n });\n } catch (error) {\n this.logger.error('Failed to initialize virtual filesystem', { error });\n throw new Error(`VFS initialization failed: ${error}`);\n }\n }\n\n private createDirIfNotExists(path: string): void {\n try {\n this.fs.mkdir(path);\n } catch (error: any) {\n // Ignore \"File exists\" errors, re-throw others\n if (error.code !== 'EEXIST') {\n throw error;\n }\n }\n }\n\n async writeBlob(path: string, blob: Blob, managed = true): Promise<void> {\n try {\n const data = await BlobUtils.toUint8Array(blob);\n this.fs.writeFile(path, data);\n\n if (managed) {\n this.managedFiles.add(path);\n }\n\n this.logger.debug('File written', { path, size: data.length });\n } catch (error) {\n this.logger.error('Failed to write blob', { path, error });\n throw new Error(`Failed to write file ${path}: ${error}`);\n }\n }\n\n writeText(path: string, content: string, managed = true): void {\n try {\n this.fs.writeFile(path, content);\n\n if (managed) {\n this.managedFiles.add(path);\n }\n\n this.logger.debug('Text file written', { path, length: content.length });\n } catch (error) {\n this.logger.error('Failed to write text', { path, error });\n throw new Error(`Failed to write text file ${path}: ${error}`);\n }\n }\n\n readFile(path: string): Uint8Array {\n try {\n const data = this.fs.readFile(path) as Uint8Array;\n this.logger.debug('File read', { path, size: data.length });\n return data;\n } catch (error) {\n this.logger.error('Failed to read file', { path, error });\n throw new Error(`Failed to read file ${path}: ${error}`);\n }\n }\n\n exists(path: string): boolean {\n try {\n this.fs.stat(path);\n return true;\n } catch {\n return false;\n }\n }\n\n cleanup(): void {\n let cleanedCount = 0;\n\n for (const path of this.managedFiles) {\n try {\n this.fs.unlink(path);\n cleanedCount++;\n } catch (error) {\n this.logger.warn('Failed to cleanup file', { path, error });\n }\n }\n\n this.managedFiles.clear();\n this.logger.info('Filesystem cleanup completed', { cleanedCount });\n }\n}\n", "import type { PDFX3Options } from './types/pdfx';\nimport { GhostscriptLoader } from './core/ghostscript-loader';\nimport { VirtualFileSystem } from './core/virtual-filesystem';\nimport { BlobUtils } from './utils/blob-utils';\n\n/**\n * PDF/X-3 conversion function\n * Converts RGB PDF(s) to PDF/X-3 format using specified output profile\n *\n * @overload\n * @param inputPDF Single PDF blob to convert\n * @param options Conversion configuration\n * @returns Promise resolving to converted PDF blob\n *\n * @overload\n * @param inputPDFs Array of PDF blobs to convert\n * @param options Conversion configuration\n * @returns Promise resolving to array of converted PDF blobs\n */\nexport function convertToPDFX3(\n inputPDF: Blob,\n options: PDFX3Options\n): Promise<Blob>;\nexport function convertToPDFX3(\n inputPDFs: Blob[],\n options: PDFX3Options\n): Promise<Blob[]>;\nexport async function convertToPDFX3(\n input: Blob | Blob[],\n options: PDFX3Options\n): Promise<Blob | Blob[]> {\n // Handle array input (batch processing)\n if (Array.isArray(input)) {\n if (input.length === 0) {\n return [];\n }\n\n // Process each blob sequentially to avoid overwhelming the WASM module\n const results: Blob[] = [];\n for (let i = 0; i < input.length; i++) {\n try {\n // eslint-disable-next-line no-await-in-loop\n const converted = await convertToPDFX3Single(input[i], options);\n results.push(converted);\n } catch (error) {\n throw new Error(\n `Failed to convert PDF ${i + 1} of ${input.length}: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n }\n return results;\n }\n\n // Handle single blob input\n return convertToPDFX3Single(input, options);\n}\n\n/**\n * Internal function to convert a single PDF\n */\nasync function convertToPDFX3Single(\n inputPDF: Blob,\n options: PDFX3Options\n): Promise<Blob> {\n // Validate inputs\n if (!(inputPDF instanceof Blob)) {\n throw new Error('Input must be a Blob');\n }\n\n if (inputPDF.size === 0) {\n throw new Error('Input PDF is empty');\n }\n\n if (inputPDF.size > 100 * 1024 * 1024) {\n throw new Error(\n `Input PDF too large (${inputPDF.size} bytes). Maximum: 100MB`\n );\n }\n\n // Validate output profile is provided\n if (!options.outputProfile) {\n throw new Error(\n 'outputProfile is required. Must be one of: \"gracol\", \"fogra39\", \"srgb\", \"custom\"'\n );\n }\n\n // Validate output profile value\n const validProfiles = ['gracol', 'fogra39', 'srgb', 'custom'];\n if (!validProfiles.includes(options.outputProfile)) {\n throw new Error(\n `Invalid outputProfile \"${\n options.outputProfile\n }\". Must be one of: ${validProfiles.join(', ')}`\n );\n }\n\n // Validate custom profile requirement\n if (options.outputProfile === 'custom' && !options.customProfile) {\n throw new Error(\n 'customProfile Blob is required when outputProfile is \"custom\"'\n );\n }\n\n // Validate custom profile if provided\n if (options.customProfile && !(options.customProfile instanceof Blob)) {\n throw new Error('customProfile must be a Blob');\n }\n\n // Validate PDF format\n const isValidPDF = await BlobUtils.validatePDF(inputPDF);\n if (!isValidPDF) {\n throw new Error('Invalid PDF format');\n }\n\n // Load Ghostscript\n const module = await GhostscriptLoader.load();\n const vfs = new VirtualFileSystem(module);\n\n try {\n // Setup file paths\n const inputPath = '/tmp/input.pdf';\n const outputPath = '/tmp/output.pdf';\n const pdfxDefPath = '/tmp/pdfx_def.ps';\n const customProfilePath = '/tmp/custom.icc';\n\n // Write input PDF to virtual filesystem\n await vfs.writeBlob(inputPath, inputPDF);\n\n // Write ICC profiles to virtual filesystem\n if (options.outputProfile === 'custom' && options.customProfile) {\n await vfs.writeBlob(customProfilePath, options.customProfile);\n } else if (options.outputProfile !== 'custom') {\n // Load the bundled ICC profile\n const profileInfo =\n PROFILE_PRESETS[options.outputProfile as keyof typeof PROFILE_PRESETS];\n const profilePath = `/tmp/${profileInfo.file}`;\n\n // Load ICC profile - different approach for Node.js vs browser\n const isNode =\n typeof process !== 'undefined' && process.versions?.node != null;\n\n let profileBlob: Blob;\n\n if (isNode) {\n // Node.js: Load from filesystem using readFileSync\n const { readFileSync } = await import('fs');\n const { fileURLToPath } = await import('url');\n const { dirname, join } = await import('path');\n\n // Get the directory of the built module\n const moduleDir = dirname(fileURLToPath(import.meta.url));\n const profileFilePath = join(moduleDir, profileInfo.file);\n\n const profileData = readFileSync(profileFilePath);\n profileBlob = new Blob([profileData], {\n type: 'application/vnd.iccprofile',\n });\n } else {\n // Browser: Use fetch\n const profileUrl = new URL(profileInfo.file, import.meta.url).href;\n const profileResponse = await fetch(profileUrl);\n if (!profileResponse.ok) {\n throw new Error(\n `Failed to load ICC profile ${profileInfo.file}: ${profileResponse.statusText}`\n );\n }\n profileBlob = await profileResponse.blob();\n }\n\n await vfs.writeBlob(profilePath, profileBlob);\n }\n\n // Determine ICC profile path and metadata for Ghostscript\n let iccProfilePath: string;\n let outputConditionIdentifier: string;\n let outputCondition: string;\n\n if (options.outputProfile === 'custom') {\n iccProfilePath = customProfilePath;\n // Use custom values or defaults\n outputConditionIdentifier =\n options.outputConditionIdentifier || 'Custom Profile';\n outputCondition = options.outputCondition || 'Custom ICC Profile';\n } else {\n const preset =\n PROFILE_PRESETS[options.outputProfile as keyof typeof PROFILE_PRESETS];\n iccProfilePath = `/tmp/${preset.file}`;\n // Allow overriding preset values\n outputConditionIdentifier =\n options.outputConditionIdentifier || preset.identifier;\n outputCondition = options.outputCondition || preset.info;\n }\n\n // Read ICC profile data and convert to hex for embedding\n // WASM doesn't support (file) (r) file syntax, so we embed directly\n const iccData = vfs.readFile(iccProfilePath);\n const iccHex = Array.from(iccData)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n\n // Determine color conversion strategy based on profile type\n // ICC profile color space is at bytes 16-19\n // 'RGB ' = 0x52474220, 'CMYK' = 0x434D594B\n const colorSpaceBytes = iccData.slice(16, 20);\n const colorSpaceStr = String.fromCharCode(...colorSpaceBytes);\n const isCMYKProfile = colorSpaceStr.trim() === 'CMYK';\n\n // Generate PDF/X-3 definition with ICC profile hex data\n const pdfxDefinition = generatePDFXDef(\n options,\n iccHex,\n outputConditionIdentifier,\n outputCondition\n );\n vfs.writeText(pdfxDefPath, pdfxDefinition);\n\n // Execute Ghostscript conversion\n // For CMYK profiles, convert all colors to CMYK using the ICC profile\n // Note: Transparency flattening will rasterize transparent content\n const gsArgs = [\n '-dBATCH',\n '-dNOPAUSE',\n '-sDEVICE=pdfwrite',\n '-dCompatibilityLevel=1.4',\n // Disable PDF 1.5+ features to avoid warnings with PDF 1.4 compatibility\n '-dWriteObjStms=false',\n '-dWriteXRefStm=false',\n // PDF/X-3 settings\n '-dPDFSETTINGS=/prepress',\n '-dSetPageSize=false',\n '-dAutoRotatePages=/None',\n ];\n\n // Flatten transparency for PDF/X-3 compliance (default: true)\n // HaveTransparency=false tells Ghostscript the target viewer cannot handle\n // PDF 1.4 transparency, so pages with transparency are converted to bitmaps\n const shouldFlattenTransparency = options.flattenTransparency !== false;\n if (shouldFlattenTransparency) {\n gsArgs.push('-dHaveTransparency=false');\n }\n\n // Add color conversion for CMYK profiles\n if (isCMYKProfile) {\n gsArgs.push(\n '-sColorConversionStrategy=CMYK',\n '-dProcessColorModel=/DeviceCMYK',\n '-dConvertCMYKImagesToRGB=false'\n );\n } else {\n // For RGB profiles, we still need a color conversion strategy\n gsArgs.push('-sColorConversionStrategy=RGB');\n }\n\n // Add output file and input files\n gsArgs.push(`-sOutputFile=${outputPath}`, pdfxDefPath, inputPath);\n\n const exitCode = await module.callMain(gsArgs);\n if (exitCode !== 0) {\n throw new Error(\n `Ghostscript conversion failed with exit code ${exitCode}`\n );\n }\n\n // Read output\n const outputData = vfs.readFile(outputPath);\n // Create a copy of the data to ensure it's an ArrayBuffer, not SharedArrayBuffer\n const outputBuffer = new Uint8Array(outputData);\n const outputPDF = new Blob([outputBuffer], { type: 'application/pdf' });\n\n // Cleanup\n vfs.cleanup();\n\n return outputPDF;\n } catch (error) {\n vfs.cleanup();\n throw error;\n }\n}\n\n// Profile presets from the spec\nconst PROFILE_PRESETS = {\n gracol: {\n file: 'GRACoL2013_CRPC6.icc',\n identifier: 'CGATS 21.2',\n info: 'GRACoL 2013 CRPC6',\n },\n fogra39: {\n file: 'ISOcoated_v2_eci.icc',\n identifier: 'FOGRA39',\n info: 'ISO Coated v2 (ECI)',\n },\n srgb: {\n file: 'sRGB_IEC61966-2-1.icc',\n identifier: 'sRGB IEC61966-2.1',\n info: 'sRGB IEC61966-2.1',\n },\n};\n\nfunction generatePDFXDef(\n options: PDFX3Options,\n iccProfileHex: string,\n outputConditionIdentifier: string,\n outputCondition: string\n): string {\n return `%!\n% PDF/X-3 Definition File\n[ /Title (${options.title || 'Untitled'}) /DOCINFO pdfmark\n[ /Trapped /False /DOCINFO pdfmark\n\n% Set PDF/X-3 conformance\n[ /GTS_PDFXVersion (PDF/X-3:2003) /GTS_PDFXConformance (PDF/X-3:2003) /DOCINFO pdfmark\n\n% Set TrimBox to match MediaBox for all pages (required for PDF/X)\n[/TrimBox [0 0 0 0] /PAGE pdfmark\n\n% Embed ICC profile as hex stream\n[/_objdef {icc_PDFX} /type /stream /OBJ pdfmark\n[{icc_PDFX} <</N 4>> /PUT pdfmark\n[{icc_PDFX} <${iccProfileHex}> /PUT pdfmark\n\n% Define OutputIntent with embedded ICC profile\n[/_objdef {OutputIntent_PDFX} /type /dict /OBJ pdfmark\n[{OutputIntent_PDFX} <<\n /Type /OutputIntent\n /S /GTS_PDFX\n /OutputCondition (${outputCondition})\n /OutputConditionIdentifier (${outputConditionIdentifier})\n /RegistryName (http://www.color.org)\n /DestOutputProfile {icc_PDFX}\n>> /PUT pdfmark\n\n% Add OutputIntent to Catalog\n[{Catalog} <</OutputIntents [{OutputIntent_PDFX}]>> /PUT pdfmark`;\n}\n"],
5
- "mappings": "AAWO,IAAMA,EAAN,MAAMC,CAAO,CAOlB,YAAoBC,EAAmB,CAAnB,eAAAA,CAAoB,CANxC,OAAe,eAA2B,OAE1C,OAAe,KAAmB,CAAC,EAEnC,OAAe,QAAU,IAIzB,OAAO,YAAYC,EAAuB,CACxCF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C,IAAa,EACf,MAAM,IAAI,MACR,gDAAgDA,CAAQ,EAC1D,EAIF,IAAMC,EAAajC,EAAI,SAASG,CAAU,EAEpC+B,EAAe,IAAI,WAAWD,CAAU,EACxCE,EAAY,IAAI,KAAK,CAACD,CAAY,EAAG,CAAE,KAAM,iBAAkB,CAAC,EAGtE,OAAAlC,EAAI,QAAQ,EAELmC,CACT,OAASzC,EAAO,CACd,MAAAM,EAAI,QAAQ,EACNN,CACR,CACF,CAGA,IAAMa,EAAkB,CACtB,OAAQ,CACN,KAAM,uBACN,WAAY,aACZ,KAAM,mBACR,EACA,QAAS,CACP,KAAM,uBACN,WAAY,UACZ,KAAM,qBACR,EACA,KAAM,CACJ,KAAM,wBACN,WAAY,oBACZ,KAAM,mBACR,CACF,EAEA,SAASuB,EACPxC,EACA8C,EACAf,EACAC,EACQ,CACR,MAAO;AAAA;AAAA,YAEGhC,EAAQ,OAAS,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAYxB8C,CAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAONd,CAAe;AAAA,gCACLD,CAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iEAOzD",
6
- "names": ["Logger", "_Logger", "component", "level", "message", "data", "levelOrder", "entry", "prefix", "logMessage", "BrowserDetection", "createGhostscriptModule", "options", "silent", "isNode", "GhostscriptModule", "wasmPath", "createRequire", "dirname", "join", "gsPath", "moduleDir", "factory", "moduleConfig", "filename", "GhostscriptLoader", "options", "logger", "Logger", "BrowserDetection", "timeout", "error", "module", "createGhostscriptModule", "operation", "timeoutMs", "_", "reject", "BlobUtils", "blob", "buffer", "resolve", "reject", "reader", "data", "pdfHeader", "i", "VirtualFileSystem", "module", "workingDir", "Logger", "error", "path", "blob", "managed", "data", "BlobUtils", "content", "cleanedCount", "convertToPDFX3", "input", "options", "results", "converted", "convertToPDFX3Single", "error", "inputPDF", "validProfiles", "BlobUtils", "module", "GhostscriptLoader", "vfs", "VirtualFileSystem", "inputPath", "outputPath", "pdfxDefPath", "customProfilePath", "profileInfo", "PROFILE_PRESETS", "profilePath", "isNode", "profileBlob", "readFileSync", "fileURLToPath", "dirname", "join", "moduleDir", "profileFilePath", "profileData", "profileUrl", "profileResponse", "iccProfilePath", "outputConditionIdentifier", "outputCondition", "preset", "iccData", "iccHex", "b", "colorSpaceBytes", "isCMYKProfile", "pdfxDefinition", "generatePDFXDef", "gsArgs", "exitCode", "outputData", "outputBuffer", "outputPDF", "iccProfileHex"]
4
+ "sourcesContent": ["/* eslint-disable no-console */\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\nexport interface LogEntry {\n timestamp: number;\n level: LogLevel;\n component: string;\n message: string;\n data?: any;\n}\n\nexport class Logger {\n private static globalLogLevel: LogLevel = 'warn';\n\n private static logs: LogEntry[] = [];\n\n private static maxLogs = 1000;\n\n constructor(private component: string) {}\n\n static setLogLevel(level: LogLevel): void {\n Logger.globalLogLevel = level;\n }\n\n static getLogs(): LogEntry[] {\n return [...Logger.logs];\n }\n\n static clearLogs(): void {\n Logger.logs = [];\n }\n\n debug(message: string, data?: any): void {\n this.log('debug', message, data);\n }\n\n info(message: string, data?: any): void {\n this.log('info', message, data);\n }\n\n warn(message: string, data?: any): void {\n this.log('warn', message, data);\n }\n\n error(message: string, data?: any): void {\n this.log('error', message, data);\n }\n\n private log(level: LogLevel, message: string, data?: any): void {\n const levelOrder: Record<LogLevel, number> = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3,\n };\n\n if (levelOrder[level] < levelOrder[Logger.globalLogLevel]) {\n return;\n }\n\n const entry: LogEntry = {\n timestamp: Date.now(),\n level,\n component: this.component,\n message,\n data,\n };\n\n Logger.logs.push(entry);\n\n // Keep logs under the limit\n if (Logger.logs.length > Logger.maxLogs) {\n Logger.logs = Logger.logs.slice(-Logger.maxLogs);\n }\n\n // Console output\n const prefix = `[${new Date().toISOString()}] [${level.toUpperCase()}] [${\n this.component\n }]`;\n const logMessage = data ? `${message} ${JSON.stringify(data)}` : message;\n\n switch (level) {\n case 'debug':\n console.debug(prefix, logMessage);\n break;\n case 'info':\n console.info(prefix, logMessage);\n break;\n case 'warn':\n console.warn(prefix, logMessage);\n break;\n case 'error':\n console.error(prefix, logMessage);\n break;\n default:\n // All log levels handled above\n break;\n }\n }\n}\n", "export class BrowserDetection {\n supportsWebAssembly(): boolean {\n try {\n return (\n typeof WebAssembly === 'object' &&\n typeof WebAssembly.instantiate === 'function'\n );\n } catch {\n return false;\n }\n }\n}\n", "// Wrapper for the Ghostscript WASM module to ensure proper loading\nimport type {\n EmscriptenModule,\n GhostscriptModuleFactory,\n} from '../types/ghostscript';\n\nexport interface GhostscriptModuleOptions {\n /**\n * Whether to suppress Ghostscript's stdout/stderr output.\n * Default: true (silent mode)\n */\n silent?: boolean;\n}\n\nexport default async function createGhostscriptModule(\n options: GhostscriptModuleOptions = {}\n): Promise<EmscriptenModule> {\n const { silent = true } = options;\n // Check if we're in Node.js\n const isNode =\n typeof process !== 'undefined' &&\n process.versions != null &&\n process.versions.node != null;\n\n let GhostscriptModule: any;\n let wasmPath: string;\n\n if (isNode) {\n // Node.js: Use require.resolve to find gs.js relative to this module\n // Use indirect dynamic import to prevent Webpack 5 from statically analyzing these imports\n // But use direct imports in test environments (vitest) where indirect imports bypass mocking\n // See: https://github.com/imgly/ubq/issues/11471\n const isTestEnv =\n typeof process !== 'undefined' &&\n (process.env.VITEST === 'true' || process.env.NODE_ENV === 'test');\n\n // Helper for dynamic imports - uses indirect import in production to avoid Webpack static analysis\n // Note: new Function() could fail in CSP-restricted environments, but CSP is a browser\n // security mechanism and doesn't apply to Node.js. This code only runs in Node.js (isNode check above).\n // eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func\n const indirectImport = new Function('s', 'return import(s)') as (\n s: string\n ) => Promise<any>;\n const dynamicImport = isTestEnv ? (s: string) => import(s) : indirectImport;\n\n const moduleLib = await dynamicImport('module');\n const pathLib = await dynamicImport('path');\n const createRequire = moduleLib.createRequire;\n const dirname = pathLib.dirname;\n const join = pathLib.join;\n\n const requireForESM = createRequire(import.meta.url);\n\n // Resolve gs.js directly (it's copied to dist/ alongside the bundle)\n const gsPath = requireForESM.resolve('./gs.js');\n const moduleDir = dirname(gsPath);\n wasmPath = join(moduleDir, 'gs.wasm');\n\n GhostscriptModule = await dynamicImport(gsPath);\n } else {\n // Browser: Use URL-based imports\n const moduleUrl = new URL('./gs.js', import.meta.url).href;\n GhostscriptModule = await import(/* webpackIgnore: true */ moduleUrl);\n wasmPath = new URL('./gs.wasm', import.meta.url).href;\n }\n\n const factory = (GhostscriptModule.default ||\n GhostscriptModule) as GhostscriptModuleFactory;\n\n // Configure the module to load WASM from the bundled location\n const moduleConfig: Record<string, unknown> = {\n locateFile: (filename: string) => {\n if (filename === 'gs.wasm') {\n return wasmPath;\n }\n return filename;\n },\n };\n\n // Suppress Ghostscript stdout/stderr output in silent mode\n if (silent) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n moduleConfig.print = () => {};\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n moduleConfig.printErr = () => {};\n }\n\n const module = await factory(moduleConfig);\n\n return module;\n}\n", "import type { EmscriptenModule } from '../types/ghostscript';\nimport { Logger } from '../utils/logger';\nimport { BrowserDetection } from '../utils/browser-detection';\nimport createGhostscriptModule from '../wasm/ghostscript-module';\n\nexport interface LoaderOptions {\n timeout?: number;\n}\n\nexport class GhostscriptLoader {\n private static instance: Promise<EmscriptenModule> | null = null;\n\n private static readonly TIMEOUT_MS = 30000;\n\n static async load(options: LoaderOptions = {}): Promise<EmscriptenModule> {\n if (this.instance) {\n return this.instance;\n }\n\n this.instance = this.loadInternal(options);\n return this.instance;\n }\n\n private static async loadInternal(\n options: LoaderOptions\n ): Promise<EmscriptenModule> {\n const logger = new Logger('GhostscriptLoader');\n const browser = new BrowserDetection();\n\n // Check browser compatibility\n if (!browser.supportsWebAssembly()) {\n throw new Error('WebAssembly not supported in this browser');\n }\n\n const timeout = options.timeout || this.TIMEOUT_MS;\n\n try {\n logger.info('Loading bundled Ghostscript (AGPL-3.0 licensed)');\n logger.info('Source available at: https://github.com/imgly/plugins');\n return await this.loadWithTimeout(() => this.loadFromBundle(), timeout);\n } catch (error) {\n logger.error('Ghostscript loading failed', {\n error: (error as Error).message,\n });\n throw new Error(\n `Failed to load Ghostscript: ${(error as Error).message}`\n );\n }\n }\n\n private static async loadFromBundle(): Promise<EmscriptenModule> {\n // Use the bundled WASM module with proper configuration\n const logger = new Logger('GhostscriptInit');\n\n try {\n logger.info('Initializing Ghostscript module');\n\n const module = await createGhostscriptModule();\n\n logger.info('Ghostscript module initialized successfully', {\n version: module.version || 'unknown',\n hasFS: !!module.FS,\n hasCallMain: !!module.callMain,\n });\n\n return module;\n } catch (error) {\n logger.error('Ghostscript initialization failed', { error });\n throw new Error(\n `Ghostscript initialization failed: ${(error as Error).message}`\n );\n }\n }\n\n private static async loadWithTimeout<T>(\n operation: () => Promise<T>,\n timeoutMs: number\n ): Promise<T> {\n return Promise.race([\n operation(),\n new Promise<never>((_, reject) => {\n setTimeout(\n () => reject(new Error(`Loading timeout after ${timeoutMs}ms`)),\n timeoutMs\n );\n }),\n ]);\n }\n\n static reset(): void {\n this.instance = null;\n }\n}\n", "export class BlobUtils {\n static async toUint8Array(blob: Blob): Promise<Uint8Array> {\n if (blob.arrayBuffer) {\n const buffer = await blob.arrayBuffer();\n return new Uint8Array(buffer);\n }\n\n // Fallback for older browsers\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () => {\n if (reader.result instanceof ArrayBuffer) {\n resolve(new Uint8Array(reader.result));\n } else {\n reject(new Error('Failed to read blob as ArrayBuffer'));\n }\n };\n reader.onerror = () => reject(reader.error);\n reader.readAsArrayBuffer(blob);\n });\n }\n\n static async validatePDF(blob: Blob): Promise<boolean> {\n try {\n const data = await this.toUint8Array(blob);\n\n // Check PDF magic number\n const pdfHeader = new Uint8Array([0x25, 0x50, 0x44, 0x46]); // %PDF\n\n if (data.length < 4) {\n return false;\n }\n\n for (let i = 0; i < 4; i++) {\n if (data[i] !== pdfHeader[i]) {\n return false;\n }\n }\n\n return true;\n } catch {\n return false;\n }\n }\n}\n", "import type { EmscriptenModule, EmscriptenFS } from '../types/ghostscript';\nimport { Logger } from '../utils/logger';\nimport { BlobUtils } from '../utils/blob-utils';\n\nexport interface FileEntry {\n path: string;\n data: Uint8Array;\n cleanup: boolean;\n}\n\nexport class VirtualFileSystem {\n private readonly fs: EmscriptenFS;\n\n private readonly logger: Logger;\n\n private readonly managedFiles: Set<string> = new Set();\n\n private readonly workingDir: string;\n\n constructor(\n private readonly module: EmscriptenModule,\n workingDir = '/tmp/pdfx'\n ) {\n this.fs = module.FS;\n this.logger = new Logger('VirtualFileSystem');\n this.workingDir = workingDir;\n this.initialize();\n }\n\n private initialize(): void {\n try {\n // Create working directory structure (handle existing directories gracefully)\n this.createDirIfNotExists(this.workingDir);\n this.createDirIfNotExists(`${this.workingDir}/input`);\n this.createDirIfNotExists(`${this.workingDir}/output`);\n this.createDirIfNotExists(`${this.workingDir}/profiles`);\n this.createDirIfNotExists(`${this.workingDir}/temp`);\n\n this.logger.info('Virtual filesystem initialized', {\n workingDir: this.workingDir,\n });\n } catch (error) {\n this.logger.error('Failed to initialize virtual filesystem', { error });\n throw new Error(`VFS initialization failed: ${error}`);\n }\n }\n\n private createDirIfNotExists(path: string): void {\n try {\n this.fs.mkdir(path);\n } catch (error: any) {\n // Ignore \"File exists\" errors, re-throw others\n if (error.code !== 'EEXIST') {\n throw error;\n }\n }\n }\n\n async writeBlob(path: string, blob: Blob, managed = true): Promise<void> {\n try {\n const data = await BlobUtils.toUint8Array(blob);\n this.fs.writeFile(path, data);\n\n if (managed) {\n this.managedFiles.add(path);\n }\n\n this.logger.debug('File written', { path, size: data.length });\n } catch (error) {\n this.logger.error('Failed to write blob', { path, error });\n throw new Error(`Failed to write file ${path}: ${error}`);\n }\n }\n\n writeText(path: string, content: string, managed = true): void {\n try {\n this.fs.writeFile(path, content);\n\n if (managed) {\n this.managedFiles.add(path);\n }\n\n this.logger.debug('Text file written', { path, length: content.length });\n } catch (error) {\n this.logger.error('Failed to write text', { path, error });\n throw new Error(`Failed to write text file ${path}: ${error}`);\n }\n }\n\n readFile(path: string): Uint8Array {\n try {\n const data = this.fs.readFile(path) as Uint8Array;\n this.logger.debug('File read', { path, size: data.length });\n return data;\n } catch (error) {\n this.logger.error('Failed to read file', { path, error });\n throw new Error(`Failed to read file ${path}: ${error}`);\n }\n }\n\n exists(path: string): boolean {\n try {\n this.fs.stat(path);\n return true;\n } catch {\n return false;\n }\n }\n\n cleanup(): void {\n let cleanedCount = 0;\n\n for (const path of this.managedFiles) {\n try {\n this.fs.unlink(path);\n cleanedCount++;\n } catch (error) {\n this.logger.warn('Failed to cleanup file', { path, error });\n }\n }\n\n this.managedFiles.clear();\n this.logger.info('Filesystem cleanup completed', { cleanedCount });\n }\n}\n", "import type { PDFX3Options } from './types/pdfx';\nimport { GhostscriptLoader } from './core/ghostscript-loader';\nimport { VirtualFileSystem } from './core/virtual-filesystem';\nimport { BlobUtils } from './utils/blob-utils';\n\n/**\n * PDF/X-3 conversion function\n * Converts RGB PDF(s) to PDF/X-3 format using specified output profile\n *\n * @overload\n * @param inputPDF Single PDF blob to convert\n * @param options Conversion configuration\n * @returns Promise resolving to converted PDF blob\n *\n * @overload\n * @param inputPDFs Array of PDF blobs to convert\n * @param options Conversion configuration\n * @returns Promise resolving to array of converted PDF blobs\n */\nexport function convertToPDFX3(\n inputPDF: Blob,\n options: PDFX3Options\n): Promise<Blob>;\nexport function convertToPDFX3(\n inputPDFs: Blob[],\n options: PDFX3Options\n): Promise<Blob[]>;\nexport async function convertToPDFX3(\n input: Blob | Blob[],\n options: PDFX3Options\n): Promise<Blob | Blob[]> {\n // Handle array input (batch processing)\n if (Array.isArray(input)) {\n if (input.length === 0) {\n return [];\n }\n\n // Process each blob sequentially to avoid overwhelming the WASM module\n const results: Blob[] = [];\n for (let i = 0; i < input.length; i++) {\n try {\n // eslint-disable-next-line no-await-in-loop\n const converted = await convertToPDFX3Single(input[i], options);\n results.push(converted);\n } catch (error) {\n throw new Error(\n `Failed to convert PDF ${i + 1} of ${input.length}: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n }\n return results;\n }\n\n // Handle single blob input\n return convertToPDFX3Single(input, options);\n}\n\n/**\n * Internal function to convert a single PDF\n */\nasync function convertToPDFX3Single(\n inputPDF: Blob,\n options: PDFX3Options\n): Promise<Blob> {\n // Validate inputs\n if (!(inputPDF instanceof Blob)) {\n throw new Error('Input must be a Blob');\n }\n\n if (inputPDF.size === 0) {\n throw new Error('Input PDF is empty');\n }\n\n if (inputPDF.size > 100 * 1024 * 1024) {\n throw new Error(\n `Input PDF too large (${inputPDF.size} bytes). Maximum: 100MB`\n );\n }\n\n // Validate output profile is provided\n if (!options.outputProfile) {\n throw new Error(\n 'outputProfile is required. Must be one of: \"gracol\", \"fogra39\", \"srgb\", \"custom\"'\n );\n }\n\n // Validate output profile value\n const validProfiles = ['gracol', 'fogra39', 'srgb', 'custom'];\n if (!validProfiles.includes(options.outputProfile)) {\n throw new Error(\n `Invalid outputProfile \"${\n options.outputProfile\n }\". Must be one of: ${validProfiles.join(', ')}`\n );\n }\n\n // Validate custom profile requirement\n if (options.outputProfile === 'custom' && !options.customProfile) {\n throw new Error(\n 'customProfile Blob is required when outputProfile is \"custom\"'\n );\n }\n\n // Validate custom profile if provided\n if (options.customProfile && !(options.customProfile instanceof Blob)) {\n throw new Error('customProfile must be a Blob');\n }\n\n // Validate PDF format\n const isValidPDF = await BlobUtils.validatePDF(inputPDF);\n if (!isValidPDF) {\n throw new Error('Invalid PDF format');\n }\n\n // Load Ghostscript\n const module = await GhostscriptLoader.load();\n const vfs = new VirtualFileSystem(module);\n\n try {\n // Setup file paths\n const inputPath = '/tmp/input.pdf';\n const outputPath = '/tmp/output.pdf';\n const pdfxDefPath = '/tmp/pdfx_def.ps';\n const customProfilePath = '/tmp/custom.icc';\n\n // Write input PDF to virtual filesystem\n await vfs.writeBlob(inputPath, inputPDF);\n\n // Write ICC profiles to virtual filesystem\n if (options.outputProfile === 'custom' && options.customProfile) {\n await vfs.writeBlob(customProfilePath, options.customProfile);\n } else if (options.outputProfile !== 'custom') {\n // Load the bundled ICC profile\n const profileInfo =\n PROFILE_PRESETS[options.outputProfile as keyof typeof PROFILE_PRESETS];\n const profilePath = `/tmp/${profileInfo.file}`;\n\n // Load ICC profile - different approach for Node.js vs browser\n const isNode =\n typeof process !== 'undefined' && process.versions?.node != null;\n\n let profileBlob: Blob;\n\n if (isNode) {\n // Node.js: Load from filesystem using readFileSync\n // Use indirect dynamic import to prevent Webpack 5 from statically analyzing these imports\n // But use direct imports in test environments (vitest) where indirect imports bypass mocking\n // See: https://github.com/imgly/ubq/issues/11471\n const isTestEnv =\n process.env.VITEST === 'true' || process.env.NODE_ENV === 'test';\n\n // Note: new Function() could fail in CSP-restricted environments, but CSP is a browser\n // security mechanism and doesn't apply to Node.js. This code only runs in Node.js (isNode check above).\n // eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func\n const indirectImport = new Function('s', 'return import(s)') as (\n s: string\n ) => Promise<any>;\n const dynamicImport = isTestEnv\n ? (s: string) => import(s)\n : indirectImport;\n\n const { readFileSync } = await dynamicImport('fs');\n const { fileURLToPath } = await dynamicImport('url');\n const { dirname, join } = await dynamicImport('path');\n\n // Get the directory of the built module\n const moduleDir = dirname(fileURLToPath(import.meta.url));\n const profileFilePath = join(moduleDir, profileInfo.file);\n\n const profileData = readFileSync(profileFilePath);\n profileBlob = new Blob([profileData], {\n type: 'application/vnd.iccprofile',\n });\n } else {\n // Browser: Use fetch\n const profileUrl = new URL(profileInfo.file, import.meta.url).href;\n const profileResponse = await fetch(profileUrl);\n if (!profileResponse.ok) {\n throw new Error(\n `Failed to load ICC profile ${profileInfo.file}: ${profileResponse.statusText}`\n );\n }\n profileBlob = await profileResponse.blob();\n }\n\n await vfs.writeBlob(profilePath, profileBlob);\n }\n\n // Determine ICC profile path and metadata for Ghostscript\n let iccProfilePath: string;\n let outputConditionIdentifier: string;\n let outputCondition: string;\n\n if (options.outputProfile === 'custom') {\n iccProfilePath = customProfilePath;\n // Use custom values or defaults\n outputConditionIdentifier =\n options.outputConditionIdentifier || 'Custom Profile';\n outputCondition = options.outputCondition || 'Custom ICC Profile';\n } else {\n const preset =\n PROFILE_PRESETS[options.outputProfile as keyof typeof PROFILE_PRESETS];\n iccProfilePath = `/tmp/${preset.file}`;\n // Allow overriding preset values\n outputConditionIdentifier =\n options.outputConditionIdentifier || preset.identifier;\n outputCondition = options.outputCondition || preset.info;\n }\n\n // Read ICC profile data and convert to hex for embedding\n // WASM doesn't support (file) (r) file syntax, so we embed directly\n const iccData = vfs.readFile(iccProfilePath);\n const iccHex = Array.from(iccData)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n\n // Determine color conversion strategy based on profile type\n // ICC profile color space is at bytes 16-19\n // 'RGB ' = 0x52474220, 'CMYK' = 0x434D594B\n const colorSpaceBytes = iccData.slice(16, 20);\n const colorSpaceStr = String.fromCharCode(...colorSpaceBytes);\n const isCMYKProfile = colorSpaceStr.trim() === 'CMYK';\n\n // Generate PDF/X-3 definition with ICC profile hex data\n const pdfxDefinition = generatePDFXDef(\n options,\n iccHex,\n outputConditionIdentifier,\n outputCondition\n );\n vfs.writeText(pdfxDefPath, pdfxDefinition);\n\n // Execute Ghostscript conversion\n // For CMYK profiles, convert all colors to CMYK using the ICC profile\n // Note: Transparency flattening will rasterize transparent content\n const gsArgs = [\n '-dBATCH',\n '-dNOPAUSE',\n '-sDEVICE=pdfwrite',\n '-dCompatibilityLevel=1.4',\n // Disable PDF 1.5+ features to avoid warnings with PDF 1.4 compatibility\n '-dWriteObjStms=false',\n '-dWriteXRefStm=false',\n // PDF/X-3 settings\n '-dPDFSETTINGS=/prepress',\n '-dSetPageSize=false',\n '-dAutoRotatePages=/None',\n ];\n\n // Flatten transparency for PDF/X-3 compliance (default: true)\n // HaveTransparency=false tells Ghostscript the target viewer cannot handle\n // PDF 1.4 transparency, so pages with transparency are converted to bitmaps\n const shouldFlattenTransparency = options.flattenTransparency !== false;\n if (shouldFlattenTransparency) {\n gsArgs.push('-dHaveTransparency=false');\n }\n\n // Add color conversion for CMYK profiles\n if (isCMYKProfile) {\n gsArgs.push(\n '-sColorConversionStrategy=CMYK',\n '-dProcessColorModel=/DeviceCMYK',\n '-dConvertCMYKImagesToRGB=false'\n );\n } else {\n // For RGB profiles, we still need a color conversion strategy\n gsArgs.push('-sColorConversionStrategy=RGB');\n }\n\n // Add output file and input files\n gsArgs.push(`-sOutputFile=${outputPath}`, pdfxDefPath, inputPath);\n\n const exitCode = await module.callMain(gsArgs);\n if (exitCode !== 0) {\n throw new Error(\n `Ghostscript conversion failed with exit code ${exitCode}`\n );\n }\n\n // Read output\n const outputData = vfs.readFile(outputPath);\n // Create a copy of the data to ensure it's an ArrayBuffer, not SharedArrayBuffer\n const outputBuffer = new Uint8Array(outputData);\n const outputPDF = new Blob([outputBuffer], { type: 'application/pdf' });\n\n // Cleanup\n vfs.cleanup();\n\n return outputPDF;\n } catch (error) {\n vfs.cleanup();\n throw error;\n }\n}\n\n// Profile presets from the spec\nconst PROFILE_PRESETS = {\n gracol: {\n file: 'GRACoL2013_CRPC6.icc',\n identifier: 'CGATS 21.2',\n info: 'GRACoL 2013 CRPC6',\n },\n fogra39: {\n file: 'ISOcoated_v2_eci.icc',\n identifier: 'FOGRA39',\n info: 'ISO Coated v2 (ECI)',\n },\n srgb: {\n file: 'sRGB_IEC61966-2-1.icc',\n identifier: 'sRGB IEC61966-2.1',\n info: 'sRGB IEC61966-2.1',\n },\n};\n\nfunction generatePDFXDef(\n options: PDFX3Options,\n iccProfileHex: string,\n outputConditionIdentifier: string,\n outputCondition: string\n): string {\n return `%!\n% PDF/X-3 Definition File\n[ /Title (${options.title || 'Untitled'}) /DOCINFO pdfmark\n[ /Trapped /False /DOCINFO pdfmark\n\n% Set PDF/X-3 conformance\n[ /GTS_PDFXVersion (PDF/X-3:2003) /GTS_PDFXConformance (PDF/X-3:2003) /DOCINFO pdfmark\n\n% Set TrimBox to match MediaBox for all pages (required for PDF/X)\n[/TrimBox [0 0 0 0] /PAGE pdfmark\n\n% Embed ICC profile as hex stream\n[/_objdef {icc_PDFX} /type /stream /OBJ pdfmark\n[{icc_PDFX} <</N 4>> /PUT pdfmark\n[{icc_PDFX} <${iccProfileHex}> /PUT pdfmark\n\n% Define OutputIntent with embedded ICC profile\n[/_objdef {OutputIntent_PDFX} /type /dict /OBJ pdfmark\n[{OutputIntent_PDFX} <<\n /Type /OutputIntent\n /S /GTS_PDFX\n /OutputCondition (${outputCondition})\n /OutputConditionIdentifier (${outputConditionIdentifier})\n /RegistryName (http://www.color.org)\n /DestOutputProfile {icc_PDFX}\n>> /PUT pdfmark\n\n% Add OutputIntent to Catalog\n[{Catalog} <</OutputIntents [{OutputIntent_PDFX}]>> /PUT pdfmark`;\n}\n"],
5
+ "mappings": "AAWO,IAAMA,EAAN,MAAMC,CAAO,CAOlB,YAAoBC,EAAmB,CAAnB,eAAAA,CAAoB,CANxC,OAAe,eAA2B,OAE1C,OAAe,KAAmB,CAAC,EAEnC,OAAe,QAAU,IAIzB,OAAO,YAAYC,EAAuB,CACxCF,EAAO,eAAiBE,CAC1B,CAEA,OAAO,SAAsB,CAC3B,MAAO,CAAC,GAAGF,EAAO,IAAI,CACxB,CAEA,OAAO,WAAkB,CACvBA,EAAO,KAAO,CAAC,CACjB,CAEA,MAAMG,EAAiBC,EAAkB,CACvC,KAAK,IAAI,QAASD,EAASC,CAAI,CACjC,CAEA,KAAKD,EAAiBC,EAAkB,CACtC,KAAK,IAAI,OAAQD,EAASC,CAAI,CAChC,CAEA,KAAKD,EAAiBC,EAAkB,CACtC,KAAK,IAAI,OAAQD,EAASC,CAAI,CAChC,CAEA,MAAMD,EAAiBC,EAAkB,CACvC,KAAK,I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,EAEpCmC,EAAe,IAAI,WAAWD,CAAU,EACxCE,EAAY,IAAI,KAAK,CAACD,CAAY,EAAG,CAAE,KAAM,iBAAkB,CAAC,EAGtE,OAAAtC,EAAI,QAAQ,EAELuC,CACT,OAAS7C,EAAO,CACd,MAAAM,EAAI,QAAQ,EACNN,CACR,CACF,CAGA,IAAMa,EAAkB,CACtB,OAAQ,CACN,KAAM,uBACN,WAAY,aACZ,KAAM,mBACR,EACA,QAAS,CACP,KAAM,uBACN,WAAY,UACZ,KAAM,qBACR,EACA,KAAM,CACJ,KAAM,wBACN,WAAY,oBACZ,KAAM,mBACR,CACF,EAEA,SAAS2B,EACP5C,EACAkD,EACAf,EACAC,EACQ,CACR,MAAO;AAAA;AAAA,YAEGpC,EAAQ,OAAS,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAYxBkD,CAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAONd,CAAe;AAAA,gCACLD,CAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iEAOzD",
6
+ "names": ["Logger", "_Logger", "component", "level", "message", "data", "levelOrder", "entry", "prefix", "logMessage", "BrowserDetection", "createGhostscriptModule", "options", "silent", "isNode", "GhostscriptModule", "wasmPath", "isTestEnv", "indirectImport", "dynamicImport", "s", "moduleLib", "pathLib", "createRequire", "dirname", "join", "gsPath", "moduleDir", "factory", "moduleConfig", "filename", "GhostscriptLoader", "options", "logger", "Logger", "BrowserDetection", "timeout", "error", "module", "createGhostscriptModule", "operation", "timeoutMs", "_", "reject", "BlobUtils", "blob", "buffer", "resolve", "reject", "reader", "data", "pdfHeader", "i", "VirtualFileSystem", "module", "workingDir", "Logger", "error", "path", "blob", "managed", "data", "BlobUtils", "content", "cleanedCount", "convertToPDFX3", "input", "options", "results", "converted", "convertToPDFX3Single", "error", "inputPDF", "validProfiles", "BlobUtils", "module", "GhostscriptLoader", "vfs", "VirtualFileSystem", "inputPath", "outputPath", "pdfxDefPath", "customProfilePath", "profileInfo", "PROFILE_PRESETS", "profilePath", "isNode", "profileBlob", "isTestEnv", "indirectImport", "dynamicImport", "s", "readFileSync", "fileURLToPath", "dirname", "join", "moduleDir", "profileFilePath", "profileData", "profileUrl", "profileResponse", "iccProfilePath", "outputConditionIdentifier", "outputCondition", "preset", "iccData", "iccHex", "b", "colorSpaceBytes", "isCMYKProfile", "pdfxDefinition", "generatePDFXDef", "gsArgs", "exitCode", "outputData", "outputBuffer", "outputPDF", "iccProfileHex"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imgly/plugin-print-ready-pdfs-web",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Print-Ready PDFs plugin for CE.SDK editor - PDF/X conversion and export functionality. Contains AGPL-3.0 licensed Ghostscript WASM.",
5
5
  "keywords": [
6
6
  "CE.SDK",
@@ -42,6 +42,7 @@
42
42
  "devDependencies": {
43
43
  "@cesdk/cesdk-js": "~1.61.0",
44
44
  "@cesdk/engine": "~1.61.0",
45
+ "@cesdk/node": "~1.61.0",
45
46
  "@playwright/test": "^1.54.1",
46
47
  "@types/emscripten": "^1.40.1",
47
48
  "@types/node": "^20.11.0",
@@ -93,6 +94,7 @@
93
94
  "test:content": "pnpm run build && vitest run content-preservation",
94
95
  "test:silent": "pnpm run build && vitest run silent-conversion",
95
96
  "test:all": "pnpm run test:browser && pnpm run test:integration",
96
- "test:visual": "pnpm run build && node test/visual-test.mjs"
97
+ "test:visual": "pnpm run build && node test/visual-test.mjs",
98
+ "test:webpack5": "bash test/webpack5-compatibility-test.sh"
97
99
  }
98
100
  }
@@ -27,8 +27,27 @@ export default async function createGhostscriptModule(
27
27
 
28
28
  if (isNode) {
29
29
  // Node.js: Use require.resolve to find gs.js relative to this module
30
- const { createRequire } = await import('module');
31
- const { dirname, join } = await import('path');
30
+ // Use indirect dynamic import to prevent Webpack 5 from statically analyzing these imports
31
+ // But use direct imports in test environments (vitest) where indirect imports bypass mocking
32
+ // See: https://github.com/imgly/ubq/issues/11471
33
+ const isTestEnv =
34
+ typeof process !== 'undefined' &&
35
+ (process.env.VITEST === 'true' || process.env.NODE_ENV === 'test');
36
+
37
+ // Helper for dynamic imports - uses indirect import in production to avoid Webpack static analysis
38
+ // Note: new Function() could fail in CSP-restricted environments, but CSP is a browser
39
+ // security mechanism and doesn't apply to Node.js. This code only runs in Node.js (isNode check above).
40
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
41
+ const indirectImport = new Function('s', 'return import(s)') as (
42
+ s: string
43
+ ) => Promise<any>;
44
+ const dynamicImport = isTestEnv ? (s: string) => import(s) : indirectImport;
45
+
46
+ const moduleLib = await dynamicImport('module');
47
+ const pathLib = await dynamicImport('path');
48
+ const createRequire = moduleLib.createRequire;
49
+ const dirname = pathLib.dirname;
50
+ const join = pathLib.join;
32
51
 
33
52
  const requireForESM = createRequire(import.meta.url);
34
53
 
@@ -37,7 +56,7 @@ export default async function createGhostscriptModule(
37
56
  const moduleDir = dirname(gsPath);
38
57
  wasmPath = join(moduleDir, 'gs.wasm');
39
58
 
40
- GhostscriptModule = await import(gsPath);
59
+ GhostscriptModule = await dynamicImport(gsPath);
41
60
  } else {
42
61
  // Browser: Use URL-based imports
43
62
  const moduleUrl = new URL('./gs.js', import.meta.url).href;