onda-engine 0.1.0 → 0.2.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/README.md +60 -39
- package/dist/cinema.js +1 -1
- package/dist/cinema.js.map +1 -1
- package/dist/components.d.ts +12 -1
- package/dist/components.js +24 -1
- package/dist/components.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/react.d.ts +3 -1
- package/dist/react.js +101 -17
- package/dist/react.js.map +1 -1
- package/dist/wasm/pkg/onda_wasm.d.ts +195 -0
- package/dist/wasm/pkg/onda_wasm_bg.wasm.d.ts +34 -0
- package/dist/wasm-audio/pkg/onda_wasm_audio.d.ts +106 -0
- package/dist/wasm-audio/pkg/onda_wasm_audio_bg.wasm.d.ts +20 -0
- package/dist/wasm-vello/index.d.ts +1 -0
- package/dist/wasm-vello/pkg/onda_wasm_vello.d.ts +96 -0
- package/dist/wasm-vello/pkg/onda_wasm_vello_bg.wasm.d.ts +24 -0
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export { KanbanBoard, KanbanBoardProps, KanbanColumn } from './components/Kanban
|
|
|
48
48
|
export { KenBurns, KenBurnsProps } from './components/KenBurns.js';
|
|
49
49
|
export { Ease, Keyframes, KeyframesImageContent, KeyframesProps, KeyframesTextContent, PosKey, ValKey } from './components/Keyframes.js';
|
|
50
50
|
export { KeyframeTracks, SampledKeyframes, hasKeyframeTracks, sampleKeyframes, sampleTrack } from './keyframes-sampler.js';
|
|
51
|
-
export { Box, ResponsiveTransform, entryDesignAnchor, responsiveEntryTransform } from './responsive.js';
|
|
51
|
+
export { Box, ResponsiveTransform, entryDesignAnchor, isFullBleed, responsiveCoverTransform, responsiveEntryTransform } from './responsive.js';
|
|
52
52
|
export { KineticText, KineticTextPreset, KineticTextProps } from './components/KineticText.js';
|
|
53
53
|
export { LineChart, LineChartProps } from './components/LineChart.js';
|
|
54
54
|
export { LogoReveal, LogoRevealPreset, LogoRevealProps } from './components/LogoReveal.js';
|
package/dist/react.d.ts
CHANGED
|
@@ -463,7 +463,9 @@ interface Scene {
|
|
|
463
463
|
/** A color as a hex string (`#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`) or an
|
|
464
464
|
* explicit 0..1 {@link Color}. */
|
|
465
465
|
type ColorInput = string | Color;
|
|
466
|
-
/** Normalize a {@link ColorInput} into the engine's 0..1 sRGB {@link Color}.
|
|
466
|
+
/** Normalize a {@link ColorInput} into the engine's 0..1 sRGB {@link Color}. Tolerant by design —
|
|
467
|
+
* parses hex, common named colors, and `rgb()/hsl()`; anything else degrades to transparent (with
|
|
468
|
+
* a warning) rather than throwing, so one bad value never crashes the render. */
|
|
467
469
|
declare function parseColor(input: ColorInput): Color;
|
|
468
470
|
/**
|
|
469
471
|
* Interpolate between colors — like {@link interpolate}, but each output is a
|
package/dist/react.js
CHANGED
|
@@ -78,29 +78,113 @@ function segment(input, inputRange, outputRange, i, easing) {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// ../react/src/color.ts
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
81
|
+
var clamp01 = (v) => v < 0 ? 0 : v > 1 ? 1 : v;
|
|
82
|
+
var TRANSPARENT = { r: 0, g: 0, b: 0, a: 0 };
|
|
83
|
+
var NAMED_COLORS = {
|
|
84
|
+
black: "#000000",
|
|
85
|
+
white: "#ffffff",
|
|
86
|
+
red: "#ff0000",
|
|
87
|
+
green: "#008000",
|
|
88
|
+
blue: "#0000ff",
|
|
89
|
+
yellow: "#ffff00",
|
|
90
|
+
orange: "#ffa500",
|
|
91
|
+
purple: "#800080",
|
|
92
|
+
pink: "#ffc0cb",
|
|
93
|
+
gray: "#808080",
|
|
94
|
+
grey: "#808080",
|
|
95
|
+
cyan: "#00ffff",
|
|
96
|
+
magenta: "#ff00ff",
|
|
97
|
+
brown: "#a52a2a",
|
|
98
|
+
navy: "#000080",
|
|
99
|
+
teal: "#008080",
|
|
100
|
+
lime: "#00ff00",
|
|
101
|
+
silver: "#c0c0c0",
|
|
102
|
+
gold: "#ffd700",
|
|
103
|
+
maroon: "#800000",
|
|
104
|
+
olive: "#808000",
|
|
105
|
+
aqua: "#00ffff",
|
|
106
|
+
fuchsia: "#ff00ff",
|
|
107
|
+
indigo: "#4b0082",
|
|
108
|
+
violet: "#ee82ee",
|
|
109
|
+
beige: "#f5f5dc",
|
|
110
|
+
coral: "#ff7f50",
|
|
111
|
+
crimson: "#dc143c",
|
|
112
|
+
khaki: "#f0e68c",
|
|
113
|
+
salmon: "#fa8072",
|
|
114
|
+
turquoise: "#40e0d0",
|
|
115
|
+
tan: "#d2b48c",
|
|
116
|
+
ivory: "#fffff0",
|
|
117
|
+
lavender: "#e6e6fa",
|
|
118
|
+
mint: "#98ff98"
|
|
119
|
+
};
|
|
120
|
+
function hexToColor(input) {
|
|
91
121
|
let hex = input.trim().replace(/^#/, "");
|
|
92
122
|
if (hex.length === 3 || hex.length === 4) {
|
|
93
123
|
hex = hex.split("").map((c) => c + c).join("");
|
|
94
124
|
}
|
|
95
|
-
if (hex.length !== 6 && hex.length !== 8 || !/^[0-9a-fA-F]+$/.test(hex))
|
|
96
|
-
throw new Error(`invalid color '${input}': expected #rgb, #rgba, #rrggbb, or #rrggbbaa`);
|
|
97
|
-
}
|
|
125
|
+
if (hex.length !== 6 && hex.length !== 8 || !/^[0-9a-fA-F]+$/.test(hex)) return null;
|
|
98
126
|
const channel = (i) => Number.parseInt(hex.slice(i, i + 2), 16) / 255;
|
|
99
127
|
const color = { r: channel(0), g: channel(2), b: channel(4) };
|
|
100
128
|
if (hex.length === 8) color.a = channel(6);
|
|
101
129
|
return color;
|
|
102
130
|
}
|
|
103
|
-
var
|
|
131
|
+
var hslToColor = (hDeg, sPct, lPct, a) => {
|
|
132
|
+
const s = sPct / 100;
|
|
133
|
+
const l = lPct / 100;
|
|
134
|
+
const k = (n) => (n + hDeg / 30) % 12;
|
|
135
|
+
const f = (n) => clamp01(l - s * Math.min(l, 1 - l) * Math.max(-1, Math.min(k(n) - 3, 9 - k(n), 1)));
|
|
136
|
+
return { r: f(0), g: f(8), b: f(4), ...a < 1 ? { a } : {} };
|
|
137
|
+
};
|
|
138
|
+
function cssToColor(input) {
|
|
139
|
+
const s = input.trim().toLowerCase();
|
|
140
|
+
const named = NAMED_COLORS[s];
|
|
141
|
+
if (named) return hexToColor(named);
|
|
142
|
+
const parts = (body) => (body ?? "").split(/[\s,/]+/).filter(Boolean);
|
|
143
|
+
const alpha = (v) => v === void 0 ? 1 : clamp01(v.endsWith("%") ? Number.parseFloat(v) / 100 : Number.parseFloat(v));
|
|
144
|
+
const rgb = s.match(/^rgba?\(([^)]+)\)$/);
|
|
145
|
+
if (rgb) {
|
|
146
|
+
const [r, g, b, a] = parts(rgb[1]);
|
|
147
|
+
if (r !== void 0 && g !== void 0 && b !== void 0)
|
|
148
|
+
return {
|
|
149
|
+
r: clamp01(Number.parseFloat(r) / 255),
|
|
150
|
+
g: clamp01(Number.parseFloat(g) / 255),
|
|
151
|
+
b: clamp01(Number.parseFloat(b) / 255),
|
|
152
|
+
...alpha(a) < 1 ? { a: alpha(a) } : {}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
const hsl = s.match(/^hsla?\(([^)]+)\)$/);
|
|
156
|
+
if (hsl) {
|
|
157
|
+
const [h, sat, light, a] = parts(hsl[1]);
|
|
158
|
+
if (h !== void 0 && sat !== void 0 && light !== void 0)
|
|
159
|
+
return hslToColor(
|
|
160
|
+
Number.parseFloat(h),
|
|
161
|
+
Number.parseFloat(sat),
|
|
162
|
+
Number.parseFloat(light),
|
|
163
|
+
alpha(a)
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
function parseColor(input) {
|
|
169
|
+
if (input === "none" || input === "transparent") return { r: 0, g: 0, b: 0, a: 0 };
|
|
170
|
+
if (typeof input !== "string") {
|
|
171
|
+
if (input == null || typeof input !== "object" || typeof input.r !== "number" || typeof input.g !== "number" || typeof input.b !== "number") {
|
|
172
|
+
console.warn(
|
|
173
|
+
`onda: invalid color ${JSON.stringify(input)} \u2014 expected a hex string or a {r,g,b} object; using transparent.`
|
|
174
|
+
);
|
|
175
|
+
return { ...TRANSPARENT };
|
|
176
|
+
}
|
|
177
|
+
return { r: input.r, g: input.g, b: input.b, ...input.a !== void 0 ? { a: input.a } : {} };
|
|
178
|
+
}
|
|
179
|
+
const hex = hexToColor(input);
|
|
180
|
+
if (hex) return hex;
|
|
181
|
+
const css = cssToColor(input);
|
|
182
|
+
if (css) return css;
|
|
183
|
+
console.warn(
|
|
184
|
+
`onda: unrecognized color '${input}' \u2014 using transparent. Supply hex (#rrggbb), rgb()/hsl(), or a common name.`
|
|
185
|
+
);
|
|
186
|
+
return { ...TRANSPARENT };
|
|
187
|
+
}
|
|
104
188
|
var toHex = (v) => Math.round(clamp01(v) * 255).toString(16).padStart(2, "0");
|
|
105
189
|
function interpolateColors(input, inputRange, outputRange, options = {}) {
|
|
106
190
|
const colors = outputRange.map(parseColor);
|
|
@@ -1824,9 +1908,9 @@ function parseGrain(input) {
|
|
|
1824
1908
|
return void 0;
|
|
1825
1909
|
}
|
|
1826
1910
|
function parseBackdropBlur(input) {
|
|
1827
|
-
const
|
|
1911
|
+
const TRANSPARENT2 = { r: 0, g: 0, b: 0, a: 0 };
|
|
1828
1912
|
if (typeof input === "number") {
|
|
1829
|
-
return input > 0 ? { effect: "backdrop_blur", sigma: input, tint:
|
|
1913
|
+
return input > 0 ? { effect: "backdrop_blur", sigma: input, tint: TRANSPARENT2, brightness: 1, saturation: 1 } : void 0;
|
|
1830
1914
|
}
|
|
1831
1915
|
if (input && typeof input === "object") {
|
|
1832
1916
|
const b = input;
|
|
@@ -1834,7 +1918,7 @@ function parseBackdropBlur(input) {
|
|
|
1834
1918
|
return {
|
|
1835
1919
|
effect: "backdrop_blur",
|
|
1836
1920
|
sigma: b.sigma,
|
|
1837
|
-
tint: b.tint !== void 0 ? parseColor(b.tint) :
|
|
1921
|
+
tint: b.tint !== void 0 ? parseColor(b.tint) : TRANSPARENT2,
|
|
1838
1922
|
brightness: typeof b.brightness === "number" ? b.brightness : 1,
|
|
1839
1923
|
saturation: typeof b.saturation === "number" ? b.saturation : 1
|
|
1840
1924
|
};
|