sketchmark 2.0.0 → 2.1.1
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 +274 -188
- package/bin/editor-ui.cjs +2285 -0
- package/bin/preview-ui.cjs +74 -0
- package/bin/sketchmark.cjs +648 -2008
- package/dist/src/animatable.d.ts +21 -0
- package/dist/src/animatable.js +439 -0
- package/dist/src/builders/index.d.ts +1 -11
- package/dist/src/builders/index.js +1 -19
- package/dist/src/diagnostics.js +1 -64
- package/dist/src/edit.d.ts +27 -0
- package/dist/src/edit.js +162 -0
- package/dist/src/index.d.ts +4 -13
- package/dist/src/index.js +4 -13
- package/dist/src/keyframes.d.ts +48 -0
- package/dist/src/keyframes.js +182 -0
- package/dist/src/motion.d.ts +4 -0
- package/dist/src/motion.js +262 -0
- package/dist/src/normalize.js +120 -151
- package/dist/src/presets/characters.d.ts +15 -0
- package/dist/src/presets/characters.js +113 -0
- package/dist/src/presets/compose.d.ts +5 -0
- package/dist/src/presets/compose.js +80 -0
- package/dist/src/presets/effects.d.ts +40 -0
- package/dist/src/presets/effects.js +79 -0
- package/dist/src/presets/helpers.d.ts +33 -0
- package/dist/src/presets/helpers.js +165 -0
- package/dist/src/presets/index.d.ts +9 -0
- package/dist/src/presets/index.js +48 -0
- package/dist/src/presets/motions.d.ts +33 -0
- package/dist/src/presets/motions.js +75 -0
- package/dist/src/presets/scenes.d.ts +35 -0
- package/dist/src/presets/scenes.js +134 -0
- package/dist/src/presets/shapes.d.ts +71 -0
- package/dist/src/presets/shapes.js +96 -0
- package/dist/src/presets/transitions.d.ts +29 -0
- package/dist/src/presets/transitions.js +113 -0
- package/dist/src/presets/types.d.ts +34 -0
- package/dist/src/presets/types.js +2 -0
- package/dist/src/render/html.js +1 -4
- package/dist/src/render/svg.d.ts +2 -2
- package/dist/src/render/svg.js +86 -82
- package/dist/src/render/three-html.js +67 -113
- package/dist/src/scenes.js +1 -0
- package/dist/src/schema.js +218 -280
- package/dist/src/shapes/builtins.js +11 -47
- package/dist/src/shapes/common.js +12 -11
- package/dist/src/shapes/registry.d.ts +0 -1
- package/dist/src/shapes/registry.js +0 -4
- package/dist/src/shapes/types.d.ts +1 -3
- package/dist/src/types.d.ts +57 -288
- package/dist/src/utils.d.ts +2 -11
- package/dist/src/utils.js +13 -70
- package/dist/src/validate.js +321 -275
- package/dist/tests/run.js +576 -510
- package/package.json +46 -52
- package/schema/visual.schema.json +1086 -930
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function previewHtml(title) {
|
|
4
|
+
return `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Sketchmark Preview - ${escapeHtml(title)}</title><style>
|
|
5
|
+
@font-face{font-family:'Roboto';src:url('/fonts/Roboto-Light.ttf') format('truetype');font-weight:300;font-style:normal;font-display:swap}
|
|
6
|
+
@font-face{font-family:'Roboto';src:url('/fonts/Roboto-Regular.ttf') format('truetype');font-weight:400;font-style:normal;font-display:swap}
|
|
7
|
+
@font-face{font-family:'Roboto';src:url('/fonts/Roboto-Bold.ttf') format('truetype');font-weight:700;font-style:normal;font-display:swap}
|
|
8
|
+
html,body{margin:0;width:100%;height:100%;background:#0f172a;color:#e2e8f0;font:14px/1.4 Roboto,Arial,sans-serif}
|
|
9
|
+
body{display:grid;grid-template-rows:1fr auto}
|
|
10
|
+
#stage{display:grid;place-items:center;min-height:0;padding:24px}
|
|
11
|
+
#stage svg{max-width:100%;max-height:100%;box-shadow:0 24px 80px rgba(0,0,0,.35)}
|
|
12
|
+
#controls{display:grid;grid-template-columns:auto 1fr auto;gap:14px;align-items:center;padding:14px 18px;background:#111827;border-top:1px solid rgba(255,255,255,.08)}
|
|
13
|
+
button{width:42px;height:34px;border:1px solid rgba(255,255,255,.18);border-radius:6px;background:#f8fafc;color:#0f172a;font-weight:800;cursor:pointer}
|
|
14
|
+
input{width:100%;accent-color:#38bdf8}
|
|
15
|
+
#clock{font-variant-numeric:tabular-nums;min-width:110px;text-align:right;color:#cbd5e1}
|
|
16
|
+
#error{position:absolute;left:16px;top:16px;right:16px;color:#fecaca}
|
|
17
|
+
</style></head><body><div id="stage"><div id="error"></div></div><div id="controls"><button id="play" aria-label="Play">Play</button><input id="time" type="range" min="0" max="1" step="0.001" value="0"><div id="clock">0.00 / 0.00</div></div><script>
|
|
18
|
+
const stage = document.getElementById("stage");
|
|
19
|
+
const errorBox = document.getElementById("error");
|
|
20
|
+
const play = document.getElementById("play");
|
|
21
|
+
const slider = document.getElementById("time");
|
|
22
|
+
const clock = document.getElementById("clock");
|
|
23
|
+
let duration = 0;
|
|
24
|
+
let current = 0;
|
|
25
|
+
let playing = false;
|
|
26
|
+
let last = 0;
|
|
27
|
+
async function frame(time) {
|
|
28
|
+
const response = await fetch("/api/frame?time=" + encodeURIComponent(time), { cache: "no-store" });
|
|
29
|
+
const data = await response.json();
|
|
30
|
+
if (!data.ok) throw new Error(data.error || "Preview failed.");
|
|
31
|
+
duration = Number(data.duration || 0);
|
|
32
|
+
stage.innerHTML = data.svg + "<div id=\\"error\\"></div>";
|
|
33
|
+
slider.max = String(Math.max(duration, 0.001));
|
|
34
|
+
slider.value = String(time);
|
|
35
|
+
clock.textContent = time.toFixed(2) + " / " + duration.toFixed(2);
|
|
36
|
+
}
|
|
37
|
+
async function draw(time) {
|
|
38
|
+
try {
|
|
39
|
+
errorBox.textContent = "";
|
|
40
|
+
await frame(time);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
const box = document.getElementById("error") || errorBox;
|
|
43
|
+
box.textContent = error.message || String(error);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function tick(now) {
|
|
47
|
+
if (!playing) return;
|
|
48
|
+
if (!last) last = now;
|
|
49
|
+
current += (now - last) / 1000;
|
|
50
|
+
last = now;
|
|
51
|
+
if (duration > 0) current = current % duration;
|
|
52
|
+
draw(current);
|
|
53
|
+
requestAnimationFrame(tick);
|
|
54
|
+
}
|
|
55
|
+
play.addEventListener("click", () => {
|
|
56
|
+
playing = !playing;
|
|
57
|
+
play.textContent = playing ? "Pause" : "Play";
|
|
58
|
+
last = 0;
|
|
59
|
+
if (playing) requestAnimationFrame(tick);
|
|
60
|
+
});
|
|
61
|
+
slider.addEventListener("input", () => {
|
|
62
|
+
current = Number(slider.value || 0);
|
|
63
|
+
draw(current);
|
|
64
|
+
});
|
|
65
|
+
draw(0);
|
|
66
|
+
</script></body></html>`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
function escapeHtml(value) {
|
|
71
|
+
return String(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
module.exports = { previewHtml };
|