@pixldocs/canvas-renderer 0.5.37 → 0.5.39

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.d.ts CHANGED
@@ -221,7 +221,7 @@ export declare function normalizeFontFamily(fontStack: string): string;
221
221
  * Package version banner. Bump alongside package.json so we can confirm
222
222
  * (via browser:log) that the deployed bundle matches the expected build.
223
223
  */
224
- export declare const PACKAGE_VERSION = "0.5.37";
224
+ export declare const PACKAGE_VERSION = "0.5.39";
225
225
 
226
226
  export declare interface PageSettings {
227
227
  backgroundColor?: string;
package/dist/index.js CHANGED
@@ -12053,11 +12053,94 @@ function PixldocsPreview(props) {
12053
12053
  !canvasSettled && /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) })
12054
12054
  ] });
12055
12055
  }
12056
- const PACKAGE_VERSION = "0.5.37";
12056
+ const PACKAGE_VERSION = "0.5.39";
12057
+ let __underlineFixInstalled = false;
12058
+ function installUnderlineFix(fab) {
12059
+ var _a;
12060
+ if (__underlineFixInstalled) return;
12061
+ const TextProto = (_a = fab.Text) == null ? void 0 : _a.prototype;
12062
+ if (!TextProto || typeof TextProto._renderTextDecoration !== "function") return;
12063
+ const original = TextProto._renderTextDecoration;
12064
+ TextProto._renderTextDecoration = function patchedRenderTextDecoration(ctx, type) {
12065
+ try {
12066
+ const hasOwn = !!this[type];
12067
+ const hasStyled = typeof this.styleHas === "function" && this.styleHas(type);
12068
+ if (!hasOwn && !hasStyled) return;
12069
+ const lines = this._textLines;
12070
+ const offsets = this.offsets;
12071
+ if (!Array.isArray(lines) || !offsets) {
12072
+ return original.call(this, ctx, type);
12073
+ }
12074
+ const offsetY = offsets[type];
12075
+ const offsetAligner = type === "linethrough" ? 0.5 : type === "overline" ? 1 : 0;
12076
+ const leftOffset = this._getLeftOffset();
12077
+ let topOffset = this._getTopOffset();
12078
+ for (let i = 0, len = lines.length; i < len; i++) {
12079
+ const heightOfLine = this.getHeightOfLine(i);
12080
+ const lineHas = !!this[type] || typeof this.styleHas === "function" && this.styleHas(type, i);
12081
+ if (!lineHas) {
12082
+ topOffset += heightOfLine;
12083
+ continue;
12084
+ }
12085
+ const fillStyle = this.getValueOfPropertyAt(i, 0, "fill");
12086
+ const thickness = this.getValueOfPropertyAt(i, 0, "textDecorationThickness");
12087
+ const charSize = this.getHeightOfChar(i, 0);
12088
+ const dy = this.getValueOfPropertyAt(i, 0, "deltaY") || 0;
12089
+ const finalThickness = this.fontSize * (thickness || 0) / 1e3;
12090
+ if (!fillStyle || !finalThickness) {
12091
+ topOffset += heightOfLine;
12092
+ continue;
12093
+ }
12094
+ if (Array.isArray(this.__lineWidths)) {
12095
+ this.__lineWidths[i] = void 0;
12096
+ }
12097
+ let lineWidth = 0;
12098
+ try {
12099
+ lineWidth = this.getLineWidth(i);
12100
+ } catch {
12101
+ lineWidth = 0;
12102
+ }
12103
+ if (!lineWidth) {
12104
+ topOffset += heightOfLine;
12105
+ continue;
12106
+ }
12107
+ const lineLeftOffset = this._getLineLeftOffset(i);
12108
+ let drawStart = leftOffset + lineLeftOffset;
12109
+ if (this.direction === "rtl") {
12110
+ drawStart = this.width - drawStart - lineWidth;
12111
+ }
12112
+ const maxHeight = heightOfLine / this.lineHeight;
12113
+ const top = topOffset + maxHeight * (1 - this._fontSizeFraction);
12114
+ ctx.fillStyle = fillStyle;
12115
+ ctx.fillRect(
12116
+ drawStart,
12117
+ top + offsetY * charSize + dy - offsetAligner * finalThickness,
12118
+ lineWidth,
12119
+ finalThickness
12120
+ );
12121
+ topOffset += heightOfLine;
12122
+ }
12123
+ if (typeof this._removeShadow === "function") {
12124
+ try {
12125
+ this._removeShadow(ctx);
12126
+ } catch {
12127
+ }
12128
+ }
12129
+ } catch {
12130
+ try {
12131
+ return original.call(this, ctx, type);
12132
+ } catch {
12133
+ }
12134
+ }
12135
+ };
12136
+ __underlineFixInstalled = true;
12137
+ console.log(`[canvas-renderer] underline-fix monkey patch installed (v${PACKAGE_VERSION})`);
12138
+ }
12057
12139
  class PixldocsRenderer {
12058
12140
  constructor(config) {
12059
12141
  __publicField(this, "config");
12060
12142
  this.config = config;
12143
+ installUnderlineFix(fabric);
12061
12144
  try {
12062
12145
  console.log(`[canvas-renderer] PixldocsRenderer v${PACKAGE_VERSION} initialized`);
12063
12146
  } catch {