remotion 4.0.508 → 4.0.509
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/cjs/RemotionRoot.d.ts +1 -0
- package/dist/cjs/RemotionRoot.js +2 -2
- package/dist/cjs/audio/shared-audio-tags.d.ts +2 -0
- package/dist/cjs/audio/shared-audio-tags.js +74 -5
- package/dist/cjs/audio/wait-until-actually-resumed.js +21 -8
- package/dist/cjs/internals.d.ts +5 -1
- package/dist/cjs/interpolate.js +81 -2
- package/dist/cjs/use-schema.d.ts +2 -1
- package/dist/cjs/use-schema.js +3 -3
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/index.mjs +147 -16
- package/dist/esm/no-react.mjs +607 -72
- package/dist/esm/version.mjs +1 -1
- package/package.json +2 -2
package/dist/esm/index.mjs
CHANGED
|
@@ -1340,7 +1340,7 @@ var getSingleChildComponent = (children) => {
|
|
|
1340
1340
|
};
|
|
1341
1341
|
|
|
1342
1342
|
// src/version.ts
|
|
1343
|
-
var VERSION = "4.0.
|
|
1343
|
+
var VERSION = "4.0.509";
|
|
1344
1344
|
|
|
1345
1345
|
// src/multiple-versions-warning.ts
|
|
1346
1346
|
var checkMultipleRemotionVersions = () => {
|
|
@@ -2715,10 +2715,13 @@ var transformOriginCenter = { value: 50, unit: "%" };
|
|
|
2715
2715
|
var stringifyNumber = (value) => {
|
|
2716
2716
|
return String(normalizeNumber(value));
|
|
2717
2717
|
};
|
|
2718
|
+
|
|
2719
|
+
class UnsupportedStringInterpolationValueError extends TypeError {
|
|
2720
|
+
}
|
|
2718
2721
|
var parseStringInterpolationComponent = (component, value) => {
|
|
2719
2722
|
const match = cssNumberRegex.exec(component);
|
|
2720
2723
|
if (match === null) {
|
|
2721
|
-
throw new
|
|
2724
|
+
throw new UnsupportedStringInterpolationValueError(`Cannot interpolate "${value}" because "${component}" is not a supported scale, translate, or rotate value`);
|
|
2722
2725
|
}
|
|
2723
2726
|
const unit = match[2] ?? null;
|
|
2724
2727
|
const numberValue = Number(match[1]);
|
|
@@ -3185,6 +3188,52 @@ var interpolateString = ({
|
|
|
3185
3188
|
axisRotation: hasAxisRotation
|
|
3186
3189
|
});
|
|
3187
3190
|
};
|
|
3191
|
+
var interpolateDiscreteString = ({
|
|
3192
|
+
input,
|
|
3193
|
+
inputRange,
|
|
3194
|
+
outputRange,
|
|
3195
|
+
options
|
|
3196
|
+
}) => {
|
|
3197
|
+
if (inputRange.length === 1) {
|
|
3198
|
+
return outputRange[0];
|
|
3199
|
+
}
|
|
3200
|
+
for (let segmentIndex = 0;segmentIndex < inputRange.length - 1; segmentIndex++) {
|
|
3201
|
+
if (resolveEasingForSegment({
|
|
3202
|
+
easing: options?.easing,
|
|
3203
|
+
segmentIndex
|
|
3204
|
+
}) !== Easing.step1) {
|
|
3205
|
+
throw new TypeError("Non-numeric strings can only be interpolated using Easing.step1");
|
|
3206
|
+
}
|
|
3207
|
+
}
|
|
3208
|
+
const posterizedInput = options?.posterize === undefined ? input : Math.floor(input / options.posterize) * options.posterize;
|
|
3209
|
+
const inputMin = inputRange[0];
|
|
3210
|
+
const inputMax = inputRange[inputRange.length - 1];
|
|
3211
|
+
let resolvedInput = posterizedInput;
|
|
3212
|
+
if (resolvedInput < inputMin) {
|
|
3213
|
+
if (options?.extrapolateLeft === "identity") {
|
|
3214
|
+
throw new TypeError('extrapolateLeft: "identity" is not supported for non-numeric strings');
|
|
3215
|
+
}
|
|
3216
|
+
if (options?.extrapolateLeft === "wrap") {
|
|
3217
|
+
const wrapRange = inputMax - inputMin;
|
|
3218
|
+
resolvedInput = ((resolvedInput - inputMin) % wrapRange + wrapRange) % wrapRange + inputMin;
|
|
3219
|
+
} else {
|
|
3220
|
+
return outputRange[0];
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
if (resolvedInput > inputMax) {
|
|
3224
|
+
if (options?.extrapolateRight === "identity") {
|
|
3225
|
+
throw new TypeError('extrapolateRight: "identity" is not supported for non-numeric strings');
|
|
3226
|
+
}
|
|
3227
|
+
if (options?.extrapolateRight === "wrap") {
|
|
3228
|
+
const wrapRange = inputMax - inputMin;
|
|
3229
|
+
resolvedInput = ((resolvedInput - inputMin) % wrapRange + wrapRange) % wrapRange + inputMin;
|
|
3230
|
+
} else {
|
|
3231
|
+
return outputRange[outputRange.length - 1];
|
|
3232
|
+
}
|
|
3233
|
+
}
|
|
3234
|
+
const range = findRange(resolvedInput, inputRange);
|
|
3235
|
+
return resolvedInput >= inputRange[range + 1] ? outputRange[range + 1] : outputRange[range];
|
|
3236
|
+
};
|
|
3188
3237
|
var validateTupleOutputRange = (outputRange) => {
|
|
3189
3238
|
const dimensions = outputRange[0]?.length;
|
|
3190
3239
|
if (dimensions === undefined) {
|
|
@@ -3299,7 +3348,30 @@ function interpolate(input, inputRange, outputRange, options) {
|
|
|
3299
3348
|
if (!outputRange.every((output) => typeof output === "string" || typeof output === "number")) {
|
|
3300
3349
|
throw new TypeError("outputRange must contain only numbers, or supported scale, translate, and rotate strings");
|
|
3301
3350
|
}
|
|
3302
|
-
|
|
3351
|
+
try {
|
|
3352
|
+
return interpolateString({ input, inputRange, outputRange, options });
|
|
3353
|
+
} catch (error2) {
|
|
3354
|
+
if (!outputRange.every((output) => typeof output === "string")) {
|
|
3355
|
+
throw error2;
|
|
3356
|
+
}
|
|
3357
|
+
const hasNonNumericString = outputRange.some((output) => {
|
|
3358
|
+
try {
|
|
3359
|
+
parseStringInterpolationValue(output);
|
|
3360
|
+
return false;
|
|
3361
|
+
} catch (parseError) {
|
|
3362
|
+
return parseError instanceof UnsupportedStringInterpolationValueError;
|
|
3363
|
+
}
|
|
3364
|
+
});
|
|
3365
|
+
if (!hasNonNumericString) {
|
|
3366
|
+
throw error2;
|
|
3367
|
+
}
|
|
3368
|
+
return interpolateDiscreteString({
|
|
3369
|
+
input,
|
|
3370
|
+
inputRange,
|
|
3371
|
+
outputRange,
|
|
3372
|
+
options
|
|
3373
|
+
});
|
|
3374
|
+
}
|
|
3303
3375
|
}
|
|
3304
3376
|
if (outputRange.every((output) => Array.isArray(output))) {
|
|
3305
3377
|
return interpolateTuple({ input, inputRange, outputRange, options });
|
|
@@ -4599,7 +4671,8 @@ var makeStaticDragOverride = (value) => {
|
|
|
4599
4671
|
var makeKeyframedDragOverride = ({
|
|
4600
4672
|
status,
|
|
4601
4673
|
frame,
|
|
4602
|
-
value
|
|
4674
|
+
value,
|
|
4675
|
+
defaultEasing: defaultEasing2 = DEFAULT_LINEAR_EASING
|
|
4603
4676
|
}) => {
|
|
4604
4677
|
const existingIndex = status.keyframes.findIndex((keyframe) => keyframe.frame === frame);
|
|
4605
4678
|
const keyframes = existingIndex === -1 ? [...status.keyframes, { frame, value }].sort((first, second) => first.frame - second.frame) : status.keyframes.map((keyframe, index) => index === existingIndex ? { frame, value } : keyframe);
|
|
@@ -4611,11 +4684,11 @@ var makeKeyframedDragOverride = ({
|
|
|
4611
4684
|
easingLength: easing.length,
|
|
4612
4685
|
keyframeCount: keyframes.length
|
|
4613
4686
|
});
|
|
4614
|
-
const easingToDuplicate = easingIndexToDuplicate === null ?
|
|
4687
|
+
const easingToDuplicate = easingIndexToDuplicate === null ? defaultEasing2 : easing[easingIndexToDuplicate];
|
|
4615
4688
|
easing.splice(insertedKeyframeIndex, 0, easingToDuplicate);
|
|
4616
4689
|
}
|
|
4617
4690
|
while (easing.length < keyframes.length - 1) {
|
|
4618
|
-
easing.push(
|
|
4691
|
+
easing.push(defaultEasing2);
|
|
4619
4692
|
}
|
|
4620
4693
|
if (easing.length > keyframes.length - 1) {
|
|
4621
4694
|
easing.length = keyframes.length - 1;
|
|
@@ -7291,13 +7364,17 @@ var waitUntilActuallyResumed = (audioContext, logLevel, signal) => {
|
|
|
7291
7364
|
resolve(result);
|
|
7292
7365
|
};
|
|
7293
7366
|
onAbort = () => finish("cancelled");
|
|
7367
|
+
const hasAudiblyStarted = (startPerformanceTime) => {
|
|
7368
|
+
const outputTimestamp = audioContext.getOutputTimestamp();
|
|
7369
|
+
return startPerformanceTime !== undefined && outputTimestamp.performanceTime !== undefined && outputTimestamp.performanceTime > startPerformanceTime && outputTimestamp.contextTime !== undefined && outputTimestamp.contextTime > startCurrentTime;
|
|
7370
|
+
};
|
|
7294
7371
|
const check = () => {
|
|
7295
7372
|
animationFrame = null;
|
|
7296
7373
|
const { currentTime } = audioContext;
|
|
7297
7374
|
const outputTimestamp = audioContext.getOutputTimestamp();
|
|
7298
7375
|
const elapsedWallClock = performance.now() - startWallClock;
|
|
7299
|
-
if (startOutputPerformanceTime
|
|
7300
|
-
Log.verbose({ logLevel, tag: "audio" }, `waitUntilActuallyResumed: getOutputTimestamp.performanceTime advanced from ${startOutputPerformanceTime.toFixed(6)} to ${outputTimestamp.performanceTime
|
|
7376
|
+
if (hasAudiblyStarted(startOutputPerformanceTime)) {
|
|
7377
|
+
Log.verbose({ logLevel, tag: "audio" }, `waitUntilActuallyResumed: getOutputTimestamp.performanceTime advanced from ${startOutputPerformanceTime.toFixed(6)} to ${outputTimestamp.performanceTime?.toFixed(6)} after ${elapsedWallClock.toFixed(1)}ms. currentTime=${currentTime.toFixed(6)} (advanced by ${(currentTime - startCurrentTime).toFixed(6)}), getOutputTimestamp.performanceTime=${outputTimestamp.performanceTime?.toFixed(1) ?? "undefined"}`);
|
|
7301
7378
|
finish("resumed");
|
|
7302
7379
|
return;
|
|
7303
7380
|
}
|
|
@@ -7309,6 +7386,10 @@ var waitUntilActuallyResumed = (audioContext, logLevel, signal) => {
|
|
|
7309
7386
|
}
|
|
7310
7387
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
7311
7388
|
timeout = setTimeout(() => {
|
|
7389
|
+
if (hasAudiblyStarted(startOutputPerformanceTime)) {
|
|
7390
|
+
finish("resumed");
|
|
7391
|
+
return;
|
|
7392
|
+
}
|
|
7312
7393
|
Log.warn({ logLevel, tag: "audio" }, "WARNING: You enabled autoPlay on an unmuted <Player /> and the browser did not allow the video to be started. Remotion muted the <Player /> so it can play. To properly handle this, either set the `muted` prop or remove the `autoPlay` prop");
|
|
7313
7394
|
finish("failed");
|
|
7314
7395
|
}, RESUME_WAIT_TIMEOUT);
|
|
@@ -7355,7 +7436,13 @@ var shouldSaveForLater = (state) => {
|
|
|
7355
7436
|
}
|
|
7356
7437
|
throw new Error(`Unexpected audio context state: ${state}`);
|
|
7357
7438
|
};
|
|
7358
|
-
var SharedAudioContextProvider = ({
|
|
7439
|
+
var SharedAudioContextProvider = ({
|
|
7440
|
+
children,
|
|
7441
|
+
audioLatencyHint,
|
|
7442
|
+
audioEnabled,
|
|
7443
|
+
previewSampleRate,
|
|
7444
|
+
_experimentalKeepAudioContextAlive
|
|
7445
|
+
}) => {
|
|
7359
7446
|
const logLevel = useLogLevel();
|
|
7360
7447
|
const sampleRate = previewSampleRate ?? 48000;
|
|
7361
7448
|
useEffect7(() => {
|
|
@@ -7371,6 +7458,10 @@ var SharedAudioContextProvider = ({ children, audioLatencyHint, audioEnabled, pr
|
|
|
7371
7458
|
sampleRate
|
|
7372
7459
|
});
|
|
7373
7460
|
const audioContextIsPlayingEventually = useRef13(false);
|
|
7461
|
+
const initialExperimentalKeepAudioContextAlive = useRef13(_experimentalKeepAudioContextAlive);
|
|
7462
|
+
if (initialExperimentalKeepAudioContextAlive.current !== _experimentalKeepAudioContextAlive) {
|
|
7463
|
+
throw new Error("`_experimentalKeepAudioContextAlive` cannot be changed dynamically.");
|
|
7464
|
+
}
|
|
7374
7465
|
const isResuming = useRef13(null);
|
|
7375
7466
|
const nextResumeAttemptId = useRef13(0);
|
|
7376
7467
|
const audioSyncAnchor = useMemo23(() => ({ value: 0 }), []);
|
|
@@ -7415,7 +7506,7 @@ var SharedAudioContextProvider = ({ children, audioLatencyHint, audioEnabled, pr
|
|
|
7415
7506
|
reason: "audio context is closed"
|
|
7416
7507
|
};
|
|
7417
7508
|
}
|
|
7418
|
-
const saveForLater = shouldSaveForLater(currentState);
|
|
7509
|
+
const saveForLater = shouldSaveForLater(currentState) || _experimentalKeepAudioContextAlive && !audioContextIsPlayingEventually.current;
|
|
7419
7510
|
if (duration > 0) {
|
|
7420
7511
|
if (saveForLater) {
|
|
7421
7512
|
nodesToResume.current.set(node, {
|
|
@@ -7446,7 +7537,7 @@ var SharedAudioContextProvider = ({ children, audioLatencyHint, audioEnabled, pr
|
|
|
7446
7537
|
reason: "missed " + Math.abs(offset).toFixed(2) + "s"
|
|
7447
7538
|
};
|
|
7448
7539
|
};
|
|
7449
|
-
}, [ctxAndGain, logLevel]);
|
|
7540
|
+
}, [ctxAndGain, _experimentalKeepAudioContextAlive, logLevel]);
|
|
7450
7541
|
const resume = useCallback10(() => {
|
|
7451
7542
|
if (!ctxAndGain) {
|
|
7452
7543
|
return Promise.resolve();
|
|
@@ -7462,6 +7553,9 @@ var SharedAudioContextProvider = ({ children, audioLatencyHint, audioEnabled, pr
|
|
|
7462
7553
|
node.start(r.scheduledTime, r.offset, r.duration);
|
|
7463
7554
|
});
|
|
7464
7555
|
nodesToResume.current.clear();
|
|
7556
|
+
if (_experimentalKeepAudioContextAlive && ctxAndGain.audioContext.state === "running") {
|
|
7557
|
+
return Promise.resolve();
|
|
7558
|
+
}
|
|
7465
7559
|
const resumePromise = ctxAndGain.resume();
|
|
7466
7560
|
const abortController = new AbortController;
|
|
7467
7561
|
const resumeAttemptId = nextResumeAttemptId.current++;
|
|
@@ -7483,7 +7577,7 @@ var SharedAudioContextProvider = ({ children, audioLatencyHint, audioEnabled, pr
|
|
|
7483
7577
|
promise: waitPromise
|
|
7484
7578
|
};
|
|
7485
7579
|
return resumePromise.catch(() => {});
|
|
7486
|
-
}, [ctxAndGain, logLevel]);
|
|
7580
|
+
}, [ctxAndGain, _experimentalKeepAudioContextAlive, logLevel]);
|
|
7487
7581
|
const getIsResumingAudioContext = useCallback10(() => {
|
|
7488
7582
|
return isResuming.current?.promise ?? null;
|
|
7489
7583
|
}, []);
|
|
@@ -7496,8 +7590,41 @@ var SharedAudioContextProvider = ({ children, audioLatencyHint, audioEnabled, pr
|
|
|
7496
7590
|
return Promise.resolve();
|
|
7497
7591
|
}
|
|
7498
7592
|
audioContextIsPlayingEventually.current = false;
|
|
7593
|
+
if (_experimentalKeepAudioContextAlive) {
|
|
7594
|
+
ctxAndGain.gainNode.gain.cancelScheduledValues(ctxAndGain.audioContext.currentTime);
|
|
7595
|
+
ctxAndGain.gainNode.gain.setValueAtTime(0, ctxAndGain.audioContext.currentTime);
|
|
7596
|
+
return Promise.resolve();
|
|
7597
|
+
}
|
|
7499
7598
|
return ctxAndGain.suspend();
|
|
7500
|
-
}, [ctxAndGain]);
|
|
7599
|
+
}, [ctxAndGain, _experimentalKeepAudioContextAlive]);
|
|
7600
|
+
useEffect7(() => {
|
|
7601
|
+
if (!_experimentalKeepAudioContextAlive) {
|
|
7602
|
+
return;
|
|
7603
|
+
}
|
|
7604
|
+
if (!ctxAndGain) {
|
|
7605
|
+
return;
|
|
7606
|
+
}
|
|
7607
|
+
if (typeof window === "undefined") {
|
|
7608
|
+
return;
|
|
7609
|
+
}
|
|
7610
|
+
const wake = () => {
|
|
7611
|
+
if (ctxAndGain.audioContext.state === "running") {
|
|
7612
|
+
return;
|
|
7613
|
+
}
|
|
7614
|
+
ctxAndGain.resume().catch(() => {});
|
|
7615
|
+
};
|
|
7616
|
+
wake();
|
|
7617
|
+
window.addEventListener("pointerdown", wake, {
|
|
7618
|
+
capture: true,
|
|
7619
|
+
passive: true
|
|
7620
|
+
});
|
|
7621
|
+
window.addEventListener("keydown", wake, { capture: true, passive: true });
|
|
7622
|
+
return () => {
|
|
7623
|
+
window.removeEventListener("pointerdown", wake, { capture: true });
|
|
7624
|
+
window.removeEventListener("keydown", wake, { capture: true });
|
|
7625
|
+
ctxAndGain.suspend().catch(() => {});
|
|
7626
|
+
};
|
|
7627
|
+
}, [ctxAndGain, _experimentalKeepAudioContextAlive]);
|
|
7501
7628
|
const audioContextValue = useMemo23(() => {
|
|
7502
7629
|
return {
|
|
7503
7630
|
audioContext: ctxAndGain?.audioContext ?? null,
|
|
@@ -7509,7 +7636,8 @@ var SharedAudioContextProvider = ({ children, audioLatencyHint, audioEnabled, pr
|
|
|
7509
7636
|
resume,
|
|
7510
7637
|
suspend,
|
|
7511
7638
|
getIsResumingAudioContext,
|
|
7512
|
-
unscheduleAudioNode
|
|
7639
|
+
unscheduleAudioNode,
|
|
7640
|
+
_experimentalKeepAudioContextAlive
|
|
7513
7641
|
};
|
|
7514
7642
|
}, [
|
|
7515
7643
|
ctxAndGain,
|
|
@@ -7519,7 +7647,8 @@ var SharedAudioContextProvider = ({ children, audioLatencyHint, audioEnabled, pr
|
|
|
7519
7647
|
resume,
|
|
7520
7648
|
suspend,
|
|
7521
7649
|
getIsResumingAudioContext,
|
|
7522
|
-
unscheduleAudioNode
|
|
7650
|
+
unscheduleAudioNode,
|
|
7651
|
+
_experimentalKeepAudioContextAlive
|
|
7523
7652
|
]);
|
|
7524
7653
|
return /* @__PURE__ */ jsx20(SharedAudioContext.Provider, {
|
|
7525
7654
|
value: audioContextValue,
|
|
@@ -11775,7 +11904,8 @@ var RemotionRootContexts = ({
|
|
|
11775
11904
|
previewSampleRate,
|
|
11776
11905
|
videoEnabled,
|
|
11777
11906
|
audioEnabled,
|
|
11778
|
-
frameState
|
|
11907
|
+
frameState,
|
|
11908
|
+
_experimentalKeepAudioContextAlive
|
|
11779
11909
|
}) => {
|
|
11780
11910
|
const nonceContext = useMemo36(() => {
|
|
11781
11911
|
let counter = 0;
|
|
@@ -11804,6 +11934,7 @@ var RemotionRootContexts = ({
|
|
|
11804
11934
|
audioLatencyHint,
|
|
11805
11935
|
audioEnabled,
|
|
11806
11936
|
previewSampleRate,
|
|
11937
|
+
_experimentalKeepAudioContextAlive,
|
|
11807
11938
|
children: /* @__PURE__ */ jsx33(SharedAudioTagsContextProvider, {
|
|
11808
11939
|
numberOfAudioTags,
|
|
11809
11940
|
children
|