@gui-chat-plugin/sequence 0.5.0 → 0.5.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/CHANGELOG.md +10 -0
- package/README.md +3 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/slideHtml.d.ts +6 -0
- package/dist/{core-g9C3DDiR.js → core-5sCYCU63.js} +334 -199
- package/dist/core-BW_pUGJl.cjs +236 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/style.css +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +43 -43
- package/package.json +1 -1
- package/dist/core-DNUfOXPo.cjs +0 -232
|
@@ -4,7 +4,142 @@ var t = 1280, n = 720, r = 6e4, i = "https://cdn.jsdelivr.net/npm/@tailwindcss/b
|
|
|
4
4
|
"animate",
|
|
5
5
|
"counter",
|
|
6
6
|
"typewriter"
|
|
7
|
-
], s = 8, c = "
|
|
7
|
+
], s = 8, c = "() => {\n for (const el of document.querySelectorAll(\"[data-fit]\")) {\n let size = parseFloat(getComputedStyle(el).fontSize);\n while (size > 12 && (el.scrollHeight > el.clientHeight + 1 || el.scrollWidth > el.clientWidth + 1)) {\n size -= 1;\n el.style.fontSize = size + \"px\";\n }\n }\n }", l = `(() => {
|
|
8
|
+
const fit = ${c};
|
|
9
|
+
fit();
|
|
10
|
+
addEventListener("load", fit);
|
|
11
|
+
})();`, u = `
|
|
12
|
+
(() => {
|
|
13
|
+
const EASE = {
|
|
14
|
+
linear: (t) => t,
|
|
15
|
+
easeIn: (t) => t * t,
|
|
16
|
+
easeOut: (t) => 1 - (1 - t) * (1 - t),
|
|
17
|
+
easeInOut: (t) => (t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2),
|
|
18
|
+
};
|
|
19
|
+
const AUTO_END = 8;
|
|
20
|
+
const TRANSFORMS = [
|
|
21
|
+
["data-translate-x", "translateX", "px"],
|
|
22
|
+
["data-translate-y", "translateY", "px"],
|
|
23
|
+
["data-scale", "scale", ""],
|
|
24
|
+
["data-rotate", "rotate", "deg"],
|
|
25
|
+
["data-rotate-x", "rotateX", "deg"],
|
|
26
|
+
["data-rotate-y", "rotateY", "deg"],
|
|
27
|
+
["data-rotate-z", "rotateZ", "deg"],
|
|
28
|
+
];
|
|
29
|
+
const STYLES = [
|
|
30
|
+
["data-opacity", "opacity", ""],
|
|
31
|
+
["data-width", "width", "px"],
|
|
32
|
+
["data-height", "height", "px"],
|
|
33
|
+
];
|
|
34
|
+
const number = (value, fallback) => {
|
|
35
|
+
const n = Number(value);
|
|
36
|
+
return value !== null && value.trim() !== "" && Number.isFinite(n) ? n : fallback;
|
|
37
|
+
};
|
|
38
|
+
const range = (value, unit) => {
|
|
39
|
+
if (value === null) return null;
|
|
40
|
+
const parts = value.split(",").map((part) => part.trim());
|
|
41
|
+
const from = Number(parts[0]);
|
|
42
|
+
const to = Number(parts[1]);
|
|
43
|
+
if (!Number.isFinite(from) || !Number.isFinite(to)) return null;
|
|
44
|
+
return { from, to, unit: parts[2] || unit };
|
|
45
|
+
};
|
|
46
|
+
const ranges = (el, table) =>
|
|
47
|
+
table
|
|
48
|
+
.map(([attr, name, unit]) => [name, range(el.getAttribute(attr), unit)])
|
|
49
|
+
.filter(([, r]) => r);
|
|
50
|
+
let entries = [];
|
|
51
|
+
const collect = () => {
|
|
52
|
+
entries = [...document.querySelectorAll("[data-animation]")].map((el) => {
|
|
53
|
+
const kind = el.getAttribute("data-animation");
|
|
54
|
+
const end = el.getAttribute("data-end");
|
|
55
|
+
const entry = {
|
|
56
|
+
el,
|
|
57
|
+
kind,
|
|
58
|
+
start: number(el.getAttribute("data-start"), 0),
|
|
59
|
+
end: end === null || end.trim() === "auto" ? null : number(end, null),
|
|
60
|
+
ease: EASE[el.getAttribute("data-easing")] || EASE.linear,
|
|
61
|
+
};
|
|
62
|
+
if (kind === "animate") {
|
|
63
|
+
entry.transforms = ranges(el, TRANSFORMS);
|
|
64
|
+
entry.styles = ranges(el, STYLES);
|
|
65
|
+
} else if (kind === "counter") {
|
|
66
|
+
entry.from = number(el.getAttribute("data-from"), 0);
|
|
67
|
+
entry.to = number(el.getAttribute("data-to"), 0);
|
|
68
|
+
entry.decimals = Math.max(0, Math.round(number(el.getAttribute("data-decimals"), 0)));
|
|
69
|
+
entry.prefix = el.getAttribute("data-prefix") || "";
|
|
70
|
+
entry.suffix = el.getAttribute("data-suffix") || "";
|
|
71
|
+
} else if (kind === "typewriter") {
|
|
72
|
+
entry.text = el.getAttribute("data-text") ?? el.textContent;
|
|
73
|
+
} else {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
return entry;
|
|
77
|
+
}).filter(Boolean);
|
|
78
|
+
};
|
|
79
|
+
const seek = (t) => {
|
|
80
|
+
for (const e of entries) {
|
|
81
|
+
const end = e.end ?? AUTO_END;
|
|
82
|
+
const span = end - e.start;
|
|
83
|
+
const p = span > 0 ? Math.min(1, Math.max(0, (t - e.start) / span)) : t >= e.start ? 1 : 0;
|
|
84
|
+
const k = e.ease(p);
|
|
85
|
+
const at = (r) => r.from + (r.to - r.from) * k;
|
|
86
|
+
if (e.kind === "animate") {
|
|
87
|
+
if (e.transforms.length) {
|
|
88
|
+
e.el.style.transform = e.transforms.map(([name, r]) => name + "(" + at(r) + r.unit + ")").join(" ");
|
|
89
|
+
}
|
|
90
|
+
for (const [name, r] of e.styles) e.el.style[name] = at(r) + r.unit;
|
|
91
|
+
} else if (e.kind === "counter") {
|
|
92
|
+
e.el.textContent = e.prefix + (e.from + (e.to - e.from) * k).toFixed(e.decimals) + e.suffix;
|
|
93
|
+
} else {
|
|
94
|
+
e.el.textContent = e.text.slice(0, Math.floor(e.text.length * k));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
window.__slideSeek = seek;
|
|
99
|
+
const fit = ${c};
|
|
100
|
+
const play = () => {
|
|
101
|
+
const last = Math.max(0, ...entries.map((e) => e.end ?? AUTO_END));
|
|
102
|
+
const begun = performance.now();
|
|
103
|
+
const tick = (now) => {
|
|
104
|
+
const t = (now - begun) / 1000;
|
|
105
|
+
seek(t);
|
|
106
|
+
if (t <= last) requestAnimationFrame(tick);
|
|
107
|
+
};
|
|
108
|
+
requestAnimationFrame(tick);
|
|
109
|
+
};
|
|
110
|
+
// Collected once the body is parsed: at DOMContentLoaded, or earlier when
|
|
111
|
+
// the fallback shows the slide while a slow Tailwind still holds
|
|
112
|
+
// DOMContentLoaded back (the body is parsed by then: readyState is
|
|
113
|
+
// "interactive" before deferred scripts run). Played once both are done.
|
|
114
|
+
let collected = false;
|
|
115
|
+
let shown = false;
|
|
116
|
+
const init = () => {
|
|
117
|
+
if (collected || document.readyState === "loading") return;
|
|
118
|
+
collected = true;
|
|
119
|
+
collect();
|
|
120
|
+
seek(0);
|
|
121
|
+
if (shown) play();
|
|
122
|
+
};
|
|
123
|
+
const show = () => {
|
|
124
|
+
if (shown) return;
|
|
125
|
+
init();
|
|
126
|
+
fit();
|
|
127
|
+
shown = true;
|
|
128
|
+
document.documentElement.classList.add("ready");
|
|
129
|
+
if (collected) play();
|
|
130
|
+
};
|
|
131
|
+
const ready = () => requestAnimationFrame(() => requestAnimationFrame(show));
|
|
132
|
+
const check = () =>
|
|
133
|
+
document.querySelector("style:not([type]):not(#slide-base)") ? ready() : setTimeout(check, 30);
|
|
134
|
+
addEventListener("DOMContentLoaded", () => {
|
|
135
|
+
init();
|
|
136
|
+
check();
|
|
137
|
+
});
|
|
138
|
+
setTimeout(show, 1000);
|
|
139
|
+
addEventListener("click", (event) => {
|
|
140
|
+
if (event.target instanceof Element && event.target.closest("a, area")) event.preventDefault();
|
|
141
|
+
}, true);
|
|
142
|
+
})();`, d = [
|
|
8
143
|
"default-src 'none'",
|
|
9
144
|
`script-src 'sha256-bNBxv6ehYc2PHOgmTReFSYsrxiGvq6aqqg9m5RwS7Lc=' ${i}`,
|
|
10
145
|
"style-src 'unsafe-inline' https://fonts.googleapis.com",
|
|
@@ -14,33 +149,33 @@ var t = 1280, n = 720, r = 6e4, i = "https://cdn.jsdelivr.net/npm/@tailwindcss/b
|
|
|
14
149
|
"connect-src 'none'",
|
|
15
150
|
"form-action 'none'",
|
|
16
151
|
"base-uri 'none'"
|
|
17
|
-
].join("; "),
|
|
152
|
+
].join("; "), f = {
|
|
18
153
|
"&": "&",
|
|
19
154
|
"<": "<",
|
|
20
155
|
">": ">",
|
|
21
156
|
"\"": """
|
|
22
|
-
},
|
|
157
|
+
}, p = (e) => e.replace(/[&<>"]/g, (e) => f[e] ?? e), ee = (e) => e.replace(/<(?=(meta|base|link)\b)/gi, "<").replace(/shadowroot/gi, "data-no-shadow-root"), m = "*, *::before, *::after { animation-play-state: paused !important; animation-duration: 0s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; animation-fill-mode: both !important; transition: none !important; }", te = `
|
|
23
158
|
html, body { margin: 0; width: ${t}px; height: 720px; overflow: hidden; }
|
|
24
159
|
html:not(.ready) body { visibility: hidden; }
|
|
25
|
-
${
|
|
26
|
-
function
|
|
160
|
+
${m}`;
|
|
161
|
+
function ne(e) {
|
|
27
162
|
return `<!doctype html>
|
|
28
163
|
<html lang="en">
|
|
29
164
|
<head>
|
|
30
165
|
<meta charset="utf-8">
|
|
31
|
-
<meta http-equiv="Content-Security-Policy" content="${
|
|
32
|
-
<style id="slide-base">${
|
|
33
|
-
<script>${
|
|
166
|
+
<meta http-equiv="Content-Security-Policy" content="${d}">
|
|
167
|
+
<style id="slide-base">${te}</style>
|
|
168
|
+
<script>${u}<\/script>
|
|
34
169
|
<script defer src="${i}" integrity="${a}" crossorigin="anonymous"><\/script>
|
|
35
170
|
</head>
|
|
36
171
|
<body class="bg-white text-slate-900 font-sans antialiased">
|
|
37
|
-
${
|
|
172
|
+
${ee(e)}
|
|
38
173
|
</body>
|
|
39
174
|
</html>`;
|
|
40
175
|
}
|
|
41
176
|
//#endregion
|
|
42
177
|
//#region src/core/chartSlide.ts
|
|
43
|
-
var
|
|
178
|
+
var h = [
|
|
44
179
|
"bar",
|
|
45
180
|
"line",
|
|
46
181
|
"pie",
|
|
@@ -49,35 +184,35 @@ var m = [
|
|
|
49
184
|
"polarArea",
|
|
50
185
|
"scatter",
|
|
51
186
|
"bubble"
|
|
52
|
-
],
|
|
187
|
+
], g = "https://cdn.jsdelivr.net/npm/chart.js@4.5.1/dist/chart.umd.min.js", re = "sha384-jb8JQMbMoBUzgWatfe6COACi2ljcDdZQ2OxczGA3bGNeWe+6DChMTBJemed7ZnvJ", ie = "\n(() => {\n const fail = (why) => {\n document.getElementById(\"chart-error\").textContent = why;\n document.documentElement.classList.add(\"failed\");\n };\n addEventListener(\"DOMContentLoaded\", () => {\n if (!window.Chart) return fail(\"The chart couldn't be drawn: Chart.js didn't load.\");\n let config;\n try {\n config = JSON.parse(document.getElementById(\"chart-config\").textContent);\n } catch {\n return fail(\"The chart couldn't be drawn: its configuration isn't valid.\");\n }\n Chart.defaults.font.size = 22;\n Chart.defaults.color = \"#334155\";\n Chart.defaults.animation.duration = 1200;\n config.options = { ...config.options, responsive: true, maintainAspectRatio: false };\n try {\n new Chart(document.getElementById(\"chart\"), config);\n } catch (error) {\n fail(\"The chart couldn't be drawn: \" + (error && error.message ? error.message : error));\n }\n });\n})();", ae = [
|
|
53
188
|
"default-src 'none'",
|
|
54
|
-
`script-src 'sha256-TfZZxJX+yWgzYLy7zqsMa85OJEaC+zNLIpKLDZVnUqA=' ${
|
|
189
|
+
`script-src 'sha256-TfZZxJX+yWgzYLy7zqsMa85OJEaC+zNLIpKLDZVnUqA=' ${g}`,
|
|
55
190
|
"style-src 'unsafe-inline'",
|
|
56
191
|
"img-src data: blob:",
|
|
57
192
|
"connect-src 'none'",
|
|
58
193
|
"form-action 'none'",
|
|
59
194
|
"base-uri 'none'"
|
|
60
|
-
].join("; "),
|
|
195
|
+
].join("; "), oe = `
|
|
61
196
|
html, body { margin: 0; width: ${t}px; height: 720px; overflow: hidden; background: #ffffff; color: #0f172a; font-family: ui-sans-serif, system-ui, sans-serif; }
|
|
62
197
|
body { box-sizing: border-box; padding: 40px 64px 48px; display: flex; flex-direction: column; gap: 24px; }
|
|
63
198
|
h1 { margin: 0; font-size: 52px; font-weight: 800; color: #1e3a8a; line-height: 1.15; text-align: center; }
|
|
64
199
|
.chart { position: relative; flex: 1; min-height: 0; }
|
|
65
200
|
#chart-error { display: none; margin: auto; font-size: 28px; color: #b91c1c; }
|
|
66
201
|
.failed .chart { display: none; }
|
|
67
|
-
.failed #chart-error { display: block; }`,
|
|
68
|
-
function
|
|
202
|
+
.failed #chart-error { display: block; }`, se = (e) => JSON.stringify(e).replace(/</g, "\\u003c");
|
|
203
|
+
function ce(e, t) {
|
|
69
204
|
return `<!doctype html>
|
|
70
205
|
<html lang="en">
|
|
71
206
|
<head>
|
|
72
207
|
<meta charset="utf-8">
|
|
73
|
-
<meta http-equiv="Content-Security-Policy" content="${
|
|
74
|
-
<style>${
|
|
75
|
-
<script>${
|
|
76
|
-
<script defer src="${
|
|
77
|
-
<script type="application/json" id="chart-config">${
|
|
208
|
+
<meta http-equiv="Content-Security-Policy" content="${ae}">
|
|
209
|
+
<style>${oe}</style>
|
|
210
|
+
<script>${ie}<\/script>
|
|
211
|
+
<script defer src="${g}" integrity="${re}" crossorigin="anonymous"><\/script>
|
|
212
|
+
<script type="application/json" id="chart-config">${se(t)}<\/script>
|
|
78
213
|
</head>
|
|
79
214
|
<body>
|
|
80
|
-
${e ? `<h1>${
|
|
215
|
+
${e ? `<h1>${p(e)}</h1>` : ""}
|
|
81
216
|
<div class="chart"><canvas id="chart"></canvas></div>
|
|
82
217
|
<p id="chart-error"></p>
|
|
83
218
|
</body>
|
|
@@ -85,8 +220,8 @@ ${e ? `<h1>${d(e)}</h1>` : ""}
|
|
|
85
220
|
}
|
|
86
221
|
//#endregion
|
|
87
222
|
//#region src/core/definitions.ts
|
|
88
|
-
var
|
|
89
|
-
function
|
|
223
|
+
var _ = "presentSlide", le = "defineStoryboard", ue = "presentPanel", de = 4, fe = 12, pe = 3, v = /^[0-9a-f]{12}$/, y = (e) => typeof e == "object" && !!e && !Array.isArray(e), b = (e) => typeof e == "string" ? e.trim() : "", x = (e, t) => e.toLowerCase() === t.toLowerCase(), S = (e) => typeof e == "number" && Number.isInteger(e), C = "presentSlide needs slide and totalSlides (whole numbers, slide from 1 to totalSlides), and one of imagePrompt, html, markdown or chart", w = `presentSlide's slide is too long: keep its html, markdown or chart under ${r} characters`, T = `presentSlide's chart must be a Chart.js configuration: an object with type (${h.join(", ")}), data ({ labels, datasets }) and optionally options`;
|
|
224
|
+
function me(e) {
|
|
90
225
|
let t = e;
|
|
91
226
|
if (typeof t == "string") try {
|
|
92
227
|
t = JSON.parse(t);
|
|
@@ -95,13 +230,13 @@ function pe(e) {
|
|
|
95
230
|
}
|
|
96
231
|
if (!y(t) || !y(t.data)) return null;
|
|
97
232
|
let n = t.type;
|
|
98
|
-
return !
|
|
233
|
+
return !h.some((e) => e === n) || t.options !== void 0 && !y(t.options) ? null : t;
|
|
99
234
|
}
|
|
100
|
-
function
|
|
235
|
+
function E(e) {
|
|
101
236
|
let { slide: t, totalSlides: n, title: r, imagePrompt: i } = e, a = b(e.html), o = a ? "" : b(e.markdown), s = !a && !o && e.chart !== void 0 && e.chart !== null;
|
|
102
|
-
if (!S(t) || !S(n) || t < 1 || n < t || !a && !o && !s && !b(i)) return
|
|
103
|
-
let c = s ?
|
|
104
|
-
return s && !c ?
|
|
237
|
+
if (!S(t) || !S(n) || t < 1 || n < t || !a && !o && !s && !b(i)) return C;
|
|
238
|
+
let c = s ? me(e.chart) : null;
|
|
239
|
+
return s && !c ? T : Math.max(a.length, o.length, c ? JSON.stringify(c).length : 0) > 6e4 ? w : {
|
|
105
240
|
slide: t,
|
|
106
241
|
totalSlides: n,
|
|
107
242
|
title: typeof r == "string" ? r : "",
|
|
@@ -112,22 +247,22 @@ function me(e) {
|
|
|
112
247
|
mode: e.mode === "steps" ? "steps" : "presentation"
|
|
113
248
|
};
|
|
114
249
|
}
|
|
115
|
-
var
|
|
250
|
+
var D = "teach its subject in at least two sentences, as a presenter speaking to the audience. Begin with the content itself, never with the slide or your plan: no \"This slide is about…\", \"The first slide shows…\", \"Let's unpack this one\", \"Next, I'll…\". A line about the slide is not an explanation.", O = ({ slide: e, totalSlides: t, title: n, mode: r }) => {
|
|
116
251
|
let i = n ? ` ("${n}")` : "";
|
|
117
252
|
if (r === "steps") {
|
|
118
253
|
let n = `Step ${e} of ${t}${i}`;
|
|
119
254
|
return e < t ? `${n} is now on the screen. Say what to do in this step, directly ("Crack two eggs into a bowl…", not "This step is about eggs"), then stop and wait while the user does it. When they say they're ready (next, done, go on), call presentSlide for step ${e + 1} with mode "steps". If they ask to go back or to see a step again, call presentSlide for that step.` : `${n}, the last one, is now on the screen. Say what to do, directly, then wrap up the guide once the user is done.`;
|
|
120
255
|
}
|
|
121
256
|
let a = `Slide ${e} of ${t}${i}`;
|
|
122
|
-
return e < t ? `${a} is now on the screen. Explain it: ${
|
|
123
|
-
},
|
|
257
|
+
return e < t ? `${a} is now on the screen. Explain it: ${D} Then, in this same reply and without waiting for the user, call presentSlide for slide ${e + 1}. If the user has asked you to stop, or asked something else, since the slideshow began, answer them instead of going on.` : `${a}, the last one, is now on the screen. Explain it: ${D} Then wrap up the slideshow.`;
|
|
258
|
+
}, he = [
|
|
124
259
|
`For an HTML slide, instead of imagePrompt: the slide's content, the inside of <body> only (no <html>, <head> or <body> tags), for a ${t}x720 px canvas, which it should fill (start with a <div class="w-full h-full ...">). Style it with Tailwind CSS v4 classes, which are loaded for you: a clear layout, a large title (text-6xl or so), few words in large type, a color scheme, and inline SVG or emoji for icons and diagrams. There is no network: no <img> from URLs, no links to follow.`,
|
|
125
260
|
"Animate it so it builds up as you explain it, with MulmoCast's data-animation attributes (the same ones make it move in a movie of the slideshow): data-animation=\"animate\" with data-opacity=\"0,1\", data-translate-x, data-translate-y (px), data-scale, data-rotate (deg), data-width or data-height (\"0,80,%\"), each \"from,to\"; data-animation=\"counter\" with data-from, data-to, data-decimals, data-prefix, data-suffix; data-animation=\"typewriter\" (its text, or data-text). Give every one data-start and data-end in seconds, and optionally data-easing (linear, easeIn, easeOut, easeInOut); stagger the parts with later data-start values so they appear one after another over a few seconds (for example 0, 0.6, 1.2). Set the first frame inline too (style=\"opacity:0\" on an element that fades in).",
|
|
126
261
|
"CSS animations, transitions and scripts don't play: animate only with data-animation. A <style> for layout is allowed (and Google Fonts by @import)."
|
|
127
|
-
].join(" "),
|
|
262
|
+
].join(" "), ge = "For a Markdown slide, instead of imagePrompt: the slide in Markdown (GitHub's: headings, lists, bold, tables, code), with math in TeX between $...$ inline or $$...$$ for a displayed equation (on lines of its own). Start with a # heading, and keep it to what fits on one slide: a heading and a few lines, a list or an equation or two. Write a dollar sign that isn't math as \\$.", _e = `For a chart slide, instead of imagePrompt: a Chart.js configuration as JSON text, {"type": ..., "data": ...}: { type, data: { labels, datasets: [{ label, data, backgroundColor }] }, options }. type is one of ${h.join(", ")}. It is drawn under the slide's title, so leave out options.plugins.title; give the datasets colors, and the axes titles (options.scales.x.title) when their units aren't obvious. JSON values only: no functions.`, k = "When the user asks for a slideshow (or to explain something with slides), plan four to six slides, then show them one at a time with presentSlide: slide 1 first, and each next slide only after you have explained the one on the screen. Explain the subject, not the slides: say what the slide teaches, not that a slide is about it. Go on to the last slide without asking whether to continue. A slide is a generated picture (imagePrompt), a chart (chart), a text slide in Markdown (markdown) or a designed slide in HTML (html): use a picture for a scene, an object or a place; a chart for numbers to compare, a trend or proportions; Markdown for equations and formulas (TeX math), definitions, short lists and small tables; and HTML for designed layouts, comparisons, timelines and diagrams. A picture model draws words, numbers and math badly, so they go on the other kinds; a slideshow can mix them. When the user asks for HTML slides (slides in HTML, an HTML presentation), this is the tool: make them HTML slides with presentSlide, one call per slide, not one HTML page. When the user wants to be shown how to do something they will do along with you (cooking, folding, fixing, an exercise), make it a step-by-step guide instead: mode \"steps\", one slide per step, and after each step wait for the user to say they are ready. Use generateImage for a single picture, not for slides.", A = {
|
|
128
263
|
type: "function",
|
|
129
|
-
name:
|
|
130
|
-
prompt:
|
|
264
|
+
name: _,
|
|
265
|
+
prompt: k,
|
|
131
266
|
description: "Show one slide of a slideshow, full screen: a picture generated from imagePrompt, a chart (chart), a slide written in Markdown with TeX math (markdown), or a slide written in HTML (html). Give one of the four. Call it once per slide, in order, starting with slide 1. With mode \"steps\" it is a step-by-step guide: one slide per step, and the next step waits for the user.",
|
|
132
267
|
parameters: {
|
|
133
268
|
type: "object",
|
|
@@ -150,15 +285,15 @@ var he = "teach its subject in at least two sentences, as a presenter speaking t
|
|
|
150
285
|
},
|
|
151
286
|
html: {
|
|
152
287
|
type: "string",
|
|
153
|
-
description:
|
|
288
|
+
description: he
|
|
154
289
|
},
|
|
155
290
|
markdown: {
|
|
156
291
|
type: "string",
|
|
157
|
-
description:
|
|
292
|
+
description: ge
|
|
158
293
|
},
|
|
159
294
|
chart: {
|
|
160
295
|
type: "string",
|
|
161
|
-
description:
|
|
296
|
+
description: _e
|
|
162
297
|
},
|
|
163
298
|
mode: {
|
|
164
299
|
type: "string",
|
|
@@ -173,7 +308,7 @@ var he = "teach its subject in at least two sentences, as a presenter speaking t
|
|
|
173
308
|
]
|
|
174
309
|
}
|
|
175
310
|
};
|
|
176
|
-
function
|
|
311
|
+
function j(e) {
|
|
177
312
|
let { totalPanels: t } = e;
|
|
178
313
|
if (!S(t) || t < 1 || t > 12) return "totalPanels must be a whole number from 1 to 12";
|
|
179
314
|
let n = [];
|
|
@@ -194,8 +329,8 @@ function D(e) {
|
|
|
194
329
|
interactive: e.interactive === !0
|
|
195
330
|
};
|
|
196
331
|
}
|
|
197
|
-
var
|
|
198
|
-
function
|
|
332
|
+
var M = ({ title: e, id: t }) => `The cast of "${e}" is now on the screen. Introduce the characters briefly, then, in this same reply and without waiting for the user, call presentPanel for panel 1 with storyboardId "${t}". If the user has asked you to stop, or asked something else, answer them instead of going on.`, N = "presentPanel needs a storyboardId, a panel number (from 1) and an imagePrompt";
|
|
333
|
+
function P(e) {
|
|
199
334
|
let { panel: t } = e, n = b(e.storyboardId), r = b(e.imagePrompt);
|
|
200
335
|
if (!n || !r || !S(t) || t < 1) return null;
|
|
201
336
|
let i = (e) => (Array.isArray(e) ? e : []).map(b).filter(Boolean);
|
|
@@ -208,14 +343,14 @@ function A(e) {
|
|
|
208
343
|
choices: i(e.choices).slice(0, 3)
|
|
209
344
|
};
|
|
210
345
|
}
|
|
211
|
-
function
|
|
346
|
+
function F(e, t, n) {
|
|
212
347
|
let { id: r, totalPanels: i } = e;
|
|
213
348
|
return n.length ? `Panel ${t} of ${i} is now on the screen, with the user's choices: ${n.map((e, t) => `${t + 1}. ${e}`).join(" ")} Tell this part of the story, then read the choices out and ask the user which one they pick, and wait for their answer. Then call presentPanel for panel ${t + 1} with storyboardId "${r}", going on the way they chose.` : t < i ? `Panel ${t} of ${i} is now on the screen. Tell this part of the story, then, in this same reply and without waiting for the user, call presentPanel for panel ${t + 1} with storyboardId "${r}". If the user has asked you to stop, or asked something else, since the story began, answer them instead of going on.` : `Panel ${t} of ${i}, the last one, is now on the screen. Tell this part of the story, then bring it to an end.`;
|
|
214
349
|
}
|
|
215
|
-
var
|
|
350
|
+
var ve = "When the user asks for a story, a picture book, a comic or a storyboard, tell it in pictures: first call defineStoryboard with the art style and the characters who appear more than once (it draws a reference sheet for each, so they look the same in every panel), then show the panels one at a time with presentPanel, naming the characters in each, and tell each part of the story when its panel appears. Go on to the last panel without asking whether to continue, unless the story is interactive. When the user wants to decide what happens (an adventure, a story for a child who wants to choose), set interactive, and give two or three choices on two or three of the panels: the story waits there for the user's pick and goes on their way; it still ends at the last panel whichever way it goes. Use presentSlide to explain a topic, not to tell a story.", I = {
|
|
216
351
|
type: "function",
|
|
217
|
-
name:
|
|
218
|
-
prompt:
|
|
352
|
+
name: le,
|
|
353
|
+
prompt: ve,
|
|
219
354
|
description: "Start a story told in pictures: set its art style and draw a reference sheet for each recurring character, shown as the cast. Then call presentPanel for each panel, in order.",
|
|
220
355
|
parameters: {
|
|
221
356
|
type: "object",
|
|
@@ -262,9 +397,9 @@ var M = "When the user asks for a story, a picture book, a comic or a storyboard
|
|
|
262
397
|
"characters"
|
|
263
398
|
]
|
|
264
399
|
}
|
|
265
|
-
},
|
|
400
|
+
}, L = {
|
|
266
401
|
type: "function",
|
|
267
|
-
name:
|
|
402
|
+
name: ue,
|
|
268
403
|
description: "Show one panel of a storyboard made with defineStoryboard: a picture of the scene with its characters drawn as in their reference sheets, and a caption. Call it once per panel, in order, starting with panel 1.",
|
|
269
404
|
parameters: {
|
|
270
405
|
type: "object",
|
|
@@ -303,60 +438,60 @@ var M = "When the user asks for a story, a picture book, a comic or a storyboard
|
|
|
303
438
|
"imagePrompt"
|
|
304
439
|
]
|
|
305
440
|
}
|
|
306
|
-
},
|
|
307
|
-
function
|
|
308
|
-
let t =
|
|
441
|
+
}, R = (e) => typeof e == "object" && !!e && !Array.isArray(e), ye = (e) => R(e) && typeof e.message == "string";
|
|
442
|
+
function z(e) {
|
|
443
|
+
let t = R(e?.data) ? e.data : {};
|
|
309
444
|
return {
|
|
310
445
|
...typeof t.imageData == "string" && { imageData: t.imageData },
|
|
311
446
|
...typeof t.imagePath == "string" && { imagePath: t.imagePath }
|
|
312
447
|
};
|
|
313
448
|
}
|
|
314
|
-
function
|
|
315
|
-
let t =
|
|
449
|
+
function B(e) {
|
|
450
|
+
let t = R(e?.data) ? e.data : {};
|
|
316
451
|
return typeof t.html == "string" ? t.html : "";
|
|
317
452
|
}
|
|
318
|
-
function
|
|
319
|
-
let t =
|
|
320
|
-
return
|
|
453
|
+
function V(e) {
|
|
454
|
+
let t = R(e?.data) ? e.data : {};
|
|
455
|
+
return R(t.chart) ? JSON.stringify(t.chart) : "";
|
|
321
456
|
}
|
|
322
|
-
var
|
|
323
|
-
function
|
|
324
|
-
let n =
|
|
457
|
+
var be = (e) => !!z(e).imageData || !!B(e) || !!V(e);
|
|
458
|
+
function xe(e, t) {
|
|
459
|
+
let n = z(e), r = z(t);
|
|
325
460
|
if (n.imagePath && r.imagePath) return n.imagePath === r.imagePath;
|
|
326
461
|
if (n.imageData) return n.imageData === r.imageData;
|
|
327
|
-
let i =
|
|
328
|
-
if (i) return i ===
|
|
329
|
-
let a =
|
|
330
|
-
return !!a && a ===
|
|
462
|
+
let i = B(e);
|
|
463
|
+
if (i) return i === B(t);
|
|
464
|
+
let a = V(e);
|
|
465
|
+
return !!a && a === V(t);
|
|
331
466
|
}
|
|
332
|
-
var
|
|
333
|
-
async function
|
|
467
|
+
var H = (e, t) => e.userSpokeAt === void 0 || e.userSpokeAt > t, U = () => crypto.randomUUID().replace(/-/g, "").slice(0, 12), Se = "artifacts/";
|
|
468
|
+
async function W(e, t) {
|
|
334
469
|
let n = e.files?.artifacts;
|
|
335
470
|
if (!e.app?.editImages || !n) return [];
|
|
336
471
|
let r = [];
|
|
337
|
-
for (let e of t) if (e.startsWith(
|
|
472
|
+
for (let e of t) if (e.startsWith(Se)) try {
|
|
338
473
|
await n.exists(e.slice(10)) && r.push(e);
|
|
339
474
|
} catch {}
|
|
340
475
|
return r;
|
|
341
476
|
}
|
|
342
|
-
async function
|
|
477
|
+
async function G(e, t, n = []) {
|
|
343
478
|
let r = e.app, i = r?.editImages, a = r?.generateImage;
|
|
344
479
|
try {
|
|
345
480
|
let e;
|
|
346
481
|
if (n.length && i) e = await i(t, [...n]);
|
|
347
482
|
else if (a) e = await a(t);
|
|
348
483
|
else return { message: "image generation isn't available" };
|
|
349
|
-
return
|
|
484
|
+
return ye(e) ? e : { message: "image generation returned an unrecognized result" };
|
|
350
485
|
} catch (e) {
|
|
351
486
|
return { message: `image generation failed: ${e instanceof Error ? e.message : String(e)}` };
|
|
352
487
|
}
|
|
353
488
|
}
|
|
354
|
-
var
|
|
355
|
-
function
|
|
489
|
+
var Ce = 50;
|
|
490
|
+
function K(e) {
|
|
356
491
|
let t = /* @__PURE__ */ new Map();
|
|
357
492
|
return (n) => {
|
|
358
493
|
let r = n.conversationId ?? "", i = t.get(r);
|
|
359
|
-
if (i === void 0 ? i = e() : t.delete(r), t.set(r, i), t.size >
|
|
494
|
+
if (i === void 0 ? i = e() : t.delete(r), t.set(r, i), t.size > Ce) {
|
|
360
495
|
let e = t.keys().next().value;
|
|
361
496
|
e !== void 0 && t.delete(e);
|
|
362
497
|
}
|
|
@@ -365,41 +500,41 @@ function U(e) {
|
|
|
365
500
|
}
|
|
366
501
|
//#endregion
|
|
367
502
|
//#region src/core/markdownSlide.ts
|
|
368
|
-
var
|
|
369
|
-
.${
|
|
370
|
-
.${
|
|
371
|
-
.${
|
|
372
|
-
.${
|
|
373
|
-
.${
|
|
374
|
-
.${
|
|
375
|
-
.${
|
|
376
|
-
.${
|
|
377
|
-
.${
|
|
378
|
-
.${
|
|
379
|
-
.${
|
|
380
|
-
.${
|
|
381
|
-
.${
|
|
382
|
-
.${
|
|
383
|
-
.${
|
|
384
|
-
.${
|
|
385
|
-
.${
|
|
386
|
-
.${
|
|
387
|
-
.${
|
|
388
|
-
.${
|
|
389
|
-
.${
|
|
390
|
-
.${
|
|
391
|
-
.${
|
|
392
|
-
.${
|
|
393
|
-
.${
|
|
394
|
-
.${
|
|
395
|
-
.${
|
|
396
|
-
.${
|
|
397
|
-
function
|
|
503
|
+
var q = "slide-md", we = `
|
|
504
|
+
.${q} { box-sizing: border-box; flex-shrink: 0; width: ${t}px; height: 720px; padding: 56px 80px; overflow: hidden; display: flex; flex-direction: column; justify-content: center; gap: 0.5em; background: #ffffff; color: #0f172a; font-family: ui-sans-serif, system-ui, sans-serif; line-height: 1.35; }
|
|
505
|
+
.${q} > * { margin: 0; }
|
|
506
|
+
.${q} h1 { font-size: 1.9em; font-weight: 800; color: #1e3a8a; line-height: 1.15; }
|
|
507
|
+
.${q} h2 { font-size: 1.5em; font-weight: 700; color: #1e40af; line-height: 1.2; }
|
|
508
|
+
.${q} h3 { font-size: 1.2em; font-weight: 700; color: #334155; }
|
|
509
|
+
.${q} ul, .${q} ol { padding-left: 1.3em; display: flex; flex-direction: column; gap: 0.3em; }
|
|
510
|
+
.${q} ul { list-style: disc; }
|
|
511
|
+
.${q} ol { list-style: decimal; }
|
|
512
|
+
.${q} li > ul, .${q} li > ol { margin-top: 0.3em; font-size: 0.9em; }
|
|
513
|
+
.${q} li::marker { color: #2563eb; }
|
|
514
|
+
.${q} strong { font-weight: 700; color: #1e3a8a; }
|
|
515
|
+
.${q} em { font-style: italic; }
|
|
516
|
+
.${q} a { color: #2563eb; text-decoration: underline; }
|
|
517
|
+
.${q} code { font-family: ui-monospace, monospace; font-size: 0.85em; background: #f1f5f9; border-radius: 0.2em; padding: 0.05em 0.3em; }
|
|
518
|
+
.${q} pre { background: #0f172a; color: #e2e8f0; border-radius: 0.4em; padding: 0.6em 0.8em; font-size: 0.75em; overflow: hidden; }
|
|
519
|
+
.${q} pre code { background: none; padding: 0; color: inherit; }
|
|
520
|
+
.${q} blockquote { border-left: 0.2em solid #93c5fd; padding-left: 0.8em; color: #475569; font-style: italic; }
|
|
521
|
+
.${q} table { border-collapse: collapse; font-size: 0.85em; align-self: flex-start; }
|
|
522
|
+
.${q} th, .${q} td { border: 1px solid #cbd5e1; padding: 0.25em 0.7em; text-align: left; }
|
|
523
|
+
.${q} th { background: #eff6ff; font-weight: 700; }
|
|
524
|
+
.${q} hr { border: 0; border-top: 2px solid #e2e8f0; }
|
|
525
|
+
.${q} img { max-width: 100%; max-height: 60%; }
|
|
526
|
+
.${q} .math-display { display: block; text-align: center; font-size: 1.15em; }
|
|
527
|
+
.${q} math { font-family: "Latin Modern Math", "STIX Two Math", "Cambria Math", math; }
|
|
528
|
+
.${q} mtd { padding: 0.1em 0.4em; }
|
|
529
|
+
.${q} mtd:first-child { padding-left: 0; }
|
|
530
|
+
.${q} mtd:last-child { padding-right: 0; }
|
|
531
|
+
.${q} .math-error { color: #b91c1c; font-family: ui-monospace, monospace; }`;
|
|
532
|
+
function Te(e) {
|
|
398
533
|
let t = e.split("\n").filter((e) => e.trim()).length, n = e.length;
|
|
399
534
|
return t <= 5 && n <= 250 ? 40 : t <= 8 && n <= 450 ? 34 : t <= 12 && n <= 700 ? 28 : 24;
|
|
400
535
|
}
|
|
401
|
-
var
|
|
402
|
-
function
|
|
536
|
+
var Ee = /^[ \t]*(?:\$\$([\s\S]+?)\$\$|\\\[([\s\S]+?)\\\])[ \t]*(?:\n|$)/, De = /^(?:\$\$(.+?)\$\$|\$(?!\s)((?:\\.|[^\\$\n])+?)(?<!\s)\$(?!\d)|\\\((.+?)\\\))/;
|
|
537
|
+
function Oe(e) {
|
|
403
538
|
return [{
|
|
404
539
|
name: "blockMath",
|
|
405
540
|
level: "block",
|
|
@@ -408,7 +543,7 @@ function ke(e) {
|
|
|
408
543
|
return t ? t.index + (t[1] ?? "").length : void 0;
|
|
409
544
|
},
|
|
410
545
|
tokenizer(e) {
|
|
411
|
-
let t =
|
|
546
|
+
let t = Ee.exec(e);
|
|
412
547
|
if (t) return {
|
|
413
548
|
type: "blockMath",
|
|
414
549
|
raw: t[0],
|
|
@@ -421,7 +556,7 @@ function ke(e) {
|
|
|
421
556
|
level: "inline",
|
|
422
557
|
start: (e) => e.match(/(?<!\\)\$|\\\(/)?.index,
|
|
423
558
|
tokenizer(e) {
|
|
424
|
-
let t =
|
|
559
|
+
let t = De.exec(e);
|
|
425
560
|
if (t) return {
|
|
426
561
|
type: "inlineMath",
|
|
427
562
|
raw: t[0],
|
|
@@ -432,44 +567,44 @@ function ke(e) {
|
|
|
432
567
|
renderer: (t) => e(String(t.text), t.display === !0)
|
|
433
568
|
}];
|
|
434
569
|
}
|
|
435
|
-
var
|
|
436
|
-
async function
|
|
570
|
+
var ke = /(<\/mi>|<\/mn>|<\/mrow>|<mo[^>]*>[)\]]<\/mo>)?(<mi(?: mathvariant="normal")?>[A-Za-z]{2,}<\/mi>)<mo>\u2061<\/mo>/g, Ae = "<mspace width=\"0.1667em\"></mspace>", je = (e) => e.replace(ke, (e, t, n) => `${t ? t + Ae : ""}${n}<mo lspace="0" rspace="0.1667em">\u2061</mo>`);
|
|
571
|
+
async function J(e) {
|
|
437
572
|
let [{ Marked: t }, { default: n }] = await Promise.all([import("marked"), import("katex")]), r = (e, t) => {
|
|
438
573
|
try {
|
|
439
|
-
return
|
|
574
|
+
return je(n.renderToString(e, {
|
|
440
575
|
output: "mathml",
|
|
441
576
|
displayMode: t,
|
|
442
577
|
throwOnError: !0
|
|
443
578
|
}));
|
|
444
579
|
} catch {
|
|
445
|
-
return `<code class="math-error">${
|
|
580
|
+
return `<code class="math-error">${p(e)}</code>`;
|
|
446
581
|
}
|
|
447
582
|
}, i = new t({
|
|
448
583
|
gfm: !0,
|
|
449
584
|
breaks: !1
|
|
450
585
|
});
|
|
451
|
-
i.use({ extensions:
|
|
586
|
+
i.use({ extensions: Oe(r) });
|
|
452
587
|
let a = await i.parse(e);
|
|
453
|
-
return `<style>${
|
|
454
|
-
<div class="${
|
|
588
|
+
return `<style>${we}</style>
|
|
589
|
+
<div class="${q}" data-fit style="font-size: ${Te(e)}px">
|
|
455
590
|
${a}</div>`;
|
|
456
591
|
}
|
|
457
592
|
//#endregion
|
|
458
593
|
//#region src/core/records.ts
|
|
459
|
-
var
|
|
460
|
-
function
|
|
461
|
-
let t =
|
|
462
|
-
return t ||
|
|
463
|
-
}
|
|
464
|
-
function
|
|
465
|
-
let r =
|
|
466
|
-
r ||
|
|
594
|
+
var Y = "slideshows", X = "storyboards", Me = {}, Ne = /* @__PURE__ */ new WeakMap(), Pe = /* @__PURE__ */ new WeakMap();
|
|
595
|
+
function Fe(e) {
|
|
596
|
+
let t = Ne.get(e);
|
|
597
|
+
return t || Ne.set(e, t = /* @__PURE__ */ new Map()), t;
|
|
598
|
+
}
|
|
599
|
+
function Ie(t, n) {
|
|
600
|
+
let r = Pe.get(t);
|
|
601
|
+
r || Pe.set(t, r = /* @__PURE__ */ new Map());
|
|
467
602
|
let i = r.get(n);
|
|
468
603
|
return i || r.set(n, i = e()), i;
|
|
469
604
|
}
|
|
470
|
-
var
|
|
471
|
-
async function
|
|
472
|
-
let n =
|
|
605
|
+
var Le = (e, t) => `${e}/${t}.json`;
|
|
606
|
+
async function Re(e, t) {
|
|
607
|
+
let n = Fe(e ?? Me), r = n.get(t);
|
|
473
608
|
if (r) return r;
|
|
474
609
|
if (!e) return null;
|
|
475
610
|
try {
|
|
@@ -479,14 +614,14 @@ async function Ie(e, t) {
|
|
|
479
614
|
return null;
|
|
480
615
|
}
|
|
481
616
|
}
|
|
482
|
-
async function
|
|
483
|
-
return
|
|
617
|
+
async function ze(e, t, n) {
|
|
618
|
+
return v.test(n) ? Re(e, Le(t, n)) : null;
|
|
484
619
|
}
|
|
485
620
|
async function Z(e, t, n, r) {
|
|
486
|
-
let i =
|
|
487
|
-
return
|
|
488
|
-
let t = r(await
|
|
489
|
-
if (
|
|
621
|
+
let i = Le(t, n), a = e ?? Me;
|
|
622
|
+
return Ie(a, i)(async () => {
|
|
623
|
+
let t = r(await Re(e, i));
|
|
624
|
+
if (Fe(a).set(i, t), !e) return !1;
|
|
490
625
|
try {
|
|
491
626
|
return await e.write(i, JSON.stringify(t, null, 2)), !0;
|
|
492
627
|
} catch (e) {
|
|
@@ -494,12 +629,12 @@ async function Z(e, t, n, r) {
|
|
|
494
629
|
}
|
|
495
630
|
});
|
|
496
631
|
}
|
|
497
|
-
var Q = (e) => `the ${e} could not be saved, so it lasts only until the app or server restarts`,
|
|
498
|
-
function
|
|
632
|
+
var Q = (e) => `the ${e} could not be saved, so it lasts only until the app or server restarts`, Be = 6e4;
|
|
633
|
+
function Ve() {
|
|
499
634
|
let e = /* @__PURE__ */ new Map();
|
|
500
635
|
return { claim: (t) => {
|
|
501
636
|
let n = Date.now();
|
|
502
|
-
for (let [t, r] of e) n - r.at >
|
|
637
|
+
for (let [t, r] of e) n - r.at > Be && e.delete(t);
|
|
503
638
|
let r = e.get(t);
|
|
504
639
|
if (r) return { earlier: r.shown };
|
|
505
640
|
let i = () => void 0, a = new Promise((e) => i = e);
|
|
@@ -513,7 +648,7 @@ function ze() {
|
|
|
513
648
|
}
|
|
514
649
|
//#endregion
|
|
515
650
|
//#region src/core/presentSlide.ts
|
|
516
|
-
function
|
|
651
|
+
function He({ slide: e, totalSlides: t, mode: n }) {
|
|
517
652
|
return n === "steps" ? {
|
|
518
653
|
step: e,
|
|
519
654
|
total: t,
|
|
@@ -531,7 +666,7 @@ function Be({ slide: e, totalSlides: t, mode: n }) {
|
|
|
531
666
|
nextCall: `call presentSlide for slide ${e + 1} of ${t}`
|
|
532
667
|
};
|
|
533
668
|
}
|
|
534
|
-
var
|
|
669
|
+
var Ue = (e, { slide: t, totalSlides: n, title: r, imagePrompt: i, html: a, markdown: o, chart: s }) => JSON.stringify([
|
|
535
670
|
e,
|
|
536
671
|
t,
|
|
537
672
|
n,
|
|
@@ -540,19 +675,19 @@ var Ve = (e, { slide: t, totalSlides: n, title: r, imagePrompt: i, html: a, mark
|
|
|
540
675
|
a,
|
|
541
676
|
o,
|
|
542
677
|
s
|
|
543
|
-
]),
|
|
678
|
+
]), We = K(() => ({
|
|
544
679
|
latest: {
|
|
545
680
|
presentation: null,
|
|
546
681
|
steps: null
|
|
547
682
|
},
|
|
548
683
|
lastShown: null,
|
|
549
|
-
repeats:
|
|
684
|
+
repeats: Ve()
|
|
550
685
|
}));
|
|
551
|
-
function
|
|
686
|
+
function Ge(e, t) {
|
|
552
687
|
let n = e.latest[t.mode], r = n?.totalSlides === t.totalSlides && (t.slide !== 1 || n.firstTitle === t.title);
|
|
553
688
|
if (n && r) return n;
|
|
554
689
|
let i = {
|
|
555
|
-
id:
|
|
690
|
+
id: U(),
|
|
556
691
|
mode: t.mode,
|
|
557
692
|
totalSlides: t.totalSlides,
|
|
558
693
|
firstTitle: t.slide === 1 ? t.title : "",
|
|
@@ -562,18 +697,18 @@ function Ue(e, t) {
|
|
|
562
697
|
};
|
|
563
698
|
return e.latest[t.mode] = i, i;
|
|
564
699
|
}
|
|
565
|
-
function
|
|
700
|
+
function Ke(e, t, n, r) {
|
|
566
701
|
t.current = n.slide, t.shownAt = Date.now(), e.lastShown = t;
|
|
567
702
|
let i = n.mode === "steps" ? "step" : "slide", { uuid: a, ...o } = r;
|
|
568
703
|
return {
|
|
569
704
|
...o,
|
|
570
705
|
message: `${i} ${n.slide} of ${n.totalSlides} is on the screen again, as it was`,
|
|
571
|
-
instructions:
|
|
706
|
+
instructions: O(n),
|
|
572
707
|
instructionsRequired: !0,
|
|
573
|
-
sequence:
|
|
708
|
+
sequence: He(n)
|
|
574
709
|
};
|
|
575
710
|
}
|
|
576
|
-
function
|
|
711
|
+
function qe(e, t) {
|
|
577
712
|
if (e.mode !== "steps") return e.title ? `A presentation slide titled "${e.title}". ${e.imagePrompt}` : e.imagePrompt;
|
|
578
713
|
let n = e.title ? `, "${e.title}"` : "";
|
|
579
714
|
return [
|
|
@@ -582,7 +717,7 @@ function We(e, t) {
|
|
|
582
717
|
"Show the action clearly, with little or no text."
|
|
583
718
|
].filter(Boolean).join(" ");
|
|
584
719
|
}
|
|
585
|
-
async function
|
|
720
|
+
async function Je(e, t, n) {
|
|
586
721
|
if (n.html) return {
|
|
587
722
|
html: n.html,
|
|
588
723
|
prompt: ""
|
|
@@ -592,11 +727,11 @@ async function Ge(e, t, n) {
|
|
|
592
727
|
prompt: ""
|
|
593
728
|
};
|
|
594
729
|
if (n.markdown) return {
|
|
595
|
-
html: await
|
|
730
|
+
html: await J(n.markdown),
|
|
596
731
|
markdown: n.markdown,
|
|
597
732
|
prompt: ""
|
|
598
733
|
};
|
|
599
|
-
let r = t.slides.get(n.slide - 1), i = n.mode === "steps" ?
|
|
734
|
+
let r = t.slides.get(n.slide - 1), i = n.mode === "steps" ? z(r).imagePath : void 0, a = i ? await W(e, [i]) : [], o = qe(n, a.length > 0), s = await G(e, o, a), { imageData: c, imagePath: l } = z(s);
|
|
600
735
|
return c ? {
|
|
601
736
|
imageData: c,
|
|
602
737
|
...l && { imagePath: l },
|
|
@@ -606,10 +741,10 @@ async function Ge(e, t, n) {
|
|
|
606
741
|
sequence: null
|
|
607
742
|
} };
|
|
608
743
|
}
|
|
609
|
-
async function
|
|
610
|
-
let r = await
|
|
744
|
+
async function Ye(e, t, n) {
|
|
745
|
+
let r = await Je(e, t, n);
|
|
611
746
|
if ("failed" in r) return r.failed;
|
|
612
|
-
let { imageData: i, imagePath: a, html: o, markdown: s, chart: c, prompt: l } = r, u = t.id, d = await Z(e.files?.artifacts,
|
|
747
|
+
let { imageData: i, imagePath: a, html: o, markdown: s, chart: c, prompt: l } = r, u = t.id, d = await Z(e.files?.artifacts, Y, u, (e) => {
|
|
613
748
|
let t = e ?? {
|
|
614
749
|
id: u,
|
|
615
750
|
title: "",
|
|
@@ -646,19 +781,19 @@ async function Ke(e, t, n) {
|
|
|
646
781
|
a ? `saved to ${a}` : "",
|
|
647
782
|
d ? "" : Q("slideshow")
|
|
648
783
|
].filter(Boolean).join("; "),
|
|
649
|
-
instructions:
|
|
784
|
+
instructions: O(n),
|
|
650
785
|
instructionsRequired: !0,
|
|
651
|
-
sequence:
|
|
786
|
+
sequence: He(n)
|
|
652
787
|
};
|
|
653
788
|
}
|
|
654
|
-
async function
|
|
655
|
-
let n =
|
|
789
|
+
async function Xe(e, t) {
|
|
790
|
+
let n = E(t);
|
|
656
791
|
if (typeof n == "string") return {
|
|
657
792
|
message: n,
|
|
658
793
|
sequence: null
|
|
659
794
|
};
|
|
660
|
-
let r =
|
|
661
|
-
if (a && n.slide > i.current && i.current > 0 && !
|
|
795
|
+
let r = We(e), i = Ge(r, n), a = n.mode === "steps";
|
|
796
|
+
if (a && n.slide > i.current && i.current > 0 && !H(e, i.shownAt)) {
|
|
662
797
|
console.info(`[sequence] holding step ${n.slide} for the user`);
|
|
663
798
|
let e = i.shownAt === Infinity ? "is still being drawn" : "is still on the screen";
|
|
664
799
|
return {
|
|
@@ -667,15 +802,15 @@ async function qe(e, t) {
|
|
|
667
802
|
};
|
|
668
803
|
}
|
|
669
804
|
let o = a ? i.slides.get(n.slide) : void 0;
|
|
670
|
-
if (o) return
|
|
805
|
+
if (o) return xe(e.currentResult, o) ? {
|
|
671
806
|
message: `step ${n.slide} of ${n.totalSlides} is already on the screen`,
|
|
672
807
|
cancelled: !0
|
|
673
|
-
} :
|
|
674
|
-
let s = r.repeats.claim(
|
|
808
|
+
} : Ke(r, i, n, o);
|
|
809
|
+
let s = r.repeats.claim(Ue(i.id, n));
|
|
675
810
|
if ("earlier" in s) {
|
|
676
|
-
if (!await s.earlier) return
|
|
811
|
+
if (!await s.earlier) return Xe(e, t);
|
|
677
812
|
let a = i.slides.get(n.slide);
|
|
678
|
-
return a && r.lastShown !== i ?
|
|
813
|
+
return a && r.lastShown !== i ? Ke(r, i, n, a) : {
|
|
679
814
|
message: `slide ${n.slide} of ${n.totalSlides} is already on the screen`,
|
|
680
815
|
cancelled: !0
|
|
681
816
|
};
|
|
@@ -687,22 +822,22 @@ async function qe(e, t) {
|
|
|
687
822
|
i.current = n.slide, i.shownAt = Infinity;
|
|
688
823
|
let u = !1;
|
|
689
824
|
try {
|
|
690
|
-
let t = await
|
|
691
|
-
return u =
|
|
825
|
+
let t = await Ye(e, i, n);
|
|
826
|
+
return u = be(t), u && (i.slides.set(n.slide, t), i.current = n.slide, i.shownAt = Date.now(), r.lastShown = i), t;
|
|
692
827
|
} finally {
|
|
693
828
|
c(u), !u && i.current === n.slide && (i.current = l.current, i.shownAt = l.shownAt);
|
|
694
829
|
}
|
|
695
830
|
}
|
|
696
831
|
//#endregion
|
|
697
832
|
//#region src/core/storyboard.ts
|
|
698
|
-
var
|
|
833
|
+
var Ze = ({ id: e, title: t, totalPanels: n }) => ({
|
|
699
834
|
step: 0,
|
|
700
835
|
total: n,
|
|
701
836
|
kind: "story",
|
|
702
837
|
label: `The cast of "${t}"`,
|
|
703
838
|
onShown: "introduce the characters",
|
|
704
839
|
nextCall: `call presentPanel for panel 1 of ${n} with storyboardId "${e}"`
|
|
705
|
-
}),
|
|
840
|
+
}), Qe = ({ id: e, totalPanels: t }, n, r) => ({
|
|
706
841
|
step: n,
|
|
707
842
|
total: t,
|
|
708
843
|
kind: "story",
|
|
@@ -710,21 +845,21 @@ var Je = ({ id: e, title: t, totalPanels: n }) => ({
|
|
|
710
845
|
onShown: "tell that part of the story",
|
|
711
846
|
nextCall: `call presentPanel for panel ${n + 1} of ${t} with storyboardId "${e}"`,
|
|
712
847
|
...r.length > 0 && { waitsForUser: !0 }
|
|
713
|
-
}),
|
|
714
|
-
async function
|
|
715
|
-
let n =
|
|
848
|
+
}), $e = (e, t) => e ? `${e}. ${t}` : t, et = (e, { name: t, description: n }) => $e(e, `Character reference sheet of ${t}: ${n}. Full body, front, side and back views, on a plain white background. No text or labels.`);
|
|
849
|
+
async function tt(e, t) {
|
|
850
|
+
let n = j(t);
|
|
716
851
|
if (typeof n == "string") return {
|
|
717
852
|
message: n,
|
|
718
853
|
sequence: null
|
|
719
854
|
};
|
|
720
|
-
let r = await Promise.all(n.characters.map((t) =>
|
|
855
|
+
let r = await Promise.all(n.characters.map((t) => G(e, et(n.style, t)))), i = r.map(z), a = r.find((e, t) => !i[t]?.imageData);
|
|
721
856
|
if (i.every(({ imageData: e }) => !e) && a) return {
|
|
722
857
|
...a,
|
|
723
858
|
message: `the character sheets couldn't be made: ${a.message}`,
|
|
724
859
|
sequence: null
|
|
725
860
|
};
|
|
726
861
|
let o = {
|
|
727
|
-
id:
|
|
862
|
+
id: U(),
|
|
728
863
|
...n,
|
|
729
864
|
characters: n.characters.map((e, t) => {
|
|
730
865
|
let n = i[t]?.imagePath;
|
|
@@ -734,7 +869,7 @@ async function Qe(e, t) {
|
|
|
734
869
|
};
|
|
735
870
|
}),
|
|
736
871
|
panels: {}
|
|
737
|
-
}, s = await Z(e.files?.artifacts,
|
|
872
|
+
}, s = await Z(e.files?.artifacts, X, o.id, () => o), c = o.characters.filter((e) => e.imagePath).map((e) => `${e.name}: ${e.imagePath}`), l = n.characters.map(({ name: e }, t) => i[t]?.imageData ? null : `${e} (${r[t]?.message ?? ""})`).filter((e) => !!e), u = i.find((e) => e.imageData)?.imageData;
|
|
738
873
|
return {
|
|
739
874
|
data: {
|
|
740
875
|
storyboardId: o.id,
|
|
@@ -757,37 +892,37 @@ async function Qe(e, t) {
|
|
|
757
892
|
l.length ? `no sheet for ${l.join("; ")}: they will be drawn from their description` : "",
|
|
758
893
|
s ? "" : Q("storyboard")
|
|
759
894
|
].filter(Boolean).join("; "),
|
|
760
|
-
instructions:
|
|
895
|
+
instructions: M(o),
|
|
761
896
|
instructionsRequired: !0,
|
|
762
|
-
sequence:
|
|
897
|
+
sequence: Ze(o)
|
|
763
898
|
};
|
|
764
899
|
}
|
|
765
|
-
function
|
|
766
|
-
let r = [
|
|
900
|
+
function nt(e, t, n) {
|
|
901
|
+
let r = [$e(e.style, `Panel ${t.panel} of ${e.totalPanels} of the illustrated story "${e.title}". ${t.imagePrompt}`)], i = 0, a = n.map(({ character: e, hasSheet: t }) => t ? `${e.name} is the character in reference image ${++i}` : `${e.name}: ${e.description}`);
|
|
767
902
|
return a.length && r.push(`${a.join(". ")}.`), i && r.push("Draw each character exactly as in their reference image: the same face, hair, clothes and colors. Use the reference images only for how the characters look, not for their pose or the background."), r.push("No captions, speech bubbles or other text in the picture."), r.join(" ");
|
|
768
903
|
}
|
|
769
|
-
async function
|
|
904
|
+
async function rt(e, t, n) {
|
|
770
905
|
let r = [], i = [];
|
|
771
906
|
for (let a of n.characters) {
|
|
772
907
|
let n = t.characters.find((e) => x(e.name, a));
|
|
773
908
|
if (!n) r.push(a);
|
|
774
909
|
else if (!i.some((e) => e.character === n)) {
|
|
775
|
-
let [t] = n.imagePath ? await
|
|
910
|
+
let [t] = n.imagePath ? await W(e, [n.imagePath]) : [];
|
|
776
911
|
i.push({
|
|
777
912
|
character: n,
|
|
778
913
|
sheet: t ?? null
|
|
779
914
|
});
|
|
780
915
|
}
|
|
781
916
|
}
|
|
782
|
-
let a = i.map(({ sheet: e }) => e).filter((e) => !!e), o =
|
|
917
|
+
let a = i.map(({ sheet: e }) => e).filter((e) => !!e), o = nt(t, n, i.map(({ character: e, sheet: t }) => ({
|
|
783
918
|
character: e,
|
|
784
919
|
hasSheet: !!t
|
|
785
|
-
}))), s = await
|
|
920
|
+
}))), s = await G(e, o, a), { imageData: c, imagePath: l } = z(s);
|
|
786
921
|
if (!c) return {
|
|
787
922
|
...s,
|
|
788
923
|
sequence: null
|
|
789
924
|
};
|
|
790
|
-
let u = n.panel < t.totalPanels && n.choices.length >= 2 ? n.choices : [], d = await Z(e.files?.artifacts,
|
|
925
|
+
let u = n.panel < t.totalPanels && n.choices.length >= 2 ? n.choices : [], d = await Z(e.files?.artifacts, X, t.id, (e) => {
|
|
791
926
|
let r = e ?? t;
|
|
792
927
|
return u.length && (r.interactive = !0), r.panels[String(n.panel)] = {
|
|
793
928
|
caption: n.caption,
|
|
@@ -815,23 +950,23 @@ async function et(e, t, n) {
|
|
|
815
950
|
r.length ? `not in the cast, so drawn from the prompt alone: ${r.join(", ")}` : "",
|
|
816
951
|
d ? "" : Q("storyboard")
|
|
817
952
|
].filter(Boolean).join("; "),
|
|
818
|
-
instructions:
|
|
953
|
+
instructions: F(t, n.panel, u),
|
|
819
954
|
instructionsRequired: !0,
|
|
820
|
-
sequence:
|
|
955
|
+
sequence: Qe(t, n.panel, u)
|
|
821
956
|
};
|
|
822
957
|
}
|
|
823
|
-
var
|
|
824
|
-
repeats:
|
|
958
|
+
var it = K(() => ({
|
|
959
|
+
repeats: Ve(),
|
|
825
960
|
awaitingChoice: /* @__PURE__ */ new Map()
|
|
826
961
|
}));
|
|
827
|
-
async function
|
|
828
|
-
let n =
|
|
962
|
+
async function $(e, t) {
|
|
963
|
+
let n = P(t);
|
|
829
964
|
if (!n) return {
|
|
830
|
-
message:
|
|
965
|
+
message: N,
|
|
831
966
|
sequence: null
|
|
832
967
|
};
|
|
833
|
-
let { storyboardId: r, panel: i } = n, { repeats: a, awaitingChoice: o } =
|
|
834
|
-
if (s && i > s.panel && !
|
|
968
|
+
let { storyboardId: r, panel: i } = n, { repeats: a, awaitingChoice: o } = it(e), s = o.get(r);
|
|
969
|
+
if (s && i > s.panel && !H(e, s.shownAt)) return console.info(`[sequence] holding panel ${i} for the user`), {
|
|
835
970
|
message: s.shownAt === Infinity ? `panel ${i} was not shown: panel ${s.panel} is still being drawn. Wait for it before going on.` : `panel ${i} was not shown: the user hasn't picked a choice yet, and panel ${s.panel} is still on the screen. Wait for their answer.`,
|
|
836
971
|
cancelled: !0
|
|
837
972
|
};
|
|
@@ -839,7 +974,7 @@ async function nt(e, t) {
|
|
|
839
974
|
if ("earlier" in c) return await c.earlier ? {
|
|
840
975
|
message: `panel ${i} is already on the screen`,
|
|
841
976
|
cancelled: !0
|
|
842
|
-
} :
|
|
977
|
+
} : $(e, t);
|
|
843
978
|
let { settle: l } = c, u = {
|
|
844
979
|
panel: i,
|
|
845
980
|
shownAt: Infinity
|
|
@@ -847,7 +982,7 @@ async function nt(e, t) {
|
|
|
847
982
|
o.set(r, u);
|
|
848
983
|
let f = () => o.get(r) === u, p = !1;
|
|
849
984
|
try {
|
|
850
|
-
let t = await
|
|
985
|
+
let t = await ze(e.files?.artifacts, X, r);
|
|
851
986
|
if (!t) return {
|
|
852
987
|
message: `there is no storyboard "${r}"; call defineStoryboard first`,
|
|
853
988
|
sequence: null
|
|
@@ -856,8 +991,8 @@ async function nt(e, t) {
|
|
|
856
991
|
message: `storyboard "${t.id}" has ${t.totalPanels} panels`,
|
|
857
992
|
sequence: null
|
|
858
993
|
};
|
|
859
|
-
let a = await
|
|
860
|
-
p = !!
|
|
994
|
+
let a = await rt(e, t, n);
|
|
995
|
+
p = !!z(a).imageData;
|
|
861
996
|
let s = a.data;
|
|
862
997
|
return p && f() && (s?.choices?.length ? o.set(r, {
|
|
863
998
|
panel: i,
|
|
@@ -869,21 +1004,21 @@ async function nt(e, t) {
|
|
|
869
1004
|
}
|
|
870
1005
|
//#endregion
|
|
871
1006
|
//#region src/core/index.ts
|
|
872
|
-
var
|
|
873
|
-
toolDefinition:
|
|
1007
|
+
var at = {
|
|
1008
|
+
toolDefinition: A,
|
|
874
1009
|
generatingMessage: "Making the slide...",
|
|
875
1010
|
isEnabled: () => !0,
|
|
876
|
-
execute: (e, t) =>
|
|
877
|
-
},
|
|
878
|
-
toolDefinition:
|
|
1011
|
+
execute: (e, t) => Xe(e, t)
|
|
1012
|
+
}, ot = {
|
|
1013
|
+
toolDefinition: I,
|
|
879
1014
|
generatingMessage: "Drawing the characters...",
|
|
880
1015
|
isEnabled: () => !0,
|
|
881
|
-
execute: (e, t) =>
|
|
882
|
-
},
|
|
883
|
-
toolDefinition:
|
|
1016
|
+
execute: (e, t) => tt(e, t)
|
|
1017
|
+
}, st = {
|
|
1018
|
+
toolDefinition: L,
|
|
884
1019
|
generatingMessage: "Drawing the panel...",
|
|
885
1020
|
isEnabled: () => !0,
|
|
886
|
-
execute: (e, t) =>
|
|
1021
|
+
execute: (e, t) => $(e, t)
|
|
887
1022
|
};
|
|
888
1023
|
//#endregion
|
|
889
|
-
export {
|
|
1024
|
+
export { O as A, ne as B, ve as C, E as D, P as E, s as F, m as I, l as L, ce as M, r as N, j as O, o as P, n as R, w as S, F as T, A as _, X as a, C as b, le as c, pe as d, fe as f, _ as g, L as h, Y as i, h as j, x as k, I as l, ue as m, st as n, ze as o, N as p, at as r, J as s, ot as t, de as u, k as v, M as w, T as x, v as y, t as z };
|