@gui-chat-plugin/sequence 0.6.0 → 0.6.2
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 +15 -0
- package/README.md +1 -1
- package/dist/core/definitions.d.ts +0 -1
- package/dist/core/slideHtml.d.ts +3 -0
- package/dist/{core-BCDyutCB.js → core-Czn02RGP.js} +254 -236
- package/dist/core-f9NCxgnh.cjs +245 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +30 -30
- package/package.json +1 -1
- package/dist/core-BVG-aDg8.cjs +0 -245
|
@@ -157,11 +157,24 @@ var t = 1280, n = 720, r = 6e4, i = "https://cdn.jsdelivr.net/npm/@tailwindcss/b
|
|
|
157
157
|
}, p = (e) => e.replace(/[&<>"]/g, (e) => f[e] ?? e), m = (e) => e.replace(/<(?=(meta|base|link)\b)/gi, "<").replace(/shadowroot/gi, "data-no-shadow-root"), h = "*, *::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; }", ee = `
|
|
158
158
|
html, body { margin: 0; width: ${t}px; height: 720px; overflow: hidden; }
|
|
159
159
|
html:not(.ready) body { visibility: hidden; }
|
|
160
|
-
${h}`, g = "{{image}}", _ = /(\bsrc\s*=\s*["']?|\burl\(\s*["']?)(?:\{\{image\}\}|%7B%7Bimage%7D%7D)/gi, te = /^data:image\/[a-z0-9.+-]+;base64,[a-z0-9+/=]+$/i, ne = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", v = /(<pre\b[\s\S]*?<\/pre>|<code\b[\s\S]*?<\/code>)/gi, y = (e) => e.split(v).some((e, t) => t % 2 == 0 && new RegExp(_.source, "i").test(e)), re =
|
|
160
|
+
${h}`, g = "{{image}}", _ = /(\bsrc\s*=\s*["']?|\burl\(\s*["']?)(?:\{\{image\}\}|%7B%7Bimage%7D%7D)/gi, te = /^data:image\/[a-z0-9.+-]+;base64,[a-z0-9+/=]+$/i, ne = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", v = /(<pre\b[\s\S]*?<\/pre>|<code\b[\s\S]*?<\/code>)/gi, y = (e) => e.split(v).some((e, t) => t % 2 == 0 && new RegExp(_.source, "i").test(e)), re = {
|
|
161
|
+
"&": "&",
|
|
162
|
+
"<": "<",
|
|
163
|
+
">": ">",
|
|
164
|
+
""": "\"",
|
|
165
|
+
"'": "'"
|
|
166
|
+
}, ie = (e) => {
|
|
167
|
+
for (let t of e.split(v).filter((e, t) => t % 2 == 0)) for (let e of t.match(/<img\b[^>]*>/gi) ?? []) {
|
|
168
|
+
if (!new RegExp(_.source, "i").test(e)) continue;
|
|
169
|
+
let t = /\balt\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(e);
|
|
170
|
+
return (t?.[1] ?? t?.[2] ?? "").replace(/&(?:amp|lt|gt|quot|#39);/g, (e) => re[e] ?? e).trim();
|
|
171
|
+
}
|
|
172
|
+
return "";
|
|
173
|
+
}, ae = (e, t) => {
|
|
161
174
|
let n = t && te.test(t) ? t : ne;
|
|
162
175
|
return e.split(v).map((e, t) => t % 2 == 1 ? e : e.replace(_, (e, t) => t + n)).join("");
|
|
163
176
|
};
|
|
164
|
-
function
|
|
177
|
+
function oe(e) {
|
|
165
178
|
return `<!doctype html>
|
|
166
179
|
<html lang="en">
|
|
167
180
|
<head>
|
|
@@ -187,32 +200,32 @@ var b = [
|
|
|
187
200
|
"polarArea",
|
|
188
201
|
"scatter",
|
|
189
202
|
"bubble"
|
|
190
|
-
],
|
|
203
|
+
], x = "https://cdn.jsdelivr.net/npm/chart.js@4.5.1/dist/chart.umd.min.js", se = "sha384-jb8JQMbMoBUzgWatfe6COACi2ljcDdZQ2OxczGA3bGNeWe+6DChMTBJemed7ZnvJ", ce = "\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})();", le = [
|
|
191
204
|
"default-src 'none'",
|
|
192
|
-
`script-src 'sha256-TfZZxJX+yWgzYLy7zqsMa85OJEaC+zNLIpKLDZVnUqA=' ${
|
|
205
|
+
`script-src 'sha256-TfZZxJX+yWgzYLy7zqsMa85OJEaC+zNLIpKLDZVnUqA=' ${x}`,
|
|
193
206
|
"style-src 'unsafe-inline'",
|
|
194
207
|
"img-src data: blob:",
|
|
195
208
|
"connect-src 'none'",
|
|
196
209
|
"form-action 'none'",
|
|
197
210
|
"base-uri 'none'"
|
|
198
|
-
].join("; "),
|
|
211
|
+
].join("; "), ue = `
|
|
199
212
|
html, body { margin: 0; width: ${t}px; height: 720px; overflow: hidden; background: #ffffff; color: #0f172a; font-family: ui-sans-serif, system-ui, sans-serif; }
|
|
200
213
|
body { box-sizing: border-box; padding: 40px 64px 48px; display: flex; flex-direction: column; gap: 24px; }
|
|
201
214
|
h1 { margin: 0; font-size: 52px; font-weight: 800; color: #1e3a8a; line-height: 1.15; text-align: center; }
|
|
202
215
|
.chart { position: relative; flex: 1; min-height: 0; }
|
|
203
216
|
#chart-error { display: none; margin: auto; font-size: 28px; color: #b91c1c; }
|
|
204
217
|
.failed .chart { display: none; }
|
|
205
|
-
.failed #chart-error { display: block; }`,
|
|
206
|
-
function
|
|
218
|
+
.failed #chart-error { display: block; }`, de = (e) => JSON.stringify(e).replace(/</g, "\\u003c");
|
|
219
|
+
function fe(e, t) {
|
|
207
220
|
return `<!doctype html>
|
|
208
221
|
<html lang="en">
|
|
209
222
|
<head>
|
|
210
223
|
<meta charset="utf-8">
|
|
211
|
-
<meta http-equiv="Content-Security-Policy" content="${
|
|
212
|
-
<style>${
|
|
213
|
-
<script>${
|
|
214
|
-
<script defer src="${
|
|
215
|
-
<script type="application/json" id="chart-config">${
|
|
224
|
+
<meta http-equiv="Content-Security-Policy" content="${le}">
|
|
225
|
+
<style>${ue}</style>
|
|
226
|
+
<script>${ce}<\/script>
|
|
227
|
+
<script defer src="${x}" integrity="${se}" crossorigin="anonymous"><\/script>
|
|
228
|
+
<script type="application/json" id="chart-config">${de(t)}<\/script>
|
|
216
229
|
</head>
|
|
217
230
|
<body>
|
|
218
231
|
${e ? `<h1>${p(e)}</h1>` : ""}
|
|
@@ -223,52 +236,52 @@ ${e ? `<h1>${p(e)}</h1>` : ""}
|
|
|
223
236
|
}
|
|
224
237
|
//#endregion
|
|
225
238
|
//#region src/core/definitions.ts
|
|
226
|
-
var
|
|
227
|
-
function
|
|
239
|
+
var S = "presentSlide", pe = "defineStoryboard", C = "presentPanel", me = 4, he = 12, ge = 3, w = /^[0-9a-f]{12}$/, T = (e) => typeof e == "object" && !!e && !Array.isArray(e), E = (e) => typeof e == "string" ? e.trim() : "", D = (e, t) => e.toLowerCase() === t.toLowerCase(), O = (e) => typeof e == "number" && Number.isInteger(e), _e = "presentSlide needs slide and totalSlides (whole numbers, slide from 1 to totalSlides), and one of imagePrompt, html, markdown or chart", ve = `presentSlide's slide is too long: keep its html, markdown or chart under ${r} characters`, ye = `presentSlide's chart must be a Chart.js configuration: an object with type (${b.join(", ")}), data ({ labels, datasets }) and optionally options`;
|
|
240
|
+
function be(e) {
|
|
228
241
|
let t = e;
|
|
229
242
|
if (typeof t == "string") try {
|
|
230
243
|
t = JSON.parse(t);
|
|
231
244
|
} catch {
|
|
232
245
|
return null;
|
|
233
246
|
}
|
|
234
|
-
if (!
|
|
247
|
+
if (!T(t) || !T(t.data)) return null;
|
|
235
248
|
let n = t.type;
|
|
236
|
-
return !b.some((e) => e === n) || t.options !== void 0 && !
|
|
249
|
+
return !b.some((e) => e === n) || t.options !== void 0 && !T(t.options) ? null : t;
|
|
237
250
|
}
|
|
238
|
-
function
|
|
239
|
-
let { slide: t, totalSlides: n, title: r, imagePrompt: i } = e, a =
|
|
240
|
-
if (!
|
|
241
|
-
let c = s ?
|
|
242
|
-
if (s && !c) return
|
|
243
|
-
if (Math.max(a.length, o.length, c ? JSON.stringify(c).length : 0) > 6e4) return
|
|
251
|
+
function xe(e) {
|
|
252
|
+
let { slide: t, totalSlides: n, title: r, imagePrompt: i } = e, a = E(e.html), o = a ? "" : E(e.markdown), s = !a && !o && e.chart !== void 0 && e.chart !== null;
|
|
253
|
+
if (!O(t) || !O(n) || t < 1 || n < t || !a && !o && !s && !E(i)) return _e;
|
|
254
|
+
let c = s ? be(e.chart) : null;
|
|
255
|
+
if (s && !c) return ye;
|
|
256
|
+
if (Math.max(a.length, o.length, c ? JSON.stringify(c).length : 0) > 6e4) return ve;
|
|
244
257
|
let l = !a && !o && !c, u = !!a && y(a);
|
|
245
|
-
return
|
|
258
|
+
return {
|
|
246
259
|
slide: t,
|
|
247
260
|
totalSlides: n,
|
|
248
261
|
title: typeof r == "string" ? r : "",
|
|
249
|
-
imagePrompt: l
|
|
262
|
+
imagePrompt: l ? String(i) : u || o ? E(i) : "",
|
|
250
263
|
...a && { html: a },
|
|
251
264
|
...o && { markdown: o },
|
|
252
265
|
...c && { chart: c },
|
|
253
266
|
mode: e.mode === "steps" ? "steps" : "presentation"
|
|
254
267
|
};
|
|
255
268
|
}
|
|
256
|
-
var
|
|
269
|
+
var Se = "teach its subject as a presenter speaking to the audience, and cover everything on it: every section, point and number, in order, each in a sentence or more. The slide is replaced by the next one as soon as you stop talking, so a point you leave out is never explained. 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.", k = ({ slide: e, totalSlides: t, title: n, mode: r }) => {
|
|
257
270
|
let i = n ? ` ("${n}")` : "";
|
|
258
271
|
if (r === "steps") {
|
|
259
272
|
let n = `Step ${e} of ${t}${i}`;
|
|
260
273
|
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.`;
|
|
261
274
|
}
|
|
262
275
|
let a = `Slide ${e} of ${t}${i}`;
|
|
263
|
-
return e < t ? `${a} is now on the screen. Explain it: ${
|
|
264
|
-
},
|
|
276
|
+
return e < t ? `${a} is now on the screen. Explain it: ${Se} This reply is only the explanation: don't call presentSlide in it. When you have finished, you will be asked 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: ${Se} Then wrap up the slideshow.`;
|
|
277
|
+
}, Ce = [
|
|
265
278
|
`For an HTML slide: 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. For one generated picture on the slide (a photo, a scene, an object beside the text), give imagePrompt too and put <img src="${g}" alt="..." class="..."> where it goes, sized by its classes (for example class="w-1/2 h-full object-cover rounded-2xl").`,
|
|
266
279
|
"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).",
|
|
267
280
|
"CSS animations, transitions and scripts don't play: animate only with data-animation. A <style> for layout is allowed (and Google Fonts by @import)."
|
|
268
|
-
].join(" "),
|
|
281
|
+
].join(" "), we = `For a Markdown slide: 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 \\$. For one generated picture on the slide, give imagePrompt too and put  on a line of its own: the slide is then two columns, the text on the left and the picture on the right. Without imagePrompt, the alt text is what is drawn.`, Te = `For a chart slide, instead of imagePrompt (for numbers: real figures you have, never a picture of a chart): a Chart.js configuration as JSON text, {"type": ..., "data": ...}: { type, data: { labels, datasets: [{ label, data, backgroundColor }] }, options }. type is one of ${b.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.`, Ee = "When the user asks for a slideshow (or to explain something with slides), plan four to six slides (more when the subject or your instructions need them), 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, and explain everything on a slide before showing the next; put on a slide only what you will explain. 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 a picture helps the text (the thing being explained, beside its key points), make an HTML or Markdown slide with one generated picture on it: imagePrompt for the picture, and {{image}} where it goes. Numbers go on a chart slide: when you have figures (from a search, a document or the user: revenue, market share, growth, prices, counts over time), show them in a chart with those exact values, labelled with their units and the year or period, and say where they come from. Figures over time, shares of a whole or values side by side are a chart, not a list or table on a Markdown or HTML slide. Never make a chart, graph or table a picture (imagePrompt): a picture of a chart has made-up bars and no real numbers. A slideshow about a business, a market or a comparison of companies has its figures on chart slides, not only in text. Never invent figures; with none to show, leave the chart out. A slide holds only its subject, never notes about your work (what you searched for, that a search succeeded). 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 = {
|
|
269
282
|
type: "function",
|
|
270
|
-
name:
|
|
271
|
-
prompt:
|
|
283
|
+
name: S,
|
|
284
|
+
prompt: Ee,
|
|
272
285
|
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; an HTML or Markdown slide can also hold one generated picture (imagePrompt, placed at {{image}}). 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.",
|
|
273
286
|
parameters: {
|
|
274
287
|
type: "object",
|
|
@@ -291,15 +304,15 @@ var j = "teach its subject as a presenter speaking to the audience, and cover ev
|
|
|
291
304
|
},
|
|
292
305
|
html: {
|
|
293
306
|
type: "string",
|
|
294
|
-
description:
|
|
307
|
+
description: Ce
|
|
295
308
|
},
|
|
296
309
|
markdown: {
|
|
297
310
|
type: "string",
|
|
298
|
-
description:
|
|
311
|
+
description: we
|
|
299
312
|
},
|
|
300
313
|
chart: {
|
|
301
314
|
type: "string",
|
|
302
|
-
description:
|
|
315
|
+
description: Te
|
|
303
316
|
},
|
|
304
317
|
mode: {
|
|
305
318
|
type: "string",
|
|
@@ -314,49 +327,49 @@ var j = "teach its subject as a presenter speaking to the audience, and cover ev
|
|
|
314
327
|
]
|
|
315
328
|
}
|
|
316
329
|
};
|
|
317
|
-
function
|
|
330
|
+
function j(e) {
|
|
318
331
|
let { totalPanels: t } = e;
|
|
319
|
-
if (!
|
|
332
|
+
if (!O(t) || t < 1 || t > 12) return "totalPanels must be a whole number from 1 to 12";
|
|
320
333
|
let n = [];
|
|
321
334
|
for (let t of Array.isArray(e.characters) ? e.characters : []) {
|
|
322
|
-
let e =
|
|
335
|
+
let e = T(t) ? E(t.name) : "", r = T(t) ? E(t.description) : "";
|
|
323
336
|
if (!e || !r) return "every character needs a name and a description";
|
|
324
|
-
if (n.some((t) =>
|
|
337
|
+
if (n.some((t) => D(t.name, e))) return `two characters are named ${e}`;
|
|
325
338
|
n.push({
|
|
326
339
|
name: e,
|
|
327
340
|
description: r
|
|
328
341
|
});
|
|
329
342
|
}
|
|
330
343
|
return n.length < 1 || n.length > 4 ? "a storyboard has 1 to 4 characters" : {
|
|
331
|
-
title:
|
|
332
|
-
style:
|
|
344
|
+
title: E(e.title),
|
|
345
|
+
style: E(e.style),
|
|
333
346
|
totalPanels: t,
|
|
334
347
|
characters: n,
|
|
335
348
|
interactive: e.interactive === !0
|
|
336
349
|
};
|
|
337
350
|
}
|
|
338
|
-
var
|
|
339
|
-
function
|
|
340
|
-
let { panel: t } = e, n =
|
|
341
|
-
if (!n || !r || !
|
|
342
|
-
let i = (e) => (Array.isArray(e) ? e : []).map(
|
|
351
|
+
var M = ({ title: e }) => `The cast of "${e}" is now on the screen. Introduce the characters briefly. This reply is only the introduction: don't call presentPanel in it. When you have finished, you will be asked for panel 1. 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";
|
|
352
|
+
function P(e) {
|
|
353
|
+
let { panel: t } = e, n = E(e.storyboardId), r = E(e.imagePrompt);
|
|
354
|
+
if (!n || !r || !O(t) || t < 1) return null;
|
|
355
|
+
let i = (e) => (Array.isArray(e) ? e : []).map(E).filter(Boolean);
|
|
343
356
|
return {
|
|
344
357
|
storyboardId: n,
|
|
345
358
|
panel: t,
|
|
346
359
|
characters: i(e.characters),
|
|
347
360
|
imagePrompt: r,
|
|
348
|
-
caption:
|
|
361
|
+
caption: E(e.caption),
|
|
349
362
|
choices: i(e.choices).slice(0, 3)
|
|
350
363
|
};
|
|
351
364
|
}
|
|
352
|
-
function
|
|
365
|
+
function F(e, t, n) {
|
|
353
366
|
let { id: r, totalPanels: i } = e;
|
|
354
367
|
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, aloud, as a storyteller. This reply is only the telling: don't call presentPanel in it. When you have finished, you will be asked for panel ${t + 1}. 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.`;
|
|
355
368
|
}
|
|
356
|
-
var
|
|
369
|
+
var I = "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.", L = {
|
|
357
370
|
type: "function",
|
|
358
371
|
name: pe,
|
|
359
|
-
prompt:
|
|
372
|
+
prompt: I,
|
|
360
373
|
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.",
|
|
361
374
|
parameters: {
|
|
362
375
|
type: "object",
|
|
@@ -403,9 +416,9 @@ var B = "When the user asks for a story, a picture book, a comic or a storyboard
|
|
|
403
416
|
"characters"
|
|
404
417
|
]
|
|
405
418
|
}
|
|
406
|
-
},
|
|
419
|
+
}, R = {
|
|
407
420
|
type: "function",
|
|
408
|
-
name:
|
|
421
|
+
name: C,
|
|
409
422
|
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.",
|
|
410
423
|
parameters: {
|
|
411
424
|
type: "object",
|
|
@@ -444,60 +457,60 @@ var B = "When the user asks for a story, a picture book, a comic or a storyboard
|
|
|
444
457
|
"imagePrompt"
|
|
445
458
|
]
|
|
446
459
|
}
|
|
447
|
-
},
|
|
448
|
-
function
|
|
449
|
-
let t =
|
|
460
|
+
}, z = (e) => typeof e == "object" && !!e && !Array.isArray(e), De = (e) => z(e) && typeof e.message == "string";
|
|
461
|
+
function B(e) {
|
|
462
|
+
let t = z(e?.data) ? e.data : {};
|
|
450
463
|
return {
|
|
451
464
|
...typeof t.imageData == "string" && { imageData: t.imageData },
|
|
452
465
|
...typeof t.imagePath == "string" && { imagePath: t.imagePath }
|
|
453
466
|
};
|
|
454
467
|
}
|
|
455
|
-
function
|
|
456
|
-
let t =
|
|
468
|
+
function V(e) {
|
|
469
|
+
let t = z(e?.data) ? e.data : {};
|
|
457
470
|
return typeof t.html == "string" ? t.html : "";
|
|
458
471
|
}
|
|
459
|
-
function
|
|
460
|
-
let t =
|
|
461
|
-
return
|
|
472
|
+
function H(e) {
|
|
473
|
+
let t = z(e?.data) ? e.data : {};
|
|
474
|
+
return z(t.chart) ? JSON.stringify(t.chart) : "";
|
|
462
475
|
}
|
|
463
|
-
var
|
|
464
|
-
function
|
|
465
|
-
let n =
|
|
476
|
+
var Oe = (e) => !!B(e).imageData || !!V(e) || !!H(e);
|
|
477
|
+
function ke(e, t) {
|
|
478
|
+
let n = B(e), r = B(t);
|
|
466
479
|
if (n.imagePath && r.imagePath) return n.imagePath === r.imagePath;
|
|
467
480
|
if (n.imageData) return n.imageData === r.imageData;
|
|
468
|
-
let i =
|
|
469
|
-
if (i) return i ===
|
|
470
|
-
let a =
|
|
471
|
-
return !!a && a ===
|
|
481
|
+
let i = V(e);
|
|
482
|
+
if (i) return i === V(t);
|
|
483
|
+
let a = H(e);
|
|
484
|
+
return !!a && a === H(t);
|
|
472
485
|
}
|
|
473
|
-
var
|
|
474
|
-
async function
|
|
486
|
+
var U = (e, t) => e.userSpokeAt === void 0 || e.userSpokeAt > t, W = () => crypto.randomUUID().replace(/-/g, "").slice(0, 12), Ae = "artifacts/";
|
|
487
|
+
async function G(e, t) {
|
|
475
488
|
let n = e.files?.artifacts;
|
|
476
489
|
if (!e.app?.editImages || !n) return [];
|
|
477
490
|
let r = [];
|
|
478
|
-
for (let e of t) if (e.startsWith(
|
|
491
|
+
for (let e of t) if (e.startsWith(Ae)) try {
|
|
479
492
|
await n.exists(e.slice(10)) && r.push(e);
|
|
480
493
|
} catch {}
|
|
481
494
|
return r;
|
|
482
495
|
}
|
|
483
|
-
async function
|
|
496
|
+
async function K(e, t, n = []) {
|
|
484
497
|
let r = e.app, i = r?.editImages, a = r?.generateImage;
|
|
485
498
|
try {
|
|
486
499
|
let e;
|
|
487
500
|
if (n.length && i) e = await i(t, [...n]);
|
|
488
501
|
else if (a) e = await a(t);
|
|
489
502
|
else return { message: "image generation isn't available" };
|
|
490
|
-
return
|
|
503
|
+
return De(e) ? e : { message: "image generation returned an unrecognized result" };
|
|
491
504
|
} catch (e) {
|
|
492
505
|
return { message: `image generation failed: ${e instanceof Error ? e.message : String(e)}` };
|
|
493
506
|
}
|
|
494
507
|
}
|
|
495
|
-
var
|
|
496
|
-
function
|
|
508
|
+
var je = 50;
|
|
509
|
+
function q(e) {
|
|
497
510
|
let t = /* @__PURE__ */ new Map();
|
|
498
511
|
return (n) => {
|
|
499
512
|
let r = n.conversationId ?? "", i = t.get(r);
|
|
500
|
-
if (i === void 0 ? i = e() : t.delete(r), t.set(r, i), t.size >
|
|
513
|
+
if (i === void 0 ? i = e() : t.delete(r), t.set(r, i), t.size > je) {
|
|
501
514
|
let e = t.keys().next().value;
|
|
502
515
|
e !== void 0 && t.delete(e);
|
|
503
516
|
}
|
|
@@ -506,45 +519,45 @@ function ke(e) {
|
|
|
506
519
|
}
|
|
507
520
|
//#endregion
|
|
508
521
|
//#region src/core/markdownSlide.ts
|
|
509
|
-
var
|
|
510
|
-
.${
|
|
511
|
-
.${
|
|
512
|
-
.${
|
|
513
|
-
.${
|
|
514
|
-
.${
|
|
515
|
-
.${
|
|
516
|
-
.${
|
|
517
|
-
.${
|
|
518
|
-
.${
|
|
519
|
-
.${
|
|
520
|
-
.${
|
|
521
|
-
.${
|
|
522
|
-
.${
|
|
523
|
-
.${
|
|
524
|
-
.${
|
|
525
|
-
.${
|
|
526
|
-
.${
|
|
527
|
-
.${
|
|
528
|
-
.${
|
|
529
|
-
.${
|
|
530
|
-
.${
|
|
531
|
-
.${
|
|
532
|
-
.${
|
|
533
|
-
.${
|
|
534
|
-
.${
|
|
535
|
-
.${
|
|
536
|
-
.${
|
|
537
|
-
.${
|
|
538
|
-
.${
|
|
539
|
-
.${
|
|
540
|
-
.${
|
|
541
|
-
.${
|
|
542
|
-
function
|
|
522
|
+
var J = "slide-md", Me = "slide-md-split", Y = "slide-md-text", Ne = "slide-md-picture", Pe = .8, Fe = `
|
|
523
|
+
.${J} { 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; }
|
|
524
|
+
.${J} > * { margin: 0; }
|
|
525
|
+
.${J} h1 { font-size: 1.9em; font-weight: 800; color: #1e3a8a; line-height: 1.15; }
|
|
526
|
+
.${J} h2 { font-size: 1.5em; font-weight: 700; color: #1e40af; line-height: 1.2; }
|
|
527
|
+
.${J} h3 { font-size: 1.2em; font-weight: 700; color: #334155; }
|
|
528
|
+
.${J} ul, .${J} ol { padding-left: 1.3em; display: flex; flex-direction: column; gap: 0.3em; }
|
|
529
|
+
.${J} ul { list-style: disc; }
|
|
530
|
+
.${J} ol { list-style: decimal; }
|
|
531
|
+
.${J} li > ul, .${J} li > ol { margin-top: 0.3em; font-size: 0.9em; }
|
|
532
|
+
.${J} li::marker { color: #2563eb; }
|
|
533
|
+
.${J} strong { font-weight: 700; color: #1e3a8a; }
|
|
534
|
+
.${J} em { font-style: italic; }
|
|
535
|
+
.${J} a { color: #2563eb; text-decoration: underline; }
|
|
536
|
+
.${J} code { font-family: ui-monospace, monospace; font-size: 0.85em; background: #f1f5f9; border-radius: 0.2em; padding: 0.05em 0.3em; }
|
|
537
|
+
.${J} pre { background: #0f172a; color: #e2e8f0; border-radius: 0.4em; padding: 0.6em 0.8em; font-size: 0.75em; overflow: hidden; }
|
|
538
|
+
.${J} pre code { background: none; padding: 0; color: inherit; }
|
|
539
|
+
.${J} blockquote { border-left: 0.2em solid #93c5fd; padding-left: 0.8em; color: #475569; font-style: italic; }
|
|
540
|
+
.${J} table { border-collapse: collapse; font-size: 0.85em; align-self: flex-start; }
|
|
541
|
+
.${J} th, .${J} td { border: 1px solid #cbd5e1; padding: 0.25em 0.7em; text-align: left; }
|
|
542
|
+
.${J} th { background: #eff6ff; font-weight: 700; }
|
|
543
|
+
.${J} hr { border: 0; border-top: 2px solid #e2e8f0; }
|
|
544
|
+
.${J} img { max-width: 100%; max-height: 60%; }
|
|
545
|
+
.${J}.${Me} { flex-direction: row; align-items: center; gap: 48px; }
|
|
546
|
+
.${J} .${Y} { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 0.5em; }
|
|
547
|
+
.${J} .${Y} > * { margin: 0; }
|
|
548
|
+
.${J} .${Ne} { flex: 0 0 44%; width: 44%; height: 100%; max-width: none; max-height: 100%; object-fit: cover; border-radius: 0.6em; box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18); }
|
|
549
|
+
.${J} .math-display { display: block; text-align: center; font-size: 1.15em; }
|
|
550
|
+
.${J} math { font-family: "Latin Modern Math", "STIX Two Math", "Cambria Math", math; }
|
|
551
|
+
.${J} mtd { padding: 0.1em 0.4em; }
|
|
552
|
+
.${J} mtd:first-child { padding-left: 0; }
|
|
553
|
+
.${J} mtd:last-child { padding-right: 0; }
|
|
554
|
+
.${J} .math-error { color: #b91c1c; font-family: ui-monospace, monospace; }`;
|
|
555
|
+
function Ie(e) {
|
|
543
556
|
let t = e.split("\n").filter((e) => e.trim()).length, n = e.length;
|
|
544
557
|
return t <= 5 && n <= 250 ? 40 : t <= 8 && n <= 450 ? 34 : t <= 12 && n <= 700 ? 28 : 24;
|
|
545
558
|
}
|
|
546
|
-
var
|
|
547
|
-
function
|
|
559
|
+
var Le = /^[ \t]*(?:\$\$([\s\S]+?)\$\$|\\\[([\s\S]+?)\\\])[ \t]*(?:\n|$)/, Re = /^(?:\$\$(.+?)\$\$|\$(?!\s)((?:\\.|[^\\$\n])+?)(?<!\s)\$(?!\d)|\\\((.+?)\\\))/;
|
|
560
|
+
function ze(e) {
|
|
548
561
|
return [{
|
|
549
562
|
name: "blockMath",
|
|
550
563
|
level: "block",
|
|
@@ -553,7 +566,7 @@ function Le(e) {
|
|
|
553
566
|
return t ? t.index + (t[1] ?? "").length : void 0;
|
|
554
567
|
},
|
|
555
568
|
tokenizer(e) {
|
|
556
|
-
let t =
|
|
569
|
+
let t = Le.exec(e);
|
|
557
570
|
if (t) return {
|
|
558
571
|
type: "blockMath",
|
|
559
572
|
raw: t[0],
|
|
@@ -566,7 +579,7 @@ function Le(e) {
|
|
|
566
579
|
level: "inline",
|
|
567
580
|
start: (e) => e.match(/(?<!\\)\$|\\\(/)?.index,
|
|
568
581
|
tokenizer(e) {
|
|
569
|
-
let t =
|
|
582
|
+
let t = Re.exec(e);
|
|
570
583
|
if (t) return {
|
|
571
584
|
type: "inlineMath",
|
|
572
585
|
raw: t[0],
|
|
@@ -577,11 +590,11 @@ function Le(e) {
|
|
|
577
590
|
renderer: (t) => e(String(t.text), t.display === !0)
|
|
578
591
|
}];
|
|
579
592
|
}
|
|
580
|
-
var
|
|
581
|
-
async function
|
|
593
|
+
var Be = /(<\/mi>|<\/mn>|<\/mrow>|<mo[^>]*>[)\]]<\/mo>)?(<mi(?: mathvariant="normal")?>[A-Za-z]{2,}<\/mi>)<mo>\u2061<\/mo>/g, Ve = "<mspace width=\"0.1667em\"></mspace>", He = (e) => e.replace(Be, (e, t, n) => `${t ? t + Ve : ""}${n}<mo lspace="0" rspace="0.1667em">\u2061</mo>`);
|
|
594
|
+
async function Ue(e) {
|
|
582
595
|
let [{ Marked: t }, { default: n }] = await Promise.all([import("marked"), import("katex")]), r = (e, t) => {
|
|
583
596
|
try {
|
|
584
|
-
return
|
|
597
|
+
return He(n.renderToString(e, {
|
|
585
598
|
output: "mathml",
|
|
586
599
|
displayMode: t,
|
|
587
600
|
throwOnError: !0
|
|
@@ -593,38 +606,42 @@ async function Ve(e) {
|
|
|
593
606
|
gfm: !0,
|
|
594
607
|
breaks: !1
|
|
595
608
|
});
|
|
596
|
-
i.use({ extensions:
|
|
597
|
-
let a = i.lexer(e), o = a.findIndex((e) =>
|
|
609
|
+
i.use({ extensions: ze(r) });
|
|
610
|
+
let a = i.lexer(e), o = a.findIndex((e) => {
|
|
611
|
+
if (e.type !== "paragraph" || e.tokens?.length !== 1) return !1;
|
|
612
|
+
let t = e.tokens[0];
|
|
613
|
+
return t?.type === "image" ? t.href.trim() === g : t?.type === "text" && t.text.trim() === "{{image}}";
|
|
614
|
+
});
|
|
598
615
|
if (o >= 0) {
|
|
599
616
|
let [t] = a.splice(o, 1), n = t?.type === "paragraph" ? t.tokens?.[0] : void 0, r = n?.type === "image" ? n.text : "", s = i.parser(a), c = e.replace(t?.raw ?? "", "");
|
|
600
|
-
return `<style>${
|
|
601
|
-
<div class="${
|
|
602
|
-
<div class="${
|
|
617
|
+
return `<style>${Fe}</style>
|
|
618
|
+
<div class="${J} ${Me}" data-fit style="font-size: ${Math.round(Ie(c) * Pe)}px">
|
|
619
|
+
<div class="${Y}">
|
|
603
620
|
${s}</div>
|
|
604
|
-
<img class="${
|
|
621
|
+
<img class="${Ne}" src="${g}" alt="${p(r)}">
|
|
605
622
|
</div>`;
|
|
606
623
|
}
|
|
607
624
|
let s = await i.parse(e);
|
|
608
|
-
return `<style>${
|
|
609
|
-
<div class="${
|
|
625
|
+
return `<style>${Fe}</style>
|
|
626
|
+
<div class="${J}" data-fit style="font-size: ${Ie(e)}px">
|
|
610
627
|
${s}</div>`;
|
|
611
628
|
}
|
|
612
629
|
//#endregion
|
|
613
630
|
//#region src/core/records.ts
|
|
614
|
-
var
|
|
615
|
-
function
|
|
616
|
-
let t =
|
|
617
|
-
return t ||
|
|
631
|
+
var We = "slideshows", X = "storyboards", Ge = {}, Ke = /* @__PURE__ */ new WeakMap(), qe = /* @__PURE__ */ new WeakMap();
|
|
632
|
+
function Je(e) {
|
|
633
|
+
let t = Ke.get(e);
|
|
634
|
+
return t || Ke.set(e, t = /* @__PURE__ */ new Map()), t;
|
|
618
635
|
}
|
|
619
|
-
function
|
|
620
|
-
let r =
|
|
621
|
-
r ||
|
|
636
|
+
function Ye(t, n) {
|
|
637
|
+
let r = qe.get(t);
|
|
638
|
+
r || qe.set(t, r = /* @__PURE__ */ new Map());
|
|
622
639
|
let i = r.get(n);
|
|
623
640
|
return i || r.set(n, i = e()), i;
|
|
624
641
|
}
|
|
625
|
-
var
|
|
626
|
-
async function
|
|
627
|
-
let n =
|
|
642
|
+
var Xe = (e, t) => `${e}/${t}.json`;
|
|
643
|
+
async function Ze(e, t) {
|
|
644
|
+
let n = Je(e ?? Ge), r = n.get(t);
|
|
628
645
|
if (r) return r;
|
|
629
646
|
if (!e) return null;
|
|
630
647
|
try {
|
|
@@ -634,14 +651,14 @@ async function Ye(e, t) {
|
|
|
634
651
|
return null;
|
|
635
652
|
}
|
|
636
653
|
}
|
|
637
|
-
async function
|
|
638
|
-
return
|
|
654
|
+
async function Qe(e, t, n) {
|
|
655
|
+
return w.test(n) ? Ze(e, Xe(t, n)) : null;
|
|
639
656
|
}
|
|
640
|
-
async function
|
|
641
|
-
let i =
|
|
642
|
-
return
|
|
643
|
-
let t = r(await
|
|
644
|
-
if (
|
|
657
|
+
async function Z(e, t, n, r) {
|
|
658
|
+
let i = Xe(t, n), a = e ?? Ge;
|
|
659
|
+
return Ye(a, i)(async () => {
|
|
660
|
+
let t = r(await Ze(e, i));
|
|
661
|
+
if (Je(a).set(i, t), !e) return !1;
|
|
645
662
|
try {
|
|
646
663
|
return await e.write(i, JSON.stringify(t, null, 2)), !0;
|
|
647
664
|
} catch (e) {
|
|
@@ -649,12 +666,12 @@ async function Q(e, t, n, r) {
|
|
|
649
666
|
}
|
|
650
667
|
});
|
|
651
668
|
}
|
|
652
|
-
var
|
|
653
|
-
function
|
|
669
|
+
var Q = (e) => `the ${e} could not be saved, so it lasts only until the app or server restarts`, $e = 6e4;
|
|
670
|
+
function et() {
|
|
654
671
|
let e = /* @__PURE__ */ new Map();
|
|
655
672
|
return { claim: (t) => {
|
|
656
673
|
let n = Date.now();
|
|
657
|
-
for (let [t, r] of e) n - r.at >
|
|
674
|
+
for (let [t, r] of e) n - r.at > $e && e.delete(t);
|
|
658
675
|
let r = e.get(t);
|
|
659
676
|
if (r) return { earlier: r.shown };
|
|
660
677
|
let i = () => void 0, a = new Promise((e) => i = e);
|
|
@@ -668,7 +685,7 @@ function Qe() {
|
|
|
668
685
|
}
|
|
669
686
|
//#endregion
|
|
670
687
|
//#region src/core/presentSlide.ts
|
|
671
|
-
function
|
|
688
|
+
function tt({ slide: e, totalSlides: t, mode: n }) {
|
|
672
689
|
return n === "steps" ? {
|
|
673
690
|
step: e,
|
|
674
691
|
total: t,
|
|
@@ -686,7 +703,7 @@ function $e({ slide: e, totalSlides: t, mode: n }) {
|
|
|
686
703
|
nextCall: `call presentSlide for slide ${e + 1} of ${t}`
|
|
687
704
|
};
|
|
688
705
|
}
|
|
689
|
-
var
|
|
706
|
+
var nt = (e, { slide: t, totalSlides: n, title: r, imagePrompt: i, html: a, markdown: o, chart: s }) => JSON.stringify([
|
|
690
707
|
e,
|
|
691
708
|
t,
|
|
692
709
|
n,
|
|
@@ -695,19 +712,19 @@ var et = (e, { slide: t, totalSlides: n, title: r, imagePrompt: i, html: a, mark
|
|
|
695
712
|
a,
|
|
696
713
|
o,
|
|
697
714
|
s
|
|
698
|
-
]),
|
|
715
|
+
]), rt = q(() => ({
|
|
699
716
|
latest: {
|
|
700
717
|
presentation: null,
|
|
701
718
|
steps: null
|
|
702
719
|
},
|
|
703
720
|
lastShown: null,
|
|
704
|
-
repeats:
|
|
721
|
+
repeats: et()
|
|
705
722
|
}));
|
|
706
|
-
function
|
|
723
|
+
function it(e, t) {
|
|
707
724
|
let n = e.latest[t.mode], r = n?.totalSlides === t.totalSlides && (t.slide !== 1 || n.firstTitle === t.title);
|
|
708
725
|
if (n && r) return n;
|
|
709
726
|
let i = {
|
|
710
|
-
id:
|
|
727
|
+
id: W(),
|
|
711
728
|
mode: t.mode,
|
|
712
729
|
totalSlides: t.totalSlides,
|
|
713
730
|
firstTitle: t.slide === 1 ? t.title : "",
|
|
@@ -717,69 +734,70 @@ function nt(e, t) {
|
|
|
717
734
|
};
|
|
718
735
|
return e.latest[t.mode] = i, i;
|
|
719
736
|
}
|
|
720
|
-
function
|
|
737
|
+
function at(e, t, n, r) {
|
|
721
738
|
t.current = n.slide, t.shownAt = Date.now(), e.lastShown = t;
|
|
722
739
|
let i = n.mode === "steps" ? "step" : "slide", { uuid: a, ...o } = r;
|
|
723
740
|
return {
|
|
724
741
|
...o,
|
|
725
742
|
message: `${i} ${n.slide} of ${n.totalSlides} is on the screen again, as it was`,
|
|
726
|
-
instructions:
|
|
743
|
+
instructions: k(n),
|
|
727
744
|
instructionsRequired: !0,
|
|
728
|
-
sequence:
|
|
745
|
+
sequence: tt(n)
|
|
729
746
|
};
|
|
730
747
|
}
|
|
731
|
-
function
|
|
748
|
+
function ot(e, t) {
|
|
732
749
|
if (e.mode !== "steps") return e.title ? `A presentation slide titled "${e.title}". ${e.imagePrompt}` : e.imagePrompt;
|
|
733
750
|
let n = e.title ? `, "${e.title}"` : "";
|
|
734
751
|
return [
|
|
735
752
|
`An instructional illustration of step ${e.slide} of ${e.totalSlides}${n}. ${e.imagePrompt}`,
|
|
736
|
-
t ?
|
|
753
|
+
t ? st : "",
|
|
737
754
|
"Show the action clearly, with little or no text."
|
|
738
755
|
].filter(Boolean).join(" ");
|
|
739
756
|
}
|
|
740
|
-
var
|
|
741
|
-
async function
|
|
757
|
+
var st = "The reference image is the previous step: keep the same objects, hands, tools and setting, and show what this step changes.";
|
|
758
|
+
async function ct(e, t, n) {
|
|
742
759
|
if (n.mode !== "steps") return [];
|
|
743
|
-
let r =
|
|
744
|
-
return r ? await
|
|
760
|
+
let r = B(t.slides.get(n.slide - 1)).imagePath;
|
|
761
|
+
return r ? await G(e, [r]) : [];
|
|
745
762
|
}
|
|
746
|
-
var
|
|
763
|
+
var lt = (e, t) => [
|
|
747
764
|
e.mode === "steps" ? `An instructional illustration for step ${e.slide} of ${e.totalSlides}${e.title ? `, "${e.title}"` : ""}. ${e.imagePrompt}` : `A picture for a presentation slide${e.title ? ` titled "${e.title}"` : ""}. ${e.imagePrompt}`,
|
|
748
|
-
t ?
|
|
765
|
+
t ? st : "",
|
|
749
766
|
e.markdown ? "Keep the subject in the middle: the picture is cropped to a tall frame." : "",
|
|
750
767
|
"No text, letters or numbers in the picture."
|
|
751
768
|
].filter(Boolean).join(" ");
|
|
752
|
-
async function
|
|
769
|
+
async function ut(e, t, n) {
|
|
753
770
|
if (n.chart) return {
|
|
754
771
|
chart: n.chart,
|
|
755
772
|
prompt: ""
|
|
756
773
|
};
|
|
757
774
|
if (n.html || n.markdown) {
|
|
758
775
|
let r = n.html ? { html: n.html } : {
|
|
759
|
-
html: await
|
|
776
|
+
html: await Ue(n.markdown ?? ""),
|
|
760
777
|
markdown: n.markdown ?? ""
|
|
761
|
-
}
|
|
762
|
-
if (
|
|
763
|
-
message: O,
|
|
764
|
-
sequence: null
|
|
765
|
-
} };
|
|
766
|
-
if (!i) return {
|
|
778
|
+
};
|
|
779
|
+
if (!y(r.html)) return {
|
|
767
780
|
...r,
|
|
768
781
|
prompt: ""
|
|
769
782
|
};
|
|
770
|
-
let
|
|
771
|
-
|
|
783
|
+
let i = n.imagePrompt || ie(r.html) || n.title, a = {
|
|
784
|
+
...n,
|
|
785
|
+
imagePrompt: i
|
|
786
|
+
}, o = await ct(e, t, a), s = lt(a, o.length > 0), c = await K(e, s, o), { imageData: l, imagePath: u } = B(c);
|
|
787
|
+
return l ? {
|
|
772
788
|
...r,
|
|
773
|
-
imageData:
|
|
774
|
-
...
|
|
775
|
-
prompt:
|
|
789
|
+
imageData: l,
|
|
790
|
+
...u && { imagePath: u },
|
|
791
|
+
prompt: s,
|
|
792
|
+
imagePrompt: i
|
|
776
793
|
} : {
|
|
777
794
|
...r,
|
|
778
|
-
prompt:
|
|
779
|
-
|
|
795
|
+
prompt: s,
|
|
796
|
+
imagePrompt: i,
|
|
797
|
+
pictureFailed: c.message
|
|
780
798
|
};
|
|
781
799
|
}
|
|
782
|
-
let r = await
|
|
800
|
+
let r = await ct(e, t, n), i = ot(n, r.length > 0), a = await K(e, i, r), { imageData: o, imagePath: s } = B(a);
|
|
783
801
|
return o ? {
|
|
784
802
|
imageData: o,
|
|
785
803
|
...s && { imagePath: s },
|
|
@@ -789,10 +807,10 @@ async function ct(e, t, n) {
|
|
|
789
807
|
sequence: null
|
|
790
808
|
} };
|
|
791
809
|
}
|
|
792
|
-
async function
|
|
793
|
-
let r = await
|
|
810
|
+
async function dt(e, t, n) {
|
|
811
|
+
let r = await ut(e, t, n);
|
|
794
812
|
if ("failed" in r) return r.failed;
|
|
795
|
-
let { imageData: i, imagePath: a, html: o, markdown: s, chart: c, prompt: l, pictureFailed: u } = r, d = t.id, f = await
|
|
813
|
+
let { imageData: i, imagePath: a, html: o, markdown: s, chart: c, prompt: l, pictureFailed: u } = r, d = t.id, f = await Z(e.files?.artifacts, We, d, (e) => {
|
|
796
814
|
let t = e ?? {
|
|
797
815
|
id: d,
|
|
798
816
|
title: "",
|
|
@@ -802,7 +820,7 @@ async function lt(e, t, n) {
|
|
|
802
820
|
};
|
|
803
821
|
return n.slide === 1 && (t.title = n.title), t.slides[String(n.slide)] = {
|
|
804
822
|
title: n.title,
|
|
805
|
-
imagePrompt: o
|
|
823
|
+
imagePrompt: o ? r.imagePrompt ?? "" : n.imagePrompt,
|
|
806
824
|
...a && { imagePath: a },
|
|
807
825
|
...o && { html: o },
|
|
808
826
|
...s && { markdown: s },
|
|
@@ -828,21 +846,21 @@ async function lt(e, t, n) {
|
|
|
828
846
|
`${m} ${n.slide} of ${n.totalSlides} of slideshow "${d}" is on the screen`,
|
|
829
847
|
a ? `saved to ${a}` : "",
|
|
830
848
|
u ? `its picture couldn't be drawn (${u}), so the slide is shown without it` : "",
|
|
831
|
-
f ? "" :
|
|
849
|
+
f ? "" : Q("slideshow")
|
|
832
850
|
].filter(Boolean).join("; "),
|
|
833
|
-
instructions:
|
|
851
|
+
instructions: k(n),
|
|
834
852
|
instructionsRequired: !0,
|
|
835
|
-
sequence:
|
|
853
|
+
sequence: tt(n)
|
|
836
854
|
};
|
|
837
855
|
}
|
|
838
|
-
async function
|
|
839
|
-
let n =
|
|
856
|
+
async function $(e, t) {
|
|
857
|
+
let n = xe(t);
|
|
840
858
|
if (typeof n == "string") return {
|
|
841
859
|
message: n,
|
|
842
860
|
sequence: null
|
|
843
861
|
};
|
|
844
|
-
let r =
|
|
845
|
-
if (a && n.slide > i.current && i.current > 0 && !
|
|
862
|
+
let r = rt(e), i = it(r, n), a = n.mode === "steps";
|
|
863
|
+
if (a && n.slide > i.current && i.current > 0 && !U(e, i.shownAt)) {
|
|
846
864
|
console.info(`[sequence] holding step ${n.slide} for the user`);
|
|
847
865
|
let e = i.shownAt === Infinity ? "is still being drawn" : "is still on the screen";
|
|
848
866
|
return {
|
|
@@ -851,15 +869,15 @@ async function ut(e, t) {
|
|
|
851
869
|
};
|
|
852
870
|
}
|
|
853
871
|
let o = a ? i.slides.get(n.slide) : void 0;
|
|
854
|
-
if (o) return
|
|
872
|
+
if (o) return ke(e.currentResult, o) ? {
|
|
855
873
|
message: `step ${n.slide} of ${n.totalSlides} is already on the screen`,
|
|
856
874
|
cancelled: !0
|
|
857
|
-
} :
|
|
858
|
-
let s = r.repeats.claim(
|
|
875
|
+
} : at(r, i, n, o);
|
|
876
|
+
let s = r.repeats.claim(nt(i.id, n));
|
|
859
877
|
if ("earlier" in s) {
|
|
860
|
-
if (!await s.earlier) return
|
|
878
|
+
if (!await s.earlier) return $(e, t);
|
|
861
879
|
let a = i.slides.get(n.slide);
|
|
862
|
-
return a && r.lastShown !== i ?
|
|
880
|
+
return a && r.lastShown !== i ? at(r, i, n, a) : {
|
|
863
881
|
message: `slide ${n.slide} of ${n.totalSlides} is already on the screen`,
|
|
864
882
|
cancelled: !0
|
|
865
883
|
};
|
|
@@ -871,22 +889,22 @@ async function ut(e, t) {
|
|
|
871
889
|
i.current = n.slide, i.shownAt = Infinity;
|
|
872
890
|
let u = !1;
|
|
873
891
|
try {
|
|
874
|
-
let t = await
|
|
875
|
-
return u =
|
|
892
|
+
let t = await dt(e, i, n);
|
|
893
|
+
return u = Oe(t), u && (i.slides.set(n.slide, t), i.current = n.slide, i.shownAt = Date.now(), r.lastShown = i), t;
|
|
876
894
|
} finally {
|
|
877
895
|
c(u), !u && i.current === n.slide && (i.current = l.current, i.shownAt = l.shownAt);
|
|
878
896
|
}
|
|
879
897
|
}
|
|
880
898
|
//#endregion
|
|
881
899
|
//#region src/core/storyboard.ts
|
|
882
|
-
var
|
|
900
|
+
var ft = ({ id: e, title: t, totalPanels: n }) => ({
|
|
883
901
|
step: 0,
|
|
884
902
|
total: n,
|
|
885
903
|
kind: "story",
|
|
886
904
|
label: `The cast of "${t}"`,
|
|
887
905
|
onShown: "introduce the characters",
|
|
888
906
|
nextCall: `call presentPanel for panel 1 of ${n} with storyboardId "${e}"`
|
|
889
|
-
}),
|
|
907
|
+
}), pt = ({ id: e, totalPanels: t }, n, r) => ({
|
|
890
908
|
step: n,
|
|
891
909
|
total: t,
|
|
892
910
|
kind: "story",
|
|
@@ -894,21 +912,21 @@ var dt = ({ id: e, title: t, totalPanels: n }) => ({
|
|
|
894
912
|
onShown: "tell that part of the story",
|
|
895
913
|
nextCall: `call presentPanel for panel ${n + 1} of ${t} with storyboardId "${e}"`,
|
|
896
914
|
...r.length > 0 && { waitsForUser: !0 }
|
|
897
|
-
}),
|
|
898
|
-
async function
|
|
899
|
-
let n =
|
|
915
|
+
}), mt = (e, t) => e ? `${e}. ${t}` : t, ht = (e, { name: t, description: n }) => mt(e, `Character reference sheet of ${t}: ${n}. Full body, front, side and back views, on a plain white background. No text or labels.`);
|
|
916
|
+
async function gt(e, t) {
|
|
917
|
+
let n = j(t);
|
|
900
918
|
if (typeof n == "string") return {
|
|
901
919
|
message: n,
|
|
902
920
|
sequence: null
|
|
903
921
|
};
|
|
904
|
-
let r = await Promise.all(n.characters.map((t) =>
|
|
922
|
+
let r = await Promise.all(n.characters.map((t) => K(e, ht(n.style, t)))), i = r.map(B), a = r.find((e, t) => !i[t]?.imageData);
|
|
905
923
|
if (i.every(({ imageData: e }) => !e) && a) return {
|
|
906
924
|
...a,
|
|
907
925
|
message: `the character sheets couldn't be made: ${a.message}`,
|
|
908
926
|
sequence: null
|
|
909
927
|
};
|
|
910
928
|
let o = {
|
|
911
|
-
id:
|
|
929
|
+
id: W(),
|
|
912
930
|
...n,
|
|
913
931
|
characters: n.characters.map((e, t) => {
|
|
914
932
|
let n = i[t]?.imagePath;
|
|
@@ -918,7 +936,7 @@ async function ht(e, t) {
|
|
|
918
936
|
};
|
|
919
937
|
}),
|
|
920
938
|
panels: {}
|
|
921
|
-
}, s = await
|
|
939
|
+
}, 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;
|
|
922
940
|
return {
|
|
923
941
|
data: {
|
|
924
942
|
storyboardId: o.id,
|
|
@@ -939,39 +957,39 @@ async function ht(e, t) {
|
|
|
939
957
|
`storyboard "${o.id}" is ready with ${o.totalPanels} panels; the cast is on the screen`,
|
|
940
958
|
c.length ? `character sheets saved to ${c.join(", ")}` : "",
|
|
941
959
|
l.length ? `no sheet for ${l.join("; ")}: they will be drawn from their description` : "",
|
|
942
|
-
s ? "" :
|
|
960
|
+
s ? "" : Q("storyboard")
|
|
943
961
|
].filter(Boolean).join("; "),
|
|
944
|
-
instructions:
|
|
962
|
+
instructions: M(o),
|
|
945
963
|
instructionsRequired: !0,
|
|
946
|
-
sequence:
|
|
964
|
+
sequence: ft(o)
|
|
947
965
|
};
|
|
948
966
|
}
|
|
949
|
-
function
|
|
950
|
-
let r = [
|
|
967
|
+
function _t(e, t, n) {
|
|
968
|
+
let r = [mt(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}`);
|
|
951
969
|
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(" ");
|
|
952
970
|
}
|
|
953
|
-
async function
|
|
971
|
+
async function vt(e, t, n) {
|
|
954
972
|
let r = [], i = [];
|
|
955
973
|
for (let a of n.characters) {
|
|
956
|
-
let n = t.characters.find((e) =>
|
|
974
|
+
let n = t.characters.find((e) => D(e.name, a));
|
|
957
975
|
if (!n) r.push(a);
|
|
958
976
|
else if (!i.some((e) => e.character === n)) {
|
|
959
|
-
let [t] = n.imagePath ? await
|
|
977
|
+
let [t] = n.imagePath ? await G(e, [n.imagePath]) : [];
|
|
960
978
|
i.push({
|
|
961
979
|
character: n,
|
|
962
980
|
sheet: t ?? null
|
|
963
981
|
});
|
|
964
982
|
}
|
|
965
983
|
}
|
|
966
|
-
let a = i.map(({ sheet: e }) => e).filter((e) => !!e), o =
|
|
984
|
+
let a = i.map(({ sheet: e }) => e).filter((e) => !!e), o = _t(t, n, i.map(({ character: e, sheet: t }) => ({
|
|
967
985
|
character: e,
|
|
968
986
|
hasSheet: !!t
|
|
969
|
-
}))), s = await
|
|
987
|
+
}))), s = await K(e, o, a), { imageData: c, imagePath: l } = B(s);
|
|
970
988
|
if (!c) return {
|
|
971
989
|
...s,
|
|
972
990
|
sequence: null
|
|
973
991
|
};
|
|
974
|
-
let u = n.panel < t.totalPanels && n.choices.length >= 2 ? n.choices : [], d = await
|
|
992
|
+
let u = n.panel < t.totalPanels && n.choices.length >= 2 ? n.choices : [], d = await Z(e.files?.artifacts, X, t.id, (e) => {
|
|
975
993
|
let r = e ?? t;
|
|
976
994
|
return u.length && (r.interactive = !0), r.panels[String(n.panel)] = {
|
|
977
995
|
caption: n.caption,
|
|
@@ -997,25 +1015,25 @@ async function _t(e, t, n) {
|
|
|
997
1015
|
`panel ${n.panel} of ${t.totalPanels} is on the screen`,
|
|
998
1016
|
l ? `saved to ${l}` : "",
|
|
999
1017
|
r.length ? `not in the cast, so drawn from the prompt alone: ${r.join(", ")}` : "",
|
|
1000
|
-
d ? "" :
|
|
1018
|
+
d ? "" : Q("storyboard")
|
|
1001
1019
|
].filter(Boolean).join("; "),
|
|
1002
|
-
instructions:
|
|
1020
|
+
instructions: F(t, n.panel, u),
|
|
1003
1021
|
instructionsRequired: !0,
|
|
1004
|
-
sequence:
|
|
1022
|
+
sequence: pt(t, n.panel, u)
|
|
1005
1023
|
};
|
|
1006
1024
|
}
|
|
1007
|
-
var
|
|
1008
|
-
repeats:
|
|
1025
|
+
var yt = q(() => ({
|
|
1026
|
+
repeats: et(),
|
|
1009
1027
|
awaitingChoice: /* @__PURE__ */ new Map()
|
|
1010
1028
|
}));
|
|
1011
|
-
async function
|
|
1012
|
-
let n =
|
|
1029
|
+
async function bt(e, t) {
|
|
1030
|
+
let n = P(t);
|
|
1013
1031
|
if (!n) return {
|
|
1014
|
-
message:
|
|
1032
|
+
message: N,
|
|
1015
1033
|
sequence: null
|
|
1016
1034
|
};
|
|
1017
|
-
let { storyboardId: r, panel: i } = n, { repeats: a, awaitingChoice: o } =
|
|
1018
|
-
if (s && i > s.panel && !
|
|
1035
|
+
let { storyboardId: r, panel: i } = n, { repeats: a, awaitingChoice: o } = yt(e), s = o.get(r);
|
|
1036
|
+
if (s && i > s.panel && !U(e, s.shownAt)) return console.info(`[sequence] holding panel ${i} for the user`), {
|
|
1019
1037
|
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.`,
|
|
1020
1038
|
cancelled: !0
|
|
1021
1039
|
};
|
|
@@ -1023,7 +1041,7 @@ async function yt(e, t) {
|
|
|
1023
1041
|
if ("earlier" in c) return await c.earlier ? {
|
|
1024
1042
|
message: `panel ${i} is already on the screen`,
|
|
1025
1043
|
cancelled: !0
|
|
1026
|
-
} :
|
|
1044
|
+
} : bt(e, t);
|
|
1027
1045
|
let { settle: l } = c, u = {
|
|
1028
1046
|
panel: i,
|
|
1029
1047
|
shownAt: Infinity
|
|
@@ -1031,7 +1049,7 @@ async function yt(e, t) {
|
|
|
1031
1049
|
o.set(r, u);
|
|
1032
1050
|
let f = () => o.get(r) === u, p = !1;
|
|
1033
1051
|
try {
|
|
1034
|
-
let t = await
|
|
1052
|
+
let t = await Qe(e.files?.artifacts, X, r);
|
|
1035
1053
|
if (!t) return {
|
|
1036
1054
|
message: `there is no storyboard "${r}"; call defineStoryboard first`,
|
|
1037
1055
|
sequence: null
|
|
@@ -1040,8 +1058,8 @@ async function yt(e, t) {
|
|
|
1040
1058
|
message: `storyboard "${t.id}" has ${t.totalPanels} panels`,
|
|
1041
1059
|
sequence: null
|
|
1042
1060
|
};
|
|
1043
|
-
let a = await
|
|
1044
|
-
p = !!
|
|
1061
|
+
let a = await vt(e, t, n);
|
|
1062
|
+
p = !!B(a).imageData;
|
|
1045
1063
|
let s = a.data;
|
|
1046
1064
|
return p && f() && (s?.choices?.length ? o.set(r, {
|
|
1047
1065
|
panel: i,
|
|
@@ -1053,21 +1071,21 @@ async function yt(e, t) {
|
|
|
1053
1071
|
}
|
|
1054
1072
|
//#endregion
|
|
1055
1073
|
//#region src/core/index.ts
|
|
1056
|
-
var
|
|
1057
|
-
toolDefinition:
|
|
1074
|
+
var xt = {
|
|
1075
|
+
toolDefinition: A,
|
|
1058
1076
|
generatingMessage: "Making the slide...",
|
|
1059
1077
|
isEnabled: () => !0,
|
|
1060
|
-
execute: (e, t) =>
|
|
1061
|
-
},
|
|
1062
|
-
toolDefinition:
|
|
1078
|
+
execute: (e, t) => $(e, t)
|
|
1079
|
+
}, St = {
|
|
1080
|
+
toolDefinition: L,
|
|
1063
1081
|
generatingMessage: "Drawing the characters...",
|
|
1064
1082
|
isEnabled: () => !0,
|
|
1065
|
-
execute: (e, t) =>
|
|
1066
|
-
},
|
|
1067
|
-
toolDefinition:
|
|
1083
|
+
execute: (e, t) => gt(e, t)
|
|
1084
|
+
}, Ct = {
|
|
1085
|
+
toolDefinition: R,
|
|
1068
1086
|
generatingMessage: "Drawing the panel...",
|
|
1069
1087
|
isEnabled: () => !0,
|
|
1070
|
-
execute: (e, t) =>
|
|
1088
|
+
execute: (e, t) => bt(e, t)
|
|
1071
1089
|
};
|
|
1072
1090
|
//#endregion
|
|
1073
|
-
export {
|
|
1091
|
+
export { k as A, t as B, I as C, xe as D, P as E, s as F, oe as H, h as I, l as L, fe as M, r as N, j as O, o as P, n as R, ve as S, F as T, ae as U, y as V, A as _, X as a, _e as b, pe as c, ge as d, he as f, S as g, R as h, We as i, b as j, D as k, L as l, C as m, Ct as n, Qe as o, N as p, xt as r, Ue as s, St as t, me as u, Ee as v, M as w, ye as x, w as y, g as z };
|