@cutcraft/player 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +102 -2
- package/dist/backdrop-BqrzCzTB.d.mts +131 -0
- package/dist/engine.d.mts +3 -0
- package/dist/engine.mjs +3 -0
- package/dist/frame-plan-BNwblf1s.mjs +1074 -0
- package/dist/index.d.mts +298 -0
- package/dist/index.mjs +1410 -0
- package/dist/layer-interiors-r4SeMbp2.d.mts +8 -0
- package/dist/nested-Bd4Y7qrF.d.mts +720 -0
- package/dist/nested-DSXA1q8d.mjs +1698 -0
- package/dist/overlays.d.mts +201 -0
- package/dist/overlays.mjs +3 -0
- package/dist/svg-element-BUXbz-U5.mjs +1736 -0
- package/fonts.css +23 -0
- package/package.json +67 -3
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { E as TransitionRole, N as layerClock, a as Motion, i as GraphicAnimation, l as motionAt, m as Matrix2D, r as ClipRect, t as OVERLAY_KINDS, u as Box } from "./backdrop-BqrzCzTB.mjs";
|
|
2
|
+
import { t as indexLayerInteriors } from "./layer-interiors-r4SeMbp2.mjs";
|
|
3
|
+
import { FitMode, Placement, ResolvedState, ResolvedTheme } from "@cutcraft/kit";
|
|
4
|
+
import { CSSProperties, ReactNode } from "react";
|
|
5
|
+
import { Label } from "@cutcraft/graphics";
|
|
6
|
+
interface ElementProps {
|
|
7
|
+
readonly placement: Placement;
|
|
8
|
+
readonly children: readonly Placement[];
|
|
9
|
+
readonly state: ResolvedState;
|
|
10
|
+
/** Composition time. */
|
|
11
|
+
readonly time: number;
|
|
12
|
+
/** The transition the element is in, if any. */
|
|
13
|
+
readonly transition?: TransitionRole | undefined;
|
|
14
|
+
}
|
|
15
|
+
/** Where and how an overlay of `size` composition pixels is drawn: its box, matrix, opacity, filter, blend and corner radius. */
|
|
16
|
+
interface OverlayLayout {
|
|
17
|
+
readonly rect: {
|
|
18
|
+
readonly w: number;
|
|
19
|
+
readonly h: number;
|
|
20
|
+
};
|
|
21
|
+
readonly matrix: Matrix2D;
|
|
22
|
+
readonly opacity: number;
|
|
23
|
+
/** A CSS filter list, or null. */
|
|
24
|
+
readonly filter: string | null;
|
|
25
|
+
/** A canvas compositing operation, or null for normal. */
|
|
26
|
+
readonly blend: GlobalCompositeOperation | null;
|
|
27
|
+
readonly borderRadius: number;
|
|
28
|
+
/** The part shown while an entrance or exit wipes or reveals it, in the element's own pixels; null for all. */
|
|
29
|
+
readonly clip: readonly ClipRect[] | null;
|
|
30
|
+
/** How much of its strokes are drawn (0..1) during a `draw` entrance or exit; null when not drawing. */
|
|
31
|
+
readonly draw: number | null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* `drawable` elements (shapes, SVG) draw their strokes progressively for a `draw` entrance;
|
|
35
|
+
* others fade instead.
|
|
36
|
+
*/
|
|
37
|
+
export declare function overlayLayout(p: ElementProps, size: Box, fit?: FitMode, drawable?: boolean): OverlayLayout;
|
|
38
|
+
/** A clip as a CSS `path()`: rectangles in the element's own pixels, an empty one when nothing shows. */
|
|
39
|
+
export declare function clipPathCss(clip: readonly ClipRect[]): string;
|
|
40
|
+
/** A title's box: its width and height props, the whole frame when left out. */
|
|
41
|
+
export declare function titleBox(props: Readonly<Record<string, unknown>>, comp: {
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
}): {
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
};
|
|
48
|
+
/** Text title: the file's text content with font props; entrance/exit presets as CSS transforms. */
|
|
49
|
+
export declare function titleContent(p: ElementProps & {
|
|
50
|
+
readonly text: string;
|
|
51
|
+
}): ReactNode;
|
|
52
|
+
/** The active caption lines, positioned by the captions style; karaoke colours words by their timing. */
|
|
53
|
+
export declare function captionsContent(p: {
|
|
54
|
+
readonly placement: Placement;
|
|
55
|
+
readonly state: ElementProps["state"];
|
|
56
|
+
readonly time: number;
|
|
57
|
+
}): ReactNode;
|
|
58
|
+
/** The interior as written, with the Layer's handles (edited props) applied to its one component. */
|
|
59
|
+
export declare function layerContent(interior: ReactNode, props: Readonly<Record<string, unknown>> | undefined): ReactNode;
|
|
60
|
+
/** The labelled box shown for a sticker with no media. */
|
|
61
|
+
export declare function stickerPlaceholder(label: string): ReactNode;
|
|
62
|
+
/** Side length of the box a sticker is drawn in. */
|
|
63
|
+
export declare function stickerSize(p: ElementProps): number;
|
|
64
|
+
/**
|
|
65
|
+
* SVG markup as both surfaces draw it. The browser preview inlines the string,
|
|
66
|
+
* the Node export rasterises it with skia, so whatever this module returns is
|
|
67
|
+
* what both show: it parses the markup once, drops what must not run, sizes the
|
|
68
|
+
* root to the element's box, renames ids so two elements never share one, puts
|
|
69
|
+
* theme tokens in, and applies the colour mode as an SVG filter (skia and the
|
|
70
|
+
* browser both implement the filters used here).
|
|
71
|
+
*/
|
|
72
|
+
interface SvgNode {
|
|
73
|
+
readonly name: string;
|
|
74
|
+
readonly attrs: Record<string, string>;
|
|
75
|
+
readonly children: (SvgNode | string)[];
|
|
76
|
+
}
|
|
77
|
+
interface SvgViewBox {
|
|
78
|
+
readonly minX: number;
|
|
79
|
+
readonly minY: number;
|
|
80
|
+
readonly width: number;
|
|
81
|
+
readonly height: number;
|
|
82
|
+
}
|
|
83
|
+
interface SvgColor {
|
|
84
|
+
readonly mode: "none" | "tint" | "replace";
|
|
85
|
+
readonly tint?: string;
|
|
86
|
+
readonly opacity?: number;
|
|
87
|
+
}
|
|
88
|
+
interface PrepareSvgOptions {
|
|
89
|
+
/** The box the root is drawn into, in pixels. */
|
|
90
|
+
readonly box: {
|
|
91
|
+
readonly width: number;
|
|
92
|
+
readonly height: number;
|
|
93
|
+
};
|
|
94
|
+
readonly viewBox?: SvgViewBox | undefined;
|
|
95
|
+
readonly preserveAspectRatio?: string | undefined;
|
|
96
|
+
readonly color?: SvgColor | undefined;
|
|
97
|
+
/** Values for `$name` and `var(--cc-name)` in attributes and styles. */
|
|
98
|
+
readonly tokens?: Readonly<Record<string, string>> | undefined;
|
|
99
|
+
/** Prefixed to every id, so two inline SVGs on one page cannot collide. */
|
|
100
|
+
readonly idPrefix?: string | undefined;
|
|
101
|
+
/** How much of the strokes are drawn (0..1); fills fade in over the last 40%. Omit for all of it. */
|
|
102
|
+
readonly draw?: number | null | undefined;
|
|
103
|
+
/** Room, in pixels, kept on every side of the box for strokes and shadows that reach past it. */
|
|
104
|
+
readonly bleed?: number | undefined;
|
|
105
|
+
/** Seconds into the element, for SMIL animation (see `svgAnimated`); 0 when omitted. */
|
|
106
|
+
readonly time?: number | undefined;
|
|
107
|
+
}
|
|
108
|
+
interface PreparedSvg {
|
|
109
|
+
readonly markup: string;
|
|
110
|
+
/** Whether the markup changes over time (SMIL), so a cached picture is not enough. */
|
|
111
|
+
readonly animated: boolean;
|
|
112
|
+
readonly warnings: readonly string[];
|
|
113
|
+
}
|
|
114
|
+
interface Parsed {
|
|
115
|
+
readonly root: SvgNode | null;
|
|
116
|
+
readonly warnings: readonly string[];
|
|
117
|
+
}
|
|
118
|
+
/** Parses SVG markup into a small tree; the result is cached by the markup string. */
|
|
119
|
+
export declare function parseSvg(markup: string): Parsed;
|
|
120
|
+
/** Whether markup animates (SMIL or CSS animations): such markup is prepared for each moment, the rest once. */
|
|
121
|
+
export declare function svgAnimated(markup: string): boolean;
|
|
122
|
+
/** The size an SVG asks for: its width and height, else its viewBox, else the HTML default of 300 by 150. */
|
|
123
|
+
export declare function svgIntrinsicSize(markup: string, viewBox?: SvgViewBox): {
|
|
124
|
+
width: number;
|
|
125
|
+
height: number;
|
|
126
|
+
};
|
|
127
|
+
/** The markup to draw for an SVG element in a box of `options.box` pixels. Results are cached by markup and options. */
|
|
128
|
+
export declare function prepareSvg(markup: string, options: PrepareSvgOptions): PreparedSvg;
|
|
129
|
+
/** A CSS colour as 0..1 channels; named colours other than black and white count as white. */
|
|
130
|
+
export declare function rgb(color: string): [number, number, number];
|
|
131
|
+
export declare function serialize(node: SvgNode | string): string;
|
|
132
|
+
interface ShapeMarkup {
|
|
133
|
+
readonly markup: string;
|
|
134
|
+
readonly size: {
|
|
135
|
+
readonly width: number;
|
|
136
|
+
readonly height: number;
|
|
137
|
+
};
|
|
138
|
+
/** Pixels the stroke and shadows reach past the box on any side. */
|
|
139
|
+
readonly bleed: number;
|
|
140
|
+
readonly warnings: readonly string[];
|
|
141
|
+
}
|
|
142
|
+
/** The size a shape draws at, before layout. */
|
|
143
|
+
export declare function shapeSize(p: ElementProps): {
|
|
144
|
+
width: number;
|
|
145
|
+
height: number;
|
|
146
|
+
};
|
|
147
|
+
export declare function shapeMarkup(props: Readonly<Record<string, unknown>>, size: {
|
|
148
|
+
width: number;
|
|
149
|
+
height: number;
|
|
150
|
+
}): ShapeMarkup;
|
|
151
|
+
interface ShapeDrawing {
|
|
152
|
+
readonly layout: OverlayLayout;
|
|
153
|
+
readonly prepared: PreparedSvg;
|
|
154
|
+
readonly bleed: number;
|
|
155
|
+
}
|
|
156
|
+
/** How a `<Shape>` element draws at its time: its layout, and the markup with entrance drawing applied. */
|
|
157
|
+
export declare function shapeDrawing(p: ElementProps, tokens?: Readonly<Record<string, string>>): ShapeDrawing;
|
|
158
|
+
interface SvgDrawing {
|
|
159
|
+
/** The size the SVG asks for, before `fit`. */
|
|
160
|
+
readonly size: {
|
|
161
|
+
readonly width: number;
|
|
162
|
+
readonly height: number;
|
|
163
|
+
};
|
|
164
|
+
readonly fit: FitMode;
|
|
165
|
+
readonly layout: OverlayLayout;
|
|
166
|
+
readonly prepared: PreparedSvg;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* How an `<Svg>` element draws its markup: at the size the SVG asks for (or fitted to the
|
|
170
|
+
* composition with `fit`), with its `viewBox`, `preserveAspectRatio` and `color` applied, and
|
|
171
|
+
* `$name` / `var(--cc-name)` filled from `tokens` (by default the composition's theme).
|
|
172
|
+
*/
|
|
173
|
+
export declare function svgDrawing(p: ElementProps, markup: string, tokens?: Readonly<Record<string, string>>): SvgDrawing;
|
|
174
|
+
/** A theme's tokens as SVG attribute values. */
|
|
175
|
+
export declare function themeTokens(theme: ResolvedTheme | undefined): Readonly<Record<string, string>>;
|
|
176
|
+
/** Whether a tree has SMIL animations in it. */
|
|
177
|
+
export declare function hasSmil(node: SvgNode): boolean;
|
|
178
|
+
/** The tree with every animation applied at `time` seconds and removed. Returns a copy; the input is not changed. */
|
|
179
|
+
export declare function freezeSmil(root: SvgNode, time: number, warnings: string[]): SvgNode;
|
|
180
|
+
/** Two values `k` of the way from `a` to `b`: numbers in the same places interpolate, colours mix, anything else switches halfway. */
|
|
181
|
+
export declare function interpolate(a: string, b: string, k: number): string;
|
|
182
|
+
/** A SMIL clock value in seconds: `2s`, `500ms`, `1.5`, `1min`, `0.1h`, `01:02.5`, `00:01:02`. */
|
|
183
|
+
export declare function clock(v: string): number | null;
|
|
184
|
+
interface GraphicDrawing {
|
|
185
|
+
readonly layout: OverlayLayout;
|
|
186
|
+
/** The art, sized to the layout's box. */
|
|
187
|
+
readonly prepared: PreparedSvg;
|
|
188
|
+
/** Text above the art, in the box's pixels. */
|
|
189
|
+
readonly labels: readonly Label[];
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* How a `<Graphic>` draws at the element's time: the kind's art through the
|
|
193
|
+
* same SVG preparation as `<Svg>` (so `draw` and the theme apply), and its
|
|
194
|
+
* labels, which both surfaces lay out as text the way they lay out titles.
|
|
195
|
+
*/
|
|
196
|
+
export declare function graphicDrawing(p: ElementProps): GraphicDrawing;
|
|
197
|
+
/** A sticker whose `src` is `icon:name`, drawn as the icon graphic in the sticker's square. Null for other stickers. */
|
|
198
|
+
export declare function iconStickerDrawing(p: ElementProps, side: number): GraphicDrawing | null;
|
|
199
|
+
/** A graphic's labels as positioned text, a tree both the DOM and Satori lay out. */
|
|
200
|
+
export declare function graphicLabels(labels: readonly Label[]): ReactNode;
|
|
201
|
+
export { type ClipRect, type ElementProps, type GraphicAnimation, type GraphicDrawing, type Motion, OVERLAY_KINDS, type OverlayLayout, type PrepareSvgOptions, type PreparedSvg, type ShapeDrawing, type ShapeMarkup, type SvgColor, type SvgDrawing, type SvgNode, type SvgViewBox, indexLayerInteriors, layerClock, motionAt };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { P as layerClock, i as OVERLAY_KINDS, u as motionAt } from "./frame-plan-BNwblf1s.mjs";
|
|
2
|
+
import { A as indexLayerInteriors, C as titleBox, O as overlayLayout, S as stickerSize, T as clipPathCss, _ as hasSmil, a as iconStickerDrawing, b as layerContent, c as shapeSize, d as rgb, f as serialize, g as freezeSmil, h as clock, i as graphicLabels, l as parseSvg, m as svgIntrinsicSize, n as themeTokens, o as shapeDrawing, p as svgAnimated, r as graphicDrawing, s as shapeMarkup, t as svgDrawing, u as prepareSvg, v as interpolate, w as titleContent, x as stickerPlaceholder, y as captionsContent } from "./svg-element-BUXbz-U5.mjs";
|
|
3
|
+
export { OVERLAY_KINDS, captionsContent, clipPathCss, clock, freezeSmil, graphicDrawing, graphicLabels, hasSmil, iconStickerDrawing, indexLayerInteriors, interpolate, layerClock, layerContent, motionAt, overlayLayout, parseSvg, prepareSvg, rgb, serialize, shapeDrawing, shapeMarkup, shapeSize, stickerPlaceholder, stickerSize, svgAnimated, svgDrawing, svgIntrinsicSize, themeTokens, titleBox, titleContent };
|