wiki-plugin-rcntimeline 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/client/rcntimeline.js +56 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,3 +49,5 @@ Part of the [RCN toolset](https://github.com/marpie1/rcn), MIT.
|
|
|
49
49
|
Marc Pierson and Claude Opus 5.5 · September 2026
|
|
50
50
|
|
|
51
51
|
**Walks** (0.3.0). A timeline made in the full tool can carry `walks`: readings that play one step at a time. **▶ Walk** under the timeline redraws each step's years, fades the other bars, and reads the words aloud with a caption; Space, ← →, Esc. Open in RCN Timeline and Save to wiki carry the walks both ways.
|
|
52
|
+
|
|
53
|
+
**Recorded voices** (0.3.1). A step may carry `voices`, people's own recordings of its words, made with ● Record in the timeline's walk editor: `{"<name>": {audio, say}}`. The walk plays a step's recording when it has one and the computer voice otherwise; a chooser in the walk bar picks whose, or the computer voice only (kept in `rcnWalkPrefs.speaker`).
|
package/client/rcntimeline.js
CHANGED
|
@@ -311,7 +311,7 @@
|
|
|
311
311
|
['Samantha', 'Daniel', 'Karen', 'Moira', 'Google UK English Female', 'Google US English', 'Microsoft Aria']
|
|
312
312
|
.map(p => vs.find(v => v.name.indexOf(p) === 0)).find(Boolean) || vs[0] || null
|
|
313
313
|
}
|
|
314
|
-
const stopVoice = () => { try { if (window.speechSynthesis) speechSynthesis.cancel() } catch (e) {} }
|
|
314
|
+
const stopVoice = () => { recHush(); try { if (window.speechSynthesis) speechSynthesis.cancel() } catch (e) {} }
|
|
315
315
|
// Say the words; done() runs once when they have been said. One utterance per
|
|
316
316
|
// sentence, because Chrome stops a long one after about fifteen seconds.
|
|
317
317
|
function walkSay (text, isCurrent, done) {
|
|
@@ -332,6 +332,55 @@
|
|
|
332
332
|
})
|
|
333
333
|
}
|
|
334
334
|
|
|
335
|
+
// People's own recordings of a step, made in the Graph Tool, Map or Timeline walk
|
|
336
|
+
// editor: step.voices = {name: {audio, say}}. A step plays its recording when it has
|
|
337
|
+
// one, else the computer voice. The listener picks whose, kept in this browser with
|
|
338
|
+
// the other walk settings (rcnWalkPrefs.speaker: '' any, '-' computer only, or a name).
|
|
339
|
+
let recAudio = null
|
|
340
|
+
const recOk = src => typeof src === 'string' && /^(data:audio\/|https?:\/\/|\/)/.test(src)
|
|
341
|
+
const recNames = st => st && st.voices ? Object.keys(st.voices).filter(n => st.voices[n] && recOk(st.voices[n].audio)) : []
|
|
342
|
+
const recSpeakers = walk => [...new Set(((walk && walk.steps) || []).flatMap(recNames))].sort()
|
|
343
|
+
function recSpeaker () {
|
|
344
|
+
try { return JSON.parse(localStorage.getItem('rcnWalkPrefs') || '{}').speaker || '' } catch (e) { return '' }
|
|
345
|
+
}
|
|
346
|
+
function recSetSpeaker (v) {
|
|
347
|
+
let p = {}
|
|
348
|
+
try { p = JSON.parse(localStorage.getItem('rcnWalkPrefs') || '{}') } catch (e) {}
|
|
349
|
+
p.speaker = v
|
|
350
|
+
try { localStorage.setItem('rcnWalkPrefs', JSON.stringify(p)) } catch (e) {}
|
|
351
|
+
}
|
|
352
|
+
function recSpeakerOptions (walk) {
|
|
353
|
+
const ns = recSpeakers(walk), cur = recSpeaker()
|
|
354
|
+
if (!ns.length) return ''
|
|
355
|
+
const opt = (v, label) => `<option value="${esc(v)}"${cur === v ? ' selected' : ''}>${esc(label)}</option>`
|
|
356
|
+
return opt('', 'Recorded voices') + ns.map(n => opt(n, 'Recorded: ' + n)).join('') + opt('-', 'Computer voice only')
|
|
357
|
+
}
|
|
358
|
+
function recHush () {
|
|
359
|
+
const a = recAudio
|
|
360
|
+
recAudio = null
|
|
361
|
+
if (a) { a.onended = a.onerror = null; try { a.pause() } catch (e) {} }
|
|
362
|
+
}
|
|
363
|
+
// Say a step: a person's recording when it has one, else the computer voice.
|
|
364
|
+
function walkSayStep (st, isCurrent, done) {
|
|
365
|
+
const ns = recNames(st), want = recSpeaker()
|
|
366
|
+
if (!walkPrefs().on || want === '-' || !ns.length) { walkSay(st.say, isCurrent, done); return }
|
|
367
|
+
try { if (window.speechSynthesis) speechSynthesis.cancel() } catch (e) {}
|
|
368
|
+
recHush()
|
|
369
|
+
const a = new Audio(st.voices[ns.includes(want) ? want : ns[0]].audio)
|
|
370
|
+
recAudio = a
|
|
371
|
+
let out = false
|
|
372
|
+
const fin = ok => {
|
|
373
|
+
if (out || recAudio !== a) return
|
|
374
|
+
out = true; recAudio = null
|
|
375
|
+
if (!isCurrent()) return
|
|
376
|
+
if (ok) done(); else walkSay(st.say, isCurrent, done)
|
|
377
|
+
}
|
|
378
|
+
a.onended = () => fin(true)
|
|
379
|
+
a.onerror = () => fin(false)
|
|
380
|
+
const p = a.play()
|
|
381
|
+
if (p && p.catch) p.catch(() => fin(false))
|
|
382
|
+
}
|
|
383
|
+
|
|
335
384
|
function walkBar (item) {
|
|
336
385
|
const ws = walkList(item)
|
|
337
386
|
if (!ws.length) return ''
|
|
@@ -348,6 +397,7 @@
|
|
|
348
397
|
<button class="walk-next" style="${b}display:none" title="Next step (→)">▶</button>
|
|
349
398
|
<span class="walk-count" style="display:none;font-size:12px;color:#64748b;min-width:70px;text-align:center"></span>
|
|
350
399
|
<button class="walk-voice" style="${b}display:none" title="Read the words aloud, or show them only"></button>
|
|
400
|
+
<select class="walk-speaker" style="font-size:12px;max-width:170px;display:none" title="Whose voice reads the walk (kept in this browser)"></select>
|
|
351
401
|
<button class="walk-close" style="${b}display:none" title="Stop the walk (Esc)">■ Stop</button>
|
|
352
402
|
</div>
|
|
353
403
|
<div class="walk-say" aria-live="polite" style="display:none;margin:8px 4px 0;padding:10px 12px;background:#fff;border:1px solid #c7d2fe;border-radius:8px;font-size:17px;line-height:1.45;color:#1e1b4b"></div>
|
|
@@ -370,6 +420,9 @@
|
|
|
370
420
|
$bar.find('.walk-say').toggle(open)
|
|
371
421
|
$bar.find('.walk-play').text(wk.playing ? '❚❚' : '▶')
|
|
372
422
|
$bar.find('.walk-voice').text(walkPrefs().on ? '🔈 Voice on' : '🔇 Voice off')
|
|
423
|
+
const so = open ? recSpeakerOptions(walk) : '', $sp = $bar.find('.walk-speaker')
|
|
424
|
+
if ($sp.data('opts') !== so) $sp.html(so).data('opts', so)
|
|
425
|
+
$sp.toggle(!!so)
|
|
373
426
|
$bar.find('.walk-count').text(open ? 'Step ' + (wk.i + 1) + ' of ' + walk.steps.length : '')
|
|
374
427
|
$bar.find('.walk-note').text(note || (open && !wk.playing ? 'Space plays · ← → step · Esc stops' : ''))
|
|
375
428
|
}
|
|
@@ -377,7 +430,7 @@
|
|
|
377
430
|
const tok = ++wk.token, walk = cur(), st = walk && walk.steps[wk.i]
|
|
378
431
|
if (!st) return
|
|
379
432
|
wk.heard = wk.i
|
|
380
|
-
|
|
433
|
+
walkSayStep(st, () => tok === wk.token && window.rcnActiveWalk === wk, () => {
|
|
381
434
|
const last = wk.i >= walk.steps.length - 1
|
|
382
435
|
if (st.ask || last) { wk.playing = false; ui(last && !st.ask ? 'End of the walk. ← to go back, Esc to stop.' : 'Over to you. Press Space or ▶ to go on.'); return }
|
|
383
436
|
setTimeout(() => { if (tok === wk.token && wk.playing) show(wk.i + 1) }, 800)
|
|
@@ -425,6 +478,7 @@
|
|
|
425
478
|
$item.on('click.rcntwalk', '.walk-prev', () => show(wk.i - 1))
|
|
426
479
|
$item.on('click.rcntwalk', '.walk-next', () => show(wk.i + 1))
|
|
427
480
|
$item.on('click.rcntwalk', '.walk-close', () => end())
|
|
481
|
+
$item.on('change.rcntwalk', '.walk-speaker', e => { recSetSpeaker(e.target.value); if (wk.playing) speak() })
|
|
428
482
|
$item.on('click.rcntwalk', '.walk-voice', () => {
|
|
429
483
|
const on = !walkPrefs().on
|
|
430
484
|
try { localStorage.setItem('rcnWalkVoice', on ? 'on' : 'off') } catch (e) {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wiki-plugin-rcntimeline",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Federated Wiki plugin: a small RCN timeline on a page — intervals with fuzzy edges, the links between them, a date axis; each bar opens its page",
|
|
5
5
|
"keywords": ["wiki", "federated wiki", "plugin", "rcn", "timeline"],
|
|
6
6
|
"author": "RCN Network <rcn@relocalizecreativity.net>",
|