captions.js 0.1.0 → 0.1.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/index.js CHANGED
@@ -887,7 +887,7 @@ async function loadGoogleFont2(fontFamily) {
887
887
  } catch (err) {
888
888
  console.warn(`[loadGoogleFont] failed to load font "${fontFamily}":`, err);
889
889
  }
890
- await new Promise((resolve) => setTimeout(resolve, 1e3));
890
+ await new Promise((resolve) => setTimeout(resolve, 2e3));
891
891
  import_konva.default.stages?.forEach((stage) => stage.batchDraw());
892
892
  }
893
893
 
@@ -1581,8 +1581,25 @@ var renderStylePreset = async (stylePreset, size, frames, text = "Hello World")
1581
1581
  });
1582
1582
  const layer = new import_konva4.default.Layer({ listening: false });
1583
1583
  stage.add(layer);
1584
+ const fontSettings = stylePreset.captionsSettings.style.font;
1584
1585
  const fontFamily = stylePreset.captionsSettings.style.font.fontFamily;
1585
1586
  await loadGoogleFont2(fontFamily);
1587
+ await new Promise((resolve) => requestAnimationFrame(resolve));
1588
+ const warmupText = new import_konva4.default.Text({
1589
+ text: "warmup",
1590
+ x: -9999,
1591
+ y: -9999,
1592
+ fontFamily: fontSettings.fontFamily,
1593
+ fontSize: fontSettings.fontSize,
1594
+ fontStyle: fontWeightToFontStyle(
1595
+ fontSettings.fontWeight,
1596
+ fontSettings.italic
1597
+ ),
1598
+ fill: "transparent"
1599
+ });
1600
+ layer.add(warmupText);
1601
+ layer.draw();
1602
+ warmupText.destroy();
1586
1603
  const [firstWord, secondWord = ""] = text.split(" ");
1587
1604
  const previewCaptions = [
1588
1605
  {
package/dist/index.mjs CHANGED
@@ -843,7 +843,7 @@ async function loadGoogleFont2(fontFamily) {
843
843
  } catch (err) {
844
844
  console.warn(`[loadGoogleFont] failed to load font "${fontFamily}":`, err);
845
845
  }
846
- await new Promise((resolve) => setTimeout(resolve, 1e3));
846
+ await new Promise((resolve) => setTimeout(resolve, 2e3));
847
847
  Konva.stages?.forEach((stage) => stage.batchDraw());
848
848
  }
849
849
 
@@ -1537,8 +1537,25 @@ var renderStylePreset = async (stylePreset, size, frames, text = "Hello World")
1537
1537
  });
1538
1538
  const layer = new Konva4.Layer({ listening: false });
1539
1539
  stage.add(layer);
1540
+ const fontSettings = stylePreset.captionsSettings.style.font;
1540
1541
  const fontFamily = stylePreset.captionsSettings.style.font.fontFamily;
1541
1542
  await loadGoogleFont2(fontFamily);
1543
+ await new Promise((resolve) => requestAnimationFrame(resolve));
1544
+ const warmupText = new Konva4.Text({
1545
+ text: "warmup",
1546
+ x: -9999,
1547
+ y: -9999,
1548
+ fontFamily: fontSettings.fontFamily,
1549
+ fontSize: fontSettings.fontSize,
1550
+ fontStyle: fontWeightToFontStyle(
1551
+ fontSettings.fontWeight,
1552
+ fontSettings.italic
1553
+ ),
1554
+ fill: "transparent"
1555
+ });
1556
+ layer.add(warmupText);
1557
+ layer.draw();
1558
+ warmupText.destroy();
1542
1559
  const [firstWord, secondWord = ""] = text.split(" ");
1543
1560
  const previewCaptions = [
1544
1561
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "captions.js",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "repository": {