@inditextech/weave-sdk 5.7.0-SNAPSHOT.596.1 → 5.7.0-SNAPSHOT.597.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/dist/sdk.js CHANGED
@@ -9502,7 +9502,7 @@ var WeaveRegisterManager = class {
9502
9502
  };
9503
9503
  //#endregion
9504
9504
  //#region package.json
9505
- var version = "5.7.0-SNAPSHOT.596.1";
9505
+ var version = "5.7.0-SNAPSHOT.597.1";
9506
9506
  //#endregion
9507
9507
  //#region src/managers/setup.ts
9508
9508
  var WeaveSetupManager = class {
@@ -15040,34 +15040,39 @@ var WeaveTextV2Shape = class extends Konva.Shape {
15040
15040
  setViewport(range) {
15041
15041
  this.viewport = range;
15042
15042
  }
15043
- visibleRange() {
15043
+ /**
15044
+ * Visible y-range in local coordinates, derived from the context being
15045
+ * painted (current transform + backing canvas size) instead of the stage.
15046
+ * The stage is not the paint target during export (off-screen canvases,
15047
+ * tiles, server-side), so using it culled visible lines. Returns null (paint
15048
+ * everything) when the transform cannot be read.
15049
+ */
15050
+ visibleRange(ctx) {
15044
15051
  if (this.viewport) return this.viewport;
15045
- const stage = this.getStage();
15046
- if (!stage) return null;
15047
- const inv = this.getAbsoluteTransform().copy().invert();
15048
- const w = stage.width();
15049
- const h = stage.height();
15050
- const pts = [
15051
- inv.point({
15052
- x: 0,
15053
- y: 0
15054
- }),
15055
- inv.point({
15056
- x: w,
15057
- y: 0
15058
- }),
15059
- inv.point({
15060
- x: 0,
15061
- y: h
15062
- }),
15063
- inv.point({
15064
- x: w,
15065
- y: h
15066
- })
15067
- ];
15052
+ const native = ctx._context;
15053
+ const m = native.getTransform?.() ?? native.currentTransform;
15054
+ if (!m) return null;
15055
+ const det = m.a * m.d - m.b * m.c;
15056
+ if (!det || !Number.isFinite(det)) return null;
15057
+ const canvas = ctx.getCanvas();
15058
+ const w = canvas.getWidth();
15059
+ const h = canvas.getHeight();
15060
+ if (!(w > 0) || !(h > 0)) return null;
15061
+ let y1 = Infinity;
15062
+ let y2 = -Infinity;
15063
+ for (const [px, py] of [
15064
+ [0, 0],
15065
+ [w, 0],
15066
+ [0, h],
15067
+ [w, h]
15068
+ ]) {
15069
+ const y = (m.a * (py - m.f) - m.b * (px - m.e)) / det;
15070
+ if (y < y1) y1 = y;
15071
+ if (y > y2) y2 = y;
15072
+ }
15068
15073
  return {
15069
- y1: Math.min(...pts.map((p) => p.y)),
15070
- y2: Math.max(...pts.map((p) => p.y))
15074
+ y1,
15075
+ y2
15071
15076
  };
15072
15077
  }
15073
15078
  _sceneFunc = (ctx, shape) => {
@@ -15087,8 +15092,8 @@ var WeaveTextV2Shape = class extends Konva.Shape {
15087
15092
  ctx.setAttr("textBaseline", baseline);
15088
15093
  ctx.setAttr("textAlign", "left");
15089
15094
  const alignY = self.verticalOffset(layout);
15095
+ const range = self.visibleRange(ctx);
15090
15096
  ctx.translate(padding, alignY + padding);
15091
- const range = self.visibleRange();
15092
15097
  const top = alignY + padding;
15093
15098
  for (let n = 0; n < layout.lines.length; n++) {
15094
15099
  const lineTop = top + n * lineHeightPx;
package/dist/sdk.node.js CHANGED
@@ -9505,7 +9505,7 @@ var WeaveRegisterManager = class {
9505
9505
  };
9506
9506
  //#endregion
9507
9507
  //#region package.json
9508
- var version = "5.7.0-SNAPSHOT.596.1";
9508
+ var version = "5.7.0-SNAPSHOT.597.1";
9509
9509
  //#endregion
9510
9510
  //#region src/managers/setup.ts
9511
9511
  var WeaveSetupManager = class {
@@ -15043,34 +15043,39 @@ var WeaveTextV2Shape = class extends Konva.Shape {
15043
15043
  setViewport(range) {
15044
15044
  this.viewport = range;
15045
15045
  }
15046
- visibleRange() {
15046
+ /**
15047
+ * Visible y-range in local coordinates, derived from the context being
15048
+ * painted (current transform + backing canvas size) instead of the stage.
15049
+ * The stage is not the paint target during export (off-screen canvases,
15050
+ * tiles, server-side), so using it culled visible lines. Returns null (paint
15051
+ * everything) when the transform cannot be read.
15052
+ */
15053
+ visibleRange(ctx) {
15047
15054
  if (this.viewport) return this.viewport;
15048
- const stage = this.getStage();
15049
- if (!stage) return null;
15050
- const inv = this.getAbsoluteTransform().copy().invert();
15051
- const w = stage.width();
15052
- const h = stage.height();
15053
- const pts = [
15054
- inv.point({
15055
- x: 0,
15056
- y: 0
15057
- }),
15058
- inv.point({
15059
- x: w,
15060
- y: 0
15061
- }),
15062
- inv.point({
15063
- x: 0,
15064
- y: h
15065
- }),
15066
- inv.point({
15067
- x: w,
15068
- y: h
15069
- })
15070
- ];
15055
+ const native = ctx._context;
15056
+ const m = native.getTransform?.() ?? native.currentTransform;
15057
+ if (!m) return null;
15058
+ const det = m.a * m.d - m.b * m.c;
15059
+ if (!det || !Number.isFinite(det)) return null;
15060
+ const canvas = ctx.getCanvas();
15061
+ const w = canvas.getWidth();
15062
+ const h = canvas.getHeight();
15063
+ if (!(w > 0) || !(h > 0)) return null;
15064
+ let y1 = Infinity;
15065
+ let y2 = -Infinity;
15066
+ for (const [px, py] of [
15067
+ [0, 0],
15068
+ [w, 0],
15069
+ [0, h],
15070
+ [w, h]
15071
+ ]) {
15072
+ const y = (m.a * (py - m.f) - m.b * (px - m.e)) / det;
15073
+ if (y < y1) y1 = y;
15074
+ if (y > y2) y2 = y;
15075
+ }
15071
15076
  return {
15072
- y1: Math.min(...pts.map((p) => p.y)),
15073
- y2: Math.max(...pts.map((p) => p.y))
15077
+ y1,
15078
+ y2
15074
15079
  };
15075
15080
  }
15076
15081
  _sceneFunc = (ctx, shape) => {
@@ -15090,8 +15095,8 @@ var WeaveTextV2Shape = class extends Konva.Shape {
15090
15095
  ctx.setAttr("textBaseline", baseline);
15091
15096
  ctx.setAttr("textAlign", "left");
15092
15097
  const alignY = self.verticalOffset(layout);
15098
+ const range = self.visibleRange(ctx);
15093
15099
  ctx.translate(padding, alignY + padding);
15094
- const range = self.visibleRange();
15095
15100
  const top = alignY + padding;
15096
15101
  for (let n = 0; n < layout.lines.length; n++) {
15097
15102
  const lineTop = top + n * lineHeightPx;