@hyperframes/core 0.8.190 → 0.8.192

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.
@@ -0,0 +1,34 @@
1
+ /** The attributes that configure motion blur on a composition root: names, ranges, defaults, parsing. */
2
+ export declare const MOTION_BLUR_ATTR: {
3
+ readonly enable: "data-motion-blur";
4
+ readonly shutter: "data-motion-blur-shutter";
5
+ readonly samples: "data-motion-blur-samples";
6
+ readonly events: "data-motion-blur-events";
7
+ readonly tier: "data-motion-blur-tier";
8
+ };
9
+ export declare const MOTION_BLUR_LIMITS: {
10
+ readonly shutterDeg: {
11
+ readonly min: 0;
12
+ readonly max: 720;
13
+ readonly default: 240;
14
+ };
15
+ readonly samples: {
16
+ readonly min: 2;
17
+ readonly max: 64;
18
+ };
19
+ };
20
+ export type MotionBlurTier = "auto" | "capture" | "filter";
21
+ export interface MotionBlurSettings {
22
+ enabled: boolean;
23
+ shutterDeg: number;
24
+ /** A fixed count per frame; null sizes it to each smear, never under 32. */
25
+ samples: number | null;
26
+ events: boolean;
27
+ tier: MotionBlurTier;
28
+ }
29
+ export declare function readMotionBlurSettings(attr: (name: string) => string | null): MotionBlurSettings;
30
+ /**
31
+ * The attribute writes that make `settings` true on a root: a value to set, or null to remove.
32
+ * A setting at its default is removed, so a root carries only what the author changed.
33
+ */
34
+ export declare function motionBlurAttributeEdits(settings: MotionBlurSettings): Record<string, string | null>;
@@ -0,0 +1,46 @@
1
+ /** The attributes that configure motion blur on a composition root: names, ranges, defaults, parsing. */
2
+ export const MOTION_BLUR_ATTR = {
3
+ enable: "data-motion-blur",
4
+ shutter: "data-motion-blur-shutter",
5
+ samples: "data-motion-blur-samples",
6
+ events: "data-motion-blur-events",
7
+ tier: "data-motion-blur-tier",
8
+ };
9
+ export const MOTION_BLUR_LIMITS = {
10
+ shutterDeg: { min: 0, max: 720, default: 240 },
11
+ samples: { min: 2, max: 64 },
12
+ };
13
+ const clamp = (x, lo, hi) => Math.min(hi, Math.max(lo, x));
14
+ function number(value) {
15
+ if (value === null || value.trim() === "")
16
+ return null;
17
+ const parsed = Number(value);
18
+ return Number.isFinite(parsed) ? parsed : null;
19
+ }
20
+ export function readMotionBlurSettings(attr) {
21
+ const shutter = number(attr(MOTION_BLUR_ATTR.shutter));
22
+ const samples = number(attr(MOTION_BLUR_ATTR.samples));
23
+ const tier = attr(MOTION_BLUR_ATTR.tier);
24
+ const { shutterDeg, samples: bounds } = MOTION_BLUR_LIMITS;
25
+ return {
26
+ enabled: attr(MOTION_BLUR_ATTR.enable) === "on",
27
+ shutterDeg: clamp(shutter ?? shutterDeg.default, shutterDeg.min, shutterDeg.max),
28
+ samples: samples === null ? null : Math.round(clamp(samples, bounds.min, bounds.max)),
29
+ events: attr(MOTION_BLUR_ATTR.events) === "on",
30
+ tier: tier === "capture" || tier === "filter" ? tier : "auto",
31
+ };
32
+ }
33
+ /**
34
+ * The attribute writes that make `settings` true on a root: a value to set, or null to remove.
35
+ * A setting at its default is removed, so a root carries only what the author changed.
36
+ */
37
+ export function motionBlurAttributeEdits(settings) {
38
+ const { shutterDeg } = MOTION_BLUR_LIMITS;
39
+ return {
40
+ [MOTION_BLUR_ATTR.enable]: settings.enabled ? "on" : null,
41
+ [MOTION_BLUR_ATTR.shutter]: settings.shutterDeg === shutterDeg.default ? null : String(settings.shutterDeg),
42
+ [MOTION_BLUR_ATTR.samples]: settings.samples === null ? null : String(settings.samples),
43
+ [MOTION_BLUR_ATTR.events]: settings.events ? "on" : null,
44
+ [MOTION_BLUR_ATTR.tier]: settings.tier === "auto" ? null : settings.tier,
45
+ };
46
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/core",
3
- "version": "0.8.190",
3
+ "version": "0.8.192",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -88,6 +88,10 @@
88
88
  "import": "./dist/htmlInCanvas.js",
89
89
  "types": "./dist/htmlInCanvas.d.ts"
90
90
  },
91
+ "./motion-blur-settings": {
92
+ "import": "./dist/motionBlurSettings.js",
93
+ "types": "./dist/motionBlurSettings.d.ts"
94
+ },
91
95
  "./gsap-cdn": {
92
96
  "import": "./dist/gsapCdn.js",
93
97
  "types": "./dist/gsapCdn.d.ts"
@@ -385,9 +389,9 @@
385
389
  "linkedom": "^0.18.12",
386
390
  "postcss": "^8.5.8",
387
391
  "wawoff2": "^2.0.1",
388
- "@hyperframes/lint": "0.8.190",
389
- "@hyperframes/parsers": "0.8.190",
390
- "@hyperframes/studio-server": "0.8.190"
392
+ "@hyperframes/lint": "0.8.192",
393
+ "@hyperframes/studio-server": "0.8.192",
394
+ "@hyperframes/parsers": "0.8.192"
391
395
  },
392
396
  "devDependencies": {
393
397
  "@fontsource/archivo-black": "^5.2.8",