@pixldocs/canvas-renderer 0.5.35 → 0.5.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -12072,10 +12072,15 @@ function PixldocsPreview(props) {
12072
12072
  !canvasSettled && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) })
12073
12073
  ] });
12074
12074
  }
12075
+ const PACKAGE_VERSION = "0.5.37";
12075
12076
  class PixldocsRenderer {
12076
12077
  constructor(config) {
12077
12078
  __publicField(this, "config");
12078
12079
  this.config = config;
12080
+ try {
12081
+ console.log(`[canvas-renderer] PixldocsRenderer v${PACKAGE_VERSION} initialized`);
12082
+ } catch {
12083
+ }
12079
12084
  }
12080
12085
  /**
12081
12086
  * Render a pre-resolved template config to an image using the full PageCanvas engine.
@@ -12741,40 +12746,30 @@ class PixldocsRenderer {
12741
12746
  const fabricInstance = this.getFabricCanvasFromContainer(container);
12742
12747
  if (!(fabricInstance == null ? void 0 : fabricInstance.getObjects)) return;
12743
12748
  const waitForPaint = () => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => r())));
12744
- const clearTextMetricCaches = () => {
12745
- clearFabricCharCache();
12746
- clearMeasurementCache();
12747
- };
12748
- const resyncTextboxWidths = (obj) => {
12749
+ const primeCharBounds = (obj) => {
12749
12750
  if (obj instanceof fabric__namespace.Textbox) {
12750
- const savedWidth = Math.max(1, obj.width ?? 0);
12751
- const savedScaleX = obj.scaleX ?? 1;
12752
- const savedScaleY = obj.scaleY ?? 1;
12753
- obj.initDimensions();
12754
- if (Math.abs((obj.width ?? 0) - savedWidth) > 0.01) {
12755
- obj.width = savedWidth;
12756
- }
12757
- if (Math.abs((obj.scaleX ?? 1) - savedScaleX) > 0.01) {
12758
- obj.scaleX = savedScaleX;
12759
- }
12760
- if (Math.abs((obj.scaleY ?? 1) - savedScaleY) > 0.01) {
12761
- obj.scaleY = savedScaleY;
12751
+ const lines = obj._textLines;
12752
+ if (Array.isArray(lines)) {
12753
+ for (let i = 0; i < lines.length; i++) {
12754
+ try {
12755
+ obj.getLineWidth(i);
12756
+ } catch {
12757
+ }
12758
+ }
12762
12759
  }
12763
- obj.setCoords();
12764
12760
  obj.dirty = true;
12765
12761
  return;
12766
12762
  }
12767
12763
  if (obj instanceof fabric__namespace.Group) {
12768
- obj.getObjects().forEach(resyncTextboxWidths);
12764
+ obj.getObjects().forEach(primeCharBounds);
12769
12765
  obj.dirty = true;
12770
12766
  }
12771
12767
  };
12772
- clearTextMetricCaches();
12773
- await waitForPaint();
12774
- fabricInstance.getObjects().forEach(resyncTextboxWidths);
12768
+ fabricInstance.getObjects().forEach(primeCharBounds);
12775
12769
  (_a = fabricInstance.calcOffset) == null ? void 0 : _a.call(fabricInstance);
12776
12770
  (_b = fabricInstance.renderAll) == null ? void 0 : _b.call(fabricInstance);
12777
- (_c = fabricInstance.requestRenderAll) == null ? void 0 : _c.call(fabricInstance);
12771
+ await waitForPaint();
12772
+ (_c = fabricInstance.renderAll) == null ? void 0 : _c.call(fabricInstance);
12778
12773
  await waitForPaint();
12779
12774
  }
12780
12775
  }
@@ -14891,6 +14886,7 @@ async function warmTemplateFromForm(options) {
14891
14886
  exports.FONT_FALLBACK_DEVANAGARI = FONT_FALLBACK_DEVANAGARI;
14892
14887
  exports.FONT_FALLBACK_SYMBOLS = FONT_FALLBACK_SYMBOLS;
14893
14888
  exports.FONT_FILES = FONT_FILES;
14889
+ exports.PACKAGE_VERSION = PACKAGE_VERSION;
14894
14890
  exports.PixldocsPreview = PixldocsPreview;
14895
14891
  exports.PixldocsRenderer = PixldocsRenderer;
14896
14892
  exports.applyThemeToConfig = applyThemeToConfig;