nucleus-core-ts 0.10.183 → 0.10.185
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/.build-ok +1 -1
- package/dist/fe/components/DemoFilm/_components/Caption/index.d.ts +11 -0
- package/dist/fe/components/DemoFilm/_components/Caption/index.js +42 -0
- package/dist/fe/components/DemoFilm/_components/DemoFilmRoot/index.d.ts +15 -0
- package/dist/fe/components/DemoFilm/_components/DemoFilmRoot/index.js +26 -0
- package/dist/fe/components/DemoFilm/_components/DeviceFrame/BrowserBar.d.ts +8 -0
- package/dist/fe/components/DemoFilm/_components/DeviceFrame/BrowserBar.js +50 -0
- package/dist/fe/components/DemoFilm/_components/DeviceFrame/Island.d.ts +5 -0
- package/dist/fe/components/DemoFilm/_components/DeviceFrame/Island.js +16 -0
- package/dist/fe/components/DemoFilm/_components/DeviceFrame/index.d.ts +11 -0
- package/dist/fe/components/DemoFilm/_components/DeviceFrame/index.js +46 -0
- package/dist/fe/components/DemoFilm/_components/FilmImage/index.d.ts +11 -0
- package/dist/fe/components/DemoFilm/_components/FilmImage/index.js +14 -0
- package/dist/fe/components/DemoFilm/_components/FilmPlayer/index.d.ts +25 -0
- package/dist/fe/components/DemoFilm/_components/FilmPlayer/index.js +86 -0
- package/dist/fe/components/DemoFilm/_components/Highlight/index.d.ts +13 -0
- package/dist/fe/components/DemoFilm/_components/Highlight/index.js +62 -0
- package/dist/fe/components/DemoFilm/_components/RoleStage/Body.d.ts +14 -0
- package/dist/fe/components/DemoFilm/_components/RoleStage/Body.js +67 -0
- package/dist/fe/components/DemoFilm/_components/RoleStage/RoleLabel.d.ts +10 -0
- package/dist/fe/components/DemoFilm/_components/RoleStage/RoleLabel.js +30 -0
- package/dist/fe/components/DemoFilm/_components/RoleStage/index.d.ts +8 -0
- package/dist/fe/components/DemoFilm/_components/RoleStage/index.js +36 -0
- package/dist/fe/components/DemoFilm/_components/ScreenImage/index.d.ts +11 -0
- package/dist/fe/components/DemoFilm/_components/ScreenImage/index.js +58 -0
- package/dist/fe/components/DemoFilm/_components/index.d.ts +8 -0
- package/dist/fe/components/DemoFilm/_components/index.js +8 -0
- package/dist/fe/components/DemoFilm/_hooks/index.d.ts +5 -0
- package/dist/fe/components/DemoFilm/_hooks/index.js +5 -0
- package/dist/fe/components/DemoFilm/_hooks/useDemoBeat.d.ts +3 -0
- package/dist/fe/components/DemoFilm/_hooks/useDemoBeat.js +24 -0
- package/dist/fe/components/DemoFilm/_hooks/useDemoFilm.d.ts +4 -0
- package/dist/fe/components/DemoFilm/_hooks/useDemoFilm.js +7 -0
- package/dist/fe/components/DemoFilm/_hooks/useFilmClock.d.ts +4 -0
- package/dist/fe/components/DemoFilm/_hooks/useFilmClock.js +7 -0
- package/dist/fe/components/DemoFilm/_hooks/usePlayback.d.ts +25 -0
- package/dist/fe/components/DemoFilm/_hooks/usePlayback.js +102 -0
- package/dist/fe/components/DemoFilm/_hooks/useReducedMotion.d.ts +2 -0
- package/dist/fe/components/DemoFilm/_hooks/useReducedMotion.js +14 -0
- package/dist/fe/components/DemoFilm/_host/index.d.ts +2 -0
- package/dist/fe/components/DemoFilm/_host/index.js +2 -0
- package/dist/fe/components/DemoFilm/_host/mountDemoFilmHost.d.ts +9 -0
- package/dist/fe/components/DemoFilm/_host/mountDemoFilmHost.js +60 -0
- package/dist/fe/components/DemoFilm/_host/types.d.ts +35 -0
- package/dist/fe/components/DemoFilm/_host/types.js +1 -0
- package/dist/fe/components/DemoFilm/_types/clock.d.ts +31 -0
- package/dist/fe/components/DemoFilm/_types/clock.js +1 -0
- package/dist/fe/components/DemoFilm/_types/device.d.ts +18 -0
- package/dist/fe/components/DemoFilm/_types/device.js +1 -0
- package/dist/fe/components/DemoFilm/_types/index.d.ts +6 -0
- package/dist/fe/components/DemoFilm/_types/index.js +6 -0
- package/dist/fe/components/DemoFilm/_types/player.d.ts +25 -0
- package/dist/fe/components/DemoFilm/_types/player.js +1 -0
- package/dist/fe/components/DemoFilm/_types/stage.d.ts +28 -0
- package/dist/fe/components/DemoFilm/_types/stage.js +1 -0
- package/dist/fe/components/DemoFilm/_types/theme.d.ts +38 -0
- package/dist/fe/components/DemoFilm/_types/theme.js +1 -0
- package/dist/fe/components/DemoFilm/_types/timeline.d.ts +49 -0
- package/dist/fe/components/DemoFilm/_types/timeline.js +5 -0
- package/dist/fe/components/DemoFilm/_utils/demoAssetUrl.d.ts +5 -0
- package/dist/fe/components/DemoFilm/_utils/demoAssetUrl.js +6 -0
- package/dist/fe/components/DemoFilm/_utils/device.d.ts +7 -0
- package/dist/fe/components/DemoFilm/_utils/device.js +50 -0
- package/dist/fe/components/DemoFilm/_utils/easing.d.ts +6 -0
- package/dist/fe/components/DemoFilm/_utils/easing.js +71 -0
- package/dist/fe/components/DemoFilm/_utils/index.d.ts +10 -0
- package/dist/fe/components/DemoFilm/_utils/index.js +10 -0
- package/dist/fe/components/DemoFilm/_utils/interpolate.d.ts +14 -0
- package/dist/fe/components/DemoFilm/_utils/interpolate.js +46 -0
- package/dist/fe/components/DemoFilm/_utils/motion.d.ts +6 -0
- package/dist/fe/components/DemoFilm/_utils/motion.js +19 -0
- package/dist/fe/components/DemoFilm/_utils/spring.d.ts +24 -0
- package/dist/fe/components/DemoFilm/_utils/spring.js +73 -0
- package/dist/fe/components/DemoFilm/_utils/stageSize.d.ts +9 -0
- package/dist/fe/components/DemoFilm/_utils/stageSize.js +19 -0
- package/dist/fe/components/DemoFilm/_utils/text.d.ts +3 -0
- package/dist/fe/components/DemoFilm/_utils/text.js +3 -0
- package/dist/fe/components/DemoFilm/_utils/theme.d.ts +7 -0
- package/dist/fe/components/DemoFilm/_utils/theme.js +137 -0
- package/dist/fe/components/DemoFilm/_utils/timeline.d.ts +13 -0
- package/dist/fe/components/DemoFilm/_utils/timeline.js +32 -0
- package/dist/fe/components/DemoFilm/index.d.ts +4 -0
- package/dist/fe/components/DemoFilm/index.js +4 -0
- package/dist/fe/index.d.ts +1 -0
- package/dist/fe/index.js +1 -0
- package/dist/index.js +8 -8
- package/dist/server.js +11 -11
- package/dist/src/Data/exprTypes.d.ts +29 -0
- package/dist/src/Data/index.d.ts +3 -2
- package/dist/src/Data/ruleContext.d.ts +3 -1
- package/dist/src/Data/ruleRefusals.d.ts +9 -0
- package/dist/src/Data/ruleTestKit.d.ts +2 -1
- package/dist/src/Data/ruleTypes.d.ts +12 -1
- package/dist/src/Data/unitBypass.d.ts +24 -0
- package/dist/src/Data/unitTypes.d.ts +8 -0
- package/dist/src/Data/viewAggTestKit.d.ts +1 -1
- package/dist/src/Nucleus/routes/auth/sessionPools.d.ts +16 -0
- package/dist/src/Nucleus/routes/tenant/selfSignupRateLimit.d.ts +19 -0
- package/dist/src/Nucleus/routes/tenant/types.d.ts +3 -0
- package/dist/src/Services/Auth/accountErasure.d.ts +6 -0
- package/dist/src/types.d.ts +2 -0
- package/package.json +21 -3
- package/scripts/demo-film/chrome.ts +75 -0
- package/scripts/demo-film/encoder.ts +99 -0
- package/scripts/demo-film/film.testkit.tsx +23 -0
- package/scripts/demo-film/frames.ts +47 -0
- package/scripts/demo-film/index.ts +17 -0
- package/scripts/demo-film/mp4.ts +62 -0
- package/scripts/demo-film/pageGlobals.d.ts +21 -0
- package/scripts/demo-film/render.test.ts +133 -0
- package/scripts/demo-film/renderFilm.ts +53 -0
- package/scripts/demo-film/renderStill.ts +30 -0
- package/scripts/demo-film/session.ts +66 -0
- package/scripts/demo-film/site.ts +97 -0
- package/scripts/demo-film/types.ts +63 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a run's files live: `assetBase` is a URL or an absolute path to the run folder, and `path`
|
|
3
|
+
* is relative to it. The page serves it from a public folder; the MP4 renderer serves the same layout.
|
|
4
|
+
*/
|
|
5
|
+
export declare function demoAssetUrl(assetBase: string, path: string): string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a run's files live: `assetBase` is a URL or an absolute path to the run folder, and `path`
|
|
3
|
+
* is relative to it. The page serves it from a public folder; the MP4 renderer serves the same layout.
|
|
4
|
+
*/ export function demoAssetUrl(assetBase, path) {
|
|
5
|
+
return `${assetBase.replace(/\/+$/, '')}/${path}`;
|
|
6
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DemoViewport, DeviceChrome, DeviceFit, DeviceKind, DeviceMap } from '../_types';
|
|
2
|
+
/** The device a role is shown on; a browser window unless the map says otherwise. */
|
|
3
|
+
export declare function deviceKindOf<Role extends string>(devices: DeviceMap<Role>, role: Role): DeviceKind;
|
|
4
|
+
/** Chrome sizes for a screen `screenWidth` px wide. */
|
|
5
|
+
export declare function deviceChromeOf(kind: DeviceKind, screenWidth: number): DeviceChrome;
|
|
6
|
+
/** The biggest device of `kind` that fits a box, screen aspect from the viewport. */
|
|
7
|
+
export declare function fitDevice(kind: DeviceKind, viewport: DemoViewport, boxW: number, boxH: number): DeviceFit;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** The device a role is shown on; a browser window unless the map says otherwise. */ export function deviceKindOf(devices, role) {
|
|
2
|
+
return devices[role] ?? 'browser';
|
|
3
|
+
}
|
|
4
|
+
/** Chrome sizes for a screen `screenWidth` px wide. */ export function deviceChromeOf(kind, screenWidth) {
|
|
5
|
+
if (kind === 'phone') {
|
|
6
|
+
const pad = Math.max(4, screenWidth * 0.04);
|
|
7
|
+
return {
|
|
8
|
+
kind,
|
|
9
|
+
pad,
|
|
10
|
+
top: pad,
|
|
11
|
+
radius: screenWidth * 0.16
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
if (kind === 'tablet') {
|
|
15
|
+
const pad = Math.max(5, screenWidth * 0.022);
|
|
16
|
+
return {
|
|
17
|
+
kind,
|
|
18
|
+
pad,
|
|
19
|
+
top: pad,
|
|
20
|
+
radius: screenWidth * 0.04
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const pad = Math.max(2, screenWidth * 0.004);
|
|
24
|
+
return {
|
|
25
|
+
kind,
|
|
26
|
+
pad,
|
|
27
|
+
top: Math.max(18, screenWidth * 0.032),
|
|
28
|
+
radius: Math.max(8, screenWidth * 0.012)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** The biggest device of `kind` that fits a box, screen aspect from the viewport. */ export function fitDevice(kind, viewport, boxW, boxH) {
|
|
32
|
+
const ratio = viewport.height / viewport.width;
|
|
33
|
+
// chrome grows with the screen width, so solve by a few refinements.
|
|
34
|
+
let screenWidth = Math.min(boxW, boxH / ratio);
|
|
35
|
+
for(let i = 0; i < 4; i++){
|
|
36
|
+
const chrome = deviceChromeOf(kind, screenWidth);
|
|
37
|
+
const w = boxW - chrome.pad * 2;
|
|
38
|
+
const h = (boxH - chrome.top - chrome.pad) / ratio;
|
|
39
|
+
screenWidth = Math.max(8, Math.min(w, h));
|
|
40
|
+
}
|
|
41
|
+
const chrome = deviceChromeOf(kind, screenWidth);
|
|
42
|
+
const screenHeight = screenWidth * ratio;
|
|
43
|
+
return {
|
|
44
|
+
screenWidth,
|
|
45
|
+
screenHeight,
|
|
46
|
+
chrome,
|
|
47
|
+
width: screenWidth + chrome.pad * 2,
|
|
48
|
+
height: screenHeight + chrome.top + chrome.pad
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type EasingFn = (progress: number) => number;
|
|
2
|
+
/**
|
|
3
|
+
* CSS-style cubic-bezier easing through (0,0), (x1,y1), (x2,y2), (1,1). The same solver Remotion's
|
|
4
|
+
* `Easing.bezier` used (sample table, Newton-Raphson, bisection fallback), so curves match exactly.
|
|
5
|
+
*/
|
|
6
|
+
export declare function bezier(x1: number, y1: number, x2: number, y2: number): EasingFn;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const NEWTON_ITERATIONS = 4;
|
|
2
|
+
const NEWTON_MIN_SLOPE = 0.001;
|
|
3
|
+
const SUBDIVISION_PRECISION = 0.0000001;
|
|
4
|
+
const SUBDIVISION_MAX_ITERATIONS = 10;
|
|
5
|
+
const SPLINE_TABLE_SIZE = 11;
|
|
6
|
+
const SAMPLE_STEP = 1 / (SPLINE_TABLE_SIZE - 1);
|
|
7
|
+
const coefA = (a1, a2)=>1 - 3 * a2 + 3 * a1;
|
|
8
|
+
const coefB = (a1, a2)=>3 * a2 - 6 * a1;
|
|
9
|
+
const coefC = (a1)=>3 * a1;
|
|
10
|
+
/** x(t) or y(t) of the cubic with control values `a1`, `a2`. */ function calc(t, a1, a2) {
|
|
11
|
+
return ((coefA(a1, a2) * t + coefB(a1, a2)) * t + coefC(a1)) * t;
|
|
12
|
+
}
|
|
13
|
+
function slope(t, a1, a2) {
|
|
14
|
+
return 3 * coefA(a1, a2) * t * t + 2 * coefB(a1, a2) * t + coefC(a1);
|
|
15
|
+
}
|
|
16
|
+
function subdivide(x, start, end, x1, x2) {
|
|
17
|
+
let low = start;
|
|
18
|
+
let high = end;
|
|
19
|
+
let t = low;
|
|
20
|
+
let error = 0;
|
|
21
|
+
let i = 0;
|
|
22
|
+
do {
|
|
23
|
+
t = low + (high - low) / 2;
|
|
24
|
+
error = calc(t, x1, x2) - x;
|
|
25
|
+
if (error > 0) high = t;
|
|
26
|
+
else low = t;
|
|
27
|
+
}while (Math.abs(error) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS)
|
|
28
|
+
return t;
|
|
29
|
+
}
|
|
30
|
+
function newton(x, guess, x1, x2) {
|
|
31
|
+
let t = guess;
|
|
32
|
+
for(let i = 0; i < NEWTON_ITERATIONS; i++){
|
|
33
|
+
const s = slope(t, x1, x2);
|
|
34
|
+
if (s === 0) return t;
|
|
35
|
+
t -= (calc(t, x1, x2) - x) / s;
|
|
36
|
+
}
|
|
37
|
+
return t;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* CSS-style cubic-bezier easing through (0,0), (x1,y1), (x2,y2), (1,1). The same solver Remotion's
|
|
41
|
+
* `Easing.bezier` used (sample table, Newton-Raphson, bisection fallback), so curves match exactly.
|
|
42
|
+
*/ export function bezier(x1, y1, x2, y2) {
|
|
43
|
+
if (!(x1 >= 0 && x1 <= 1 && x2 >= 0 && x2 <= 1)) throw new Error('bezier x values must be in [0, 1] range');
|
|
44
|
+
const linear = x1 === y1 && x2 === y2;
|
|
45
|
+
const samples = new Float32Array(SPLINE_TABLE_SIZE);
|
|
46
|
+
if (!linear) for(let i = 0; i < SPLINE_TABLE_SIZE; i++)samples[i] = calc(i * SAMPLE_STEP, x1, x2);
|
|
47
|
+
const sample = (i)=>samples[i] ?? 0;
|
|
48
|
+
const tForX = (x)=>{
|
|
49
|
+
let start = 0;
|
|
50
|
+
let current = 1;
|
|
51
|
+
const last = SPLINE_TABLE_SIZE - 1;
|
|
52
|
+
while(current !== last && sample(current) <= x){
|
|
53
|
+
current++;
|
|
54
|
+
start += SAMPLE_STEP;
|
|
55
|
+
}
|
|
56
|
+
current--;
|
|
57
|
+
const dist = (x - sample(current)) / (sample(current + 1) - sample(current));
|
|
58
|
+
const guess = start + dist * SAMPLE_STEP;
|
|
59
|
+
const initial = slope(guess, x1, x2);
|
|
60
|
+
if (initial >= NEWTON_MIN_SLOPE) return newton(x, guess, x1, x2);
|
|
61
|
+
if (initial === 0) return guess;
|
|
62
|
+
return subdivide(x, start, start + SAMPLE_STEP, x1, x2);
|
|
63
|
+
};
|
|
64
|
+
return (progress)=>{
|
|
65
|
+
const x = Math.min(1, Math.max(0, progress));
|
|
66
|
+
if (linear) return x;
|
|
67
|
+
if (x === 0) return 0;
|
|
68
|
+
if (x === 1) return 1;
|
|
69
|
+
return calc(tForX(x), y1, y2);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './demoAssetUrl';
|
|
2
|
+
export * from './device';
|
|
3
|
+
export * from './easing';
|
|
4
|
+
export * from './interpolate';
|
|
5
|
+
export * from './motion';
|
|
6
|
+
export * from './spring';
|
|
7
|
+
export * from './stageSize';
|
|
8
|
+
export * from './text';
|
|
9
|
+
export * from './theme';
|
|
10
|
+
export * from './timeline';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './demoAssetUrl';
|
|
2
|
+
export * from './device';
|
|
3
|
+
export * from './easing';
|
|
4
|
+
export * from './interpolate';
|
|
5
|
+
export * from './motion';
|
|
6
|
+
export * from './spring';
|
|
7
|
+
export * from './stageSize';
|
|
8
|
+
export * from './text';
|
|
9
|
+
export * from './theme';
|
|
10
|
+
export * from './timeline';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EasingFn } from './easing';
|
|
2
|
+
/** What happens outside the input range: hold the end (clamp), keep going (extend), return the input (identity) or repeat (wrap). */
|
|
3
|
+
export type Extrapolate = 'extend' | 'clamp' | 'identity' | 'wrap';
|
|
4
|
+
export interface InterpolateOptions {
|
|
5
|
+
easing?: EasingFn;
|
|
6
|
+
extrapolateLeft?: Extrapolate;
|
|
7
|
+
extrapolateRight?: Extrapolate;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Maps `value` from `inputRange` to `outputRange` (piecewise linear for longer ranges), with an
|
|
11
|
+
* easing and per-side extrapolation. A pure function of its arguments, ported from Remotion's
|
|
12
|
+
* `interpolate` for numbers (extrapolate defaults to 'extend', easing to linear).
|
|
13
|
+
*/
|
|
14
|
+
export declare function interpolate(value: number, inputRange: readonly number[], outputRange: readonly number[], options?: InterpolateOptions): number;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const linear = (t)=>t;
|
|
2
|
+
function assertRanges(input, output) {
|
|
3
|
+
if (input.length !== output.length) throw new Error(`inputRange (${input.length}) and outputRange (${output.length}) differ in length`);
|
|
4
|
+
if (input.length < 2) throw new Error('inputRange needs at least two values');
|
|
5
|
+
for(let i = 1; i < input.length; i++){
|
|
6
|
+
const prev = input[i - 1];
|
|
7
|
+
const next = input[i];
|
|
8
|
+
if (prev === undefined || next === undefined || !(next > prev)) throw new Error('inputRange must be strictly increasing');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/** Index of the segment holding `value`; the first or last segment when it lies outside. */ function segmentOf(value, input) {
|
|
12
|
+
let i = 1;
|
|
13
|
+
for(; i < input.length - 1; i++)if ((input[i] ?? Infinity) >= value) break;
|
|
14
|
+
return i - 1;
|
|
15
|
+
}
|
|
16
|
+
function wrap(value, min, max) {
|
|
17
|
+
const span = max - min;
|
|
18
|
+
return ((value - min) % span + span) % span + min;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Maps `value` from `inputRange` to `outputRange` (piecewise linear for longer ranges), with an
|
|
22
|
+
* easing and per-side extrapolation. A pure function of its arguments, ported from Remotion's
|
|
23
|
+
* `interpolate` for numbers (extrapolate defaults to 'extend', easing to linear).
|
|
24
|
+
*/ export function interpolate(value, inputRange, outputRange, options = {}) {
|
|
25
|
+
assertRanges(inputRange, outputRange);
|
|
26
|
+
const { easing = linear, extrapolateLeft = 'extend', extrapolateRight = 'extend' } = options;
|
|
27
|
+
const at = segmentOf(value, inputRange);
|
|
28
|
+
const inMin = inputRange[at] ?? 0;
|
|
29
|
+
const inMax = inputRange[at + 1] ?? 1;
|
|
30
|
+
const outMin = outputRange[at] ?? 0;
|
|
31
|
+
const outMax = outputRange[at + 1] ?? 0;
|
|
32
|
+
let result = value;
|
|
33
|
+
if (result < inMin) {
|
|
34
|
+
if (extrapolateLeft === 'identity') return result;
|
|
35
|
+
if (extrapolateLeft === 'clamp') result = inMin;
|
|
36
|
+
else if (extrapolateLeft === 'wrap') result = wrap(result, inMin, inMax);
|
|
37
|
+
}
|
|
38
|
+
if (result > inMax) {
|
|
39
|
+
if (extrapolateRight === 'identity') return result;
|
|
40
|
+
if (extrapolateRight === 'clamp') result = inMax;
|
|
41
|
+
else if (extrapolateRight === 'wrap') result = wrap(result, inMin, inMax);
|
|
42
|
+
}
|
|
43
|
+
if (outMin === outMax) return outMin;
|
|
44
|
+
const progress = easing((result - inMin) / (inMax - inMin));
|
|
45
|
+
return progress * (outMax - outMin) + outMin;
|
|
46
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Ease-out curve used for every reveal: cubic-bezier(0.2, 0.8, 0.2, 1). */
|
|
2
|
+
export declare const FILM_PASS: import("./easing").EasingFn;
|
|
3
|
+
/** 0 to 1 over `duration` frames starting at `from`, eased and clamped. */
|
|
4
|
+
export declare function filmReveal(frame: number, from: number, duration: number): number;
|
|
5
|
+
/** 1 to 0 over the last `duration` frames before `end`. */
|
|
6
|
+
export declare function filmLeave(frame: number, end: number, duration: number): number;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { bezier } from './easing';
|
|
2
|
+
import { interpolate } from './interpolate';
|
|
3
|
+
/** Ease-out curve used for every reveal: cubic-bezier(0.2, 0.8, 0.2, 1). */ export const FILM_PASS = bezier(0.2, 0.8, 0.2, 1);
|
|
4
|
+
/** 0 to 1 over `duration` frames starting at `from`, eased and clamped. */ export function filmReveal(frame, from, duration) {
|
|
5
|
+
return interpolate(frame, [
|
|
6
|
+
from,
|
|
7
|
+
from + duration
|
|
8
|
+
], [
|
|
9
|
+
0,
|
|
10
|
+
1
|
|
11
|
+
], {
|
|
12
|
+
extrapolateLeft: 'clamp',
|
|
13
|
+
extrapolateRight: 'clamp',
|
|
14
|
+
easing: FILM_PASS
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/** 1 to 0 over the last `duration` frames before `end`. */ export function filmLeave(frame, end, duration) {
|
|
18
|
+
return 1 - filmReveal(frame, end - duration, duration);
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface SpringConfig {
|
|
2
|
+
/** Friction; higher settles sooner with less overshoot. Must be above 0. */
|
|
3
|
+
damping?: number;
|
|
4
|
+
mass?: number;
|
|
5
|
+
stiffness?: number;
|
|
6
|
+
/** Never pass the target. */
|
|
7
|
+
overshootClamping?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface SpringOptions {
|
|
10
|
+
/** The frame to evaluate; fractions and negatives are fine (a negative frame is the rest position). */
|
|
11
|
+
frame: number;
|
|
12
|
+
fps: number;
|
|
13
|
+
config?: SpringConfig;
|
|
14
|
+
from?: number;
|
|
15
|
+
to?: number;
|
|
16
|
+
/** Frames to wait before the spring is released. */
|
|
17
|
+
delay?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A damped spring from `from` to `to` (default 0 to 1) evaluated at `frame`: a pure function and the
|
|
21
|
+
* same simulation as Remotion's `spring` (one fixed step per frame, 64 ms step cap), so motion
|
|
22
|
+
* matches the old renders. Defaults: damping 10, mass 1, stiffness 100.
|
|
23
|
+
*/
|
|
24
|
+
export declare function spring({ frame, fps, config, from, to, delay, }: SpringOptions): number;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { interpolate } from './interpolate';
|
|
2
|
+
const MAX_STEP_MS = 64;
|
|
3
|
+
const REST = {
|
|
4
|
+
current: 0,
|
|
5
|
+
velocity: 0,
|
|
6
|
+
at: 0
|
|
7
|
+
};
|
|
8
|
+
/** One physics step of the damped oscillator from step `from` to time `now` (ms), towards 1. */ function advance(from, now, c) {
|
|
9
|
+
if (c.damping <= 0) throw new Error('Spring damping must be greater than 0');
|
|
10
|
+
const dt = Math.min(now - from.at, MAX_STEP_MS);
|
|
11
|
+
const v0 = -from.velocity;
|
|
12
|
+
const x0 = 1 - from.current;
|
|
13
|
+
const zeta = c.damping / (2 * Math.sqrt(c.stiffness * c.mass));
|
|
14
|
+
const omega0 = Math.sqrt(c.stiffness / c.mass);
|
|
15
|
+
const omega1 = omega0 * Math.sqrt(1 - zeta ** 2);
|
|
16
|
+
const t = dt / 1000;
|
|
17
|
+
if (zeta < 1) {
|
|
18
|
+
const envelope = Math.exp(-zeta * omega0 * t);
|
|
19
|
+
const sin = Math.sin(omega1 * t);
|
|
20
|
+
const cos = Math.cos(omega1 * t);
|
|
21
|
+
const frag = envelope * (sin * ((v0 + zeta * omega0 * x0) / omega1) + x0 * cos);
|
|
22
|
+
return {
|
|
23
|
+
current: 1 - frag,
|
|
24
|
+
velocity: zeta * omega0 * frag - envelope * (cos * (v0 + zeta * omega0 * x0) - omega1 * x0 * sin),
|
|
25
|
+
at: now
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const envelope = Math.exp(-omega0 * t);
|
|
29
|
+
return {
|
|
30
|
+
current: 1 - envelope * (x0 + (v0 + omega0 * x0) * t),
|
|
31
|
+
velocity: envelope * (v0 * (t * omega0 - 1) + t * x0 * omega0 * omega0),
|
|
32
|
+
at: now
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const tables = new Map();
|
|
36
|
+
/** Steps at whole frames 0..n for one (fps, config), grown on demand so later frames reuse earlier ones. */ function tableFor(fps, c) {
|
|
37
|
+
const key = `${fps}-${c.damping}-${c.mass}-${c.stiffness}`;
|
|
38
|
+
const known = tables.get(key);
|
|
39
|
+
if (known !== undefined) return known;
|
|
40
|
+
const fresh = [
|
|
41
|
+
REST
|
|
42
|
+
];
|
|
43
|
+
tables.set(key, fresh);
|
|
44
|
+
return fresh;
|
|
45
|
+
}
|
|
46
|
+
function stepAt(frame, fps, c) {
|
|
47
|
+
const table = tableFor(fps, c);
|
|
48
|
+
const whole = Math.floor(frame);
|
|
49
|
+
for(let f = table.length; f <= whole; f++)table.push(advance(table[f - 1] ?? REST, f / fps * 1000, c));
|
|
50
|
+
const base = table[whole] ?? REST;
|
|
51
|
+
return frame % 1 > 0 ? advance(base, frame / fps * 1000, c) : base;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A damped spring from `from` to `to` (default 0 to 1) evaluated at `frame`: a pure function and the
|
|
55
|
+
* same simulation as Remotion's `spring` (one fixed step per frame, 64 ms step cap), so motion
|
|
56
|
+
* matches the old renders. Defaults: damping 10, mass 1, stiffness 100.
|
|
57
|
+
*/ export function spring({ frame, fps, config = {}, from = 0, to = 1, delay = 0 }) {
|
|
58
|
+
const resolved = {
|
|
59
|
+
damping: config.damping ?? 10,
|
|
60
|
+
mass: config.mass ?? 1,
|
|
61
|
+
stiffness: config.stiffness ?? 100,
|
|
62
|
+
overshootClamping: config.overshootClamping ?? false
|
|
63
|
+
};
|
|
64
|
+
const { current } = stepAt(Math.max(0, frame - delay), fps, resolved);
|
|
65
|
+
const position = resolved.overshootClamping ? Math.min(current, 1) : current;
|
|
66
|
+
return from === 0 && to === 1 ? position : interpolate(position, [
|
|
67
|
+
0,
|
|
68
|
+
1
|
|
69
|
+
], [
|
|
70
|
+
from,
|
|
71
|
+
to
|
|
72
|
+
]);
|
|
73
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DemoTimeline, DeviceMap } from '../_types';
|
|
2
|
+
/**
|
|
3
|
+
* Composition size of a RoleStage showing `role` with its screen at native size: device chrome, the
|
|
4
|
+
* caption band and the margins included. The renderer and the page's FilmPlayer both use it.
|
|
5
|
+
*/
|
|
6
|
+
export declare function roleStageSize<Role extends string>(timeline: DemoTimeline<Role>, role: Role, devices?: DeviceMap<Role>): {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { deviceChromeOf, deviceKindOf } from './device';
|
|
2
|
+
const GAP = 16;
|
|
3
|
+
const PAD = 8;
|
|
4
|
+
const CAPTION_SHARE = 0.17;
|
|
5
|
+
const MIN_WIDTH = 640;
|
|
6
|
+
const even = (n)=>Math.ceil(n / 2) * 2;
|
|
7
|
+
/**
|
|
8
|
+
* Composition size of a RoleStage showing `role` with its screen at native size: device chrome, the
|
|
9
|
+
* caption band and the margins included. The renderer and the page's FilmPlayer both use it.
|
|
10
|
+
*/ export function roleStageSize(timeline, role, devices = {}) {
|
|
11
|
+
const v = timeline.viewports[role];
|
|
12
|
+
const chrome = deviceChromeOf(deviceKindOf(devices, role), v.width);
|
|
13
|
+
const deviceW = v.width + chrome.pad * 2 + PAD;
|
|
14
|
+
const deviceH = v.height + chrome.top + chrome.pad + GAP + PAD;
|
|
15
|
+
return {
|
|
16
|
+
width: even(Math.max(MIN_WIDTH, deviceW)),
|
|
17
|
+
height: even(deviceH / (1 - CAPTION_SHARE))
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DemoFilmTheme, DemoFilmThemeOverride } from '../_types';
|
|
2
|
+
/** Sensible defaults: a calm paper and graphite pair with one blue accent. Products override them. */
|
|
3
|
+
export declare const DEFAULT_DEMO_FILM_THEME: DemoFilmTheme;
|
|
4
|
+
/** The defaults with a product's overrides merged in, group by group. */
|
|
5
|
+
export declare function resolveDemoFilmTheme(override?: DemoFilmThemeOverride): DemoFilmTheme;
|
|
6
|
+
/** The theme as a stylesheet scoped to `.nc-demo-film`, one block per theme. */
|
|
7
|
+
export declare function demoFilmCss(theme: DemoFilmTheme): string;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/** Sensible defaults: a calm paper and graphite pair with one blue accent. Products override them. */ export const DEFAULT_DEMO_FILM_THEME = {
|
|
2
|
+
light: {
|
|
3
|
+
bg: '#f4f5f7',
|
|
4
|
+
surface: '#ffffff',
|
|
5
|
+
surface2: '#e8eaee',
|
|
6
|
+
ink: '#14181f',
|
|
7
|
+
soft: '#434b58',
|
|
8
|
+
faint: '#5d6572',
|
|
9
|
+
line: '#d3d7de',
|
|
10
|
+
accent: '#2f6df6',
|
|
11
|
+
accentInk: '#1c4fc4',
|
|
12
|
+
onAccent: '#ffffff',
|
|
13
|
+
shadow: '0 1px 0 rgb(20 24 31 / .06), 0 18px 40px -18px rgb(20 24 31 / .35)',
|
|
14
|
+
bezel: '#0d0f12',
|
|
15
|
+
bezelLine: '#2a2f37'
|
|
16
|
+
},
|
|
17
|
+
dark: {
|
|
18
|
+
bg: '#0e1116',
|
|
19
|
+
surface: '#161a21',
|
|
20
|
+
surface2: '#1e232c',
|
|
21
|
+
ink: '#eef0f4',
|
|
22
|
+
soft: '#b6bcc8',
|
|
23
|
+
faint: '#99a1b0',
|
|
24
|
+
line: '#2a303b',
|
|
25
|
+
accent: '#5b8cff',
|
|
26
|
+
accentInk: '#8aaaff',
|
|
27
|
+
onAccent: '#08101f',
|
|
28
|
+
shadow: '0 1px 0 rgb(0 0 0 / .4), 0 22px 48px -18px rgb(0 0 0 / .8)',
|
|
29
|
+
bezel: '#050607',
|
|
30
|
+
bezelLine: '#2a2f37'
|
|
31
|
+
},
|
|
32
|
+
fonts: {
|
|
33
|
+
display: 'Georgia, ui-serif, serif',
|
|
34
|
+
sans: 'ui-sans-serif, "Segoe UI", sans-serif',
|
|
35
|
+
mono: 'ui-monospace, "Cascadia Mono", monospace'
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
/** The defaults with a product's overrides merged in, group by group. */ export function resolveDemoFilmTheme(override = {}) {
|
|
39
|
+
const base = DEFAULT_DEMO_FILM_THEME;
|
|
40
|
+
return {
|
|
41
|
+
light: {
|
|
42
|
+
...base.light,
|
|
43
|
+
...override.light
|
|
44
|
+
},
|
|
45
|
+
dark: {
|
|
46
|
+
...base.dark,
|
|
47
|
+
...override.dark
|
|
48
|
+
},
|
|
49
|
+
fonts: {
|
|
50
|
+
...base.fonts,
|
|
51
|
+
...override.fonts
|
|
52
|
+
},
|
|
53
|
+
extra: override.extra
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function paletteVars(p) {
|
|
57
|
+
return [
|
|
58
|
+
[
|
|
59
|
+
'--film-bg',
|
|
60
|
+
p.bg
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
'--film-surface',
|
|
64
|
+
p.surface
|
|
65
|
+
],
|
|
66
|
+
[
|
|
67
|
+
'--film-surface2',
|
|
68
|
+
p.surface2
|
|
69
|
+
],
|
|
70
|
+
[
|
|
71
|
+
'--film-ink',
|
|
72
|
+
p.ink
|
|
73
|
+
],
|
|
74
|
+
[
|
|
75
|
+
'--film-soft',
|
|
76
|
+
p.soft
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
'--film-faint',
|
|
80
|
+
p.faint
|
|
81
|
+
],
|
|
82
|
+
[
|
|
83
|
+
'--film-line',
|
|
84
|
+
p.line
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
'--film-accent',
|
|
88
|
+
p.accent
|
|
89
|
+
],
|
|
90
|
+
[
|
|
91
|
+
'--film-accent-ink',
|
|
92
|
+
p.accentInk
|
|
93
|
+
],
|
|
94
|
+
[
|
|
95
|
+
'--film-on-accent',
|
|
96
|
+
p.onAccent
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
'--film-shadow',
|
|
100
|
+
p.shadow
|
|
101
|
+
],
|
|
102
|
+
[
|
|
103
|
+
'--film-bezel',
|
|
104
|
+
p.bezel
|
|
105
|
+
],
|
|
106
|
+
[
|
|
107
|
+
'--film-bezel-line',
|
|
108
|
+
p.bezelLine
|
|
109
|
+
]
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
function declarations(vars) {
|
|
113
|
+
return vars.map(([name, value])=>`${name}:${value};`).join('');
|
|
114
|
+
}
|
|
115
|
+
function paletteOf(theme, which) {
|
|
116
|
+
return declarations([
|
|
117
|
+
...paletteVars(theme[which]),
|
|
118
|
+
...Object.entries(theme.extra?.[which] ?? {})
|
|
119
|
+
]);
|
|
120
|
+
}
|
|
121
|
+
/** The theme as a stylesheet scoped to `.nc-demo-film`, one block per theme. */ export function demoFilmCss(theme) {
|
|
122
|
+
const fonts = declarations([
|
|
123
|
+
[
|
|
124
|
+
'--film-display',
|
|
125
|
+
theme.fonts.display
|
|
126
|
+
],
|
|
127
|
+
[
|
|
128
|
+
'--film-sans',
|
|
129
|
+
theme.fonts.sans
|
|
130
|
+
],
|
|
131
|
+
[
|
|
132
|
+
'--film-mono',
|
|
133
|
+
theme.fonts.mono
|
|
134
|
+
]
|
|
135
|
+
]);
|
|
136
|
+
return `.nc-demo-film{${fonts}}` + `.nc-demo-film[data-theme="light"]{${paletteOf(theme, 'light')}}` + `.nc-demo-film[data-theme="dark"]{${paletteOf(theme, 'dark')}}`;
|
|
137
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DemoFrame, DemoTimeline } from '../_types';
|
|
2
|
+
/** Frame rate of the films and players built on this kit: the single default. */
|
|
3
|
+
export declare const DEMO_FILM_FPS = 30;
|
|
4
|
+
/** Seconds from the start of the film to the start of each beat. */
|
|
5
|
+
export declare function beatStarts<Role extends string>(timeline: DemoTimeline<Role>): number[];
|
|
6
|
+
/** Total length of the film in seconds. */
|
|
7
|
+
export declare function filmSeconds<Role extends string>(timeline: DemoTimeline<Role>): number;
|
|
8
|
+
/** Length of the film in whole frames (at least 1). */
|
|
9
|
+
export declare function filmFrames<Role extends string>(timeline: DemoTimeline<Role>, fps?: number): number;
|
|
10
|
+
/** The index of the beat playing at `second` (clamped to the film). */
|
|
11
|
+
export declare function beatAt<Role extends string>(timeline: DemoTimeline<Role>, second: number): number;
|
|
12
|
+
/** The frame a role shows at beat `index`: its own capture in that beat, else its latest earlier one. */
|
|
13
|
+
export declare function frameOf<Role extends string>(timeline: DemoTimeline<Role>, role: Role, index: number): DemoFrame | null;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Frame rate of the films and players built on this kit: the single default. */ export const DEMO_FILM_FPS = 30;
|
|
2
|
+
/** Seconds from the start of the film to the start of each beat. */ export function beatStarts(timeline) {
|
|
3
|
+
const starts = [];
|
|
4
|
+
let at = 0;
|
|
5
|
+
for (const beat of timeline.beats){
|
|
6
|
+
starts.push(at);
|
|
7
|
+
at += beat.seconds;
|
|
8
|
+
}
|
|
9
|
+
return starts;
|
|
10
|
+
}
|
|
11
|
+
/** Total length of the film in seconds. */ export function filmSeconds(timeline) {
|
|
12
|
+
return timeline.beats.reduce((sum, beat)=>sum + beat.seconds, 0);
|
|
13
|
+
}
|
|
14
|
+
/** Length of the film in whole frames (at least 1). */ export function filmFrames(timeline, fps = DEMO_FILM_FPS) {
|
|
15
|
+
return Math.max(1, Math.round(filmSeconds(timeline) * fps));
|
|
16
|
+
}
|
|
17
|
+
/** The index of the beat playing at `second` (clamped to the film). */ export function beatAt(timeline, second) {
|
|
18
|
+
const starts = beatStarts(timeline);
|
|
19
|
+
let index = 0;
|
|
20
|
+
for(let i = 0; i < starts.length; i++){
|
|
21
|
+
const start = starts[i];
|
|
22
|
+
if (start !== undefined && start <= second) index = i;
|
|
23
|
+
}
|
|
24
|
+
return index;
|
|
25
|
+
}
|
|
26
|
+
/** The frame a role shows at beat `index`: its own capture in that beat, else its latest earlier one. */ export function frameOf(timeline, role, index) {
|
|
27
|
+
for(let i = Math.min(index, timeline.beats.length - 1); i >= 0; i--){
|
|
28
|
+
const frame = timeline.beats[i]?.frames[role];
|
|
29
|
+
if (frame !== undefined) return frame;
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
package/dist/fe/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export { Checkbox } from './components/Checkbox';
|
|
|
16
16
|
export { DataTable } from './components/DataTable';
|
|
17
17
|
export { type DataTableLabels, DEFAULT_DATA_TABLE_LABELS } from './components/DataTable/labels';
|
|
18
18
|
export { DatePicker, type DatePickerLabels, DEFAULT_DATE_PICKER_LABELS, } from './components/DatePicker';
|
|
19
|
+
export * from './components/DemoFilm';
|
|
19
20
|
export type { ComponentCategory, ComponentEntry, ComponentExample, DesignSystemMethods, DesignSystemPageProps, DesignSystemState, PropControl, PropControlOption, PropControlType, ThemeMode, ViewportSize, } from './components/DesignSystem';
|
|
20
21
|
export { ComponentCanvas, ComponentSidebar, createDefaultRegistry, DesignSystemPage, designSystemTheme, extendDesignSystemTheme, PropsPanel, useDesignSystemStore, } from './components/DesignSystem';
|
|
21
22
|
export { DEFAULT_DESIGN_SYSTEM_LABELS, type DesignSystemLabels, } from './components/DesignSystem/labels';
|
package/dist/fe/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export { Checkbox } from './components/Checkbox';
|
|
|
14
14
|
export { DataTable } from './components/DataTable';
|
|
15
15
|
export { DEFAULT_DATA_TABLE_LABELS } from './components/DataTable/labels';
|
|
16
16
|
export { DatePicker, DEFAULT_DATE_PICKER_LABELS } from './components/DatePicker';
|
|
17
|
+
export * from './components/DemoFilm';
|
|
17
18
|
export { ComponentCanvas, ComponentSidebar, createDefaultRegistry, DesignSystemPage, designSystemTheme, extendDesignSystemTheme, PropsPanel, useDesignSystemStore } from './components/DesignSystem';
|
|
18
19
|
export { DEFAULT_DESIGN_SYSTEM_LABELS } from './components/DesignSystem/labels';
|
|
19
20
|
export { DeviceCard, DevicesHeader, DevicesPage, useDevicesStore } from './components/DevicesPage';
|