@hypersocial/decks-cli 0.9.23 → 0.9.25
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/package.json +1 -1
- package/skills/hyperdecks/SKILL.md +124 -67
- package/skills/hyperdecks/chat.md +11 -8
- package/skills/hyperdecks/terminal.md +83 -0
- package/src/bars.mjs +268 -0
- package/src/brand.mjs +51 -8
- package/src/check.mjs +333 -20
- package/src/checkRules.mjs +677 -27
- package/src/commands.mjs +171 -31
- package/src/deckSlug.mjs +41 -0
- package/src/embedCapture.mjs +126 -0
- package/src/embedSources.mjs +252 -0
- package/src/embedsGuide.mjs +36 -0
- package/src/export-video.mjs +20 -3
- package/src/files.mjs +36 -0
- package/src/guide.mjs +93 -13
- package/src/hosted.mjs +18 -8
- package/src/iconAliasNames.mjs +70 -0
- package/src/iconChoice.mjs +97 -0
- package/src/iconSets.mjs +89 -0
- package/src/iconSlots.mjs +48 -0
- package/src/icons.mjs +285 -45
- package/src/iconsCli.mjs +76 -0
- package/src/layoutRoutes.mjs +97 -0
- package/src/layouts.mjs +9 -4
- package/src/mediaPreviews.mjs +3 -1
- package/src/narrate.mjs +31 -4
- package/src/opening.mjs +9 -3
- package/src/ops.mjs +125 -0
- package/src/photosGuide.mjs +47 -0
- package/src/picturesGuide.mjs +54 -0
- package/src/play.mjs +3 -2
- package/src/presenter.mjs +3 -1
- package/src/preview-capture.mjs +70 -1
- package/src/release.mjs +13 -5
- package/src/runtime.mjs +9 -2
- package/src/scaffold.mjs +73 -13
- package/src/source.mjs +86 -14
- package/src/stockMedia.mjs +299 -0
- package/src/themeCli.mjs +41 -0
- package/src/themes.mjs +345 -0
- package/templates/icons/material.LICENSE +202 -0
- package/templates/icons/material.json.gz +0 -0
- package/templates/icons/phosphor.LICENSE +21 -0
- package/templates/icons/phosphor.json.gz +0 -0
- package/templates/icons/tabler.LICENSE +21 -0
- package/templates/icons/tabler.json.gz +0 -0
- package/templates/layouts/_deck.html +231 -41
- package/templates/layouts/bento.html +76 -0
- package/templates/layouts/chart.html +6 -4
- package/templates/layouts/closer.html +13 -4
- package/templates/layouts/compare.html +13 -4
- package/templates/layouts/cover-band.html +13 -9
- package/templates/layouts/cover-frame.html +13 -7
- package/templates/layouts/cover-poster.html +9 -5
- package/templates/layouts/cover-split.html +19 -7
- package/templates/layouts/cover-type.html +2 -1
- package/templates/layouts/embed.html +93 -0
- package/templates/layouts/features.html +18 -10
- package/templates/layouts/funnel.html +62 -0
- package/templates/layouts/hero.html +41 -23
- package/templates/layouts/lanes.html +63 -0
- package/templates/layouts/loop.html +81 -0
- package/templates/layouts/number.html +3 -2
- package/templates/layouts/phone-stage.html +78 -0
- package/templates/layouts/phones.html +1 -0
- package/templates/layouts/picture-full.html +58 -0
- package/templates/layouts/portrait.html +53 -0
- package/templates/layouts/product.html +7 -6
- package/templates/layouts/quote.html +5 -3
- package/templates/layouts/rail.html +74 -0
- package/templates/layouts/scorecard.html +71 -0
- package/templates/layouts/screens.html +85 -0
- package/templates/layouts/sentence.html +39 -0
- package/templates/layouts/split.html +35 -7
- package/templates/layouts/spotlight.html +80 -0
- package/templates/layouts/stack.html +84 -0
- package/templates/layouts/staircase.html +78 -0
- package/templates/layouts/strike.html +46 -0
- package/templates/layouts/tap-through.html +73 -0
- package/templates/layouts/team.html +21 -6
- package/templates/layouts/timeline.html +21 -8
- package/templates/layouts/two-bars.html +53 -0
- package/templates/layouts/two-by-two.html +75 -0
- package/templates/layouts/video-beats.html +66 -0
- package/templates/layouts/video-full.html +62 -0
- package/templates/layouts/wall.html +109 -0
- package/templates/layouts/zoom.html +144 -0
- package/templates/narrated-deck.html +12 -7
- package/templates/script.md +2 -2
- /package/templates/icons/{LICENSE → lucide.LICENSE} +0 -0
package/src/mediaPreviews.mjs
CHANGED
|
@@ -133,7 +133,9 @@ export function withMediaPreviews(page, previews) {
|
|
|
133
133
|
if (!p) return whole;
|
|
134
134
|
count++;
|
|
135
135
|
const poster = hasAttr(open, "poster") ? null : p.poster ?? null;
|
|
136
|
-
|
|
136
|
+
// A video always gets its clip's shape, width/height or not: layouts choose their arrangement by it (video-full
|
|
137
|
+
// reads --hd-ar), and where one side is left auto the clip's own ratio wins once it loads, so --hd-ar only states it early.
|
|
138
|
+
return annotate(open, p, { poster }) + whole.slice(open.length);
|
|
137
139
|
});
|
|
138
140
|
out = out.replace(STYLED, (tag) => {
|
|
139
141
|
if (/^<(img|video)\b/i.test(tag) || done(tag)) return tag;
|
package/src/narrate.mjs
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
// This polls the job, saves the manifest into <deck-dir>/narration/ and points the
|
|
7
7
|
// player script's data-manifest in index.html at the new manifest URL.
|
|
8
8
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
9
|
-
import {
|
|
9
|
+
import { join, resolve } from "node:path";
|
|
10
|
+
import { deckSlug, slugNote } from "./deckSlug.mjs";
|
|
10
11
|
import * as ops from "./ops.mjs";
|
|
11
12
|
import { presenterLine } from "./presenter.mjs";
|
|
12
13
|
import { writeDraftFace } from "./draftFace.mjs";
|
|
@@ -31,7 +32,7 @@ export function narrationRequest(pos, opts) {
|
|
|
31
32
|
return {
|
|
32
33
|
deckDir,
|
|
33
34
|
fields: {
|
|
34
|
-
slug:
|
|
35
|
+
slug: deckSlug(deckDir, opts),
|
|
35
36
|
script: readFileSync(scriptPath, "utf8"),
|
|
36
37
|
voice: opts.voice,
|
|
37
38
|
slides: opts.slide !== undefined ? slideList(opts.slide) : undefined,
|
|
@@ -40,9 +41,35 @@ export function narrationRequest(pos, opts) {
|
|
|
40
41
|
};
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
// One narration job runs per account (convex/narration.ts). While another runs,
|
|
45
|
+
// wait for it and try again, for up to `busyWaitMs`; then stop with its name.
|
|
46
|
+
// Nothing is charged for a refused start, so the retry (or a rerun) is safe.
|
|
47
|
+
export const BUSY_WAIT_MS = 5 * 60 * 1000;
|
|
48
|
+
const BUSY_POLL_MS = 15 * 1000;
|
|
49
|
+
const busy = (e) => /already running/i.test(String(e?.data ?? e?.message ?? e));
|
|
50
|
+
const busyText = (e) => String(e?.data ?? e?.message ?? e).replace(/^.*?(a narration job is already running)/i, "$1").split(";")[0];
|
|
51
|
+
export async function startNarration(opts, fields, { log, sleep = (ms) => new Promise((ok) => setTimeout(ok, ms)), busyWaitMs = BUSY_WAIT_MS } = {}) {
|
|
52
|
+
let waited = 0;
|
|
53
|
+
for (;;) {
|
|
54
|
+
try {
|
|
55
|
+
return await ops.narrateDeck(opts, fields);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
if (!busy(e)) throw e;
|
|
58
|
+
if (waited >= busyWaitMs) {
|
|
59
|
+
throw new Error(`${busyText(e)}; waited ${Math.round(waited / 60000)} min for it. One narration runs per account: when it finishes, run this again (it is safe: nothing was charged and cached slides stay cached)`);
|
|
60
|
+
}
|
|
61
|
+
if (!waited) log(`… ${busyText(e)}; waiting for it (up to ${Math.round(busyWaitMs / 60000)} min), then this one starts`);
|
|
62
|
+
await sleep(BUSY_POLL_MS);
|
|
63
|
+
waited += BUSY_POLL_MS;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
43
68
|
// writeFace false: leave the presenter as written (release narrates, then puts the face on the upload itself).
|
|
44
|
-
export async function narrate(pos, opts = {}, { log = (line) => console.log(line), writeFace = true } = {}) {
|
|
69
|
+
export async function narrate(pos, opts = {}, { log = (line) => console.log(line), writeFace = true, sleep, busyWaitMs } = {}) {
|
|
45
70
|
const { deckDir, fields } = narrationRequest(pos, opts);
|
|
71
|
+
const note = slugNote(deckDir, opts);
|
|
72
|
+
if (note) log(`narrating ${note}`);
|
|
46
73
|
if (opts["dry-run"]) {
|
|
47
74
|
const preview = await ops.previewNarration(opts, fields);
|
|
48
75
|
if (preview.presenterStyle) log(`presenter style: ${preview.presenterStyle}`);
|
|
@@ -54,7 +81,7 @@ export async function narrate(pos, opts = {}, { log = (line) => console.log(line
|
|
|
54
81
|
if (who) log(who);
|
|
55
82
|
return preview;
|
|
56
83
|
}
|
|
57
|
-
const { jobId, slides, presenter, credits, creditsRemaining } = await
|
|
84
|
+
const { jobId, slides, presenter, credits, creditsRemaining } = await startNarration(opts, fields, { log, sleep, busyWaitMs });
|
|
58
85
|
log(`narration job ${jobId}: ${slides.filter((s) => s.status === "render").length} to render, ${slides.filter((s) => s.status === "cached").length} cached`);
|
|
59
86
|
if (credits > 0) log(`charged ${credits} credit${credits === 1 ? "" : "s"}${creditsRemaining != null ? `, credits left: ${creditsRemaining}` : ""}`);
|
|
60
87
|
const who = presenterLine(presenter);
|
package/src/opening.mjs
CHANGED
|
@@ -75,9 +75,13 @@ export const OPENING_CSS = `#hd-open{position:fixed;inset:0;z-index:2147483000;p
|
|
|
75
75
|
|
|
76
76
|
// Runs the card `o` (#hd-open): shows it after FAST_MS unless the deck is
|
|
77
77
|
// ready, follows data-hd-boot, and on data-hd-ready jumps, fades and removes
|
|
78
|
-
// itself. In a frame, a thumbnail or an export it removes itself at once.
|
|
78
|
+
// itself. In a frame, a thumbnail or an export it removes itself at once. A
|
|
79
|
+
// deep link (#<n> past 1, or #scene=<id>, navigation.js sceneFromHash) opens
|
|
80
|
+
// on plain ground: the poster (its URL in data-src, so a deep link never
|
|
81
|
+
// fetches it) is the cover, not the slide being opened.
|
|
79
82
|
export const OPENING_RUN = `function(o){var b=document.body,d=document.documentElement;if(!o||!b)return;
|
|
80
83
|
if(self!==top||/[?&](thumb|export)\\b/.test(location.search)||d.hasAttribute("data-hyperdecks-thumb")){o.remove();return}
|
|
84
|
+
var pic=o.querySelector(".hdo-slide img");if(pic){if(/^#(scene=|(?!1$)\\d+$)/.test(location.hash||""))pic.remove();else pic.src=pic.getAttribute("data-src")}
|
|
81
85
|
var S=${JSON.stringify(BOOT_STEPS)},bar=o.querySelector(".hdo-bar i"),step=o.querySelector(".hdo-step"),who=o.getAttribute("data-name")||"the presenter",at=0,shown=false,done=false,mo;
|
|
82
86
|
var rm=window.matchMedia&&matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
83
87
|
function boot(){var s=S[b.getAttribute("data-hd-boot")];if(!s||s[0]<=at)return;at=s[0];bar.style.width=s[0]+"%";step.textContent=s[1].split("{name}").join(who)}
|
|
@@ -102,13 +106,15 @@ export const OPENING_BUDDY = `<div class="hdo-buddy"><div class="hdo-hop"><div c
|
|
|
102
106
|
// unless a route already added a card, the player is ready, or the page is
|
|
103
107
|
// framed, a thumbnail or an export, it puts a card at the top of <body> with
|
|
104
108
|
// the page's <title> and the player tag's presenter still (none when it
|
|
105
|
-
// presents nobody
|
|
109
|
+
// presents nobody, or for a silent deck the player shows with no presenter:
|
|
110
|
+
// player.js silentFaceless), with no poster and no narrator's name, and runs it.
|
|
106
111
|
export const OPENING_PAGE_SCRIPT = `<script data-hd-opening>(function(){var d=document;
|
|
107
112
|
if(self!==top||/[?&](thumb|export)\\b/.test(location.search))return;
|
|
108
113
|
function go(){if(d.readyState==="loading")return;d.removeEventListener("readystatechange",go);
|
|
109
114
|
var b=d.body,p=d.querySelector('script[src*="/player/v"][src*="/player.js"]');
|
|
110
115
|
if(!b||!p||d.getElementById("hd-open")||b.hasAttribute("data-hd-ready")||d.documentElement.hasAttribute("data-hyperdecks-thumb"))return;
|
|
111
|
-
var
|
|
116
|
+
var sv=p.getAttribute("data-silent"),mute=sv!==null&&!/^(false|0|no)$/i.test(sv)&&p.getAttribute("data-silent-presenter")==="hide"&&!p.getAttribute("data-manifest")&&!d.querySelector("section[data-clip]");
|
|
117
|
+
var o=d.createElement("div"),img=!mute&&p.getAttribute("data-presenter")!=="none"&&p.getAttribute("data-presenter-image");
|
|
112
118
|
o.id="hd-open";o.setAttribute("aria-hidden","true");
|
|
113
119
|
o.innerHTML='<div class="hdo-slide"></div><div class="hdo-card">'+(img?${JSON.stringify(OPENING_BUDDY)}:'')+'<div class="hdo-title"></div><div class="hdo-bar"><i></i></div><div class="hdo-step"></div></div>';
|
|
114
120
|
if(img){var i=o.querySelector(".hdo-buddy img");i.addEventListener("error",function(){var y=o.querySelector(".hdo-buddy");if(y)y.remove()});i.src=img}
|
package/src/ops.mjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { fitSlot, parseSlotTarget, searchHint } from "./stockMedia.mjs";
|
|
2
|
+
import { MID_STILL, PHONE_STILL, STILL_HEIGHT, STILL_WIDTH, embedMarkup, embedSiteHint, resolveEmbed, sharedLinkNote } from "./embedSources.mjs";
|
|
3
|
+
import { extensionFor, framedStill, noLocalBrowser, publishedStill, stillName } from "./embedCapture.mjs";
|
|
1
4
|
import { deckPlayer, importPlayerWarning, viewPlayerWarning } from "./deckPlayer.mjs";
|
|
2
5
|
import { zipSync } from "fflate";
|
|
3
6
|
import { SPECIES } from "./species.mjs";
|
|
@@ -219,15 +222,123 @@ export async function generateVideo(opts, fields = {}) {
|
|
|
219
222
|
// Returns { url, storageId, contentType, name?, width, height, creditsRemaining? }.
|
|
220
223
|
export async function captureUrl(opts, fields = {}) {
|
|
221
224
|
if (!fields.url) throw new Error("url is required");
|
|
225
|
+
if (fields.embed) return captureEmbed(opts, fields);
|
|
222
226
|
const args = { url: String(fields.url) };
|
|
223
227
|
if (fields.width != null && fields.width !== "") args.width = Number(fields.width);
|
|
224
228
|
if (fields.height != null && fields.height !== "") args.height = Number(fields.height);
|
|
225
229
|
if (fields.fullPage) args.fullPage = true;
|
|
226
230
|
if (fields.slug) args.slug = String(fields.slug);
|
|
227
231
|
if (fields.name) args.name = String(fields.name);
|
|
232
|
+
if (fields.requireOk) args.requireOk = true;
|
|
228
233
|
return (await client(opts)).action(api.screenshots.captureUrl, args);
|
|
229
234
|
}
|
|
230
235
|
|
|
236
|
+
// The embed slide's still (screenshot --embed, capture_url { embed: true }), saved as an asset of the deck (`slug`)
|
|
237
|
+
// at 1600x900, the frame's shape (embedCapture.mjs): a video or Figma file's own published picture; a map, a booking
|
|
238
|
+
// page or any other page captured inside a frame, in this machine's Chromium when the CLI has one (`hyperdecks
|
|
239
|
+
// preview setup`), else on the app's renderer. Refused, not saved, when the frame shows an error or a banner.
|
|
240
|
+
// Returns the asset, how the slide treats the URL (live on tap, or a still with a link out) and the frame's markup.
|
|
241
|
+
export async function captureEmbed(opts, fields = {}, { fetchImpl = fetch, framed = framedStill, local = !opts.client } = {}) {
|
|
242
|
+
const url = String(fields.url ?? "");
|
|
243
|
+
const resolved = resolveEmbed(url);
|
|
244
|
+
if (!resolved) throw new Error(`embed needs an https link (got ${url || "nothing"})`);
|
|
245
|
+
if (!resolved.live && resolved.site) throw new Error(embedSiteHint(resolved.site, resolved.host));
|
|
246
|
+
if (!fields.slug) throw new Error("embed needs the deck (--slug <deck>; capture_url: slug): the still is saved as one of its pictures");
|
|
247
|
+
const name = fields.name ? String(fields.name) : stillName(resolved);
|
|
248
|
+
const slug = String(fields.slug);
|
|
249
|
+
const save = async (still, suffix) => {
|
|
250
|
+
const c = await client(opts);
|
|
251
|
+
const storageId = await runtimeUploadBytes(c, still.bytes, still.contentType);
|
|
252
|
+
const row = await c.mutation(api.assets.saveAsset, { name: `${name}${suffix}.${extensionFor(still.contentType)}`, storageId, contentType: still.contentType, deckSlug: slug });
|
|
253
|
+
return { url: row.url, name: row.name, width: still.width, height: still.height, title: still.title };
|
|
254
|
+
};
|
|
255
|
+
// A video or Figma file: its own published picture, one for both shapes.
|
|
256
|
+
const published = resolved.live ? await publishedStill(resolved, { fetchImpl }) : null;
|
|
257
|
+
let wide, mid, phone;
|
|
258
|
+
if (published) wide = await save({ ...published, width: published.width ?? 1600, height: published.height ?? 900 }, "");
|
|
259
|
+
else {
|
|
260
|
+
// A map or a page: one still at the slide's shape and one at a phone's, each as its frame shows it, never cropped.
|
|
261
|
+
const src = resolved.live ? resolved.src : resolved.href;
|
|
262
|
+
const label = resolved.name ?? resolved.host;
|
|
263
|
+
let shots = null;
|
|
264
|
+
if (local) {
|
|
265
|
+
try {
|
|
266
|
+
shots = [await framed(src, label, { top: !resolved.live }), await framed(src, label, { top: !resolved.live, ...MID_STILL }), await framed(src, label, { top: !resolved.live, phone: true })];
|
|
267
|
+
} catch (e) {
|
|
268
|
+
// No Chromium here: the app's renderer takes it (and refuses an error page the same way).
|
|
269
|
+
if (!noLocalBrowser(e)) throw e;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (shots) [wide, mid, phone] = [await save(shots[0], ""), await save(shots[1], "-mid"), await save(shots[2], "-phone")];
|
|
273
|
+
else {
|
|
274
|
+
// requireOk: the renderer refuses an error answer or a blank page instead of saving it.
|
|
275
|
+
const shot = async (size, suffix) => {
|
|
276
|
+
const out = await captureUrl(opts, { url: src, ...size, slug, name: `${name}${suffix}`, requireOk: true });
|
|
277
|
+
return { url: out.url, name: out.name ?? `${name}${suffix}`, width: size.width, height: size.height, creditsRemaining: out.creditsRemaining };
|
|
278
|
+
};
|
|
279
|
+
wide = await shot({ width: STILL_WIDTH, height: STILL_HEIGHT }, "");
|
|
280
|
+
mid = await shot(MID_STILL, "-mid");
|
|
281
|
+
phone = await shot({ width: PHONE_STILL.width, height: PHONE_STILL.height }, "-phone");
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
// The alt says what the picture shows: the author's own, else the place a map is of, the page's or video's title.
|
|
285
|
+
const place = resolved.source === "google-maps" ? new URL(resolved.src).searchParams.get("q") : null;
|
|
286
|
+
const title = wide.title ?? published?.title;
|
|
287
|
+
const named = place ? `Map of ${place}` : title ? `${resolved.live ? `${resolved.name}: ` : ""}${title}` : null;
|
|
288
|
+
const alt = fields.alt ? String(fields.alt) : named ?? (resolved.live ? resolved.name : `The page at ${resolved.host}`);
|
|
289
|
+
return {
|
|
290
|
+
url: wide.url,
|
|
291
|
+
name: wide.name,
|
|
292
|
+
width: wide.width,
|
|
293
|
+
height: wide.height,
|
|
294
|
+
...(phone ? { phone: { url: phone.url, name: phone.name, width: phone.width, height: phone.height } } : {}),
|
|
295
|
+
...(phone?.creditsRemaining != null ? { creditsRemaining: phone.creditsRemaining } : {}),
|
|
296
|
+
alt,
|
|
297
|
+
altNote: fields.alt ? null : named ? `alt: "${alt}" (say what the picture shows, if it is not that)` : `alt: "${alt}" says only where it is from: replace it with what the picture shows`,
|
|
298
|
+
// No check catches every banner or pop-up: the author looks before the deck goes out.
|
|
299
|
+
...(mid ? { mid: { url: mid.url, name: mid.name, width: mid.width, height: mid.height } } : {}),
|
|
300
|
+
look: `look at the saved still${phone ? "s" : ""} before you use ${phone ? "them" : "it"}: ${[wide.url, mid?.url, phone?.url].filter(Boolean).join(" ")}`,
|
|
301
|
+
embed: resolved.live
|
|
302
|
+
? { live: true, source: resolved.source, label: resolved.label, frame: resolved.src, ...(sharedLinkNote(resolved) ? { note: sharedLinkNote(resolved) } : {}) }
|
|
303
|
+
: { live: false, label: resolved.label, note: `${resolved.host} is not one of the embed sources, so the slide shows the still with a link that opens it in a new tab` },
|
|
304
|
+
markup: embedMarkup(url, wide.url, { alt, width: wide.width, height: wide.height, id: fields.id, kind: resolved.live ? resolved.kind : "page", phone: phone && { src: phone.url, width: phone.width, height: phone.height }, mid: mid && { src: mid.url, width: mid.width, height: mid.height } }),
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// Found pictures (convex/stockMedia.ts): Unsplash photos and GIPHY GIFs, free.
|
|
309
|
+
// Both are embedded from the service's own URL with a credit line (their terms);
|
|
310
|
+
// see stockMedia.mjs. Results carry the shape so a layout can be picked by it.
|
|
311
|
+
export async function searchPhotos(opts, fields = {}) {
|
|
312
|
+
if (!fields.query) throw new Error("query is required");
|
|
313
|
+
const args = { query: String(fields.query) };
|
|
314
|
+
if (fields.orientation) args.orientation = String(fields.orientation);
|
|
315
|
+
if (fields.limit != null && fields.limit !== "") args.limit = Number(fields.limit);
|
|
316
|
+
const out = await (await client(opts)).action(api.stockMedia.searchPhotos, args);
|
|
317
|
+
const hint = searchHint({ orientation: args.orientation, limit: args.limit, count: out.results.length });
|
|
318
|
+
return hint ? { ...out, hint } : out;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// Use one photo from searchPhotos: its slide URL, credit and markup; tells
|
|
322
|
+
// Unsplash it was used (their download tracking).
|
|
323
|
+
export async function addPhoto(opts, fields = {}) {
|
|
324
|
+
if (!fields.id) throw new Error("id is required (a photo id from search_photos)");
|
|
325
|
+
// `for`: a layout (or a slide id made from one) whose picture slot the markup
|
|
326
|
+
// is for; checked first, so a wrong name never counts as an Unsplash download.
|
|
327
|
+
if (fields.for) parseSlotTarget(fields.for);
|
|
328
|
+
const out = await (await client(opts)).action(api.stockMedia.addPhoto, { id: String(fields.id) });
|
|
329
|
+
return fields.for ? fitSlot(out, fields.for) : out;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export async function searchGifs(opts, fields = {}) {
|
|
333
|
+
if (!fields.query) throw new Error("query is required");
|
|
334
|
+
const args = { query: String(fields.query) };
|
|
335
|
+
if (fields.rating) args.rating = String(fields.rating).toLowerCase();
|
|
336
|
+
if (fields.limit != null && fields.limit !== "") args.limit = Number(fields.limit);
|
|
337
|
+
if (fields.for) parseSlotTarget(fields.for);
|
|
338
|
+
const out = await (await client(opts)).action(api.stockMedia.searchGifs, args);
|
|
339
|
+
return fields.for ? { ...out, results: out.results.map((r) => fitSlot(r, fields.for)) } : out;
|
|
340
|
+
}
|
|
341
|
+
|
|
231
342
|
const CHART_FIELDS = ["kind", "title", "subtitle", "labels", "series", "values", "value", "label", "delta", "prefix", "suffix", "palette", "width", "height", "slug", "name"];
|
|
232
343
|
|
|
233
344
|
// Render a chart spec (convex/charts.ts) to a branded SVG asset. Unknown keys are
|
|
@@ -630,6 +741,9 @@ export async function listShares(opts, slug) {
|
|
|
630
741
|
allowForwardOverride: r.allowForwardOverride ?? null,
|
|
631
742
|
// The link's own pace (auto, slide, step); null = it follows the deck.
|
|
632
743
|
pace: r.pace ?? null,
|
|
744
|
+
// "play": an open counts (and alerts) only when the viewer presses play,
|
|
745
|
+
// for a deck embedded in a page; null = on open, the default.
|
|
746
|
+
countOn: r.countOn ?? null,
|
|
633
747
|
parentToken: r.parentToken ?? null,
|
|
634
748
|
forwardedBy: r.forwardedBy ?? null,
|
|
635
749
|
probablyForwarded: !!r.probablyForwarded,
|
|
@@ -646,6 +760,8 @@ export async function createShare(opts, fields) {
|
|
|
646
760
|
if (fields.note) args.note = fields.note;
|
|
647
761
|
if (fields.requireEmail) args.requireEmail = true;
|
|
648
762
|
if (fields.allowForward !== undefined) args.allowForward = !!fields.allowForward;
|
|
763
|
+
// Count an open only when the viewer presses play (an embedded deck).
|
|
764
|
+
if (fields.countOnPlay) args.countOn = "play";
|
|
649
765
|
// The link's own pace; absent = it follows the deck's.
|
|
650
766
|
if (fields.pace !== undefined) {
|
|
651
767
|
if (!DECK_PACES.includes(fields.pace)) throw new Error(`pace must be auto, slide or step (got ${JSON.stringify(fields.pace)})`);
|
|
@@ -670,6 +786,15 @@ export async function setShareEnabled(opts, token, enabled) {
|
|
|
670
786
|
return { token, enabled: !!enabled };
|
|
671
787
|
}
|
|
672
788
|
|
|
789
|
+
// When a link counts an open: on play (true, for a deck embedded in a page)
|
|
790
|
+
// or on open (false, the default for a link sent to a person).
|
|
791
|
+
export async function setShareCountOn(opts, token, onPlay) {
|
|
792
|
+
if (!token) throw new Error("token is required");
|
|
793
|
+
const countOn = onPlay ? "play" : null;
|
|
794
|
+
await (await client(opts)).mutation(api.shares.setCountOn, { token, countOn });
|
|
795
|
+
return { token, countOn };
|
|
796
|
+
}
|
|
797
|
+
|
|
673
798
|
export async function setShareNotify(opts, token, notify) {
|
|
674
799
|
if (!token) throw new Error("token is required");
|
|
675
800
|
await (await client(opts)).mutation(api.shares.setNotify, { token, notify });
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// hyperdecks guide photos (deck_guide topic photos; also "gifs"): found photos
|
|
2
|
+
// (Unsplash) and GIFs (GIPHY). Written per surface: the CLI's names the
|
|
3
|
+
// commands and the words they print; the hosted MCP's names the tools and the
|
|
4
|
+
// fields they return.
|
|
5
|
+
import { PICTURE_SLOTS } from "./stockMedia.mjs";
|
|
6
|
+
|
|
7
|
+
const slotList = () => {
|
|
8
|
+
const by = (cls) => Object.entries(PICTURE_SLOTS).filter(([, s]) => s.cls === cls).map(([n]) => `\`${n}\``).join(", ");
|
|
9
|
+
return `${by("art")} (\`class="art"\`), ${by("pic")} (\`class="pic"\`) or ${by("shot")} (\`class="shot"\`)`;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function photosGuide(surface) {
|
|
13
|
+
const cli = surface === "cli";
|
|
14
|
+
const ex = (tool, args, command) => (cli ? `\`\`\`\n${command}\n\`\`\`` : `\`\`\`\n${tool} { ${args} }\n\`\`\``);
|
|
15
|
+
const forName = cli ? "`--for`" : "`for`";
|
|
16
|
+
const replaces = cli ? "what it prints after \"in place of\"" : "what `slot.replaces` names";
|
|
17
|
+
const others = cli ? "what it prints under \"for each other … (no id)\"" : "`slot.otherCells.markup` (no id)";
|
|
18
|
+
const creditLine = cli ? "the line it prints under \"credit line\"" : "`creditLine`";
|
|
19
|
+
const join = cli ? "the two credits' text inside one `<p class=\"hd-credit\">`, joined with \" · \"" : "their `creditHtml` joined with \" · \" in one `<p class=\"hd-credit\">`";
|
|
20
|
+
const note = cli ? "the \"data-note credit:\" line" : "`note`";
|
|
21
|
+
const hint = cli ? "it prints a line saying so" : "the result says so in `hint`";
|
|
22
|
+
return [
|
|
23
|
+
"# Found photos and GIFs",
|
|
24
|
+
"",
|
|
25
|
+
"**When.** A found photo (Unsplash) is right for a real place, object or mood the person has no picture of: a harbour, a coffee bar, a trail. It is wrong for their product (capture it), a specific person (their own photo, with permission), their team or event, or a diagram or a number (draw it). A GIF (GIPHY) only in a casual deck or when asked: one or two a deck, on a slide of its own (a picture-full or a cover, the GIF as its picture), never beside a number, a quote or a product screenshot, nor for customers or investors unless asked.",
|
|
26
|
+
"",
|
|
27
|
+
"**1. Search** by shape for the slot: `cover-band`, `cover-frame`, `cover-poster`, `picture-full` and wide walls want landscape; `cover-split` wants square or near it; `portrait` wants portrait; `hero` takes 2:1 to 3:4.",
|
|
28
|
+
"",
|
|
29
|
+
ex("search_photos", 'query: "harbour at dawn", orientation: "landscape"', "hyperdecks photos search harbour at dawn --orientation landscape"),
|
|
30
|
+
"",
|
|
31
|
+
`Squarish comes back short (few photos are square; ${hint}): search landscape and let the slot crop it, subject near the middle.`,
|
|
32
|
+
"",
|
|
33
|
+
`**2. Add** the one you pick, naming the layout it goes in (${forName}):`,
|
|
34
|
+
"",
|
|
35
|
+
ex("add_photo", 'id: "Dwu85P9SOIk", for: "cover-band"', "hyperdecks photos add Dwu85P9SOIk --for cover-band"),
|
|
36
|
+
"",
|
|
37
|
+
`${forName} is one of ${slotList()}, or a slide id made from one (\`wall-2\`); when the slide's id is not the layout's name, give both (\`wall:proof\` for \`<section id="proof" class="slide l-wall">\`). The markup carries that slot's class and id (the layout's cues aim at it): paste it unedited in place of ${replaces}. A wall takes one add per photo: the first fills the large cell (id \`…-p1\`), the rest use ${others}. A caption: wrap it as \`<figure class="mount" data-caption="Where, when">…</figure>\`. Phone, product, zoom and video layouts take a screenshot or recording, not a found picture.`,
|
|
38
|
+
"",
|
|
39
|
+
`**3. A GIF**: the search returns the markup, so name the slot there:`,
|
|
40
|
+
"",
|
|
41
|
+
ex("search_gifs", 'query: "high five", for: "picture-full"', "hyperdecks gifs search high five --for picture-full"),
|
|
42
|
+
"",
|
|
43
|
+
`**The credit.** Each add or GIF comes with ${creditLine}, a \`<p class="hd-credit">\`: put it once on the same slide, as the slide's own child (straight inside the \`<section>\`, never inside the picture's slot, nor on a slide without the photo); it shows in the top-right corner and its links work before and after Play. Never edit it: the photographer's and Unsplash's links, or "Powered by GIPHY", are what the terms require, and check fails without them. Two found pictures on one slide share one line: ${join}. Put ${note} in the slide's \`data-note\`.`,
|
|
44
|
+
"",
|
|
45
|
+
"**Limits.** Searches and adds are free. Unsplash allows 50 requests an hour while Hyperdecks is in its demo mode (each search and each add counts), and Hyperdecks takes 20 a minute per service (searches and adds). GIFs are rated g unless the person asks for pg. Found pictures stay on Unsplash or GIPHY, so one can vanish after release: the player hides it, and check warns.",
|
|
46
|
+
].join("\n");
|
|
47
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// hyperdecks guide pictures (deck_guide topic pictures; also "icons"): which kind of picture fits which slide, each
|
|
2
|
+
// with the command (CLI) or tool (hosted MCP) that makes it, and how a layout's icon slot is filled. Short on purpose:
|
|
3
|
+
// the photos, look and layouts topics carry the detail. lib/deckIcons.test.ts holds every command and tool named here
|
|
4
|
+
// to the real ones.
|
|
5
|
+
import { THEME_ICON_PAIRINGS } from "./iconChoice.mjs";
|
|
6
|
+
import { ICON_SLOT_LAYOUTS } from "./iconSlots.mjs";
|
|
7
|
+
|
|
8
|
+
// What each kind is made with, per surface. `[cli, hosted]`.
|
|
9
|
+
export const PICTURE_MAKERS = {
|
|
10
|
+
icon: ["hyperdecks icons search <word> --for <layout>", "search_icons { query, for }"],
|
|
11
|
+
iconSet: ['hyperdecks icons <subject...> --preset line --slug <slug>', "generate_icon_set { subjects, preset }"],
|
|
12
|
+
screenshot: ["hyperdecks screenshot <url>", "capture_url { url }"],
|
|
13
|
+
upload: ["hyperdecks asset add <slug> <file>", "upload_deck_asset"],
|
|
14
|
+
photo: ["hyperdecks photos search <words>, then hyperdecks photos add <id> --for <layout>", "search_photos { query }, then add_photo { id, for }"],
|
|
15
|
+
gif: ["hyperdecks gifs search <words> --for picture-full", 'search_gifs { query, for: "picture-full" }'],
|
|
16
|
+
image: ['hyperdecks gen-image "<prompt>"', "generate_image { prompt }"],
|
|
17
|
+
chart: ["hyperdecks chart <spec.json>", "render_chart { kind }"],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function picturesGuide(surface) {
|
|
21
|
+
const cli = surface === "cli";
|
|
22
|
+
const m = (kind) => `\`${PICTURE_MAKERS[kind][cli ? 0 : 1]}\``;
|
|
23
|
+
const topic = (t) => (cli ? `\`hyperdecks guide ${t}\`` : `\`deck_guide { topic: "${t}" }\``);
|
|
24
|
+
return [
|
|
25
|
+
"# Pictures: which kind for which slide",
|
|
26
|
+
"",
|
|
27
|
+
"Pick per slide, the most real thing first. A picture must show something real: never generic clip-art or decoration.",
|
|
28
|
+
"",
|
|
29
|
+
`- **A concept or a step** (a reason, a stage, a layer, a feature), if a symbol helps: an icon in the layout's icon slot, ${m("icon")}. Optional.`,
|
|
30
|
+
`- **The product**: a screenshot or a screen recording, ${m("screenshot")}, or one the person gives you, ${m("upload")}.`,
|
|
31
|
+
`- **A real place, thing or mood** with no picture of their own: a found photo, ${m("photo")} (${topic("photos")}).`,
|
|
32
|
+
`- **One light moment**, in a casual deck only: a GIF on a slide of its own, ${m("gif")}.`,
|
|
33
|
+
`- **Something real that has no picture** (a product not built yet, a scene that cannot be photographed): a generated image, ${m("image")}. Never as decoration or a stand-in for their product, team or event.`,
|
|
34
|
+
`- **Numbers**: a chart of the real data, ${m("chart")}.`,
|
|
35
|
+
`- **Something the viewer will use**, not just look at (a map of the venues, a video on YouTube, a Figma prototype, a booking page): the embed layout, a still that goes live on tap (${topic("embeds")}).`,
|
|
36
|
+
"- **Leave it as words** when the words are the point: a quote, a one-line claim (sentence, strike), the ask on the closer.",
|
|
37
|
+
"",
|
|
38
|
+
"## Icons",
|
|
39
|
+
"",
|
|
40
|
+
`These layouts have an optional icon slot: ${ICON_SLOT_LAYOUTS.map((n) => `\`${n}\``).join(", ")}. Use an icon where it helps the reader find or remember an item; leave it out where the words carry it. A slide or a whole deck with no icons is fine. When a slide has icons, its items match (all with one, or none). Search with the layout named, and paste the svg it gives where it says, unedited; the theme sizes it and draws it (line weight, colour, bare or on a tile):`,
|
|
41
|
+
"",
|
|
42
|
+
"```",
|
|
43
|
+
cli ? "hyperdecks icons search growth --for staircase" : 'search_icons { query: "growth", for: "staircase" }',
|
|
44
|
+
"```",
|
|
45
|
+
"",
|
|
46
|
+
`Plain words work ("money", "safety", "grow", "team"); when nothing matches, ask for what the picture would show in a plainer word, or leave the icon out. **One icon style a deck**: one set and weight from this search (Lucide line, Phosphor in six weights, Tabler outline or fill, Material Symbols outline or fill; ${cli ? "`hyperdecks icons sets`" : "`icon_sets`"} shows them), set once with ${cli ? "`hyperdecks icons use <deck> <set> [weight]`" : "`use_icon_set { slug, set, weight }`"}, which records it and puts the layouts' own icons (features, split's sticker, the closer's arrow) in it, so later searches stay in it and check sees one set; when the set has no close match the answer shows the closest from the others; or one generated set (${m("iconSet")}, every subject in one call, each as \`<img class="icon">\`); never both. Check warns on a mix.`,
|
|
47
|
+
"",
|
|
48
|
+
`A start for each theme, a suggestion only (the subject may want another): ${Object.entries(THEME_ICON_PAIRINGS).map(([t, p]) => `${t} ${p}`).join(", ")}.`,
|
|
49
|
+
"",
|
|
50
|
+
"**Icons are not pictures.** The look topic's rule, a real picture on at least every other slide, counts screenshots, recordings, photos and charts only. When fewer than a third of a deck's slides (three or more) show one, check says so and names the slides that could take one, if it helps, and which kind (a photo, a screenshot, a chart). With a third or more it says nothing about pictures. Check never asks for an icon; it names a slide whose items have icons on some only.",
|
|
51
|
+
"",
|
|
52
|
+
`More: ${topic("look")} (textures, the icon set, a picture on every other slide), ${topic("layouts")} (each layout's slots).`,
|
|
53
|
+
].join("\n");
|
|
54
|
+
}
|
package/src/play.mjs
CHANGED
|
@@ -9,7 +9,8 @@ import { withAvatarView } from "./avatar-view.mjs";
|
|
|
9
9
|
// Ctrl-C. The deck's script.md and evidence.md are not served (preview-capture.mjs
|
|
10
10
|
// serves only the file types a page loads).
|
|
11
11
|
import { readFileSync } from "node:fs";
|
|
12
|
-
import {
|
|
12
|
+
import { join, relative } from "node:path";
|
|
13
|
+
import { deckSlug } from "./deckSlug.mjs";
|
|
13
14
|
import { playerScript, sectionIds } from "./checkRules.mjs";
|
|
14
15
|
import { resolveDeckDir } from "./check.mjs";
|
|
15
16
|
import * as ops from "./ops.mjs";
|
|
@@ -84,7 +85,7 @@ export async function startPlay(pos, opts = {}, { log = (line) => console.log(li
|
|
|
84
85
|
const port = portOf(opts.port);
|
|
85
86
|
const deckDir = resolveDeckDir(deckDirArg, cwd);
|
|
86
87
|
const path = pathFrom(cwd, deckDir);
|
|
87
|
-
const slug =
|
|
88
|
+
const slug = deckSlug(deckDir, opts);
|
|
88
89
|
const file = join(deckDir, "index.html");
|
|
89
90
|
const html = readFileSync(file, "utf8");
|
|
90
91
|
|
package/src/presenter.mjs
CHANGED
|
@@ -37,7 +37,9 @@ const value = (tag, name) => {
|
|
|
37
37
|
// The face this tag shows, decided as packages/player/player.js does: data-presenter
|
|
38
38
|
// head|static|none, else static when there is a still, else none. head draws
|
|
39
39
|
// data-avatar (and falls back to the still without one); static draws the
|
|
40
|
-
// still. Null: the deck plays the voice and captions with no face.
|
|
40
|
+
// still. Null: the deck plays the voice and captions with no face. A silent
|
|
41
|
+
// deck marked data-silent-presenter="hide" shows none whatever this says
|
|
42
|
+
// (player.js silentFaceless); release skips silent decks, so no caller sees one.
|
|
41
43
|
function tagFace(tag) {
|
|
42
44
|
const presenter = value(tag, "data-presenter");
|
|
43
45
|
const avatarUrl = value(tag, "data-avatar") || null;
|
package/src/preview-capture.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { lookup } from 'node:dns/promises';
|
|
2
2
|
import { isIP } from 'node:net';
|
|
3
3
|
import { createServer } from 'node:http';
|
|
4
|
+
import { existsSync, statSync } from 'node:fs';
|
|
4
5
|
import { readFile, realpath, mkdtemp, rm, stat, writeFile } from 'node:fs/promises';
|
|
5
|
-
import { resolve, dirname, extname, sep, join } from 'node:path';
|
|
6
|
+
import { resolve, dirname, extname, sep, join, normalize } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
6
8
|
import { tmpdir } from 'node:os';
|
|
7
9
|
import { randomUUID } from 'node:crypto';
|
|
8
10
|
import { execFile } from 'node:child_process';
|
|
@@ -198,12 +200,72 @@ export function unconditionalHeaders(headers) {
|
|
|
198
200
|
return Object.fromEntries(Object.entries(headers).filter(([k]) => !/^if-(none-match|modified-since|match|unmodified-since|range)$/i.test(k)));
|
|
199
201
|
}
|
|
200
202
|
|
|
203
|
+
// The app's own static files (the hosted player and the built-in avatar
|
|
204
|
+
// stills), read from a repo checkout instead of hyperdecks.ai. A scaffolded
|
|
205
|
+
// deck's head loads the player from hyperdecks.ai, so before this every local
|
|
206
|
+
// `check --layout` hit the live site, and on 2026-11-29 our own test runs got
|
|
207
|
+
// the owner's address challenged by Vercel's DDoS mitigation.
|
|
208
|
+
//
|
|
209
|
+
// Used by the capture route below, the test guard
|
|
210
|
+
// (lib/testing/productionGuard.mjs) and scripts/dev/serve-deck.mjs. Outside a
|
|
211
|
+
// checkout (the published CLI, the render worker's image, the hosted app)
|
|
212
|
+
// CHECKOUT is null and nothing here applies.
|
|
213
|
+
// Kept in this file, not its own: the render job loads these CLI modules and
|
|
214
|
+
// no others (services/render/worker.test.mjs).
|
|
215
|
+
export const STATIC_HOSTS = ['hyperdecks.ai', 'www.hyperdecks.ai', 'decks.hypersocial.ai'];
|
|
216
|
+
const TYPES = { '.js': 'text/javascript', '.mjs': 'text/javascript', '.css': 'text/css', '.json': 'application/json', '.png': 'image/png', '.bin': 'application/octet-stream', '.svg': 'image/svg+xml', '.woff2': 'font/woff2', '.glb': 'model/gltf-binary', '.webp': 'image/webp', '.wasm': 'application/wasm', '.mp3': 'audio/mpeg' };
|
|
217
|
+
export const staticType = (file) => TYPES[extname(file)] ?? 'application/octet-stream';
|
|
218
|
+
|
|
219
|
+
// `root` when it is a repo checkout, else null. .git (a folder, or a worktree's
|
|
220
|
+
// file) tells a checkout from a deployment that happens to hold both folders.
|
|
221
|
+
export function checkoutAt(root) {
|
|
222
|
+
return ['.git', 'packages/player/player.js', 'public/player/v1'].every((p) => existsSync(join(root, p))) ? root : null;
|
|
223
|
+
}
|
|
224
|
+
// packages/decks-cli/src → the repo root.
|
|
225
|
+
export const CHECKOUT = checkoutAt(join(dirname(fileURLToPath(import.meta.url)), '..', '..', '..'));
|
|
226
|
+
|
|
227
|
+
function inside(dir, name) {
|
|
228
|
+
const file = normalize(join(dir, name));
|
|
229
|
+
// statSync still throws on a name no file can have (a null byte, one too long).
|
|
230
|
+
try { return file.startsWith(dir + sep) && statSync(file, { throwIfNoEntry: false })?.isFile() ? file : null; }
|
|
231
|
+
catch { return null; }
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// The checkout's file for a path under /player/v1/, or null. The player's own
|
|
235
|
+
// modules come from packages/player; the vendored SDK files and the pinned
|
|
236
|
+
// builds (b/<hash>/) are only in public/.
|
|
237
|
+
export function playerFile(name, root = CHECKOUT) {
|
|
238
|
+
const published = join(root, 'public/player/v1');
|
|
239
|
+
return (name.startsWith('b/') ? null : inside(join(root, 'packages/player'), name)) ?? inside(published, name);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Where a URL's file is in the checkout: undefined when the URL is not one of
|
|
243
|
+
// the app's static files (or there is no checkout), null when it is but the
|
|
244
|
+
// checkout has no such file. A pinned build (b/<hash>/) is always the
|
|
245
|
+
// checkout's own player, even when public/ holds that build, so an edit to
|
|
246
|
+
// packages/player shows on every deck (as with HYPERDECKS_PLAYER_DIR).
|
|
247
|
+
export function localStaticFile(url, root = CHECKOUT) {
|
|
248
|
+
if (!root) return undefined;
|
|
249
|
+
let u, path;
|
|
250
|
+
try { u = new URL(url); } catch { return undefined; }
|
|
251
|
+
if (!/^https?:$/.test(u.protocol) || !STATIC_HOSTS.includes(u.hostname.replace(/\.+$/, ''))) return undefined;
|
|
252
|
+
const at = /^\/(player|avatars)\//.exec(u.pathname);
|
|
253
|
+
if (!at) return undefined;
|
|
254
|
+
try { path = decodeURIComponent(u.pathname); } catch { return null; }
|
|
255
|
+
if (at[1] === 'avatars') return inside(join(root, 'public/avatars'), path.slice('/avatars/'.length));
|
|
256
|
+
if (!path.startsWith('/player/v1/')) return null;
|
|
257
|
+
return playerFile(path.slice('/player/v1/'.length).replace(/^b\/[0-9a-f]+\//, ''), root);
|
|
258
|
+
}
|
|
259
|
+
|
|
201
260
|
// Playwright's continue() follows redirects without routing each hop. Fetch
|
|
202
261
|
// without following redirects and never fulfill a 3xx response into Chromium.
|
|
203
262
|
// `net` (all optional): `onRefused({ url, type, reason })` hears each request
|
|
204
263
|
// not fulfilled, its URL redacted (redactCaptureUrl); reason is 'rule',
|
|
205
264
|
// 'destination', 'redirect' or the fetch error. `resolver` and `upstream`
|
|
206
265
|
// (route, options) => APIResponse stand in for DNS and the network in tests.
|
|
266
|
+
// From a repo checkout, an allowed request for the hosted player or a built-in
|
|
267
|
+
// avatar still is answered with the checkout's file and never reaches the
|
|
268
|
+
// network, even when the checkout lacks it (localStaticFile).
|
|
207
269
|
export async function routeCaptureRequest(route, entryUrl, origins = [], net = {}) {
|
|
208
270
|
const { onRefused = () => {}, resolver, upstream = (rt, options) => rt.fetch(options) } = net;
|
|
209
271
|
const r = route.request();
|
|
@@ -217,6 +279,13 @@ export async function routeCaptureRequest(route, entryUrl, origins = [], net = {
|
|
|
217
279
|
try {
|
|
218
280
|
type = captureResourceType(r);
|
|
219
281
|
if (!allowCaptureRequest(r.url(), r.method(), type, entryUrl, origins)) return await refuse('rule');
|
|
282
|
+
const local = localStaticFile(r.url());
|
|
283
|
+
if (local === null) return await refuse('not in this checkout');
|
|
284
|
+
if (local) {
|
|
285
|
+
// A module script from another origin needs CORS, as the app sends.
|
|
286
|
+
await route.fulfill({ body: await readFile(local), contentType: staticType(local), headers: { 'access-control-allow-origin': '*' } });
|
|
287
|
+
return true;
|
|
288
|
+
}
|
|
220
289
|
if (!await allowCaptureDestination(r.url(), entryUrl, resolver)) return await refuse('destination');
|
|
221
290
|
let response;
|
|
222
291
|
try { response = await upstream(route, { headers: unconditionalHeaders(r.headers()), maxRedirects:0, timeout:15000 }); }
|
package/src/release.mjs
CHANGED
|
@@ -23,6 +23,7 @@ import { checkDeck, deckFiles, deckFolder, deckPathResolver, resolveDeckDir } fr
|
|
|
23
23
|
import { mediaRefs, withMediaPreviews } from "./mediaPreviews.mjs";
|
|
24
24
|
import { bundledFfmpeg, HTTPS_TOO, makePreview } from "./mediaPreviewMake.mjs";
|
|
25
25
|
import { narrate as runNarrate } from "./narrate.mjs";
|
|
26
|
+
import { slugNote } from "./deckSlug.mjs";
|
|
26
27
|
|
|
27
28
|
const SLUG = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
28
29
|
|
|
@@ -31,7 +32,10 @@ export function deckChanges(deckDir) {
|
|
|
31
32
|
try {
|
|
32
33
|
return execFileSync("git", ["-C", deckDir, "status", "--porcelain", "--untracked-files=all", "--", "."], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trimEnd();
|
|
33
34
|
} catch (e) {
|
|
34
|
-
|
|
35
|
+
const why = String(e.stderr || e.message).trim();
|
|
36
|
+
// Outside any repository: say how to make one, so the next try goes through.
|
|
37
|
+
const fix = /not a git repository/i.test(why) ? `; to make one: cd "${deckDir}" && git init && git add -A && git commit -m "deck"` : "";
|
|
38
|
+
throw new Error(`release needs the deck in a git repository, so a release corresponds to a commit (${why})${fix}`);
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
41
|
|
|
@@ -144,6 +148,8 @@ export async function release(pos, opts = {}, io = {}) {
|
|
|
144
148
|
const { log = (line) => console.log(line), changes = deckChanges, untracked = untrackedFiles, commit = deckCommit, narrate = runNarrate, previews = mediaPreviewsFor, fetch, cwd, measure, measureFit } = io;
|
|
145
149
|
const deckDir = resolveDeckDir(pos[0], cwd);
|
|
146
150
|
const to = recipients(opts);
|
|
151
|
+
const note = slugNote(deckDir, opts);
|
|
152
|
+
if (note) log(`releasing ${note}`);
|
|
147
153
|
|
|
148
154
|
const dirty = changes(deckDir);
|
|
149
155
|
if (dirty) throw new Error(`refusing to release: ${deckDir} has uncommitted changes\n${dirty}\ncommit them first so the release corresponds to a commit`);
|
|
@@ -215,7 +221,9 @@ async function publish({ opts, io: { log, commit }, deckDir, slug, to, checked,
|
|
|
215
221
|
|
|
216
222
|
const base = await linkBase(opts);
|
|
217
223
|
const shares = [];
|
|
218
|
-
|
|
224
|
+
// --qa with no --to: one QA link for your own check, with no email sent.
|
|
225
|
+
const qaOnly = !to.length && !!opts.qa;
|
|
226
|
+
for (const r of qaOnly ? [{ recipient: "Me" }] : to) {
|
|
219
227
|
let token;
|
|
220
228
|
try {
|
|
221
229
|
({ token } = await ops.createShare(opts, {
|
|
@@ -223,18 +231,18 @@ async function publish({ opts, io: { log, commit }, deckDir, slug, to, checked,
|
|
|
223
231
|
recipient: r.recipient,
|
|
224
232
|
email: r.email,
|
|
225
233
|
qa: opts.qa || undefined,
|
|
226
|
-
notify: opts["no-notify"] ? false : undefined,
|
|
234
|
+
notify: opts["no-notify"] || qaOnly ? false : undefined,
|
|
227
235
|
}));
|
|
228
236
|
} catch (e) {
|
|
229
237
|
// The deck is already live and earlier links exist: say so, so a retry does not duplicate them.
|
|
230
238
|
const made = shares.map((s) => ` ${s.recipient}: ${s.url}`).join("\n") || " (none)";
|
|
231
239
|
throw new Error(`share for "${r.recipient}" failed: ${ops.errorText(e)}\nthe deck is imported (${imported.deckUrl}); links already created:\n${made}\n` +
|
|
232
|
-
`create the rest with \`hyperdecks share new ${imported.slug} "<name>"\` rather than releasing again`);
|
|
240
|
+
(qaOnly ? `make your QA link with \`hyperdecks share new ${imported.slug} "Me" --qa --no-notify\` rather than releasing again` : `create the rest with \`hyperdecks share new ${imported.slug} "<name>"\` rather than releasing again`));
|
|
233
241
|
}
|
|
234
242
|
const share = { recipient: r.recipient, email: r.email, qa: !!opts.qa, url: `${base}/v/${token}` };
|
|
235
243
|
shares.push(share);
|
|
236
244
|
log(`✓ share for "${r.recipient}"${share.qa ? " (QA, untracked)" : ""} → ${share.url}`);
|
|
237
245
|
}
|
|
238
|
-
if (!shares.length) log(` no --to given: \`hyperdecks share new ${imported.slug} "Me" --qa\` makes a link for your own viewing`);
|
|
246
|
+
if (!shares.length && !qaOnly) log(` no --to given: \`hyperdecks share new ${imported.slug} "Me" --qa\` makes a link for your own viewing`);
|
|
239
247
|
return { slug: imported.slug, deckDir, commit: sha, deckUrl: imported.deckUrl, totalDuration: checked.totalDuration, silent: !!checked.silent, presenter: summary, files: bundle.files, shares };
|
|
240
248
|
}
|
package/src/runtime.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { ConvexHttpClient } from "convex/browser";
|
|
|
9
9
|
import { makeFunctionReference } from "convex/server";
|
|
10
10
|
import { recordSkillInstall } from "./skillFreshness.mjs";
|
|
11
11
|
|
|
12
|
-
export const VERSION = "0.9.
|
|
12
|
+
export const VERSION = "0.9.25";
|
|
13
13
|
|
|
14
14
|
// Sent on the CLI's calls to our routes and to Convex, so the server can see
|
|
15
15
|
// which CLI versions are still out there (not used to refuse anything).
|
|
@@ -144,6 +144,7 @@ export const api = {
|
|
|
144
144
|
listForDeck: makeFunctionReference("shares:listForDeck"),
|
|
145
145
|
remove: makeFunctionReference("shares:remove"),
|
|
146
146
|
setAllowForward: makeFunctionReference("shares:setAllowForward"),
|
|
147
|
+
setCountOn: makeFunctionReference("shares:setCountOn"),
|
|
147
148
|
setEnabled: makeFunctionReference("shares:setEnabled"),
|
|
148
149
|
setNotify: makeFunctionReference("shares:setNotify"),
|
|
149
150
|
linkOrigins: makeFunctionReference("shares:linkOrigins"),
|
|
@@ -153,6 +154,12 @@ export const api = {
|
|
|
153
154
|
checkImageJob: makeFunctionReference("imagegen:checkImageJob"),
|
|
154
155
|
generateIconSet: makeFunctionReference("imagegen:generateIconSet"),
|
|
155
156
|
},
|
|
157
|
+
// Found pictures (convex/stockMedia.ts).
|
|
158
|
+
stockMedia: {
|
|
159
|
+
searchPhotos: makeFunctionReference("stockMedia:searchPhotos"),
|
|
160
|
+
addPhoto: makeFunctionReference("stockMedia:addPhoto"),
|
|
161
|
+
searchGifs: makeFunctionReference("stockMedia:searchGifs"),
|
|
162
|
+
},
|
|
156
163
|
screenshots: {
|
|
157
164
|
captureUrl: makeFunctionReference("screenshots:captureUrl"),
|
|
158
165
|
},
|
|
@@ -214,7 +221,7 @@ export const api = {
|
|
|
214
221
|
},
|
|
215
222
|
};
|
|
216
223
|
|
|
217
|
-
const BOOL = new Set(["private-only", "prod", "dev", "admin", "json", "require-email", "qa", "no-notify", "allow-forward", "no-forward", "help", "version", "all-agents", "global", "project", "transparent", "loop", "upload", "dry-run", "narrated", "layout", "strict", "fix", "full-page", "force", "hosted", "yes", "no-voice", "no-skill", "no-release", "no-narrate", "no-open", "save-to-minimoji", "captions-only", "no-brand", "brand", "no-logo", "pdf", "notes", "mp4", "gif", "video", "no-captions", "no-avatar", "title-card", "end-card", "backup"]);
|
|
224
|
+
const BOOL = new Set(["private-only", "prod", "dev", "admin", "json", "require-email", "qa", "no-notify", "allow-forward", "no-forward", "count-on-play", "help", "version", "all-agents", "global", "project", "transparent", "loop", "upload", "dry-run", "narrated", "layout", "strict", "fix", "full-page", "force", "hosted", "yes", "no-voice", "no-skill", "no-release", "no-narrate", "no-open", "save-to-minimoji", "captions-only", "no-brand", "brand", "no-logo", "pdf", "notes", "mp4", "gif", "video", "no-captions", "no-avatar", "title-card", "end-card", "backup", "trim", "embed"]);
|
|
218
225
|
// release's recipients, in order: each --to starts one, and an --email right
|
|
219
226
|
// after it belongs to it (`--to A --email a --to B`). Collected as opts.recipients;
|
|
220
227
|
// opts.email stays the last --email for the other commands (share new).
|