fluxflow-cli 1.12.0 → 1.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/fluxflow.js +54 -9
  2. package/package.json +1 -1
package/dist/fluxflow.js CHANGED
@@ -961,7 +961,7 @@ ${mode === "Flux" ? `- FILE TOOLS (path = relative to CWD) -
961
961
  2. [tool:functions.ReadFolder(path="...")]. Detailed DIR stats
962
962
  3. [tool:functions.WriteFile(path="...", content="...")]. Creates/Overwrites. File Exist? -> update_file > write_file
963
963
  4. [tool:functions.PatchFile(path="...", content_to_replace="exact old content", content_to_add="new content")]. Surgical patching. Unsure content_to_replace? -> view_file >> guessing.
964
- 5. [tool:functions.WritePDF(path="...", content="...", orientation="...")]. A4 PDF. HTML/CSS for premium layout (100vh/vw). Handle page breaks; no manual footers
964
+ 5. [tool:functions.WritePDF(path="...", content="...", orientation="...")]. MUST HAVE PROPER A4 PAGE BREAKS. HTML/CSS for premium layout (100vh/vw). No manual footers
965
965
  6. [tool:functions.WriteDoc(path="...", content="...")]. A4 Word doc. Proper margins and page breaks
966
966
  7. [tool:functions.Run(command="...")]. Runs a shell command. Destructive/Irreversible ops -> ask user
967
967
  8. [tool:functions.SearchKeyword(keyword="...")]. Global search. Finds definitions/logic without reading every file
@@ -2834,12 +2834,10 @@ var init_write_pdf = __esm({
2834
2834
  });
2835
2835
  const page = await browser.newPage();
2836
2836
  let resolvedContent = content;
2837
- const imgRegex = /<img[^>]+src=["']([^"']+)["']/gi;
2838
- let match;
2839
- while ((match = imgRegex.exec(content)) !== null) {
2840
- const originalSrc = match[1];
2837
+ const resolvedCache = {};
2838
+ const resolveToBase64 = async (originalSrc) => {
2841
2839
  if (!originalSrc || originalSrc.startsWith("http://") || originalSrc.startsWith("https://") || originalSrc.startsWith("data:")) {
2842
- continue;
2840
+ return null;
2843
2841
  }
2844
2842
  try {
2845
2843
  const imgPath = path10.resolve(process.cwd(), originalSrc);
@@ -2847,11 +2845,58 @@ var init_write_pdf = __esm({
2847
2845
  const ext = path10.extname(imgPath).toLowerCase().replace(".", "") || "png";
2848
2846
  const mime = ext === "jpg" ? "jpeg" : ext === "svg" ? "svg+xml" : ext;
2849
2847
  const base64 = await fs11.readFile(imgPath, "base64");
2850
- const dataUri = `data:image/${mime};base64,${base64}`;
2851
- resolvedContent = resolvedContent.split(originalSrc).join(dataUri);
2848
+ return `data:image/${mime};base64,${base64}`;
2852
2849
  }
2853
2850
  } catch (e) {
2854
2851
  }
2852
+ return null;
2853
+ };
2854
+ const linkRegex = /<link[^>]+href=["']([^"']+)["']/gi;
2855
+ const cssCache = {};
2856
+ let match;
2857
+ while ((match = linkRegex.exec(content)) !== null) {
2858
+ const originalHref = match[1];
2859
+ const fullTag = match[0];
2860
+ if (originalHref && fullTag.toLowerCase().includes("stylesheet") && !originalHref.startsWith("http://") && !originalHref.startsWith("https://") && !originalHref.startsWith("data:")) {
2861
+ try {
2862
+ const cssPath = path10.resolve(process.cwd(), originalHref);
2863
+ if (await fs11.pathExists(cssPath)) {
2864
+ const cssContent = await fs11.readFile(cssPath, "utf-8");
2865
+ cssCache[fullTag] = `<style>${cssContent}</style>`;
2866
+ }
2867
+ } catch (e) {
2868
+ }
2869
+ }
2870
+ }
2871
+ for (const [tag, styleTag] of Object.entries(cssCache)) {
2872
+ resolvedContent = resolvedContent.split(tag).join(styleTag);
2873
+ }
2874
+ const imgRegex = /<img[^>]+src=["']([^"']+)["']/gi;
2875
+ while ((match = imgRegex.exec(resolvedContent)) !== null) {
2876
+ const originalSrc = match[1];
2877
+ if (originalSrc && !resolvedCache[originalSrc]) {
2878
+ const dataUri = await resolveToBase64(originalSrc);
2879
+ if (dataUri) {
2880
+ resolvedCache[originalSrc] = dataUri;
2881
+ }
2882
+ }
2883
+ }
2884
+ const urlRegex = /url\(\s*['"]?([^'")]+?)['"]?\s*\)/gi;
2885
+ while ((match = urlRegex.exec(resolvedContent)) !== null) {
2886
+ const originalSrc = match[1].trim();
2887
+ if (originalSrc && !resolvedCache[originalSrc]) {
2888
+ const dataUri = await resolveToBase64(originalSrc);
2889
+ if (dataUri) {
2890
+ resolvedCache[originalSrc] = dataUri;
2891
+ }
2892
+ }
2893
+ }
2894
+ for (const [originalSrc, dataUri] of Object.entries(resolvedCache)) {
2895
+ const escapedSrc = originalSrc.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
2896
+ const srcRegex = new RegExp(`(src=["'])(${escapedSrc})(["'])`, "gi");
2897
+ resolvedContent = resolvedContent.replace(srcRegex, `$1${dataUri}$3`);
2898
+ const urlReplaceRegex = new RegExp(`url\\(\\s*(['"]?)(${escapedSrc})\\1\\s*\\)`, "gi");
2899
+ resolvedContent = resolvedContent.replace(urlReplaceRegex, `url($1${dataUri}$1)`);
2855
2900
  }
2856
2901
  const styledContent = `
2857
2902
  <style>
@@ -2887,7 +2932,7 @@ var init_write_pdf = __esm({
2887
2932
  await page.setContent(styledContent, { waitUntil: "networkidle0", timeout: 18e4 });
2888
2933
  const pdfBytes = await page.pdf({
2889
2934
  format: "A4",
2890
- landscape: orientation.toLowerCase() === "landscape",
2935
+ landscape: String(orientation).toLowerCase() === "landscape",
2891
2936
  margin: {
2892
2937
  top: margin,
2893
2938
  right: margin,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluxflow-cli",
3
- "version": "1.12.0",
3
+ "version": "1.12.2",
4
4
  "date": "2026-05-21",
5
5
  "description": "A high-fidelity agentic terminal assistant for the Flux Era.",
6
6
  "keywords": [