captions.js 0.2.0 → 0.3.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.d.mts CHANGED
@@ -76,6 +76,40 @@ declare function renderString(canvas: HTMLCanvasElement, text: string, options:
76
76
  preset: StylePreset;
77
77
  }): Promise<boolean>;
78
78
 
79
+ /**
80
+ * Full styling + animation configuration for a single captions track.
81
+ *
82
+ * @public
83
+ */
84
+ interface CaptionsSettings {
85
+ style: {
86
+ name: string;
87
+ font: {
88
+ fontFamily: string;
89
+ fontSize: number;
90
+ fontWeight: "thin" | "light" | "regular" | "medium" | "bold" | "black";
91
+ fontColor: string;
92
+ fontCapitalize: boolean;
93
+ italic: boolean;
94
+ underline: boolean;
95
+ fontStrokeColor: string;
96
+ fontStrokeWidth: number;
97
+ shadow: {
98
+ fontShadowColor: string;
99
+ fontShadowBlur: number;
100
+ fontShadowOffsetX: number;
101
+ fontShadowOffsetY: number;
102
+ };
103
+ };
104
+ aplifiedWordColor: string;
105
+ backgroundColor: string;
106
+ };
107
+ linesPerPage: number;
108
+ lineSpacing?: number | null;
109
+ position: "auto" | "top" | "middle" | "bottom";
110
+ positionTopOffset: number;
111
+ animation: "none" | "bounce" | "underline" | "box" | "pop" | "scale" | "slide-left" | "slide-up" | "slide-down" | "box-word";
112
+ }
79
113
  /**
80
114
  * Single timed word/segment that will be highlighted as audio plays.
81
115
  *
@@ -142,7 +176,7 @@ declare class Captions {
142
176
  */
143
177
  disable(): void;
144
178
  /**
145
- * Alias for {@link Captions.disable | disable()} to match typical imperative controller APIs.
179
+ * Alias for {@link Captions.disable | disable()} to match typical imperative controller APIs.
146
180
  */
147
181
  destroy(): void;
148
182
  /**
@@ -196,4 +230,4 @@ declare function captionsjs(options: CaptionsOptions): Captions;
196
230
  */
197
231
  declare function renderCaptions(ctx: CanvasRenderingContext2D, text: string): boolean;
198
232
 
199
- export { type Caption, Captions, type CaptionsInstance, type CaptionsOptions, type StylePreset, captionsjs, captionsjs as default, googleFontsList, renderCaptions, renderString, stylePresets };
233
+ export { type Caption, Captions, type CaptionsInstance, type CaptionsOptions, type CaptionsSettings, type StylePreset, captionsjs, captionsjs as default, googleFontsList, renderCaptions, renderString, stylePresets };
package/dist/index.d.ts CHANGED
@@ -76,6 +76,40 @@ declare function renderString(canvas: HTMLCanvasElement, text: string, options:
76
76
  preset: StylePreset;
77
77
  }): Promise<boolean>;
78
78
 
79
+ /**
80
+ * Full styling + animation configuration for a single captions track.
81
+ *
82
+ * @public
83
+ */
84
+ interface CaptionsSettings {
85
+ style: {
86
+ name: string;
87
+ font: {
88
+ fontFamily: string;
89
+ fontSize: number;
90
+ fontWeight: "thin" | "light" | "regular" | "medium" | "bold" | "black";
91
+ fontColor: string;
92
+ fontCapitalize: boolean;
93
+ italic: boolean;
94
+ underline: boolean;
95
+ fontStrokeColor: string;
96
+ fontStrokeWidth: number;
97
+ shadow: {
98
+ fontShadowColor: string;
99
+ fontShadowBlur: number;
100
+ fontShadowOffsetX: number;
101
+ fontShadowOffsetY: number;
102
+ };
103
+ };
104
+ aplifiedWordColor: string;
105
+ backgroundColor: string;
106
+ };
107
+ linesPerPage: number;
108
+ lineSpacing?: number | null;
109
+ position: "auto" | "top" | "middle" | "bottom";
110
+ positionTopOffset: number;
111
+ animation: "none" | "bounce" | "underline" | "box" | "pop" | "scale" | "slide-left" | "slide-up" | "slide-down" | "box-word";
112
+ }
79
113
  /**
80
114
  * Single timed word/segment that will be highlighted as audio plays.
81
115
  *
@@ -142,7 +176,7 @@ declare class Captions {
142
176
  */
143
177
  disable(): void;
144
178
  /**
145
- * Alias for {@link Captions.disable | disable()} to match typical imperative controller APIs.
179
+ * Alias for {@link Captions.disable | disable()} to match typical imperative controller APIs.
146
180
  */
147
181
  destroy(): void;
148
182
  /**
@@ -196,4 +230,4 @@ declare function captionsjs(options: CaptionsOptions): Captions;
196
230
  */
197
231
  declare function renderCaptions(ctx: CanvasRenderingContext2D, text: string): boolean;
198
232
 
199
- export { type Caption, Captions, type CaptionsInstance, type CaptionsOptions, type StylePreset, captionsjs, captionsjs as default, googleFontsList, renderCaptions, renderString, stylePresets };
233
+ export { type Caption, Captions, type CaptionsInstance, type CaptionsOptions, type CaptionsSettings, type StylePreset, captionsjs, captionsjs as default, googleFontsList, renderCaptions, renderString, stylePresets };
package/dist/index.js CHANGED
@@ -1623,7 +1623,7 @@ var Captions = class {
1623
1623
  this.enabled = false;
1624
1624
  }
1625
1625
  /**
1626
- * Alias for {@link Captions.disable | disable()} to match typical imperative controller APIs.
1626
+ * Alias for {@link Captions.disable | disable()} to match typical imperative controller APIs.
1627
1627
  */
1628
1628
  destroy() {
1629
1629
  this.disable();
@@ -1681,15 +1681,19 @@ var Captions = class {
1681
1681
  return;
1682
1682
  }
1683
1683
  this.layer.destroyChildren();
1684
+ const captionsSettings = this.presetState.captionsSettings;
1684
1685
  renderFrame(
1685
- this.presetState.captionsSettings,
1686
+ captionsSettings,
1686
1687
  void 0,
1687
1688
  this.captionsState || [],
1688
1689
  this.video.currentTime,
1689
1690
  [this.videoWidth, this.videoHeight],
1690
1691
  this.layer,
1691
- 1,
1692
- { type: "bottom", positionTopOffset: 50 }
1692
+ 2,
1693
+ {
1694
+ type: captionsSettings.position ?? "bottom",
1695
+ positionTopOffset: captionsSettings.positionTopOffset ?? 0
1696
+ }
1693
1697
  );
1694
1698
  }
1695
1699
  syncStageDimensions() {
package/dist/index.mjs CHANGED
@@ -1581,7 +1581,7 @@ var Captions = class {
1581
1581
  this.enabled = false;
1582
1582
  }
1583
1583
  /**
1584
- * Alias for {@link Captions.disable | disable()} to match typical imperative controller APIs.
1584
+ * Alias for {@link Captions.disable | disable()} to match typical imperative controller APIs.
1585
1585
  */
1586
1586
  destroy() {
1587
1587
  this.disable();
@@ -1639,15 +1639,19 @@ var Captions = class {
1639
1639
  return;
1640
1640
  }
1641
1641
  this.layer.destroyChildren();
1642
+ const captionsSettings = this.presetState.captionsSettings;
1642
1643
  renderFrame(
1643
- this.presetState.captionsSettings,
1644
+ captionsSettings,
1644
1645
  void 0,
1645
1646
  this.captionsState || [],
1646
1647
  this.video.currentTime,
1647
1648
  [this.videoWidth, this.videoHeight],
1648
1649
  this.layer,
1649
- 1,
1650
- { type: "bottom", positionTopOffset: 50 }
1650
+ 2,
1651
+ {
1652
+ type: captionsSettings.position ?? "bottom",
1653
+ positionTopOffset: captionsSettings.positionTopOffset ?? 0
1654
+ }
1651
1655
  );
1652
1656
  }
1653
1657
  syncStageDimensions() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "captions.js",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "repository": {