volito 0.1.1 → 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.
- package/README.md +161 -5
- package/dist/browser.d.ts +50 -1
- package/dist/browser.js +352 -43
- package/dist/chunks/{chunk-CFDFWZAC.js → chunk-CUQY6YI3.js} +1032 -404
- package/dist/chunks/chunk-PM3PLI3X.js +71 -0
- package/dist/chunks/chunk-QA4SEJCZ.js +601 -0
- package/dist/chunks/chunk-ZFG3X3DU.js +67 -0
- package/dist/chunks/chunk-ZHMWEZ4C.js +186 -0
- package/dist/chunks/init-JX2BYRKT.js +189 -0
- package/dist/chunks/review-RBH5EUZN.js +18 -0
- package/dist/cli.js +232 -32
- package/dist/index.d.ts +314 -2
- package/dist/index.js +75 -21
- package/dist/mcp.js +129 -22
- package/dist/player.d.ts +643 -0
- package/dist/player.js +6320 -0
- package/dist/registry.json +1 -1
- package/examples/player.html +93 -0
- package/examples/states.html +73 -0
- package/examples/volito-intro/DESIGN.md +23 -0
- package/examples/volito-intro/frame.js +187 -0
- package/examples/volito-intro/item.json +43 -0
- package/package.json +12 -4
- package/packs/annotate/emphasis/frame.js +8 -0
- package/packs/annotate/reactions/frame.js +12 -0
- package/packs/backdrops/gradient/frame.js +5 -0
- package/packs/effects/chromatic/frame.js +17 -0
- package/packs/effects/chromatic/item.json +15 -0
- package/packs/effects/glass/frame.js +44 -0
- package/packs/effects/glass/item.json +16 -0
- package/packs/effects/grain/frame.js +20 -0
- package/packs/effects/grain/item.json +16 -0
- package/packs/effects/light-leak/frame.js +24 -0
- package/packs/effects/light-leak/item.json +15 -0
- package/packs/effects/neon/frame.js +28 -0
- package/packs/effects/neon/item.json +15 -0
- package/packs/effects/pack.json +13 -0
- package/packs/effects/shared.js +23 -0
- package/packs/effects/warp/frame.js +13 -0
- package/packs/effects/warp/item.json +15 -0
- package/packs/essentials/wipe/frame.js +13 -0
- package/packs/transitions/glitch/frame.js +14 -0
- package/packs/transitions/shared.js +12 -0
- package/packs/type/word-by-word/frame.js +10 -0
- package/packs/ui/bell/frame.js +24 -0
- package/packs/ui/bell/item.json +21 -0
- package/packs/ui/button/frame.js +55 -0
- package/packs/ui/button/item.json +26 -0
- package/packs/ui/like/frame.js +34 -0
- package/packs/ui/like/item.json +21 -0
- package/packs/ui/loader/frame.js +34 -0
- package/packs/ui/loader/item.json +23 -0
- package/packs/ui/pack.json +13 -0
- package/packs/ui/shared.js +54 -0
- package/packs/ui/toggle/frame.js +30 -0
- package/packs/ui/toggle/item.json +22 -0
- package/{skill → skills/volito}/SKILL.md +43 -3
- package/skills/volito/references/art-direction.md +58 -0
- package/skills/volito/references/brand.md +59 -0
- package/skills/volito/references/delivery.md +40 -0
- package/skills/volito/references/matching-a-reference.md +39 -0
- package/skills/volito/references/motion-craft.md +56 -0
- package/skills/volito/references/self-review.md +44 -0
- package/skills/volito/references/type-and-layout.md +44 -0
- package/skills/volito/references/voice-and-timing.md +37 -0
- package/skills/volito/references/writing-items.md +44 -0
- /package/{skill/template → templates/item}/frame.js +0 -0
- /package/{skill/template → templates/item}/item.json +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SPEC_VERSION,
|
|
3
|
+
loadSpecFile
|
|
4
|
+
} from "./chunk-QA4SEJCZ.js";
|
|
5
|
+
import {
|
|
6
|
+
MotionError
|
|
7
|
+
} from "./chunk-CUQY6YI3.js";
|
|
8
|
+
|
|
9
|
+
// src/node/bundle.ts
|
|
10
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
|
11
|
+
import { tmpdir } from "node:os";
|
|
12
|
+
import { dirname, isAbsolute, join, normalize, relative, resolve, sep } from "node:path";
|
|
13
|
+
var BUNDLE_VERSION = 1;
|
|
14
|
+
var TEXT = /\.(md|markdown|txt|js|mjs|json|svg)$/i;
|
|
15
|
+
var isUrl = (s) => /^(https?:|data:)/i.test(s);
|
|
16
|
+
function specFiles(spec, dir, imageProps = []) {
|
|
17
|
+
const out = /* @__PURE__ */ new Set();
|
|
18
|
+
const add = (p) => {
|
|
19
|
+
if (typeof p !== "string" || !p.trim() || isUrl(p)) return;
|
|
20
|
+
const abs = isAbsolute(p) ? p : resolve(dir, p);
|
|
21
|
+
if (existsSync(abs)) out.add(relative(dir, abs));
|
|
22
|
+
};
|
|
23
|
+
if (spec.style && /\.(md|markdown|txt)$/i.test(spec.style)) add(spec.style);
|
|
24
|
+
if (spec.program) add(spec.program);
|
|
25
|
+
if (typeof spec.words === "string") add(spec.words);
|
|
26
|
+
for (const name of imageProps) add(spec.props?.[name]);
|
|
27
|
+
return [...out];
|
|
28
|
+
}
|
|
29
|
+
function bundleSpec(specPath, imageProps = () => []) {
|
|
30
|
+
const loaded = loadSpecFile(specPath);
|
|
31
|
+
const files = {};
|
|
32
|
+
for (const rel of specFiles(loaded.spec, loaded.dir, imageProps(loaded.spec, loaded.dir))) {
|
|
33
|
+
if (rel.startsWith("..") || isAbsolute(rel)) throw new MotionError(`${rel} is outside the spec's folder \u2014 move it next to the spec to bundle it`);
|
|
34
|
+
const data = readFileSync(join(loaded.dir, rel));
|
|
35
|
+
files[rel.split(sep).join("/")] = TEXT.test(rel) ? { text: data.toString("utf8") } : { base64: data.toString("base64") };
|
|
36
|
+
}
|
|
37
|
+
return { volito: SPEC_VERSION, bundle: BUNDLE_VERSION, spec: loaded.spec, files };
|
|
38
|
+
}
|
|
39
|
+
function isBundleFile(path) {
|
|
40
|
+
return /\.volito$/i.test(path) && existsSync(resolve(path));
|
|
41
|
+
}
|
|
42
|
+
function loadBundleFile(path) {
|
|
43
|
+
let doc;
|
|
44
|
+
try {
|
|
45
|
+
doc = JSON.parse(readFileSync(resolve(path), "utf8"));
|
|
46
|
+
} catch (e) {
|
|
47
|
+
throw new MotionError(`${path} is not a Volito bundle: ${e.message}`);
|
|
48
|
+
}
|
|
49
|
+
if (doc?.bundle !== BUNDLE_VERSION || !doc.spec || typeof doc.files !== "object") throw new MotionError(`${path} is not a Volito bundle (version ${BUNDLE_VERSION})`);
|
|
50
|
+
const dir = mkdtempSync(join(tmpdir(), "volito-bundle-"));
|
|
51
|
+
for (const [name, f] of Object.entries(doc.files)) {
|
|
52
|
+
const rel = normalize(name);
|
|
53
|
+
if (isAbsolute(rel) || rel.startsWith("..") || rel.split(sep).includes("..")) throw new MotionError(`${path} has a file outside its folder (${name}); not unpacking it`);
|
|
54
|
+
const out = join(dir, rel);
|
|
55
|
+
mkdirSync(dirname(out), { recursive: true });
|
|
56
|
+
writeFileSync(out, "text" in f ? f.text : Buffer.from(f.base64, "base64"));
|
|
57
|
+
}
|
|
58
|
+
const spec = join(dir, "graphic.volito.json");
|
|
59
|
+
writeFileSync(spec, JSON.stringify(doc.spec));
|
|
60
|
+
return loadSpecFile(spec);
|
|
61
|
+
}
|
|
62
|
+
function loadAnySpec(path) {
|
|
63
|
+
return isBundleFile(path) ? loadBundleFile(path) : loadSpecFile(path);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export {
|
|
67
|
+
bundleSpec,
|
|
68
|
+
isBundleFile,
|
|
69
|
+
loadBundleFile,
|
|
70
|
+
loadAnySpec
|
|
71
|
+
};
|