vizmatic 0.8.3 → 0.9.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/PROMPT.md +32 -0
- package/README.md +8 -3
- package/ROADMAP.md +4 -2
- package/SCIENCE.md +69 -3
- package/dist/chunk-6JI55YX4.js +604 -0
- package/dist/{chunk-LTX44BAE.js → chunk-BYKXNUX7.js} +25 -4
- package/dist/{chunk-4MXGLMBG.js → chunk-EPZLNABN.js} +107 -37
- package/dist/chunk-EWCO6ZT6.js +696 -0
- package/dist/{chunk-JZPMGVBP.js → chunk-G7HRSKHV.js} +1 -1
- package/dist/{chunk-RPAHMKAR.js → chunk-JTWC2OPN.js} +7 -5
- package/dist/chunk-LJZO36IR.js +124 -0
- package/dist/chunk-REL2BZ2B.js +88 -0
- package/dist/chunk-RLPEOWST.js +1 -0
- package/dist/chunk-VMHOWCDL.js +296 -0
- package/dist/chunk-YDD63HHD.js +1 -0
- package/dist/{chunk-I745F4QK.js → chunk-YNGDEARY.js} +1134 -643
- package/dist/cli.js +80 -543
- package/dist/gpu-selection-CDWCZH27.js +1 -0
- package/dist/gpu-selection-MX6NHMNA.js +635 -0
- package/dist/index.cjs +473 -155
- package/dist/index.d.cts +30 -239
- package/dist/index.d.ts +30 -239
- package/dist/index.js +410 -457
- package/dist/math-E7W5LFWO.js +1 -0
- package/dist/{math-LXB4FH4E.js → math-NEFQUPRV.js} +3 -1
- package/dist/scene-browser.js +17 -17
- package/dist/scene-cli.js +1 -1
- package/dist/scene-runtime.cjs +4 -2
- package/dist/scene-runtime.js +2 -2
- package/dist/stage-browser/browser.d.ts +1206 -854
- package/dist/stage-browser/gpu-renderer.js +138 -0
- package/dist/stage-browser/{math-4WFNHVV2.js → math-KYHUOK7A.js} +46 -10
- package/dist/stage-browser/stage.js +107 -19
- package/dist/stage-export.cjs +8221 -6784
- package/dist/stage-export.d.cts +13 -5
- package/dist/stage-export.d.ts +13 -5
- package/dist/stage-export.js +111 -601
- package/dist/stage.cjs +6243 -3474
- package/dist/stage.d.cts +1064 -765
- package/dist/stage.d.ts +1064 -765
- package/dist/stage.js +3571 -2405
- package/dist/{svg-import-B5BGbC1t.d.cts → svg-import-CSCFWYaB.d.cts} +21 -12
- package/dist/{svg-import-B5BGbC1t.d.ts → svg-import-CSCFWYaB.d.ts} +21 -12
- package/dist/teaching-math-DTKc0XsB.d.cts +243 -0
- package/dist/teaching-math-ydDBhJ2M.d.ts +243 -0
- package/dist/{video-CiN1MDCS.d.cts → theme-DhVdDQKO.d.cts} +4 -237
- package/dist/{video-CiN1MDCS.d.ts → theme-DhVdDQKO.d.ts} +4 -237
- package/dist/video-BYCeOz8F.d.ts +259 -0
- package/dist/video-CGLxJXqu.d.cts +259 -0
- package/examples/catalog-science-physics.tsx +6 -6
- package/examples/films/_boltzmann-entropy/model.ts +63 -0
- package/examples/films/_catalysis/model.ts +49 -0
- package/examples/films/_gravitational-waves/model.ts +32 -0
- package/examples/films/_heat-equation/model.ts +54 -0
- package/examples/films/_hydrogen-orbitals/model.ts +31 -0
- package/examples/films/_maxwell/model.ts +84 -0
- package/examples/films/_planetary-orbits/appearance.ts +71 -0
- package/examples/films/_planetary-orbits/model.ts +152 -0
- package/examples/films/_planetary-orbits/saturn.ts +142 -0
- package/examples/films/_quantum-tunneling/model.ts +58 -0
- package/examples/films/_reaction-diffusion/model.ts +61 -0
- package/examples/films/_stationary-action/model.ts +38 -0
- package/examples/films/attention.ts +309 -253
- package/examples/films/beam-search.ts +321 -49
- package/examples/films/boltzmann-entropy.ts +104 -0
- package/examples/films/cache-miss.ts +387 -394
- package/examples/films/catalog.json +238 -77
- package/examples/films/catalysis.ts +128 -0
- package/examples/films/central-limit.ts +27 -22
- package/examples/films/complex-maps.ts +70 -56
- package/examples/films/deck-example.ts +261 -200
- package/examples/films/euler-circle.ts +72 -28
- package/examples/films/flash-attention.ts +549 -0
- package/examples/films/forecast.ts +2 -2
- package/examples/films/fourier-epicycles.ts +21 -20
- package/examples/films/gradient-descent.ts +23 -49
- package/examples/films/gravitational-waves.ts +179 -0
- package/examples/films/heat-equation.ts +124 -0
- package/examples/films/hydrogen-orbitals.ts +135 -0
- package/examples/films/io-uring.ts +635 -0
- package/examples/films/linear-maps.ts +42 -31
- package/examples/films/lorenz.ts +42 -79
- package/examples/films/maxwell.ts +197 -0
- package/examples/films/pathlines.ts +85 -0
- package/examples/films/planetary-orbits.ts +146 -0
- package/examples/films/pythagoras.ts +18 -10
- package/examples/films/quantum-tunneling.ts +116 -0
- package/examples/films/rag-citations.ts +423 -0
- package/examples/films/reaction-diffusion.ts +70 -0
- package/examples/films/ring-allreduce.ts +531 -0
- package/examples/films/stationary-action.ts +170 -0
- package/examples/films/svd-3d.ts +605 -0
- package/examples/films/taylor-series.ts +9 -9
- package/examples/films/vizmatic-title.ts +1 -0
- package/examples/vizmatic-hero.tsx +102 -32
- package/package.json +3 -1
- package/dist/chunk-3F2VQ7NW.js +0 -1
- package/dist/chunk-GGFDBJ25.js +0 -88
- package/dist/math-QVCETQDQ.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getThemeColors,
|
|
3
3
|
setDensityResolver
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-JTWC2OPN.js";
|
|
5
5
|
|
|
6
6
|
// src/brand.ts
|
|
7
7
|
import React from "react";
|
|
@@ -1703,6 +1703,38 @@ async function loopbackPair() {
|
|
|
1703
1703
|
}
|
|
1704
1704
|
}
|
|
1705
1705
|
var ffmpegOptions = /* @__PURE__ */ new Map();
|
|
1706
|
+
var NVENC_PRESETS = {
|
|
1707
|
+
ultrafast: "p1",
|
|
1708
|
+
superfast: "p2",
|
|
1709
|
+
veryfast: "p3",
|
|
1710
|
+
faster: "p4",
|
|
1711
|
+
fast: "p5",
|
|
1712
|
+
medium: "p6",
|
|
1713
|
+
slow: "p7",
|
|
1714
|
+
slower: "p7",
|
|
1715
|
+
veryslow: "p7",
|
|
1716
|
+
placebo: "p7"
|
|
1717
|
+
};
|
|
1718
|
+
function nvencArgs(options) {
|
|
1719
|
+
return [
|
|
1720
|
+
"-c:v",
|
|
1721
|
+
"h264_nvenc",
|
|
1722
|
+
"-preset",
|
|
1723
|
+
NVENC_PRESETS[options.preset ?? "fast"],
|
|
1724
|
+
"-tune",
|
|
1725
|
+
"hq",
|
|
1726
|
+
"-profile:v",
|
|
1727
|
+
"high",
|
|
1728
|
+
"-rc",
|
|
1729
|
+
"vbr",
|
|
1730
|
+
"-cq",
|
|
1731
|
+
String(options.crf ?? 18),
|
|
1732
|
+
"-b:v",
|
|
1733
|
+
"0",
|
|
1734
|
+
"-g",
|
|
1735
|
+
"250"
|
|
1736
|
+
];
|
|
1737
|
+
}
|
|
1706
1738
|
function videoToolboxArgs({ width, height, fps }) {
|
|
1707
1739
|
const args = ["-c:v", "h264_videotoolbox", "-allow_sw", "0", "-profile:v", "high", "-q:v", "75", "-g", "250"];
|
|
1708
1740
|
const blocks = Math.ceil(width / 16) * Math.ceil(height / 16);
|
|
@@ -1764,45 +1796,84 @@ async function verifyHardwareFrames(ffmpeg, path, count, fps, signal) {
|
|
|
1764
1796
|
let missing = 0;
|
|
1765
1797
|
while (missing < count && seen[Math.floor(missing / 8)] & 1 << missing % 8) missing++;
|
|
1766
1798
|
const detail = missing < count ? `; missing frame ${missing}` : "";
|
|
1767
|
-
throw new Error(`
|
|
1799
|
+
throw new Error(`Hardware H.264 packet timing mismatch: expected ${count} frames at ${fps} fps, found ${packets}${detail}`);
|
|
1768
1800
|
}
|
|
1769
1801
|
}
|
|
1770
|
-
var hardwareProbes = /* @__PURE__ */ new
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
if (requested !== "videotoolbox") throw new Error("h264Encoder must be libx264 or videotoolbox");
|
|
1802
|
+
var hardwareProbes = /* @__PURE__ */ new Set();
|
|
1803
|
+
var pendingHardwareProbes = /* @__PURE__ */ new Map();
|
|
1804
|
+
async function probeH264Encoder(encoder, ffmpegPath, format, options) {
|
|
1774
1805
|
const { width, height, fps } = format;
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1806
|
+
const args = [
|
|
1807
|
+
"-nostdin",
|
|
1808
|
+
"-v",
|
|
1809
|
+
"error",
|
|
1810
|
+
"-abort_on",
|
|
1811
|
+
"empty_output",
|
|
1812
|
+
"-f",
|
|
1813
|
+
"lavfi",
|
|
1814
|
+
"-i",
|
|
1815
|
+
`color=size=${width}x${height}:rate=${fps},format=rgba`,
|
|
1816
|
+
"-frames:v",
|
|
1817
|
+
"1",
|
|
1818
|
+
"-vf",
|
|
1819
|
+
COLOR_FILTER,
|
|
1820
|
+
...encoder === "nvenc" ? nvencArgs(options) : videoToolboxArgs(format),
|
|
1821
|
+
"-pix_fmt",
|
|
1822
|
+
"yuv420p",
|
|
1823
|
+
...COLOR_TAGS,
|
|
1824
|
+
"-f",
|
|
1825
|
+
"null",
|
|
1826
|
+
"-"
|
|
1827
|
+
];
|
|
1828
|
+
const key = JSON.stringify([ffmpegPath, args]);
|
|
1829
|
+
if (hardwareProbes.has(key)) return true;
|
|
1830
|
+
let probe = options.signal ? void 0 : pendingHardwareProbes.get(key);
|
|
1778
1831
|
if (!probe) {
|
|
1779
|
-
probe = new Promise((done) => {
|
|
1780
|
-
const
|
|
1781
|
-
|
|
1782
|
-
"
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
"-pix_fmt",
|
|
1792
|
-
"yuv420p",
|
|
1793
|
-
"-f",
|
|
1794
|
-
"null",
|
|
1795
|
-
"-"
|
|
1796
|
-
];
|
|
1797
|
-
const child = execFile(ffmpegPath, args, { timeout: 15e3, killSignal: "SIGKILL", maxBuffer: 65536 }, (error) => {
|
|
1798
|
-
if (error) hardwareProbes.delete(key);
|
|
1799
|
-
done(!error);
|
|
1832
|
+
probe = new Promise((done, fail) => {
|
|
1833
|
+
const child = execFile(ffmpegPath, args, {
|
|
1834
|
+
timeout: 15e3,
|
|
1835
|
+
killSignal: "SIGKILL",
|
|
1836
|
+
maxBuffer: 65536,
|
|
1837
|
+
signal: options.signal
|
|
1838
|
+
}, (error) => {
|
|
1839
|
+
if (options.signal?.aborted) fail(abortError());
|
|
1840
|
+
else {
|
|
1841
|
+
if (!error) hardwareProbes.add(key);
|
|
1842
|
+
done(!error);
|
|
1843
|
+
}
|
|
1800
1844
|
});
|
|
1801
1845
|
child.stdin?.end();
|
|
1802
1846
|
});
|
|
1803
|
-
|
|
1847
|
+
if (!options.signal) pendingHardwareProbes.set(key, probe);
|
|
1804
1848
|
}
|
|
1805
|
-
|
|
1849
|
+
try {
|
|
1850
|
+
return await probe;
|
|
1851
|
+
} finally {
|
|
1852
|
+
if (pendingHardwareProbes.get(key) === probe) pendingHardwareProbes.delete(key);
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
async function resolveH264Encoder(requested = "libx264", ffmpegPath = "ffmpeg", format = { width: 1920, height: 1080, fps: 30 }, options = {}) {
|
|
1856
|
+
if (options.signal?.aborted) throw abortError();
|
|
1857
|
+
if (requested === "libx264") return requested;
|
|
1858
|
+
if (requested !== "videotoolbox" && requested !== "nvenc" && requested !== "auto")
|
|
1859
|
+
throw new Error("h264Encoder must be libx264, videotoolbox, nvenc or auto");
|
|
1860
|
+
const { width, height, fps } = format;
|
|
1861
|
+
if (![width, height].every((value) => Number.isSafeInteger(value) && value > 0 && value % 2 === 0) || !Number.isInteger(fps) || fps < 1 || fps > 120) throw new Error("Invalid H.264 probe dimensions or FPS");
|
|
1862
|
+
const crf = options.crf ?? 18;
|
|
1863
|
+
const preset = options.preset ?? "fast";
|
|
1864
|
+
if (!Number.isInteger(crf) || crf < 0 || crf > 51) throw new Error("crf must be an integer between 0 and 51");
|
|
1865
|
+
if (requested === "auto" && (process.env.CI || process.env.GITHUB_ACTIONS || crf !== 18 || options.tune !== void 0 || options.x264Params !== void 0)) return "libx264";
|
|
1866
|
+
const candidates = requested === "auto" ? process.platform === "darwin" ? ["videotoolbox", "nvenc"] : ["nvenc"] : [requested];
|
|
1867
|
+
for (const encoder of candidates) {
|
|
1868
|
+
const supported = options.x264Params === void 0 && (encoder === "nvenc" ? options.tune === void 0 && crf > 0 && Object.hasOwn(NVENC_PRESETS, preset) : crf === 18 && (options.tune === void 0 || options.tune === "animation"));
|
|
1869
|
+
if (!supported) continue;
|
|
1870
|
+
const available = await probeH264Encoder(encoder, ffmpegPath, format, options);
|
|
1871
|
+
if (options.signal?.aborted) throw abortError();
|
|
1872
|
+
if (available) return encoder;
|
|
1873
|
+
}
|
|
1874
|
+
if (options.requireH264Encoder && requested !== "auto")
|
|
1875
|
+
throw new Error(`Requested H.264 encoder ${requested} is unavailable for these settings`);
|
|
1876
|
+
return "libx264";
|
|
1806
1877
|
}
|
|
1807
1878
|
function hasFfmpegOption(ffmpegPath, component, option) {
|
|
1808
1879
|
const key = JSON.stringify([ffmpegPath, component, option]);
|
|
@@ -1889,10 +1960,7 @@ async function renderRgbaVideo(renderFrame, options) {
|
|
|
1889
1960
|
if (codec !== "h264" && (options.h264Encoder !== void 0 || options.requireH264Encoder))
|
|
1890
1961
|
throw new Error("h264Encoder applies only to H.264 output");
|
|
1891
1962
|
const requested = options.h264Encoder ?? "libx264";
|
|
1892
|
-
const
|
|
1893
|
-
const h264Encoder = requested === "videotoolbox" && useSoftwareSettings ? "libx264" : await withAbort(resolveH264Encoder(requested, ffmpegPath, { width, height, fps }), options.signal);
|
|
1894
|
-
if (options.requireH264Encoder && requested !== h264Encoder)
|
|
1895
|
-
throw new Error(`Requested H.264 encoder ${requested} is unavailable for these settings`);
|
|
1963
|
+
const h264Encoder = await resolveH264Encoder(requested, ffmpegPath, { width, height, fps }, options);
|
|
1896
1964
|
const outputPath = resolve(options.outputPath);
|
|
1897
1965
|
const outputDirectory = dirname2(outputPath);
|
|
1898
1966
|
await mkdir2(outputDirectory, { recursive: true });
|
|
@@ -1956,6 +2024,8 @@ async function renderRgbaVideo(renderFrame, options) {
|
|
|
1956
2024
|
args.push("-c:v", "libvpx-vp9", "-crf", String(crf), "-b:v", "0", "-deadline", "good", "-cpu-used", "2", "-row-mt", "1", "-threads:v", String(threads));
|
|
1957
2025
|
} else if (h264Encoder === "videotoolbox") {
|
|
1958
2026
|
args.push(...videoToolboxArgs({ width, height, fps }));
|
|
2027
|
+
} else if (h264Encoder === "nvenc") {
|
|
2028
|
+
args.push(...nvencArgs(options));
|
|
1959
2029
|
} else {
|
|
1960
2030
|
args.push("-c:v", "libx264", "-preset", preset);
|
|
1961
2031
|
if (options.tune) args.push("-tune", options.tune);
|
|
@@ -2095,7 +2165,7 @@ async function renderRgbaVideo(renderFrame, options) {
|
|
|
2095
2165
|
const exit = await withAbort(exited, options.signal);
|
|
2096
2166
|
if (exit.error) throw new Error(`Unable to start FFmpeg: ${exit.error.message}`, { cause: exit.error });
|
|
2097
2167
|
if (exit.code !== 0) throw describeExit(exit.code, exit.signal, stderr);
|
|
2098
|
-
if (h264Encoder
|
|
2168
|
+
if (h264Encoder !== "libx264") await verifyHardwareFrames(ffmpegPath, tempPath, schedule.count, fps, options.signal);
|
|
2099
2169
|
const outputStat = await stat(tempPath);
|
|
2100
2170
|
await chmod(tempPath, 420);
|
|
2101
2171
|
await rename(tempPath, outputPath);
|