@inditextech/weave-sdk 0.64.0 → 0.66.0

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
@@ -21482,164 +21482,6 @@ var WeaveCloningManager = class {
21482
21482
  }
21483
21483
  };
21484
21484
 
21485
- //#endregion
21486
- //#region ../../node_modules/fontfaceobserver/fontfaceobserver.standalone.js
21487
- var require_fontfaceobserver_standalone = __commonJS({ "../../node_modules/fontfaceobserver/fontfaceobserver.standalone.js"(exports, module) {
21488
- (function() {
21489
- function p(a, c) {
21490
- document.addEventListener ? a.addEventListener("scroll", c, !1) : a.attachEvent("scroll", c);
21491
- }
21492
- function u(a) {
21493
- document.body ? a() : document.addEventListener ? document.addEventListener("DOMContentLoaded", function b() {
21494
- document.removeEventListener("DOMContentLoaded", b);
21495
- a();
21496
- }) : document.attachEvent("onreadystatechange", function g() {
21497
- if ("interactive" == document.readyState || "complete" == document.readyState) document.detachEvent("onreadystatechange", g), a();
21498
- });
21499
- }
21500
- function w(a) {
21501
- this.g = document.createElement("div");
21502
- this.g.setAttribute("aria-hidden", "true");
21503
- this.g.appendChild(document.createTextNode(a));
21504
- this.h = document.createElement("span");
21505
- this.i = document.createElement("span");
21506
- this.m = document.createElement("span");
21507
- this.j = document.createElement("span");
21508
- this.l = -1;
21509
- this.h.style.cssText = "max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;";
21510
- this.i.style.cssText = "max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;";
21511
- this.j.style.cssText = "max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;";
21512
- this.m.style.cssText = "display:inline-block;width:200%;height:200%;font-size:16px;max-width:none;";
21513
- this.h.appendChild(this.m);
21514
- this.i.appendChild(this.j);
21515
- this.g.appendChild(this.h);
21516
- this.g.appendChild(this.i);
21517
- }
21518
- function x(a, c) {
21519
- a.g.style.cssText = "max-width:none;min-width:20px;min-height:20px;display:inline-block;overflow:hidden;position:absolute;width:auto;margin:0;padding:0;top:-999px;white-space:nowrap;font-synthesis:none;font:" + c + ";";
21520
- }
21521
- function B(a) {
21522
- var c = a.g.offsetWidth, b = c + 100;
21523
- a.j.style.width = b + "px";
21524
- a.i.scrollLeft = b;
21525
- a.h.scrollLeft = a.h.scrollWidth + 100;
21526
- return a.l !== c ? (a.l = c, !0) : !1;
21527
- }
21528
- function C(a, c) {
21529
- function b() {
21530
- var e = g;
21531
- B(e) && null !== e.g.parentNode && c(e.l);
21532
- }
21533
- var g = a;
21534
- p(a.h, b);
21535
- p(a.i, b);
21536
- B(a);
21537
- }
21538
- function D(a, c, b) {
21539
- c = c || {};
21540
- b = b || window;
21541
- this.family = a;
21542
- this.style = c.style || "normal";
21543
- this.weight = c.weight || "normal";
21544
- this.stretch = c.stretch || "normal";
21545
- this.context = b;
21546
- }
21547
- var E = null, F = null, G = null, H = null;
21548
- function I(a) {
21549
- null === F && (M(a) && /Apple/.test(window.navigator.vendor) ? (a = /AppleWebKit\/([0-9]+)(?:\.([0-9]+))(?:\.([0-9]+))/.exec(window.navigator.userAgent), F = !!a && 603 > parseInt(a[1], 10)) : F = !1);
21550
- return F;
21551
- }
21552
- function M(a) {
21553
- null === H && (H = !!a.document.fonts);
21554
- return H;
21555
- }
21556
- function N(a, c) {
21557
- var b = a.style, g = a.weight;
21558
- if (null === G) {
21559
- var e = document.createElement("div");
21560
- try {
21561
- e.style.font = "condensed 100px sans-serif";
21562
- } catch (q) {}
21563
- G = "" !== e.style.font;
21564
- }
21565
- return [
21566
- b,
21567
- g,
21568
- G ? a.stretch : "",
21569
- "100px",
21570
- c
21571
- ].join(" ");
21572
- }
21573
- D.prototype.load = function(a, c) {
21574
- var b = this, g = a || "BESbswy", e = 0, q = c || 3e3, J = new Date().getTime();
21575
- return new Promise(function(K, L) {
21576
- if (M(b.context) && !I(b.context)) {
21577
- var O = new Promise(function(r, t) {
21578
- function h() {
21579
- new Date().getTime() - J >= q ? t(Error("" + q + "ms timeout exceeded")) : b.context.document.fonts.load(N(b, "\"" + b.family + "\""), g).then(function(n) {
21580
- 1 <= n.length ? r() : setTimeout(h, 25);
21581
- }, t);
21582
- }
21583
- h();
21584
- }), P = new Promise(function(r, t) {
21585
- e = setTimeout(function() {
21586
- t(Error("" + q + "ms timeout exceeded"));
21587
- }, q);
21588
- });
21589
- Promise.race([P, O]).then(function() {
21590
- clearTimeout(e);
21591
- K(b);
21592
- }, L);
21593
- } else u(function() {
21594
- function r() {
21595
- var d;
21596
- if (d = -1 != k && -1 != l || -1 != k && -1 != m || -1 != l && -1 != m) (d = k != l && k != m && l != m) || (null === E && (d = /AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent), E = !!d && (536 > parseInt(d[1], 10) || 536 === parseInt(d[1], 10) && 11 >= parseInt(d[2], 10))), d = E && (k == y && l == y && m == y || k == z && l == z && m == z || k == A && l == A && m == A)), d = !d;
21597
- d && (null !== f.parentNode && f.parentNode.removeChild(f), clearTimeout(e), K(b));
21598
- }
21599
- function t() {
21600
- if (new Date().getTime() - J >= q) null !== f.parentNode && f.parentNode.removeChild(f), L(Error("" + q + "ms timeout exceeded"));
21601
- else {
21602
- var d = b.context.document.hidden;
21603
- if (!0 === d || void 0 === d) k = h.g.offsetWidth, l = n.g.offsetWidth, m = v.g.offsetWidth, r();
21604
- e = setTimeout(t, 50);
21605
- }
21606
- }
21607
- var h = new w(g), n = new w(g), v = new w(g), k = -1, l = -1, m = -1, y = -1, z = -1, A = -1, f = document.createElement("div");
21608
- f.dir = "ltr";
21609
- x(h, N(b, "sans-serif"));
21610
- x(n, N(b, "serif"));
21611
- x(v, N(b, "monospace"));
21612
- f.appendChild(h.g);
21613
- f.appendChild(n.g);
21614
- f.appendChild(v.g);
21615
- b.context.document.body.appendChild(f);
21616
- y = h.g.offsetWidth;
21617
- z = n.g.offsetWidth;
21618
- A = v.g.offsetWidth;
21619
- t();
21620
- C(h, function(d) {
21621
- k = d;
21622
- r();
21623
- });
21624
- x(h, N(b, "\"" + b.family + "\",sans-serif"));
21625
- C(n, function(d) {
21626
- l = d;
21627
- r();
21628
- });
21629
- x(n, N(b, "\"" + b.family + "\",serif"));
21630
- C(v, function(d) {
21631
- m = d;
21632
- r();
21633
- });
21634
- x(v, N(b, "\"" + b.family + "\",monospace"));
21635
- });
21636
- });
21637
- };
21638
- "object" === typeof module ? module.exports = D : (window.FontFaceObserver = D, window.FontFaceObserver.prototype.load = D.prototype.load);
21639
- })();
21640
- } });
21641
- var import_fontfaceobserver_standalone = __toESM(require_fontfaceobserver_standalone(), 1);
21642
-
21643
21485
  //#endregion
21644
21486
  //#region src/managers/fonts.ts
21645
21487
  var WeaveFontsManager = class {
@@ -21649,31 +21491,19 @@ var WeaveFontsManager = class {
21649
21491
  this.logger = this.instance.getChildLogger("fonts-manager");
21650
21492
  this.logger.debug("Fonts manager created");
21651
21493
  }
21652
- async loadFont(font, fontFamily) {
21653
- return new Promise((resolve) => {
21654
- this.logger.debug(`Loading font with id [${font.id}]`);
21655
- fontFamily.load().then(() => {
21656
- this.logger.debug(`Font with id [${font.id}] loaded`);
21657
- this.loadedFonts.push(font);
21658
- resolve();
21659
- }).catch(() => {
21660
- this.logger.debug(`Font with id [${font.id}] failed to load`);
21661
- resolve();
21662
- });
21663
- });
21664
- }
21665
21494
  async loadFonts() {
21666
21495
  this.logger.info("Loading fonts");
21667
- if (this.instance.getConfiguration().fonts) {
21668
- const fontPromises = [];
21669
- for (const font of this.instance.getConfiguration()?.fonts ?? []) {
21670
- const fontFamily = new import_fontfaceobserver_standalone.default(font.id);
21671
- fontPromises.push(this.loadFont(font, fontFamily));
21672
- }
21673
- await Promise.allSettled(fontPromises);
21496
+ const fontsConfig = this.instance.getConfiguration().fonts;
21497
+ if (!fontsConfig) {
21498
+ this.logger.warn("No fonts defined");
21499
+ return;
21674
21500
  }
21501
+ let fontsToLoad = [];
21502
+ if (fontsConfig && fontsConfig instanceof Function) fontsToLoad = await fontsConfig();
21503
+ if (fontsConfig && fontsConfig instanceof Array) fontsToLoad = fontsConfig;
21504
+ for (const font of fontsToLoad) this.loadedFonts.push(font);
21675
21505
  this.logger.info("Fonts loaded");
21676
- this.instance.emitEvent("weaveFontsLoaded", {});
21506
+ this.instance.emitEvent("onFontsLoaded", this.loadedFonts);
21677
21507
  }
21678
21508
  getFonts() {
21679
21509
  return this.loadedFonts;
@@ -22053,7 +21883,7 @@ var WeaveRegisterManager = class {
22053
21883
 
22054
21884
  //#endregion
22055
21885
  //#region package.json
22056
- var version = "0.64.0";
21886
+ var version = "0.66.0";
22057
21887
 
22058
21888
  //#endregion
22059
21889
  //#region src/managers/setup.ts
@@ -22448,35 +22278,31 @@ var WeaveExportManager = class {
22448
22278
  const backgroundRect = background.getClientRect();
22449
22279
  stage.batchDraw();
22450
22280
  const composites = [];
22451
- const maxRenderSize = 1920;
22452
- const tileSize = Math.floor(maxRenderSize / pixelRatio);
22453
22281
  const imageWidth = Math.round(backgroundRect.width);
22454
22282
  const imageHeight = Math.round(backgroundRect.height);
22455
- let compositeX = 0;
22456
- let compositeY = 0;
22457
- for (let y = Math.round(backgroundRect.y); y < imageHeight; y += tileSize) {
22458
- compositeX = 0;
22459
- for (let x = Math.round(backgroundRect.x); x < imageWidth; x += tileSize) {
22460
- const width = Math.min(tileSize, imageWidth - x);
22461
- const height = Math.min(tileSize, imageHeight - y);
22462
- const canvas = await exportGroup.toCanvas({
22463
- x,
22464
- y,
22465
- width,
22466
- height,
22467
- mimeType: format$2,
22468
- pixelRatio,
22469
- quality: options.quality ?? 1
22470
- });
22471
- const buffer = canvas.toBuffer();
22472
- composites.push({
22473
- top: compositeY * pixelRatio,
22474
- left: compositeX * pixelRatio,
22475
- input: buffer
22476
- });
22477
- compositeX = compositeX + tileSize;
22478
- }
22479
- compositeY = compositeY + tileSize;
22283
+ const maxRenderSize = 1920;
22284
+ const cols = Math.ceil(imageWidth / maxRenderSize);
22285
+ const rows = Math.ceil(imageHeight / maxRenderSize);
22286
+ const tileWidth = Math.floor(imageWidth / cols);
22287
+ const tileHeight = Math.floor(imageHeight / rows);
22288
+ for (let y = 0; y < imageHeight; y += tileHeight) for (let x = 0; x < imageWidth; x += tileWidth) {
22289
+ const width = Math.min(tileWidth, imageWidth - x);
22290
+ const height = Math.min(tileHeight, imageHeight - y);
22291
+ const canvas = await exportGroup.toCanvas({
22292
+ x: Math.round(backgroundRect.x) + x,
22293
+ y: Math.round(backgroundRect.y) + y,
22294
+ width,
22295
+ height,
22296
+ mimeType: format$2,
22297
+ pixelRatio,
22298
+ quality: options.quality ?? 1
22299
+ });
22300
+ const buffer = canvas.toBuffer();
22301
+ composites.push({
22302
+ top: y * pixelRatio,
22303
+ left: x * pixelRatio,
22304
+ input: buffer
22305
+ });
22480
22306
  }
22481
22307
  exportGroup.destroy();
22482
22308
  stage.position(originalPosition);
@@ -23726,7 +23552,7 @@ var WeaveTextNode = class extends WeaveNode {
23726
23552
  }
23727
23553
  this.textAreaContainer.style.border = "solid 1px #1e40af";
23728
23554
  this.textArea.style.position = "absolute";
23729
- this.textArea.style.top = "0px";
23555
+ this.textArea.style.top = "-30px";
23730
23556
  this.textArea.style.left = "0px";
23731
23557
  this.textArea.style.overscrollBehavior = "contains";
23732
23558
  this.textArea.style.scrollBehavior = "auto";
@@ -23735,6 +23561,7 @@ var WeaveTextNode = class extends WeaveNode {
23735
23561
  this.textArea.style.minHeight = "auto";
23736
23562
  this.textArea.style.margin = "0px";
23737
23563
  this.textArea.style.padding = "0px";
23564
+ this.textArea.style.paddingTop = "20px";
23738
23565
  this.textArea.style.boxSizing = "content-box";
23739
23566
  this.textArea.style.overflow = "hidden";
23740
23567
  this.textArea.style.background = "transparent";