popost 4.6.6 → 4.6.7

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.
Files changed (67) hide show
  1. package/SKILL.md +2 -2
  2. package/assets/video/examples/catalogue.json +114 -0
  3. package/assets/video/examples/list-cards.html +155 -0
  4. package/assets/video/examples/page-flip.html +163 -0
  5. package/assets/video/times.js +59 -0
  6. package/dist/cli.js +2018 -754
  7. package/dist/index.js +2015 -751
  8. package/dist/types/version.d.ts +1 -1
  9. package/dist/types/video/commands/replication-books.d.ts +2 -0
  10. package/dist/types/video/compile/page-bundle.d.ts +1 -1
  11. package/dist/types/video/describe/parts.d.ts +3 -1
  12. package/dist/types/video/eval/readback-kept.d.ts +10 -0
  13. package/dist/types/video/eval/readback-run.d.ts +5 -1
  14. package/dist/types/video/generate/cast.d.ts +4 -0
  15. package/dist/types/video/page/apply.d.ts +1 -1
  16. package/dist/types/video/page/contract.d.ts +14 -0
  17. package/dist/types/video/page/dom.d.ts +5 -0
  18. package/dist/types/video/page/times.d.ts +31 -0
  19. package/dist/types/video/preview/shell/dom.d.ts +9 -0
  20. package/dist/types/video/preview/shell/studio/style.d.ts +1 -1
  21. package/dist/types/video/preview/shell/studio/ui.d.ts +2 -0
  22. package/dist/types/video/preview/shell-bundle.d.ts +1 -1
  23. package/dist/types/video/project/check-sound.d.ts +3 -0
  24. package/dist/types/video/render/chunked.d.ts +29 -0
  25. package/dist/types/video/render/chunks.d.ts +39 -0
  26. package/dist/types/video/render/encode.d.ts +5 -0
  27. package/dist/types/video/render/index.d.ts +26 -0
  28. package/dist/types/video/render/record.d.ts +1 -1
  29. package/dist/types/video/render/session.d.ts +17 -0
  30. package/dist/types/video/render/shots.d.ts +11 -0
  31. package/dist/types/video/replication/books.d.ts +64 -0
  32. package/dist/types/video/replication/production.d.ts +5 -0
  33. package/dist/types/video/replication/retiming.d.ts +16 -0
  34. package/dist/types/video/replication/review.d.ts +50 -0
  35. package/dist/types/video/retarget/fps.d.ts +3 -5
  36. package/dist/types/video/retarget/index.d.ts +10 -2
  37. package/dist/types/video/retarget/speak.d.ts +2 -0
  38. package/dist/types/video/retarget/takes.d.ts +66 -0
  39. package/dist/types/video/retarget/tempo.d.ts +2 -0
  40. package/dist/types/video/speech/types.d.ts +5 -0
  41. package/dist/types/video/template/fill.d.ts +2 -0
  42. package/dist/types/video/template/save.d.ts +2 -0
  43. package/dist/types/video/template/structure.d.ts +1 -0
  44. package/dist/types/video/voice/cache.d.ts +10 -0
  45. package/dist/types/video/voice/hosted.d.ts +10 -4
  46. package/dist/types/video/voice/index.d.ts +25 -1
  47. package/dist/types/video/wallet.d.ts +7 -0
  48. package/package.json +1 -1
  49. package/references/image-workflow.md +1 -1
  50. package/references/video-effects.md +9 -1
  51. package/references/video-performers.md +12 -2
  52. package/references/video-project.md +5 -3
  53. package/references/video-replication.md +32 -3
  54. package/references/video-scenes.md +52 -2
  55. package/references/video-sfx.md +1 -1
  56. package/references/video-sound.md +18 -3
  57. package/references/video-step-0-machine.md +61 -0
  58. package/references/video-step-1-read.md +168 -0
  59. package/references/video-step-2-structure.md +24 -0
  60. package/references/video-step-3-content.md +117 -0
  61. package/references/video-step-4-lines.md +88 -0
  62. package/references/video-step-5-scenes.md +126 -0
  63. package/references/video-step-6-voice.md +53 -0
  64. package/references/video-step-7-deliver.md +92 -0
  65. package/references/video-templates.md +17 -7
  66. package/references/video-tools.md +8 -6
  67. package/references/video.md +50 -666
package/SKILL.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: popost
3
3
  metadata:
4
- version: "4.6.6"
4
+ version: "4.6.7"
5
5
  description: Reproduce reference videos with new content; create, reproduce and edit social image posts; save supported social links to My Inspirations. Use for video remakes, single-image posts, carousels, editable canvas/Studio projects and inspiration saving from TikTok, Instagram, X, Xiaohongshu, Douyin or YouTube links, local media and written briefs. Retrieve only the source content supported by the selected link service.
6
6
  ---
7
7
 
@@ -34,7 +34,7 @@ Prepare only what the next operation needs: an inspiration save needs no rendere
34
34
  ## Select the operation
35
35
 
36
36
  - **Save inspiration.** For a supported social link, use `inspiration quote`, then `inspiration add URL --confirm --max-credits N` within fee authorization. Return its saved ID/link and actual fee; resume an existing task with `inspiration status`. Supplied text, screenshots or a PostBundle use `inspiration import` after its dry run. Read [post-bundle.md](references/post-bundle.md). Do not start a production or download local media for a save-only request.
37
- - **Reproduce a video.** Read [video.md](references/video.md) and follow its reference analysis, production and review. It links the required replication, people, motion and sound contracts when relevant. The image-post workflow does not apply. Use the reference plus the user's changes; they need not prescribe transitions, layouts or engineering details.
37
+ - **Reproduce a video.** Read [video.md](references/video.md): its rules, then the page of each step as you reach it (reference analysis, production, review). It links the required replication, people, motion and sound contracts when relevant. The image-post workflow does not apply. Use the reference plus the user's changes; they need not prescribe transitions, layouts or engineering details.
38
38
  - **Edit a video.** Read [video-editing.md](references/video-editing.md). Reuse the existing project and accepted media, change only affected parts, and review the changed output. New paid media still follows the shared authorization.
39
39
  - **Reproduce an image post.** Read [image-workflow.md](references/image-workflow.md) and [reproduce.md](references/reproduce.md). Establish what stays and what changes from the target reference.
40
40
  - **Create an image post.** Read [image-workflow.md](references/image-workflow.md) and [create.md](references/create.md). Design from the brief or select a relevant bundled template. For template selection, read `<skill>/templates/community/README.md`, inspect 1–3 useful candidates in full, and choose one or none; `template search` is a shortcut, not a complete semantic search. Use an explicitly requested template directly.
@@ -15449,6 +15449,65 @@
15449
15449
  "caption"
15450
15450
  ]
15451
15451
  },
15452
+ {
15453
+ "name": "list-cards",
15454
+ "file": "assets/video/examples/list-cards.html",
15455
+ "class": "card",
15456
+ "about": "A title and a list of cards (numbered points, steps, tools, reasons) that come on one by one as the narration says them: at the spoken lines of the shot or when each label is said, the newest card marked until the next. Without a voice they come on at even steps.",
15457
+ "seconds": 4,
15458
+ "libraries": [],
15459
+ "params": [
15460
+ "title",
15461
+ "items",
15462
+ "columns",
15463
+ "numbered",
15464
+ "highlight",
15465
+ "follow",
15466
+ "firstLine",
15467
+ "lead",
15468
+ "stagger",
15469
+ "delay",
15470
+ "ground",
15471
+ "card",
15472
+ "ink",
15473
+ "accent"
15474
+ ],
15475
+ "cues": [
15476
+ {
15477
+ "at": 0.7,
15478
+ "cue": "pop",
15479
+ "gain": 0.45
15480
+ },
15481
+ {
15482
+ "at": 1.5,
15483
+ "cue": "pop",
15484
+ "gain": 0.45
15485
+ },
15486
+ {
15487
+ "at": 2.3,
15488
+ "cue": "pop",
15489
+ "gain": 0.45
15490
+ },
15491
+ {
15492
+ "at": 3.1,
15493
+ "cue": "pop",
15494
+ "gain": 0.45
15495
+ }
15496
+ ],
15497
+ "tags": [
15498
+ "list",
15499
+ "checklist",
15500
+ "steps",
15501
+ "ranking",
15502
+ "points",
15503
+ "tools",
15504
+ "cards",
15505
+ "voice",
15506
+ "narration",
15507
+ "explainer",
15508
+ "content"
15509
+ ]
15510
+ },
15452
15511
  {
15453
15512
  "name": "motion-blur-streak",
15454
15513
  "file": "assets/video/examples/motion-blur-streak.html",
@@ -15510,6 +15569,61 @@
15510
15569
  ],
15511
15570
  "cues": []
15512
15571
  },
15572
+ {
15573
+ "name": "page-flip",
15574
+ "file": "assets/video/examples/page-flip.html",
15575
+ "class": "card",
15576
+ "about": "Pages that turn as the narration goes on: a stack of pictures or drawn pages (screenshots, slides, a catalogue, before and after) whose top page turns away like a book page, slides off the stack or is pushed aside at each spoken line of the shot, or when its label is said. Without a voice the pages turn at even steps.",
15577
+ "seconds": 4,
15578
+ "libraries": [],
15579
+ "params": [
15580
+ "pages",
15581
+ "labels",
15582
+ "style",
15583
+ "fit",
15584
+ "width",
15585
+ "height",
15586
+ "y",
15587
+ "radius",
15588
+ "turn",
15589
+ "follow",
15590
+ "firstLine",
15591
+ "lead",
15592
+ "stagger",
15593
+ "delay",
15594
+ "ground",
15595
+ "paper",
15596
+ "ink",
15597
+ "accent",
15598
+ "shadow"
15599
+ ],
15600
+ "cues": [
15601
+ {
15602
+ "at": 1.3,
15603
+ "cue": "whoosh",
15604
+ "gain": 0.4
15605
+ },
15606
+ {
15607
+ "at": 2.5,
15608
+ "cue": "whoosh",
15609
+ "gain": 0.4
15610
+ }
15611
+ ],
15612
+ "tags": [
15613
+ "page",
15614
+ "pages",
15615
+ "flip",
15616
+ "turn",
15617
+ "book",
15618
+ "slides",
15619
+ "gallery",
15620
+ "screenshots",
15621
+ "stack",
15622
+ "voice",
15623
+ "narration",
15624
+ "content"
15625
+ ]
15626
+ },
15513
15627
  {
15514
15628
  "name": "parallax-layers",
15515
15629
  "file": "assets/video/examples/parallax-layers.html",
@@ -0,0 +1,155 @@
1
+ <!doctype html>
2
+ <html><head><meta charset="utf-8"><title>List cards on the voice</title>
3
+ <style>
4
+ html, body { margin: 0; width: 1280px; height: 720px; overflow: hidden; }
5
+ body { font-family: "Inter", "PingFang SC", "Noto Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif; }
6
+ #stage { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: hidden; background: var(--ground); color: var(--ink); }
7
+ #title { position: absolute; left: 7%; right: 7%; top: 8%; text-align: center; font-weight: 800; line-height: 1.18; letter-spacing: -0.01em; }
8
+ #band { position: absolute; left: 6%; right: 6%; bottom: 22%; display: flex; align-items: center; }
9
+ #list { width: 100%; display: grid; grid-auto-rows: minmax(0, 1fr); }
10
+ .card { display: flex; align-items: center; box-sizing: border-box; min-width: 0; min-height: 0; background: var(--card); transform-origin: 50% 50%; }
11
+ .badge { flex: none; height: 1.9em; width: 1.9em; border-radius: 0.5em; background: var(--accent); color: #ffffff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.9em; }
12
+ .text { flex: 1; min-width: 0; }
13
+ .label { font-weight: 700; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
14
+ .note { margin-top: 0.25em; font-size: 0.66em; line-height: 1.4; opacity: 0.62; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
15
+ </style></head>
16
+ <body>
17
+ <!-- A title and a list of cards that come on one by one as the voice says them, the newest marked until the next.
18
+ Each item is "label" or "label :: note"; a template fill can still change the texts by their slots
19
+ (title, item-1, note-1, ...). -->
20
+ <div id="stage">
21
+ <div id="title" data-slot="title"></div>
22
+ <div id="band"><div id="list"></div></div>
23
+ </div>
24
+ <script type="application/json" id="popost-params">
25
+ {
26
+ "about": "A title and a list of cards (numbered points, steps, tools, reasons) that come on one by one as the narration says them: at the spoken lines of the shot or when each label is said, the newest card marked until the next. Without a voice they come on at even steps.",
27
+ "class": "card",
28
+ "seconds": 4,
29
+ "tags": [ "list", "checklist", "steps", "ranking", "points", "tools", "cards", "voice", "narration", "explainer", "content" ],
30
+ "params": [
31
+ { "name": "title", "type": "text", "maxLength": 60, "default": "Four tools worth saving", "what": "the headline above the list; empty for none" },
32
+ { "name": "items", "type": "text", "maxLength": 600, "default": "Find ideas :: search what sells and why|Remake :: the structure, with your content|Review :: the script before it is made|Refresh :: an old video, new lines", "what": "the items, separated by |; each is a label, or a label and a note separated by ::" },
33
+ { "name": "columns", "type": "choice", "default": "auto", "options": [ "auto", "1", "2" ], "what": "cards in a row: auto is 2 on a wide canvas with 4 items or more, else 1" },
34
+ { "name": "numbered", "type": "choice", "default": "yes", "options": [ "yes", "no" ], "what": "a numbered badge on each card" },
35
+ { "name": "highlight", "type": "choice", "default": "current", "options": [ "current", "none" ], "what": "current marks the newest card with the accent until the next comes on" },
36
+ { "name": "follow", "type": "choice", "default": "lines", "options": [ "lines", "words", "even" ], "what": "when each comes on: at the spoken lines of the shot (from firstLine on), when its text is said, or at even steps of stagger; without a voice (a sheet) always at even steps" },
37
+ { "name": "firstLine", "type": "number", "default": 2, "min": 1, "max": 30, "unit": "line of the shot", "what": "the line of the shot at which the first item comes on (the title is usually said in line 1)" },
38
+ { "name": "lead", "type": "number", "default": 0.15, "min": 0, "max": 1.5, "unit": "seconds", "what": "how long before its line or word each comes on" },
39
+ { "name": "stagger", "type": "number", "default": 0.8, "min": 0.1, "max": 6, "unit": "seconds", "what": "the step between two at even steps, and after the last time the voice gives" },
40
+ { "name": "delay", "type": "number", "default": 0.2, "min": 0, "max": 20, "unit": "seconds", "what": "when the title lands; at even steps the first item follows half a second later" },
41
+ { "name": "ground", "type": "colour", "default": "#f2f4f7", "what": "the background" },
42
+ { "name": "card", "type": "colour", "default": "#ffffff", "what": "the cards" },
43
+ { "name": "ink", "type": "colour", "default": "#16191f", "what": "the text" },
44
+ { "name": "accent", "type": "colour", "default": "#e4572e", "what": "the badges and the mark of the newest card" }
45
+ ],
46
+ "values": {}
47
+ }
48
+ </script>
49
+ <script>
50
+ (function () {
51
+ // The voice's times in this shot, which the engine puts in the address of the scene (as popost-times.js reads them):
52
+ // none in a sheet or a scene alone, and then everything comes on at even steps.
53
+ var times = (function () {
54
+ try { var h = String(location.hash), k = h.indexOf('popost-times='); return k < 0 ? null : JSON.parse(decodeURIComponent(h.slice(k + 13))); } catch (e) { return null; }
55
+ })();
56
+ var lines = times && times.lines || [], words = times && times.words || [];
57
+ var plain = function (s) { return String(s).toLowerCase().replace(/[\s\p{P}\p{S}]+/gu, ''); };
58
+ // Where the first spoken word that begins the text starts, not before after; undefined when it is not said.
59
+ var wordAt = function (text, after) {
60
+ var want = plain(text);
61
+ if (!want) return undefined;
62
+ for (var i = 0; i < words.length; i++) {
63
+ if (words[i].at < after - 0.001) continue;
64
+ var own = plain(words[i].text), joined = own;
65
+ for (var j = i + 1; j < words.length && joined.length < own.length + want.length; j++) joined += plain(words[j].text);
66
+ var found = joined.indexOf(want);
67
+ if (found >= 0 && found < Math.max(1, own.length)) return words[i].at;
68
+ }
69
+ return undefined;
70
+ };
71
+ var block = JSON.parse(document.getElementById('popost-params').textContent), P = {};
72
+ block.params.forEach(function (p) { P[p.name] = block.values && block.values[p.name] !== undefined ? block.values[p.name] : p.default; });
73
+ var size = /width:\s*(\d+)px;\s*height:\s*(\d+)px;/.exec(document.querySelector('style').textContent) || [0, 1280, 720];
74
+ var W = Number(size[1]), H = Number(size[2]);
75
+ var clamp01 = function (t) { return Math.min(1, Math.max(0, t)); };
76
+ var out3 = function (t) { t = clamp01(t); return 1 - Math.pow(1 - t, 3); };
77
+ var inOut = function (t) { t = clamp01(t); return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(2 - 2 * t, 3) / 2; };
78
+ // When each of count things comes on: at the shot's lines from firstLine, when its text is said, or at even steps;
79
+ // what the voice does not give follows the one before by stagger. Never two at once.
80
+ var timesOf = function (texts, first, firstLine) {
81
+ var at = [], lead = Number(P.lead), stagger = Number(P.stagger);
82
+ texts.forEach(function (text, k) {
83
+ var t;
84
+ if (P.follow === 'words') { var w = wordAt(text, k ? at[k - 1] + lead : 0); if (w !== undefined) t = w - lead; }
85
+ if (t === undefined && P.follow !== 'even') { var l = lines[firstLine - 1 + k]; if (l) t = l.at - lead; }
86
+ if (t === undefined) t = k ? at[k - 1] + stagger : first;
87
+ at.push(Math.max(0, k ? Math.max(t, at[k - 1] + 0.12) : t));
88
+ });
89
+ return at;
90
+ };
91
+
92
+ var items = String(P.items).split('|').map(function (s) { var two = s.split('::'); return { label: (two[0] || '').trim(), note: (two.slice(1).join('::') || '').trim() }; })
93
+ .filter(function (x) { return x.label || x.note; });
94
+ var stage = document.getElementById('stage'), title = document.getElementById('title'), band = document.getElementById('band'), list = document.getElementById('list');
95
+ ['ground', 'card', 'ink', 'accent'].forEach(function (c) { stage.style.setProperty('--' + c, P[c]); });
96
+ var cols = P.columns === 'auto' ? (W > H && items.length >= 4 ? 2 : 1) : Number(P.columns);
97
+ var rows = Math.max(1, Math.ceil(items.length / cols)), unit = Math.min(W, H), gap = unit * 0.022;
98
+ var hasNotes = items.some(function (x) { return x.note; });
99
+ title.textContent = P.title;
100
+ title.style.fontSize = (unit * 0.072).toFixed(1) + 'px';
101
+ if (!String(P.title).trim()) title.style.display = 'none';
102
+ var above = String(P.title).trim() ? 0.25 : 0.1, bandH = H * (1 - 0.22 - above);
103
+ var rowH = Math.min(bandH / rows, H * (W > H ? 0.16 : 0.12) * (hasNotes ? 1.25 : 1));
104
+ band.style.top = (above * 100).toFixed(2) + '%';
105
+ list.style.height = (rowH * rows).toFixed(1) + 'px';
106
+ list.style.gridTemplateColumns = 'repeat(' + cols + ', minmax(0, 1fr))';
107
+ list.style.gap = gap.toFixed(1) + 'px';
108
+ var fs = Math.min(unit * 0.046, (rowH - gap) * (hasNotes ? 0.26 : 0.34));
109
+ items.forEach(function (it, k) {
110
+ var card = document.createElement('div'), badge = document.createElement('div'), text = document.createElement('div'), label = document.createElement('div');
111
+ card.className = 'card';
112
+ card.style.fontSize = fs.toFixed(1) + 'px';
113
+ card.style.gap = (fs * 0.8).toFixed(1) + 'px';
114
+ card.style.padding = '0 ' + (fs * 0.9).toFixed(1) + 'px';
115
+ card.style.borderRadius = (fs * 0.7).toFixed(1) + 'px';
116
+ badge.className = 'badge';
117
+ badge.textContent = String(k + 1);
118
+ if (P.numbered !== 'yes') badge.style.display = 'none';
119
+ text.className = 'text';
120
+ label.className = 'label';
121
+ label.setAttribute('data-slot', 'item-' + (k + 1));
122
+ label.textContent = it.label;
123
+ text.appendChild(label);
124
+ if (it.note) {
125
+ var note = document.createElement('div');
126
+ note.className = 'note';
127
+ note.setAttribute('data-slot', 'note-' + (k + 1));
128
+ note.textContent = it.note;
129
+ text.appendChild(note);
130
+ }
131
+ card.appendChild(badge);
132
+ card.appendChild(text);
133
+ list.appendChild(card);
134
+ });
135
+ var cards = Array.prototype.slice.call(list.children);
136
+ var at = timesOf(items.map(function (x) { return x.label; }), Number(P.delay) + 0.5, Number(P.firstLine));
137
+
138
+ // Every frame from its time alone: the title lands and stays, each card rises in at its time and holds.
139
+ var render = function (seconds) {
140
+ var e = out3((seconds - Number(P.delay)) / 0.5);
141
+ title.style.opacity = e.toFixed(4);
142
+ title.style.transform = 'translateY(' + ((1 - e) * -2.5).toFixed(3) + 'vh)';
143
+ cards.forEach(function (card, k) {
144
+ var u = out3((seconds - at[k]) / 0.45);
145
+ var next = k + 1 < at.length ? at[k + 1] : Infinity;
146
+ var mark = P.highlight === 'current' ? clamp01((seconds - at[k]) / 0.25) * (1 - clamp01((seconds - next) / 0.25)) : 0;
147
+ card.style.opacity = u.toFixed(4);
148
+ card.style.transform = 'translateY(' + ((1 - u) * 4).toFixed(3) + 'vh) scale(' + (0.96 + 0.04 * u + 0.02 * mark).toFixed(4) + ')';
149
+ card.style.boxShadow = '0 ' + (unit * 0.008).toFixed(1) + 'px ' + (unit * 0.024).toFixed(1) + 'px rgba(0, 0, 0, 0.08), inset 0 0 0 ' + (unit * 0.005 * mark).toFixed(2) + 'px ' + P.accent;
150
+ });
151
+ };
152
+ window.__popostScene = { render: render, cues: at.map(function (t) { return { at: Math.round(t * 1000) / 1000, cue: 'pop', gain: 0.45 }; }) };
153
+ })();
154
+ </script>
155
+ </body></html>
@@ -0,0 +1,163 @@
1
+ <!doctype html>
2
+ <html><head><meta charset="utf-8"><title>Pages that turn on the voice</title>
3
+ <style>
4
+ html, body { margin: 0; width: 1280px; height: 720px; overflow: hidden; }
5
+ body { font-family: "Inter", "PingFang SC", "Noto Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif; }
6
+ #stage { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: hidden; background: var(--ground); }
7
+ #book { position: absolute; transform-origin: 50% 50%; }
8
+ .page { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: hidden; background: var(--paper); color: var(--ink); backface-visibility: hidden; }
9
+ /* A drawn stand-in under every page, seen until the page has a picture: its label and a few ruled lines. */
10
+ .paper { position: absolute; left: 8%; right: 8%; top: 10%; bottom: 10%;
11
+ background: linear-gradient(var(--accent), var(--accent)) 0 0 / 22% 3% no-repeat, linear-gradient(#d7dbe3, #d7dbe3) 0 62% / 100% 2.4% no-repeat,
12
+ linear-gradient(#d7dbe3, #d7dbe3) 0 72% / 92% 2.4% no-repeat, linear-gradient(#d7dbe3, #d7dbe3) 0 82% / 70% 2.4% no-repeat; }
13
+ .label { position: absolute; left: 0; right: 0; top: 14%; font-weight: 800; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
14
+ .page img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
15
+ .shade { position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: #000000; opacity: 0; }
16
+ </style></head>
17
+ <body>
18
+ <!-- A stack of pages; at each spoken line (or when its label is said) the top page turns away and shows the next.
19
+ Give the pages as pictures (pages=../assets/a.png|../assets/b.png, paths from the scene file) or let a fill set
20
+ their slots (page-1, page-2, ...); without pictures each page is drawn with its label. -->
21
+ <div id="stage"><div id="book"></div></div>
22
+ <script type="application/json" id="popost-params">
23
+ {
24
+ "about": "Pages that turn as the narration goes on: a stack of pictures or drawn pages (screenshots, slides, a catalogue, before and after) whose top page turns away like a book page, slides off the stack or is pushed aside at each spoken line of the shot, or when its label is said. Without a voice the pages turn at even steps.",
25
+ "class": "card",
26
+ "seconds": 4,
27
+ "tags": [ "page", "pages", "flip", "turn", "book", "slides", "gallery", "screenshots", "stack", "voice", "narration", "content" ],
28
+ "params": [
29
+ { "name": "pages", "type": "text", "maxLength": 1200, "default": "", "what": "the pictures of the pages, separated by |, as paths from the scene file (../assets/a.png); empty: drawn pages with the labels" },
30
+ { "name": "labels", "type": "text", "maxLength": 400, "default": "First page|Second page|Third page", "what": "the label of each page, separated by |: drawn on a page without a picture, and the words that turn to it with follow=words" },
31
+ { "name": "style", "type": "choice", "default": "book", "options": [ "book", "stack", "slide" ], "what": "how the top page goes: turned about its left edge, lifted off the stack, or pushed aside by the next" },
32
+ { "name": "fit", "type": "choice", "default": "cover", "options": [ "cover", "contain" ], "what": "how a picture fills its page: cover crops it, contain shows all of it" },
33
+ { "name": "width", "type": "number", "default": 0.8, "min": 0.1, "max": 1, "unit": "fraction of the canvas width", "what": "the width of the pages" },
34
+ { "name": "height", "type": "number", "default": 0.56, "min": 0.1, "max": 1, "unit": "fraction of the canvas height", "what": "the height of the pages" },
35
+ { "name": "y", "type": "number", "default": 0.43, "min": 0, "max": 1, "unit": "fraction of the canvas height", "what": "the middle of the pages (leave the caption band free)" },
36
+ { "name": "radius", "type": "number", "default": 0.03, "min": 0, "max": 0.3, "unit": "fraction of the smaller side", "what": "the corner radius of a page" },
37
+ { "name": "turn", "type": "number", "default": 0.6, "min": 0.15, "max": 3, "unit": "seconds", "what": "how long a page takes to go" },
38
+ { "name": "follow", "type": "choice", "default": "lines", "options": [ "lines", "words", "even" ], "what": "when each comes on: at the spoken lines of the shot (from firstLine on), when its text is said, or at even steps of stagger; without a voice (a sheet) always at even steps" },
39
+ { "name": "firstLine", "type": "number", "default": 2, "min": 1, "max": 30, "unit": "line of the shot", "what": "the line of the shot at which the second page comes (the first is there from the start)" },
40
+ { "name": "lead", "type": "number", "default": 0.25, "min": 0, "max": 1.5, "unit": "seconds", "what": "how long before its line or word a page starts to turn" },
41
+ { "name": "stagger", "type": "number", "default": 1.2, "min": 0.2, "max": 8, "unit": "seconds", "what": "the step between two at even steps, and after the last time the voice gives" },
42
+ { "name": "delay", "type": "number", "default": 0.1, "min": 0, "max": 20, "unit": "seconds", "what": "when the first page arrives; at even steps the second follows by stagger" },
43
+ { "name": "ground", "type": "colour", "default": "#121722", "what": "the background" },
44
+ { "name": "paper", "type": "colour", "default": "#ffffff", "what": "a page without a picture" },
45
+ { "name": "ink", "type": "colour", "default": "#1c2230", "what": "the labels" },
46
+ { "name": "accent", "type": "colour", "default": "#3a86ff", "what": "the mark on a drawn page" },
47
+ { "name": "shadow", "type": "number", "default": 0.35, "min": 0, "max": 1, "unit": "0 to 1", "what": "how dark the shadow under the pages and the shade of a turning page are" }
48
+ ],
49
+ "values": {}
50
+ }
51
+ </script>
52
+ <script>
53
+ (function () {
54
+ // The voice's times in this shot, which the engine puts in the address of the scene (as popost-times.js reads them):
55
+ // none in a sheet or a scene alone, and then everything comes on at even steps.
56
+ var times = (function () {
57
+ try { var h = String(location.hash), k = h.indexOf('popost-times='); return k < 0 ? null : JSON.parse(decodeURIComponent(h.slice(k + 13))); } catch (e) { return null; }
58
+ })();
59
+ var lines = times && times.lines || [], words = times && times.words || [];
60
+ var plain = function (s) { return String(s).toLowerCase().replace(/[\s\p{P}\p{S}]+/gu, ''); };
61
+ // Where the first spoken word that begins the text starts, not before after; undefined when it is not said.
62
+ var wordAt = function (text, after) {
63
+ var want = plain(text);
64
+ if (!want) return undefined;
65
+ for (var i = 0; i < words.length; i++) {
66
+ if (words[i].at < after - 0.001) continue;
67
+ var own = plain(words[i].text), joined = own;
68
+ for (var j = i + 1; j < words.length && joined.length < own.length + want.length; j++) joined += plain(words[j].text);
69
+ var found = joined.indexOf(want);
70
+ if (found >= 0 && found < Math.max(1, own.length)) return words[i].at;
71
+ }
72
+ return undefined;
73
+ };
74
+ var block = JSON.parse(document.getElementById('popost-params').textContent), P = {};
75
+ block.params.forEach(function (p) { P[p.name] = block.values && block.values[p.name] !== undefined ? block.values[p.name] : p.default; });
76
+ var size = /width:\s*(\d+)px;\s*height:\s*(\d+)px;/.exec(document.querySelector('style').textContent) || [0, 1280, 720];
77
+ var W = Number(size[1]), H = Number(size[2]);
78
+ var clamp01 = function (t) { return Math.min(1, Math.max(0, t)); };
79
+ var out3 = function (t) { t = clamp01(t); return 1 - Math.pow(1 - t, 3); };
80
+ var inOut = function (t) { t = clamp01(t); return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(2 - 2 * t, 3) / 2; };
81
+ // When each of count things comes on: at the shot's lines from firstLine, when its text is said, or at even steps;
82
+ // what the voice does not give follows the one before by stagger. Never two at once.
83
+ var timesOf = function (texts, first, firstLine) {
84
+ var at = [], lead = Number(P.lead), stagger = Number(P.stagger);
85
+ texts.forEach(function (text, k) {
86
+ var t;
87
+ if (P.follow === 'words') { var w = wordAt(text, k ? at[k - 1] + lead : 0); if (w !== undefined) t = w - lead; }
88
+ if (t === undefined && P.follow !== 'even') { var l = lines[firstLine - 1 + k]; if (l) t = l.at - lead; }
89
+ if (t === undefined) t = k ? at[k - 1] + stagger : first;
90
+ at.push(Math.max(0, k ? Math.max(t, at[k - 1] + 0.12) : t));
91
+ });
92
+ return at;
93
+ };
94
+
95
+ var split = function (s) { return String(s).split('|').map(function (x) { return x.trim(); }); };
96
+ var pics = split(P.pages).filter(Boolean), labels = split(P.labels);
97
+ var count = Math.max(1, pics.length, labels.filter(Boolean).length);
98
+ var stage = document.getElementById('stage'), book = document.getElementById('book');
99
+ ['ground', 'paper', 'ink', 'accent'].forEach(function (c) { stage.style.setProperty('--' + c, P[c]); });
100
+ var bw = W * Number(P.width), bh = H * Number(P.height), unit = Math.min(W, H);
101
+ book.style.left = ((W - bw) / 2).toFixed(1) + 'px';
102
+ book.style.top = (H * Number(P.y) - bh / 2).toFixed(1) + 'px';
103
+ book.style.width = bw.toFixed(1) + 'px';
104
+ book.style.height = bh.toFixed(1) + 'px';
105
+ if (P.style === 'slide') book.style.overflow = 'hidden';
106
+ var radius = (Math.min(bw, bh) * Number(P.radius)).toFixed(1) + 'px';
107
+ if (P.style === 'slide') book.style.borderRadius = radius;
108
+ book.style.boxShadow = '0 ' + (unit * 0.02).toFixed(1) + 'px ' + (unit * 0.05).toFixed(1) + 'px rgba(0, 0, 0, ' + (Number(P.shadow) * 0.9).toFixed(3) + ')';
109
+ var pages = [];
110
+ for (var k = 0; k < count; k++) {
111
+ var page = document.createElement('div'), paper = document.createElement('div'), label = document.createElement('div'), img = document.createElement('img'), shade = document.createElement('div');
112
+ page.className = 'page';
113
+ page.style.zIndex = String(count - k);
114
+ page.style.borderRadius = radius;
115
+ page.style.transformOrigin = P.style === 'book' ? '0 50%' : '50% 50%';
116
+ paper.className = 'paper';
117
+ label.className = 'label';
118
+ label.setAttribute('data-slot', 'label-' + (k + 1));
119
+ label.textContent = labels[k] || '';
120
+ label.style.fontSize = (Math.min(bw, bh) * 0.085).toFixed(1) + 'px';
121
+ paper.appendChild(label);
122
+ img.alt = '';
123
+ img.setAttribute('data-slot', 'page-' + (k + 1));
124
+ img.setAttribute('src', pics[k] || 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==');
125
+ img.style.objectFit = P.fit;
126
+ shade.className = 'shade';
127
+ page.appendChild(paper);
128
+ page.appendChild(img);
129
+ page.appendChild(shade);
130
+ book.appendChild(page);
131
+ pages.push({ page: page, shade: shade });
132
+ }
133
+ // The first page arrives at delay; page k comes when the page above it starts to go.
134
+ var later = [];
135
+ for (var n = 1; n < count; n++) later.push(labels[n] || '');
136
+ var at = [Number(P.delay)].concat(timesOf(later, Number(P.delay) + Number(P.stagger), Number(P.firstLine)));
137
+ var turn = Number(P.turn), dark = Number(P.shadow);
138
+
139
+ // Every frame from its time alone: page k goes from at[k + 1] over turn seconds; the one under it comes up.
140
+ var render = function (seconds) {
141
+ var e = out3((seconds - at[0]) / 0.45);
142
+ book.style.opacity = e.toFixed(4);
143
+ book.style.transform = 'translateY(' + ((1 - e) * 3).toFixed(3) + 'vh) scale(' + (0.95 + 0.05 * e).toFixed(4) + ')';
144
+ pages.forEach(function (p, k) {
145
+ var leave = k + 1 < count ? inOut((seconds - at[k + 1]) / turn) : 0;
146
+ var come = k > 0 ? inOut((seconds - at[k]) / turn) : 1;
147
+ p.page.style.visibility = leave >= 1 ? 'hidden' : 'visible';
148
+ if (P.style === 'book') {
149
+ p.page.style.transform = 'perspective(' + (bw * 2.2).toFixed(0) + 'px) rotateY(' + (-92 * leave).toFixed(3) + 'deg)';
150
+ p.shade.style.opacity = (dark * (leave * 1.2 + (1 - come))).toFixed(4);
151
+ } else if (P.style === 'stack') {
152
+ p.page.style.transform = 'translateY(' + (-118 * leave).toFixed(3) + '%) rotate(' + (-6 * leave).toFixed(3) + 'deg) scale(' + (0.94 + 0.06 * come).toFixed(4) + ')';
153
+ p.shade.style.opacity = (dark * 0.8 * (1 - come)).toFixed(4);
154
+ } else {
155
+ p.page.style.transform = 'translateX(' + ((k > 0 ? 1 - come : 0) * 100 - leave * 100).toFixed(3) + '%)';
156
+ p.shade.style.opacity = '0';
157
+ }
158
+ });
159
+ };
160
+ window.__popostScene = { render: render, cues: at.slice(1).map(function (t) { return { at: Math.round(t * 1000) / 1000, cue: 'whoosh', gain: 0.4 }; }) };
161
+ })();
162
+ </script>
163
+ </body></html>
@@ -0,0 +1,59 @@
1
+ /*
2
+ * popost-times.js: the voice's times in a scene of the popost Skill. Part of the popost Skill (CLIPCAT AI LTD), under
3
+ * the Skill's licence.
4
+ *
5
+ * The engine gives every scene the lines and the words that are spoken while its shot is on screen, in seconds of the
6
+ * shot: the time render(seconds) is given and the position of a tween on a timeline. Bring a thing on when it is said,
7
+ * and it moves with the voice when the narration is spoken again (another voice, a changed line, a faster reading).
8
+ * The times are there when the scene's script runs, before its first frame.
9
+ *
10
+ * popostTimes.line(2) seconds where the shot's 2nd line starts; undefined when it has fewer lines
11
+ * popostTimes.line(2, 1.4) ... or 1.4 when it has fewer (no voice: a sheet, a scene alone)
12
+ * popostTimes.lineEnd(2, 3) where that line ends
13
+ * popostTimes.word('price', 2.0) where the first spoken word that begins "price" starts (case, spaces and
14
+ * punctuation do not count; a word may run over several tokens)
15
+ * popostTimes.word('price', 2.0, popostTimes.line(3, 0)) the same, not before the 3rd line
16
+ * popostTimes.lines [{ at, end }] of every line that starts in the shot, in order
17
+ * popostTimes.words [{ text, at, end }] of every word that starts in the shot
18
+ * popostTimes.seconds the length of the shot (null without times)
19
+ * popostTimes.voiced whether the engine gave times
20
+ *
21
+ * A video without a voice gives the times of its caption lines; a shot in which nothing is said gives none, and every
22
+ * call returns what it was given to use otherwise.
23
+ */
24
+ (function () {
25
+ var KEY = 'popost-times=';
26
+ var given = null;
27
+ try {
28
+ var hash = String(location.hash || ''), at = hash.indexOf(KEY);
29
+ if (at >= 0) given = JSON.parse(decodeURIComponent(hash.slice(at + KEY.length)));
30
+ } catch (e) {
31
+ given = null;
32
+ }
33
+ var lines = given && Array.isArray(given.lines) ? given.lines : [];
34
+ var words = given && Array.isArray(given.words) ? given.words : [];
35
+ var plain = function (s) { return String(s).toLowerCase().replace(/[\s\p{P}\p{S}]+/gu, ''); };
36
+ var line = function (n, otherwise) { var l = lines[n - 1]; return l ? l.at : otherwise; };
37
+ var lineEnd = function (n, otherwise) { var l = lines[n - 1]; return l ? l.end : otherwise; };
38
+ var word = function (text, otherwise, after) {
39
+ var want = plain(text);
40
+ if (!want) return otherwise;
41
+ for (var i = 0; i < words.length; i++) {
42
+ if (after !== undefined && words[i].at < after - 0.001) continue;
43
+ var own = plain(words[i].text), joined = own;
44
+ for (var j = i + 1; j < words.length && joined.length < own.length + want.length; j++) joined += plain(words[j].text);
45
+ var found = joined.indexOf(want);
46
+ if (found >= 0 && found < Math.max(1, own.length)) return words[i].at;
47
+ }
48
+ return otherwise;
49
+ };
50
+ window.popostTimes = {
51
+ voiced: given !== null,
52
+ seconds: given && typeof given.seconds === 'number' ? given.seconds : null,
53
+ lines: lines,
54
+ words: words,
55
+ line: line,
56
+ lineEnd: lineEnd,
57
+ word: word,
58
+ };
59
+ })();