@zync/zync-screnplay-player 0.1.238 → 0.1.240

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.
@@ -16,8 +16,9 @@ var TEXT_COLOR = "#0a3567";
16
16
  var BACKGROUND_COLORS = ["#fff200", "#22f3d0", "#ff8a00", "#ff78a8", "#b9ff4a", "#f7f7f2"];
17
17
  var HORIZONTAL_SAFE_AREA = 0.86;
18
18
  var VERTICAL_SAFE_AREA = 0.5;
19
- var BACKGROUND_WIPE_FRAMES = 7;
20
- var WORD_STEP_FRAMES = 18;
19
+ var MAX_BACKGROUND_WIPE_FRAMES = 7;
20
+ var MAX_WORD_STEP_FRAMES = 18;
21
+ var WORD_REVEAL_SECONDS = 3;
21
22
  var splitWords = function splitWords() {
22
23
  var text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
23
24
  return String(text).trim().split(/\s+/).filter(Boolean);
@@ -83,13 +84,25 @@ var getFontSizeForFullText = function getFontSizeForFullText(_ref2) {
83
84
  var getBackgroundColor = function getBackgroundColor(index) {
84
85
  return BACKGROUND_COLORS[index % BACKGROUND_COLORS.length];
85
86
  };
86
- var PositionedWords = function PositionedWords(_ref3) {
87
- var fontSize = _ref3.fontSize,
88
- frame = _ref3.frame,
89
- staticUntilIndex = _ref3.staticUntilIndex,
90
- visibleUntilIndex = _ref3.visibleUntilIndex,
91
- width = _ref3.width,
92
- words = _ref3.words;
87
+ var getWordStepFrames = function getWordStepFrames(_ref3) {
88
+ var fps = _ref3.fps,
89
+ wordCount = _ref3.wordCount;
90
+ if (wordCount <= 1) {
91
+ return MAX_WORD_STEP_FRAMES;
92
+ }
93
+ var revealFrames = fps * WORD_REVEAL_SECONDS;
94
+ var maxStepFrames = Math.floor(revealFrames / (wordCount - 1));
95
+ return Math.max(1, Math.min(MAX_WORD_STEP_FRAMES, maxStepFrames));
96
+ };
97
+ var PositionedWords = function PositionedWords(_ref4) {
98
+ var backgroundWipeFrames = _ref4.backgroundWipeFrames,
99
+ fontSize = _ref4.fontSize,
100
+ frame = _ref4.frame,
101
+ staticUntilIndex = _ref4.staticUntilIndex,
102
+ visibleUntilIndex = _ref4.visibleUntilIndex,
103
+ width = _ref4.width,
104
+ wordStepFrames = _ref4.wordStepFrames,
105
+ words = _ref4.words;
93
106
  return /*#__PURE__*/React.createElement(AbsoluteFill, {
94
107
  style: {
95
108
  alignItems: "center",
@@ -120,8 +133,8 @@ var PositionedWords = function PositionedWords(_ref3) {
120
133
  }, word);
121
134
  }
122
135
  var shouldAnimate = index > staticUntilIndex;
123
- var wordFrame = frame - index * WORD_STEP_FRAMES;
124
- var progress = shouldAnimate ? interpolate(wordFrame, [0, BACKGROUND_WIPE_FRAMES + 5], [0, 1], {
136
+ var wordFrame = frame - index * wordStepFrames;
137
+ var progress = shouldAnimate ? interpolate(wordFrame, [0, backgroundWipeFrames + 5], [0, 1], {
125
138
  easing: Easing.out(Easing.cubic),
126
139
  extrapolateLeft: "clamp",
127
140
  extrapolateRight: "clamp"
@@ -151,34 +164,44 @@ var PositionedWords = function PositionedWords(_ref3) {
151
164
  }, word);
152
165
  })));
153
166
  };
154
- export var TextFullCover = function TextFullCover(_ref4) {
155
- var text = _ref4.text,
156
- children = _ref4.children,
157
- muted = _ref4.muted,
158
- _ref4$startVideoFrom = _ref4.startVideoFrom,
159
- startVideoFrom = _ref4$startVideoFrom === void 0 ? 0 : _ref4$startVideoFrom,
160
- videoUrl = _ref4.videoUrl,
161
- _ref4$videoZoom = _ref4.videoZoom,
162
- videoZoom = _ref4$videoZoom === void 0 ? 1 : _ref4$videoZoom,
163
- _ref4$disableTransiti = _ref4.disableTransitionSounds,
164
- disableTransitionSounds = _ref4$disableTransiti === void 0 ? false : _ref4$disableTransiti;
167
+ export var TextFullCover = function TextFullCover(_ref5) {
168
+ var _ref6, _ref7;
169
+ var text = _ref5.text,
170
+ sentence = _ref5.sentence,
171
+ sentenceText = _ref5.sentenceText,
172
+ children = _ref5.children,
173
+ muted = _ref5.muted,
174
+ _ref5$startVideoFrom = _ref5.startVideoFrom,
175
+ startVideoFrom = _ref5$startVideoFrom === void 0 ? 0 : _ref5$startVideoFrom,
176
+ videoUrl = _ref5.videoUrl,
177
+ _ref5$videoZoom = _ref5.videoZoom,
178
+ videoZoom = _ref5$videoZoom === void 0 ? 1 : _ref5$videoZoom,
179
+ _ref5$disableTransiti = _ref5.disableTransitionSounds,
180
+ disableTransitionSounds = _ref5$disableTransiti === void 0 ? false : _ref5$disableTransiti;
165
181
  var frame = useCurrentFrame();
166
182
  var _useVideoConfig = useVideoConfig(),
183
+ fps = _useVideoConfig.fps,
167
184
  width = _useVideoConfig.width,
168
185
  height = _useVideoConfig.height;
169
- var words = splitWords(text);
186
+ var displayText = (_ref6 = (_ref7 = text !== null && text !== void 0 ? text : sentenceText) !== null && _ref7 !== void 0 ? _ref7 : sentence) !== null && _ref6 !== void 0 ? _ref6 : "";
187
+ var words = splitWords(displayText);
170
188
  var fallbackWords = words.length ? words : [""];
171
189
  var uppercaseWords = fallbackWords.map(function (word) {
172
190
  return word.toLocaleUpperCase();
173
191
  });
192
+ var wordStepFrames = getWordStepFrames({
193
+ fps: fps,
194
+ wordCount: fallbackWords.length
195
+ });
196
+ var backgroundWipeFrames = Math.min(MAX_BACKGROUND_WIPE_FRAMES, Math.max(1, wordStepFrames - 1));
174
197
  var lastStepIndex = fallbackWords.length - 1;
175
- var stepIndex = Math.min(lastStepIndex, Math.floor(frame / WORD_STEP_FRAMES));
198
+ var stepIndex = Math.min(lastStepIndex, Math.floor(frame / wordStepFrames));
176
199
  var previousStepIndex = Math.max(0, stepIndex - 1);
177
- var frameInWord = frame - stepIndex * WORD_STEP_FRAMES;
200
+ var frameInWord = frame - stepIndex * wordStepFrames;
178
201
  var currentBackgroundColor = getBackgroundColor(stepIndex);
179
202
  var previousBackgroundColor = getBackgroundColor(Math.max(0, stepIndex - 1));
180
- var shouldWipe = stepIndex > 0 && frameInWord < BACKGROUND_WIPE_FRAMES;
181
- var wipeProgress = shouldWipe ? interpolate(frameInWord, [0, BACKGROUND_WIPE_FRAMES], [0, 1], {
203
+ var shouldWipe = stepIndex > 0 && frameInWord < backgroundWipeFrames;
204
+ var wipeProgress = shouldWipe ? interpolate(frameInWord, [0, backgroundWipeFrames], [0, 1], {
182
205
  easing: Easing.out(Easing.cubic),
183
206
  extrapolateLeft: "clamp",
184
207
  extrapolateRight: "clamp"
@@ -215,11 +238,13 @@ export var TextFullCover = function TextFullCover(_ref4) {
215
238
  width: "100%"
216
239
  }
217
240
  })) : null, shouldWipe ? /*#__PURE__*/React.createElement(PositionedWords, {
241
+ backgroundWipeFrames: backgroundWipeFrames,
218
242
  fontSize: fontSize,
219
243
  frame: frame,
220
244
  staticUntilIndex: previousStepIndex,
221
245
  visibleUntilIndex: previousStepIndex,
222
246
  width: width,
247
+ wordStepFrames: wordStepFrames,
223
248
  words: uppercaseWords
224
249
  }) : null, /*#__PURE__*/React.createElement(AbsoluteFill, {
225
250
  style: {
@@ -232,11 +257,13 @@ export var TextFullCover = function TextFullCover(_ref4) {
232
257
  zIndex: 1
233
258
  }
234
259
  }, /*#__PURE__*/React.createElement(PositionedWords, {
260
+ backgroundWipeFrames: backgroundWipeFrames,
235
261
  fontSize: fontSize,
236
262
  frame: frame,
237
263
  staticUntilIndex: previousStepIndex,
238
264
  visibleUntilIndex: stepIndex,
239
265
  width: width,
266
+ wordStepFrames: wordStepFrames,
240
267
  words: uppercaseWords
241
268
  })), !disableTransitionSounds && /*#__PURE__*/React.createElement(Audio, {
242
269
  src: "https://cdn.zync.ai/assets/static/swoosh.mp3",
@@ -7,7 +7,6 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
7
7
  import { SimpleFrameLayout } from "./SimpleFrameLayout.js";
8
8
  import { Layout } from "./DefaultLayout.js";
9
9
  import { TextWithVideoLayout } from "./TextWithVideoLayout.js";
10
- import { TextFullCoverLayout } from "./TextFullCoverLayout.js";
11
10
  import { HandoffLayout } from "./HandoffLayout.js";
12
11
  import { CreatorCollabSplitLayout } from "./CreatorCollabSplitLayout.js";
13
12
  import { CreatorCollabColdOpenLayout } from "./CreatorCollabColdOpenLayout.js";
@@ -36,11 +35,6 @@ export var LayoutFactory = /*#__PURE__*/function () {
36
35
  layout = new TextWithVideoLayout(props).flatten();
37
36
  break;
38
37
  }
39
- case "text_full_cover":
40
- {
41
- layout = new TextFullCoverLayout(props).flatten();
42
- break;
43
- }
44
38
  case "broll_background":
45
39
  case "simple_frame_broll":
46
40
  case "simple_frame_sentence":
@@ -49,6 +43,7 @@ export var LayoutFactory = /*#__PURE__*/function () {
49
43
  case "broll_studio_backdrop":
50
44
  case "broll_inset":
51
45
  case "key_point_overlay_depth":
46
+ case "text_full_cover":
52
47
  case "simple_frame":
53
48
  {
54
49
  layout = new SimpleFrameLayout(props).flatten();
@@ -49,8 +49,8 @@ import { HookVideo } from "./components/layouts/HookVideo";
49
49
  import { BrollInset } from "./components/layouts/BrollInset";
50
50
  import { MotionStillInset } from "./components/layouts/MotionStillInset";
51
51
 
52
- /** Update this so that Remotion knows which component to render when it is passed via screenplay. Ex. "title" will have rendered "Title" component
53
- * Here we are mapping directly types and component names. Types are snake_case and components PascalCase.
52
+ /** Update this so that Remotion knows which component to render when it is passed via screenplay. Ex. "title" will have rendered "Title" component
53
+ * Here we are mapping directly types and component names. Types are snake_case and components PascalCase.
54
54
  * */
55
55
  export var RegisteredComponents = {
56
56
  // Layouts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zync/zync-screnplay-player",
3
- "version": "0.1.238",
3
+ "version": "0.1.240",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -1,22 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
3
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
4
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
5
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
7
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
8
- function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
9
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
10
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
12
- function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
13
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
14
- import { TextWithVideoLayout } from "./TextWithVideoLayout.js";
15
- export var TextFullCoverLayout = /*#__PURE__*/function (_TextWithVideoLayout) {
16
- function TextFullCoverLayout() {
17
- _classCallCheck(this, TextFullCoverLayout);
18
- return _callSuper(this, TextFullCoverLayout, arguments);
19
- }
20
- _inherits(TextFullCoverLayout, _TextWithVideoLayout);
21
- return _createClass(TextFullCoverLayout);
22
- }(TextWithVideoLayout);