slidetake 0.5.1 → 0.5.3
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/README.md +2 -2
- package/dist/index.html +41 -58
- package/dist/slidetake.js +42 -37
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -98,14 +98,14 @@ window.SLIDETAKE = {
|
|
|
98
98
|
recording: false // optional: true brings back ● Studio, for your own preview
|
|
99
99
|
};
|
|
100
100
|
</script>
|
|
101
|
-
<script src="https://cdn.jsdelivr.net/npm/slidetake@0.5.
|
|
101
|
+
<script src="https://cdn.jsdelivr.net/npm/slidetake@0.5.3/dist/slidetake.js"></script>
|
|
102
102
|
```
|
|
103
103
|
|
|
104
104
|
`colors` takes any CSS colour per token, for both modes or under `light` / `dark`: `accent` (text and the current slide), `accentSoft` (smaller headings), `line` (borders and the active path), `ring` (the current slide's outline), `header` and `headerText` (a band of colour behind the header). A deck can also set its own with `accent:` in its top block.
|
|
105
105
|
|
|
106
106
|
Load it from npm through a CDN (pin the version, as above), or copy `dist/slidetake.js` into your site, or `npm install slidetake` and serve `node_modules/slidetake/dist/slidetake.js`.
|
|
107
107
|
|
|
108
|
-
The page then shows that deck as a viewer: read-only, with no editor, camera or Studio, and no bottom bar. The header carries Slidetake, the layouts, light/dark, Keys and Fullscreen. See [examples/embed.html](examples/embed.html); the [hugo-continuum](https://github.com/sakthipriyan/hugo-continuum) theme uses it for slide pages with `engine: slidetake`.
|
|
108
|
+
The page then shows that deck as a viewer: read-only, with no editor, camera or Studio, and no bottom bar. The header carries Slidetake, the layouts, and icons for light/dark, Keys and Fullscreen. See [examples/embed.html](examples/embed.html); the [hugo-continuum](https://github.com/sakthipriyan/hugo-continuum) theme uses it for slide pages with `engine: slidetake`.
|
|
109
109
|
|
|
110
110
|
To record a video of an embedded deck, open its markdown on slidetake.com or with `npx slidetake`, or set `recording: true` on a page only you see, such as your site's local preview: the page gets ● Studio, Camera and the bottom bar, as on slidetake.com. hugo-continuum does this under `hugo server`, so the live site stays a viewer. `accent:`, `brand:` and `logo:` in a deck's top block give the video your site's look.
|
|
111
111
|
|
package/dist/index.html
CHANGED
|
@@ -186,9 +186,11 @@
|
|
|
186
186
|
#editor-resizer{flex:none;width:6px;margin-right:-3px;margin-left:-3px;z-index:5;cursor:col-resize;position:relative;}
|
|
187
187
|
#editor-resizer:hover, main.resizing #editor-resizer{background:var(--accent-line, var(--accent));opacity:.6;}
|
|
188
188
|
#editor-resizer:has(+ #editor-pane.collapsed){display:none;}
|
|
189
|
-
|
|
190
|
-
.pane-
|
|
191
|
-
|
|
189
|
+
/* two lines: the buttons, then what the text below is (the deck, read-only or your copy) */
|
|
190
|
+
.pane-bar{flex:none;display:flex;flex-direction:column;align-items:stretch;gap:8px;padding:8px 10px 8px 14px;border-bottom:1px solid var(--panel-line);}
|
|
191
|
+
.pane-actions{display:flex;gap:6px;flex-wrap:wrap;}
|
|
192
|
+
.pane-state{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:24px;}
|
|
193
|
+
#doc-state{text-transform:none;letter-spacing:.02em;font-size:11px;min-width:0;flex:1 1 auto;flex-shrink:1;}
|
|
192
194
|
#doc-state .ro{color:var(--text-muted);}
|
|
193
195
|
#doc-state .mine{color:var(--text);}
|
|
194
196
|
#doc-state .edited{color:var(--accent);}
|
|
@@ -1242,15 +1244,18 @@
|
|
|
1242
1244
|
<div id="editor-resizer" role="separator" aria-orientation="vertical" aria-label="Resize the editor" title="Drag to resize"></div>
|
|
1243
1245
|
<div id="editor-pane" class="collapsed">
|
|
1244
1246
|
<div class="pane-bar">
|
|
1245
|
-
<span class="pane-label" id="doc-state" aria-live="polite"></span>
|
|
1246
1247
|
<span class="pane-actions">
|
|
1247
|
-
<a class="btn small" id="continue" href="/edit" hidden></a>
|
|
1248
1248
|
<a class="btn small" id="btn-new" href="/new" title="Start from a template">New</a>
|
|
1249
1249
|
<button class="btn small" id="btn-load" title="Load a deck from a link: GitHub, a gist or any URL">⇣ Load</button>
|
|
1250
1250
|
<button class="btn small" id="btn-open" title="Open a markdown file from this computer">Open</button>
|
|
1251
1251
|
<button class="btn small" id="btn-save" title="Save the markdown to a file on this computer">Save</button>
|
|
1252
1252
|
<button class="btn small" id="btn-share" title="Copy a link to this deck">Share</button>
|
|
1253
1253
|
</span>
|
|
1254
|
+
<!-- what the text below is: the deck, and whether typing makes your copy -->
|
|
1255
|
+
<span class="pane-state">
|
|
1256
|
+
<span class="pane-label" id="doc-state" aria-live="polite"></span>
|
|
1257
|
+
<a class="btn small" id="continue" href="/edit" hidden></a>
|
|
1258
|
+
</span>
|
|
1254
1259
|
</div>
|
|
1255
1260
|
<textarea id="editor" spellcheck="false"></textarea>
|
|
1256
1261
|
<div id="status-line"><span id="status-count"></span><span id="status-err" class="err"></span><button id="btn-reset" hidden title="Discard your edits and go back to the original">reset to original</button></div>
|
|
@@ -2277,6 +2282,7 @@
|
|
|
2277
2282
|
return out;
|
|
2278
2283
|
}
|
|
2279
2284
|
var afterPrevious = (prev, t) => t > prev ? t : prev + 1e-3;
|
|
2285
|
+
var leadIn = (first) => first > 1 / FPS ? first : 0;
|
|
2280
2286
|
var deviceName = (label) => label.replace(/\s*\([0-9a-f]{4}:[0-9a-f]{4}\)\s*$/i, "");
|
|
2281
2287
|
var sizeName = (w, h) => Math.min(w, h) + "p" + (h > w ? " portrait" : "");
|
|
2282
2288
|
|
|
@@ -3925,12 +3931,7 @@
|
|
|
3925
3931
|
const auto = autoEntrance(n);
|
|
3926
3932
|
if (auto && auto.length) {
|
|
3927
3933
|
n._auto = auto;
|
|
3928
|
-
|
|
3929
|
-
if (/^H[1-3]$/.test(head.tagName) && !head.children.length) {
|
|
3930
|
-
head.classList.add("auto-scramble");
|
|
3931
|
-
scramble(head);
|
|
3932
|
-
} else rest.unshift(head);
|
|
3933
|
-
gsap.from(rest, { opacity: 0, y: 24, duration: 0.7, ease: "power2.out", delay: 0.5, stagger: 0.45 });
|
|
3934
|
+
gsap.from(auto, { opacity: 0, y: 24, duration: 0.7, ease: "power2.out", delay: 0.3, stagger: 0.45 });
|
|
3934
3935
|
}
|
|
3935
3936
|
n.el.querySelectorAll("[data-gsap]").forEach((el) => {
|
|
3936
3937
|
let cfg;
|
|
@@ -3966,7 +3967,7 @@
|
|
|
3966
3967
|
const props = new Set(Object.keys(Object.assign({}, cfg.from, cfg.to)).map((k) => TRANSFORM_PROPS.includes(k) ? "transform" : k));
|
|
3967
3968
|
if (props.size) gsap.set(el, { clearProps: [...props].join(",") });
|
|
3968
3969
|
});
|
|
3969
|
-
n.el.querySelectorAll(".title-scramble
|
|
3970
|
+
n.el.querySelectorAll(".title-scramble").forEach((el) => {
|
|
3970
3971
|
if (el._scramble) el._scramble.kill();
|
|
3971
3972
|
if (el.dataset.text) el.textContent = el.dataset.text;
|
|
3972
3973
|
});
|
|
@@ -4580,13 +4581,14 @@
|
|
|
4580
4581
|
var recMode = load("slidetake:rec-mode") || "";
|
|
4581
4582
|
var recNote = "";
|
|
4582
4583
|
var meter = null;
|
|
4584
|
+
var SHARE_BAR = 96;
|
|
4583
4585
|
function browserRecording() {
|
|
4584
4586
|
const md = navigator.mediaDevices;
|
|
4585
4587
|
if (!window.isSecureContext || !md || !md.getDisplayMedia) return { why: "This page can\u2019t capture itself here. Open Slidetake in Chrome or Edge on a computer." };
|
|
4586
4588
|
if (!window.RestrictionTarget && !window.CropTarget) return { why: "Recording in the browser needs Chrome or Edge (or another Chromium browser) on a computer." };
|
|
4587
4589
|
const type = window.MediaRecorder ? recordingType((t) => MediaRecorder.isTypeSupported(t)) : "";
|
|
4588
4590
|
if (!type || !navigator.storage || !navigator.storage.getDirectory) return { why: "This browser can\u2019t record video here. Use a recent Chrome or Edge." };
|
|
4589
|
-
const { quality, device } = bestQuality(screen.width, screen.height, devicePixelRatio || 1, isPortrait());
|
|
4591
|
+
const { quality, device } = bestQuality(screen.width, screen.height - SHARE_BAR, devicePixelRatio || 1, isPortrait());
|
|
4590
4592
|
if (!quality) return { why: "This screen gives a " + device[0] + "\xD7" + device[1] + " frame, less than 720p. Use pro mode (OBS), or a larger screen." };
|
|
4591
4593
|
return { ok: true, type, quality };
|
|
4592
4594
|
}
|
|
@@ -4876,37 +4878,13 @@
|
|
|
4876
4878
|
if (window.RestrictionTarget && track.restrictTo) await track.restrictTo(await RestrictionTarget.fromElement(stageWrap));
|
|
4877
4879
|
else await track.cropTo(await CropTarget.fromElement(stageWrap));
|
|
4878
4880
|
}
|
|
4879
|
-
function
|
|
4880
|
-
const
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
canvas.height = h;
|
|
4887
|
-
const ctx = (
|
|
4888
|
-
/** @type {CanvasRenderingContext2D} */
|
|
4889
|
-
canvas.getContext("2d", { alpha: false })
|
|
4890
|
-
);
|
|
4891
|
-
let live = true;
|
|
4892
|
-
const draw = () => {
|
|
4893
|
-
if (!live) return;
|
|
4894
|
-
const vw = video.videoWidth, vh = video.videoHeight;
|
|
4895
|
-
if (vw && vh) {
|
|
4896
|
-
const s = Math.max(w / vw, h / vh), dw = vw * s, dh = vh * s;
|
|
4897
|
-
ctx.drawImage(video, (w - dw) / 2, (h - dh) / 2, dw, dh);
|
|
4898
|
-
}
|
|
4899
|
-
video.requestVideoFrameCallback(draw);
|
|
4900
|
-
};
|
|
4901
|
-
video.requestVideoFrameCallback(draw);
|
|
4902
|
-
video.play().catch(() => {
|
|
4903
|
-
});
|
|
4904
|
-
const out = canvas.captureStream(FPS).getVideoTracks()[0];
|
|
4905
|
-
return { track: out, stop() {
|
|
4906
|
-
live = false;
|
|
4907
|
-
out.stop();
|
|
4908
|
-
video.srcObject = null;
|
|
4909
|
-
} };
|
|
4881
|
+
function fittedQuality(q) {
|
|
4882
|
+
const dpr = devicePixelRatio || 1, w = stageWrap.clientWidth * dpr, h = stageWrap.clientHeight * dpr;
|
|
4883
|
+
const down = QUALITIES.slice(QUALITIES.indexOf(q));
|
|
4884
|
+
return down.find((x) => {
|
|
4885
|
+
const t = turned(x, isPortrait());
|
|
4886
|
+
return w >= t.w - 2 && h >= t.h - 2;
|
|
4887
|
+
}) || down[down.length - 1];
|
|
4910
4888
|
}
|
|
4911
4889
|
async function reattachCapture(b) {
|
|
4912
4890
|
try {
|
|
@@ -4915,7 +4893,12 @@
|
|
|
4915
4893
|
await attachCapture(b.track);
|
|
4916
4894
|
} catch (e) {
|
|
4917
4895
|
}
|
|
4918
|
-
|
|
4896
|
+
const fit = fittedQuality(b.quality);
|
|
4897
|
+
if (fit !== b.quality) {
|
|
4898
|
+
showToast("Recording at " + fit.name + ": the frame on this screen is too small for " + b.quality.name + ".", 5e3);
|
|
4899
|
+
b.quality = fit;
|
|
4900
|
+
}
|
|
4901
|
+
await b.track.applyConstraints(outputSize(b.quality)).catch((e) => console.warn("Slidetake: the recording size was refused", e));
|
|
4919
4902
|
await nextFrame();
|
|
4920
4903
|
}
|
|
4921
4904
|
async function beginBrowserCapture() {
|
|
@@ -4943,8 +4926,7 @@
|
|
|
4943
4926
|
stopAll();
|
|
4944
4927
|
throw new Error("Chrome could not record just the slides (" + (e.message || e.name) + ").");
|
|
4945
4928
|
}
|
|
4946
|
-
|
|
4947
|
-
if (!scaled) await track.applyConstraints(outputSize(quality)).catch((e) => console.warn("Slidetake: the recording size was refused", e));
|
|
4929
|
+
await track.applyConstraints(outputSize(quality)).catch((e) => console.warn("Slidetake: the recording size was refused", e));
|
|
4948
4930
|
let mic;
|
|
4949
4931
|
try {
|
|
4950
4932
|
const id2 = load("slidetake:mic");
|
|
@@ -4961,8 +4943,7 @@
|
|
|
4961
4943
|
track,
|
|
4962
4944
|
quality,
|
|
4963
4945
|
type: b.type,
|
|
4964
|
-
|
|
4965
|
-
stream: new MediaStream([scaled ? scaled.track : track, ...mic.getAudioTracks()]),
|
|
4946
|
+
stream: new MediaStream([track, ...mic.getAudioTracks()]),
|
|
4966
4947
|
dir: await takesDir(id, true),
|
|
4967
4948
|
clips: [],
|
|
4968
4949
|
cur: null,
|
|
@@ -4978,7 +4959,6 @@
|
|
|
4978
4959
|
if (!b) return;
|
|
4979
4960
|
b.display.getTracks().forEach((t) => t.stop());
|
|
4980
4961
|
b.mic.getTracks().forEach((t) => t.stop());
|
|
4981
|
-
if (b.scaled) b.scaled.stop();
|
|
4982
4962
|
setRecFrame(false);
|
|
4983
4963
|
}
|
|
4984
4964
|
function startClip(ev) {
|
|
@@ -5786,21 +5766,23 @@
|
|
|
5786
5766
|
await out.start();
|
|
5787
5767
|
}
|
|
5788
5768
|
const vMeta = { decoderConfig: await vt.getDecoderConfig() };
|
|
5769
|
+
const firstPk = await new MB.EncodedPacketSink(vt).getFirstPacket();
|
|
5770
|
+
const t0 = leadIn(firstPk ? firstPk.timestamp : 0);
|
|
5789
5771
|
let end = 0, first = true;
|
|
5790
5772
|
for await (const pk of new MB.EncodedPacketSink(vt).packets()) {
|
|
5791
5773
|
if (pk.timestamp >= part.keep) continue;
|
|
5792
|
-
lastV = afterPrevious(lastV, offset + pk.timestamp);
|
|
5774
|
+
lastV = afterPrevious(lastV, offset + pk.timestamp - t0);
|
|
5793
5775
|
await vSrc.add(pk.clone({ timestamp: lastV }), first && i === 0 ? vMeta : void 0);
|
|
5794
5776
|
first = false;
|
|
5795
|
-
end = Math.max(end, pk.timestamp + pk.duration);
|
|
5777
|
+
end = Math.max(end, pk.timestamp - t0 + pk.duration);
|
|
5796
5778
|
}
|
|
5797
5779
|
if (at && aSrc && reencode) {
|
|
5798
|
-
for await (const smp of new MB.AudioSampleSink(at).samples(
|
|
5799
|
-
if (smp.timestamp + smp.duration > end + 1e-4) {
|
|
5780
|
+
for await (const smp of new MB.AudioSampleSink(at).samples(t0, t0 + end)) {
|
|
5781
|
+
if (smp.timestamp < t0 - 1e-4 || smp.timestamp - t0 + smp.duration > end + 1e-4) {
|
|
5800
5782
|
smp.close();
|
|
5801
5783
|
continue;
|
|
5802
5784
|
}
|
|
5803
|
-
lastA = afterPrevious(lastA, offset + smp.timestamp);
|
|
5785
|
+
lastA = afterPrevious(lastA, offset + smp.timestamp - t0);
|
|
5804
5786
|
const planes = planesOf(smp);
|
|
5805
5787
|
planes.forEach((p) => {
|
|
5806
5788
|
for (let k = 0; k < p.length; k++) p[k] *= gain;
|
|
@@ -5822,8 +5804,8 @@
|
|
|
5822
5804
|
const aMeta = { decoderConfig: await at.getDecoderConfig() };
|
|
5823
5805
|
let aFirst = true;
|
|
5824
5806
|
for await (const pk of new MB.EncodedPacketSink(at).packets()) {
|
|
5825
|
-
if (pk.timestamp + pk.duration > end + 1e-4) continue;
|
|
5826
|
-
lastA = afterPrevious(lastA, offset + pk.timestamp);
|
|
5807
|
+
if (pk.timestamp < t0 - 1e-4 || pk.timestamp - t0 + pk.duration > end + 1e-4) continue;
|
|
5808
|
+
lastA = afterPrevious(lastA, offset + pk.timestamp - t0);
|
|
5827
5809
|
await aSrc.add(pk.clone({ timestamp: lastA }), aFirst && i === 0 ? aMeta : void 0);
|
|
5828
5810
|
aFirst = false;
|
|
5829
5811
|
}
|
|
@@ -6709,9 +6691,10 @@
|
|
|
6709
6691
|
const actions = document.querySelector("header .hdr-actions");
|
|
6710
6692
|
actions.insertBefore(credit, actions.firstChild);
|
|
6711
6693
|
if (!RECORDING_UI) {
|
|
6694
|
+
const svg2 = (d) => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">' + d + "</svg>";
|
|
6712
6695
|
actions.insertAdjacentHTML(
|
|
6713
6696
|
"beforeend",
|
|
6714
|
-
'<button class="btn" id="hdr-keys" title="Keyboard shortcuts (K)"
|
|
6697
|
+
'<button class="btn icon" id="hdr-keys" title="Keyboard shortcuts (K)" aria-label="Keyboard shortcuts">' + svg2('<rect x="2" y="5" width="20" height="14" rx="2"/><path d="M6 9h.01M10 9h.01M14 9h.01M18 9h.01M6 13h.01M18 13h.01M8 16h8M10 13h4"/>') + '</button><button class="btn icon" id="hdr-full" title="Fullscreen (F)" aria-label="Fullscreen">' + svg2('<path d="M8 3H5a2 2 0 0 0-2 2v3M21 8V5a2 2 0 0 0-2-2h-3M3 16v3a2 2 0 0 0 2 2h3M16 21h3a2 2 0 0 0 2-2v-3"/>') + "</button>"
|
|
6715
6698
|
);
|
|
6716
6699
|
document.getElementById("hdr-keys").onclick = () => document.getElementById("help").classList.add("open");
|
|
6717
6700
|
document.getElementById("hdr-full").onclick = () => setPresent(!presenting);
|