@depths/waves 0.2.0 → 0.3.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.
@@ -1,20 +1,58 @@
1
1
  import {
2
+ Fill,
2
3
  WavesRenderError,
3
4
  globalRegistry,
4
5
  registerBuiltInComponents
5
- } from "../chunk-PKLHVWMD.mjs";
6
+ } from "../chunk-YYS6AVTN.mjs";
6
7
 
7
8
  // src/remotion/WavesComposition.tsx
8
9
  import React from "react";
9
10
  import { Sequence } from "remotion";
10
- import { Fragment, jsx } from "react/jsx-runtime";
11
- var WavesComposition = ({ ir, registry }) => {
12
- return /* @__PURE__ */ jsx(Fragment, { children: ir.timeline.map((node) => renderComponent(node, registry)) });
11
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
+ var WavesComposition = ({ ir, registry, debug }) => {
13
+ return /* @__PURE__ */ jsx(Fragment, { children: ir.timeline.map((node) => renderComponent(node, registry, debug, "absolute-fill")) });
13
14
  };
14
15
  var getProps = (component) => {
15
16
  return component.props ?? {};
16
17
  };
17
- function renderComponent(component, registry) {
18
+ function debugColor(key) {
19
+ let hash = 0;
20
+ for (let i = 0; i < key.length; i++) hash = hash * 31 + key.charCodeAt(i) | 0;
21
+ const hue = Math.abs(hash) % 360;
22
+ return `hsl(${hue} 90% 55%)`;
23
+ }
24
+ function DebugWrap(props) {
25
+ const { enabled, showLabel, id, type, children } = props;
26
+ if (!enabled) return /* @__PURE__ */ jsx(Fragment, { children });
27
+ const color = debugColor(`${type}:${id}`);
28
+ const label = `${type} (${id})`;
29
+ return /* @__PURE__ */ jsxs(Fill, { style: { outline: `2px solid ${color}`, outlineOffset: -2 }, children: [
30
+ children,
31
+ showLabel ? /* @__PURE__ */ jsx(
32
+ "div",
33
+ {
34
+ style: {
35
+ position: "absolute",
36
+ left: 0,
37
+ top: 0,
38
+ padding: "2px 6px",
39
+ fontSize: 12,
40
+ fontWeight: 800,
41
+ color: "#000",
42
+ backgroundColor: color,
43
+ borderBottomRightRadius: 6,
44
+ pointerEvents: "none",
45
+ maxWidth: "100%",
46
+ overflow: "hidden",
47
+ textOverflow: "ellipsis",
48
+ whiteSpace: "nowrap"
49
+ },
50
+ children: label
51
+ }
52
+ ) : null
53
+ ] });
54
+ }
55
+ function renderComponent(component, registry, debug, sequenceLayout) {
18
56
  const registration = registry.get(component.type);
19
57
  if (!registration) {
20
58
  throw new WavesRenderError("Unknown component type", { type: component.type });
@@ -30,20 +68,23 @@ function renderComponent(component, registry) {
30
68
  if (!parsedProps || typeof parsedProps !== "object") {
31
69
  throw new WavesRenderError("Component props must be an object", { type: component.type });
32
70
  }
33
- const children = component.children?.length ? component.children.map((c) => renderComponent(c, registry)) : null;
71
+ const children = component.children?.length ? component.children.map((c) => renderComponent(c, registry, debug, "none")) : null;
72
+ const debugEnabled = Boolean(debug?.bounds);
73
+ const showLabel = Boolean(debug?.labels);
34
74
  return /* @__PURE__ */ jsx(
35
75
  Sequence,
36
76
  {
37
77
  from: component.timing.from,
38
78
  durationInFrames: component.timing.durationInFrames,
39
- children: React.createElement(
79
+ layout: sequenceLayout,
80
+ children: /* @__PURE__ */ jsx(DebugWrap, { enabled: debugEnabled, showLabel, id: component.id, type: component.type, children: React.createElement(
40
81
  registration.component,
41
82
  {
42
83
  ...parsedProps,
43
84
  __wavesDurationInFrames: component.timing.durationInFrames
44
85
  },
45
86
  children
46
- )
87
+ ) })
47
88
  },
48
89
  component.id
49
90
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depths/waves",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Type-safe video generation engine for converting JSON IR to rendered videos using Remotion",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",