@cliptude/cli 0.1.19 → 0.1.30

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.
@@ -0,0 +1,126 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Cliptude video</title>
7
+ <style>
8
+ /*@BASE_CSS@*/
9
+ .player { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: var(--border-radius-md); display: block; }
10
+ .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
11
+ .progress { height: 6px; border-radius: 99px; background: var(--color-background-tertiary); overflow: hidden; }
12
+ .progress > span { display: block; height: 100%; background: var(--accent); }
13
+ .pending { display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: var(--border-radius-md); background: var(--color-background-secondary); }
14
+ </style>
15
+ </head>
16
+ <body>
17
+ <main class="app" aria-labelledby="title">
18
+ <div class="head">
19
+ <h1 id="title">Your video</h1>
20
+ <span class="sub" id="facts"></span>
21
+ </div>
22
+ <div id="content"><div class="status" role="status">Loading the video…</div></div>
23
+ </main>
24
+ <div id="toast" role="status" aria-live="polite"></div>
25
+ <script>
26
+ /*@BRIDGE_JS@*/
27
+ (function () {
28
+ "use strict";
29
+ var h = UI.h;
30
+ var content = document.getElementById("content");
31
+
32
+ /** One shape for get_render, get_product_video_status and show_video results. */
33
+ function normalize(data) {
34
+ if (!data) return null;
35
+ if (data.render && typeof data.render === "object") {
36
+ var r = data.render;
37
+ return { title: r.title || data.title || "Edited video", url: r.output_url || "", status: r.status || "",
38
+ progress: r.progress, step: r.current_step || "", error: r.error_message || "", expires: r.output_url_expires_in_s,
39
+ kind: "render", id: r.id };
40
+ }
41
+ if (data.stage !== undefined) {
42
+ var out = data.output || {};
43
+ return { title: (data.product && data.product.title) ? "Video for " + data.product.title : (data.title || "Product video"),
44
+ url: out.url || "", status: data.stage, progress: data.progress, step: data.current_step || "",
45
+ error: data.error || "", duration: data.duration, editorUrl: data.editor_url || "", kind: "product", id: data.job_id };
46
+ }
47
+ return { title: data.title || "Your video", url: data.url || (data.output && data.output.url) || "",
48
+ status: data.status || "", progress: data.progress, step: data.current_step || "", error: data.error || "",
49
+ duration: data.duration_s || data.duration, editorUrl: data.editor_url || "", kind: "job", id: data.job_id };
50
+ }
51
+
52
+ function fmtDuration(s) {
53
+ s = Number(s);
54
+ if (!s || !isFinite(s)) return "";
55
+ s = Math.round(s);
56
+ var m = Math.floor(s / 60), sec = s % 60;
57
+ return m + ":" + (sec < 10 ? "0" : "") + sec;
58
+ }
59
+
60
+ function setFacts(parts) {
61
+ document.getElementById("facts").textContent = parts.filter(Boolean).join(" · ");
62
+ }
63
+
64
+ function linkButton(label, url, primary) {
65
+ return h("button", { type: "button", class: primary ? "primary" : "", onclick: function () {
66
+ Cliptude.openLink(url).catch(function () { UI.toast("The link could not be opened here."); });
67
+ } }, [label]);
68
+ }
69
+
70
+ function renderPending(v) {
71
+ var pct = typeof v.progress === "number" ? Math.max(0, Math.min(100, Math.round(v.progress))) : null;
72
+ var failed = /fail|error|cancel/i.test(v.status || "") || (!!v.error && !v.url);
73
+ var box = h("div", { class: "pending", role: "status" }, [
74
+ h("strong", {}, [failed ? "This video did not render." : "Not rendered yet"]),
75
+ h("span", { class: "sub" }, [failed ? (v.error || "The render failed.")
76
+ : (v.step || (v.status ? "Status: " + v.status.replace(/_/g, " ") : "Still working on it.")) +
77
+ ". Ask Claude to check again in a minute."]),
78
+ pct !== null && !failed ? h("div", { class: "progress", role: "progressbar", "aria-valuemin": "0", "aria-valuemax": "100",
79
+ "aria-valuenow": String(pct), "aria-label": "Render progress" }, [h("span", { style: { width: pct + "%" } })]) : null,
80
+ v.editorUrl ? h("div", { class: "toolbar" }, [linkButton("Open in the editor", v.editorUrl)]) : null
81
+ ]);
82
+ UI.clear(content).appendChild(box);
83
+ }
84
+
85
+ function renderVideo(v) {
86
+ var video = h("video", { class: "player", controls: true, preload: "metadata", playsinline: true, src: v.url,
87
+ "aria-label": v.title });
88
+ var durationText = fmtDuration(v.duration);
89
+ video.addEventListener("loadedmetadata", function () {
90
+ if (!durationText && video.duration) setFacts([fmtDuration(video.duration), "MP4"]);
91
+ Cliptude.reportSize();
92
+ });
93
+ video.addEventListener("play", function () { Media.claimVideo("player", video); });
94
+ video.addEventListener("error", function () {
95
+ UI.toast("The video could not play here. Use Open MP4.");
96
+ });
97
+ var actions = h("div", { class: "toolbar" }, [
98
+ linkButton("Open MP4", v.url, true),
99
+ v.editorUrl ? linkButton("Open in the editor", v.editorUrl) : null
100
+ ]);
101
+ UI.clear(content).appendChild(h("div", { class: "list" }, [
102
+ video,
103
+ h("div", { class: "meta" }, [
104
+ actions,
105
+ v.expires ? h("span", { class: "muted" }, ["The link expires in " + Math.round(v.expires / 86400) +
106
+ " days; ask Claude for a fresh one any time. The MP4 stays in your account."]) : null
107
+ ])
108
+ ]));
109
+ }
110
+
111
+ Cliptude.connect({
112
+ name: "cliptude-video-player",
113
+ onResult: function (data) {
114
+ var err = UI.errorText(data);
115
+ if (err) { UI.status(content, err, "error"); return; }
116
+ var v = normalize(data);
117
+ document.getElementById("title").textContent = v.title;
118
+ setFacts([fmtDuration(v.duration), v.url ? "MP4" : (v.status || "").replace(/_/g, " ")]);
119
+ if (v.url) renderVideo(v); else renderPending(v);
120
+ },
121
+ onCancelled: function () { UI.status(content, "Cancelled."); }
122
+ }).catch(function () { UI.status(content, "This view could not connect to the chat.", "error"); });
123
+ })();
124
+ </script>
125
+ </body>
126
+ </html>
@@ -0,0 +1,170 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Publish kit</title>
7
+ <style>
8
+ /*@BASE_CSS@*/
9
+ section { display: flex; flex-direction: column; gap: 8px; }
10
+ h2 { font-size: var(--font-text-md-size); margin: 0; font-weight: 600; }
11
+ .sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
12
+ .big { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--border-radius-md); background: var(--color-background-tertiary); display: block; }
13
+ .thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
14
+ .thumbs .card .thumb { aspect-ratio: 16 / 9; }
15
+ pre.copy {
16
+ margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font-sans); font-size: var(--font-text-sm-size);
17
+ background: var(--color-background-secondary); border: 1px solid var(--color-border-secondary); border-radius: var(--border-radius-md);
18
+ padding: 10px 12px; max-height: 260px; overflow: auto; user-select: text;
19
+ }
20
+ .title-row .name { font-weight: 500; }
21
+ .tag { user-select: text; }
22
+ </style>
23
+ </head>
24
+ <body>
25
+ <main class="app" aria-labelledby="title">
26
+ <div class="head">
27
+ <h1 id="title">Publish kit</h1>
28
+ <span class="sub" id="facts"></span>
29
+ </div>
30
+ <div id="content" class="list"><div class="status" role="status">Loading the publish kit…</div></div>
31
+ </main>
32
+ <div id="toast" role="status" aria-live="polite"></div>
33
+ <script>
34
+ /*@BRIDGE_JS@*/
35
+ (function () {
36
+ "use strict";
37
+ var h = UI.h;
38
+ var content = document.getElementById("content");
39
+ var kit = null;
40
+ var current = 0;
41
+
42
+ function selectText(el) {
43
+ try {
44
+ var range = document.createRange(); range.selectNodeContents(el);
45
+ var sel = window.getSelection(); sel.removeAllRanges(); sel.addRange(range);
46
+ } catch (e) {}
47
+ }
48
+
49
+ /** Clipboard API (clipboardWrite permission), else execCommand, else select the text for the user. */
50
+ function copy(text, el) {
51
+ function fallback() {
52
+ var area = h("textarea", { style: { position: "fixed", opacity: "0", top: "0", left: "0" } });
53
+ area.value = text; document.body.appendChild(area); area.select();
54
+ var ok = false;
55
+ try { ok = document.execCommand("copy"); } catch (e) { ok = false; }
56
+ area.remove();
57
+ if (ok) { UI.toast("Copied."); return; }
58
+ if (el) selectText(el);
59
+ UI.toast("Selected. Press ⌘C or Ctrl+C to copy.");
60
+ }
61
+ if (navigator.clipboard && navigator.clipboard.writeText) {
62
+ navigator.clipboard.writeText(text).then(function () { UI.toast("Copied."); }, fallback);
63
+ } else fallback();
64
+ }
65
+
66
+ function open(url) { Cliptude.openLink(url).catch(function () { UI.toast("The link could not be opened here."); }); }
67
+
68
+ function thumbsSection(items, status) {
69
+ if (!items.length) {
70
+ return h("section", {}, [h("h2", {}, ["Thumbnails"]),
71
+ h("div", { class: "status" }, [status && status !== "completed" ? "Thumbnails are " + status.replace(/_/g, " ") + "." : "No thumbnails yet."])]);
72
+ }
73
+ var item = items[current] || items[0];
74
+ var big = h("img", { class: "big", src: item.url, alt: (item.label || "Thumbnail") + " preview" });
75
+ var grid = h("div", { class: "thumbs", role: "list" });
76
+ items.forEach(function (t, i) {
77
+ var c = h("button", { type: "button", class: "card", role: "listitem", "aria-pressed": String(i === current),
78
+ "aria-label": "Show " + (t.label || "thumbnail " + (i + 1)), onclick: function () { current = i; render(); } },
79
+ [UI.img(t.url, "", String(i + 1)), h("span", { class: "body" }, [h("span", { class: "name" }, [t.label || "Thumbnail " + (i + 1)])])]);
80
+ grid.appendChild(c);
81
+ });
82
+ return h("section", {}, [
83
+ h("div", { class: "sec-head" }, [h("h2", {}, ["Thumbnails (" + items.length + ")"]),
84
+ h("span", { class: "toolbar" }, [
85
+ h("button", { type: "button", onclick: function () { open(item.url); } }, ["Open full size"]),
86
+ h("button", { type: "button", onclick: function () {
87
+ UI.choose("I will use “" + (item.label || "this thumbnail") + "” as the thumbnail: " + item.url, { thumbnail_url: item.url });
88
+ } }, ["Use this thumbnail"])
89
+ ])]),
90
+ big, grid
91
+ ]);
92
+ }
93
+
94
+ function titlesSection(titles) {
95
+ if (!titles.length) return null;
96
+ var list = h("div", { class: "list", role: "list" });
97
+ titles.forEach(function (t) {
98
+ list.appendChild(h("div", { class: "row title-row", role: "listitem" }, [
99
+ h("div", { class: "main" }, [h("span", { class: "name" }, [t])]),
100
+ h("button", { type: "button", "aria-label": "Copy title: " + t, onclick: function () { copy(t); } }, ["Copy"]),
101
+ h("button", { type: "button", onclick: function () { UI.choose("Use this title for the video: “" + t + "”", { title: t }); } }, ["Use"])
102
+ ]));
103
+ });
104
+ return h("section", {}, [h("h2", {}, ["Title ideas"]), list]);
105
+ }
106
+
107
+ function textSection(title, text) {
108
+ if (!text) return null;
109
+ var pre = h("pre", { class: "copy", tabindex: "0" }, [text]);
110
+ return h("section", {}, [
111
+ h("div", { class: "sec-head" }, [h("h2", {}, [title]),
112
+ h("button", { type: "button", onclick: function () { copy(text, pre); } }, ["Copy " + title.toLowerCase()])]),
113
+ pre
114
+ ]);
115
+ }
116
+
117
+ function tagsSection(tags) {
118
+ if (!tags.length) return null;
119
+ var box = h("div", { class: "chips", role: "list" });
120
+ tags.forEach(function (t) { box.appendChild(h("span", { class: "chip tag", role: "listitem" }, [t])); });
121
+ return h("section", {}, [
122
+ h("div", { class: "sec-head" }, [h("h2", {}, ["Tags (" + tags.length + ")"]),
123
+ h("button", { type: "button", onclick: function () { copy(tags.join(", "), box); } }, ["Copy all tags"])]),
124
+ box
125
+ ]);
126
+ }
127
+
128
+ function render() {
129
+ var meta = kit.publish_metadata || {};
130
+ var thumbs = (kit.thumbnails && kit.thumbnails.items) || [];
131
+ var tags = meta.tags || [];
132
+ var description = String(meta.description || "");
133
+ if (tags.length) {
134
+ // The generated description ends with its tags line; show it once, as chips.
135
+ var line = tags.join(", ").toLowerCase();
136
+ description = description.split(/\n\s*\n/).filter(function (p) {
137
+ var flat = p.split(",").map(function (x) { return x.trim().replace(/^#/, "").toLowerCase(); }).filter(Boolean);
138
+ return !(flat.length >= 5 && flat.every(function (x) { return line.indexOf(x) >= 0; }));
139
+ }).join("\n\n");
140
+ }
141
+ var downloads = meta.downloads || {};
142
+ UI.clear(content);
143
+ [thumbsSection(thumbs, kit.thumbnails && kit.thumbnails.status),
144
+ titlesSection(meta.title_variants || []),
145
+ textSection("Description", description.trim()),
146
+ textSection("Chapters", meta.chapters || ""),
147
+ tagsSection(tags),
148
+ downloads.voiceover_url || downloads.project_zip_url ? h("section", {}, [h("h2", {}, ["Downloads"]), h("div", { class: "toolbar" }, [
149
+ downloads.voiceover_url ? h("button", { type: "button", onclick: function () { open(downloads.voiceover_url); } }, ["Voiceover"]) : null,
150
+ downloads.project_zip_url ? h("button", { type: "button", onclick: function () { open(downloads.project_zip_url); } }, ["Project files"]) : null
151
+ ])]) : null
152
+ ].forEach(function (s) { if (s) content.appendChild(s); });
153
+ if (!content.childNodes.length) UI.status(content, "Nothing to publish yet.");
154
+ }
155
+
156
+ Cliptude.connect({
157
+ name: "cliptude-publish-kit",
158
+ onResult: function (data) {
159
+ var err = UI.errorText(data);
160
+ if (err) { UI.status(content, err, "error"); return; }
161
+ kit = data.project && !data.publish_metadata ? data.project : data;
162
+ document.getElementById("title").textContent = kit.title ? "Publish kit · " + kit.title : "Publish kit";
163
+ render();
164
+ },
165
+ onCancelled: function () { UI.status(content, "Cancelled."); }
166
+ }).catch(function () { UI.status(content, "This view could not connect to the chat.", "error"); });
167
+ })();
168
+ </script>
169
+ </body>
170
+ </html>