@pinecall/dot 0.0.0-stage → 0.11.22
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/LICENSE +202 -0
- package/README.md +316 -2
- package/dist/agent/index.d.ts +4 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +3 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/tutor.d.ts +67 -0
- package/dist/agent/tutor.d.ts.map +1 -0
- package/dist/agent/tutor.js +351 -0
- package/dist/agent/tutor.js.map +1 -0
- package/dist/face/draw.d.ts +43 -0
- package/dist/face/draw.d.ts.map +1 -0
- package/dist/face/draw.js +74 -0
- package/dist/face/draw.js.map +1 -0
- package/dist/face/ear.d.ts +23 -0
- package/dist/face/ear.d.ts.map +1 -0
- package/dist/face/ear.js +111 -0
- package/dist/face/ear.js.map +1 -0
- package/dist/face/index.d.ts +23 -0
- package/dist/face/index.d.ts.map +1 -0
- package/dist/face/index.js +138 -0
- package/dist/face/index.js.map +1 -0
- package/dist/face/motion.d.ts +25 -0
- package/dist/face/motion.d.ts.map +1 -0
- package/dist/face/motion.js +58 -0
- package/dist/face/motion.js.map +1 -0
- package/dist/face/mouth.d.ts +45 -0
- package/dist/face/mouth.d.ts.map +1 -0
- package/dist/face/mouth.js +61 -0
- package/dist/face/mouth.js.map +1 -0
- package/dist/face/shape.d.ts +15 -0
- package/dist/face/shape.d.ts.map +1 -0
- package/dist/face/shape.js +50 -0
- package/dist/face/shape.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/page/page.d.ts +34 -0
- package/dist/page/page.d.ts.map +1 -0
- package/dist/page/page.js +218 -0
- package/dist/page/page.js.map +1 -0
- package/dist/page/roles.d.ts +10 -0
- package/dist/page/roles.d.ts.map +1 -0
- package/dist/page/roles.js +87 -0
- package/dist/page/roles.js.map +1 -0
- package/dist/pointer/card.d.ts +13 -0
- package/dist/pointer/card.d.ts.map +1 -0
- package/dist/pointer/card.js +75 -0
- package/dist/pointer/card.js.map +1 -0
- package/dist/pointer/code.d.ts +21 -0
- package/dist/pointer/code.d.ts.map +1 -0
- package/dist/pointer/code.js +147 -0
- package/dist/pointer/code.js.map +1 -0
- package/dist/pointer/flight.d.ts +30 -0
- package/dist/pointer/flight.d.ts.map +1 -0
- package/dist/pointer/flight.js +92 -0
- package/dist/pointer/flight.js.map +1 -0
- package/dist/pointer/hover.d.ts +20 -0
- package/dist/pointer/hover.d.ts.map +1 -0
- package/dist/pointer/hover.js +96 -0
- package/dist/pointer/hover.js.map +1 -0
- package/dist/pointer/menu.d.ts +48 -0
- package/dist/pointer/menu.d.ts.map +1 -0
- package/dist/pointer/menu.js +252 -0
- package/dist/pointer/menu.js.map +1 -0
- package/dist/pointer/person.d.ts +91 -0
- package/dist/pointer/person.d.ts.map +1 -0
- package/dist/pointer/person.js +345 -0
- package/dist/pointer/person.js.map +1 -0
- package/dist/pointer/sections.d.ts +24 -0
- package/dist/pointer/sections.d.ts.map +1 -0
- package/dist/pointer/sections.js +64 -0
- package/dist/pointer/sections.js.map +1 -0
- package/dist/pointer/syntax.d.ts +10 -0
- package/dist/pointer/syntax.d.ts.map +1 -0
- package/dist/pointer/syntax.js +61 -0
- package/dist/pointer/syntax.js.map +1 -0
- package/dist/pointer/typing.d.ts +6 -0
- package/dist/pointer/typing.d.ts.map +1 -0
- package/dist/pointer/typing.js +62 -0
- package/dist/pointer/typing.js.map +1 -0
- package/dist/tutor/captions.d.ts +22 -0
- package/dist/tutor/captions.d.ts.map +1 -0
- package/dist/tutor/captions.js +62 -0
- package/dist/tutor/captions.js.map +1 -0
- package/dist/tutor/macro.d.ts +19 -0
- package/dist/tutor/macro.d.ts.map +1 -0
- package/dist/tutor/macro.js +67 -0
- package/dist/tutor/macro.js.map +1 -0
- package/dist/tutor/options.d.ts +42 -0
- package/dist/tutor/options.d.ts.map +1 -0
- package/dist/tutor/options.js +3 -0
- package/dist/tutor/options.js.map +1 -0
- package/dist/tutor/tutor.d.ts +14 -0
- package/dist/tutor/tutor.d.ts.map +1 -0
- package/dist/tutor/tutor.js +389 -0
- package/dist/tutor/tutor.js.map +1 -0
- package/dist/tutor/views.d.ts +27 -0
- package/dist/tutor/views.d.ts.map +1 -0
- package/dist/tutor/views.js +63 -0
- package/dist/tutor/views.js.map +1 -0
- package/dist/tutor/walking.d.ts +44 -0
- package/dist/tutor/walking.d.ts.map +1 -0
- package/dist/tutor/walking.js +142 -0
- package/dist/tutor/walking.js.map +1 -0
- package/dist/tutor/walks.d.ts +46 -0
- package/dist/tutor/walks.d.ts.map +1 -0
- package/dist/tutor/walks.js +112 -0
- package/dist/tutor/walks.js.map +1 -0
- package/dist/wire/index.d.ts +133 -0
- package/dist/wire/index.d.ts.map +1 -0
- package/dist/wire/index.js +204 -0
- package/dist/wire/index.js.map +1 -0
- package/package.json +53 -3
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/** A recorded walk played on the page with no call: its sentences in the agent's voice, their words lit as said, the beats on their words. */
|
|
2
|
+
//
|
|
3
|
+
// One audio element plays every sentence in turn: Safari lets an element the visitor's click
|
|
4
|
+
// started go on to its next source, where a new element would need another click. Each frame
|
|
5
|
+
// reads where the audio is, so the words and the pointer follow the sound, whatever the network.
|
|
6
|
+
import { walksOf } from "../wire/index.js";
|
|
7
|
+
import { Player } from "./macro.js";
|
|
8
|
+
/** The walks an agent published, read with no key; none where the page cannot read them. */
|
|
9
|
+
export async function publishedWalks(url) {
|
|
10
|
+
if (url === "")
|
|
11
|
+
return [];
|
|
12
|
+
try {
|
|
13
|
+
const answer = await fetch(url);
|
|
14
|
+
return answer.ok ? walksOf(await answer.json()) : [];
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** A walk's length, in ms. */
|
|
21
|
+
export function lengthOf(walk) {
|
|
22
|
+
return walk.steps.reduce((total, step) => total + step.durationMs, 0);
|
|
23
|
+
}
|
|
24
|
+
export class Walking {
|
|
25
|
+
audio;
|
|
26
|
+
#ended;
|
|
27
|
+
#shows;
|
|
28
|
+
#player = new Player();
|
|
29
|
+
#walk = null;
|
|
30
|
+
#step = 0;
|
|
31
|
+
#paused = false;
|
|
32
|
+
/**
|
|
33
|
+
* Play through `audio`; `ended` hears a walk that played to its end, or failed to play; `shows`
|
|
34
|
+
* hears each sentence as it starts, for what it shows beside the page, and null as the walk stops.
|
|
35
|
+
*/
|
|
36
|
+
constructor(audio, ended, shows = () => undefined) {
|
|
37
|
+
this.audio = audio;
|
|
38
|
+
this.#ended = ended;
|
|
39
|
+
this.#shows = shows;
|
|
40
|
+
// The ear reads the audio through Web Audio, which hears silence from a source fetched without CORS.
|
|
41
|
+
audio.crossOrigin = "anonymous";
|
|
42
|
+
audio.preload = "auto";
|
|
43
|
+
audio.addEventListener("ended", () => this.#next());
|
|
44
|
+
audio.addEventListener("error", () => this.#finish(false));
|
|
45
|
+
}
|
|
46
|
+
/** The walk playing, or null. */
|
|
47
|
+
get playing() {
|
|
48
|
+
return this.#walk;
|
|
49
|
+
}
|
|
50
|
+
/** Whether the walk playing is paused. */
|
|
51
|
+
get paused() {
|
|
52
|
+
return this.#paused;
|
|
53
|
+
}
|
|
54
|
+
/** Hold the walk where it is: the voice, and the words and beats that follow it. */
|
|
55
|
+
pause() {
|
|
56
|
+
if (this.#walk === null || this.#paused)
|
|
57
|
+
return;
|
|
58
|
+
this.#paused = true;
|
|
59
|
+
this.audio.pause();
|
|
60
|
+
}
|
|
61
|
+
/** Go on from where it was held. Call it from the visitor's click, as `start`. */
|
|
62
|
+
resume() {
|
|
63
|
+
if (this.#walk === null || !this.#paused)
|
|
64
|
+
return;
|
|
65
|
+
this.#paused = false;
|
|
66
|
+
this.audio.play().catch(() => this.#finish(false));
|
|
67
|
+
}
|
|
68
|
+
/** Play a walk from its first sentence. Call it from the visitor's click: a browser starts audio only inside one. */
|
|
69
|
+
start(walk) {
|
|
70
|
+
this.#walk = walk;
|
|
71
|
+
this.#step = 0;
|
|
72
|
+
this.#play();
|
|
73
|
+
}
|
|
74
|
+
/** Where the walk is now; null while none plays. */
|
|
75
|
+
frame() {
|
|
76
|
+
const walk = this.#walk;
|
|
77
|
+
const step = walk?.steps[this.#step];
|
|
78
|
+
if (walk === null || step === undefined)
|
|
79
|
+
return null;
|
|
80
|
+
const now = this.audio.currentTime * 1000;
|
|
81
|
+
const lit = step.words.filter((word) => word.startMs <= now).map((word) => word.text).join(" ");
|
|
82
|
+
const rest = step.words.filter((word) => word.startMs > now).map((word) => word.text).join(" ");
|
|
83
|
+
const before = walk.steps.slice(0, this.#step).reduce((total, one) => total + one.durationMs, 0);
|
|
84
|
+
return {
|
|
85
|
+
lit,
|
|
86
|
+
coming: lit !== "" && rest !== "" ? ` ${rest}` : rest,
|
|
87
|
+
beats: this.#player.due(this.#speech(walk), lit),
|
|
88
|
+
fraction: Math.min(1, (before + now) / Math.max(1, lengthOf(walk))),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/** Stop where it is: how far the visitor got, or null when nothing played. */
|
|
92
|
+
stop() {
|
|
93
|
+
const walk = this.#walk;
|
|
94
|
+
if (walk === null)
|
|
95
|
+
return null;
|
|
96
|
+
const walked = { walk: walk.name, step: this.#step + 1, of: walk.steps.length, done: false };
|
|
97
|
+
this.#reset();
|
|
98
|
+
return walked;
|
|
99
|
+
}
|
|
100
|
+
#play() {
|
|
101
|
+
const walk = this.#walk;
|
|
102
|
+
const step = walk?.steps[this.#step];
|
|
103
|
+
if (walk === null || step === undefined)
|
|
104
|
+
return;
|
|
105
|
+
const asStep = { type: "macro.step", macro: walk.name, step: this.#step, say: step.say, beats: step.beats };
|
|
106
|
+
this.#player.arm(asStep, null);
|
|
107
|
+
this.#shows(step);
|
|
108
|
+
this.audio.src = step.audio;
|
|
109
|
+
this.audio.play().catch(() => this.#finish(false));
|
|
110
|
+
}
|
|
111
|
+
#next() {
|
|
112
|
+
const walk = this.#walk;
|
|
113
|
+
if (walk === null)
|
|
114
|
+
return;
|
|
115
|
+
if (this.#step + 1 < walk.steps.length) {
|
|
116
|
+
this.#step += 1;
|
|
117
|
+
this.#play();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
this.#finish(true);
|
|
121
|
+
}
|
|
122
|
+
#finish(done) {
|
|
123
|
+
const walk = this.#walk;
|
|
124
|
+
if (walk === null)
|
|
125
|
+
return;
|
|
126
|
+
const walked = { walk: walk.name, step: done ? walk.steps.length : this.#step + 1, of: walk.steps.length, done };
|
|
127
|
+
this.#reset();
|
|
128
|
+
this.#ended(walked);
|
|
129
|
+
}
|
|
130
|
+
#reset() {
|
|
131
|
+
this.#walk = null;
|
|
132
|
+
this.#paused = false;
|
|
133
|
+
this.#player.drop();
|
|
134
|
+
this.#shows(null);
|
|
135
|
+
this.audio.pause();
|
|
136
|
+
}
|
|
137
|
+
// The player binds a step to a "speech": a sentence of the walk is its own.
|
|
138
|
+
#speech(walk) {
|
|
139
|
+
return `walk:${walk.name}:${this.#step}`;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=walking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walking.js","sourceRoot":"","sources":["../../src/tutor/walking.ts"],"names":[],"mappings":"AAAA,8IAA8I;AAC9I,EAAE;AACF,6FAA6F;AAC7F,6FAA6F;AAC7F,iGAAiG;AAEjG,OAAO,EAAE,OAAO,EAA8D,MAAM,kBAAkB,CAAC;AACvG,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAkBpC,4FAA4F;AAC5F,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,GAAW;IAC9C,IAAI,GAAG,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IAC1B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAChC,OAAO,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KAAK,CAAC;QACxB,IAAI,IAAI,KAAK,IAAI;YAAE,OAAO;QAC1B,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC;QACjH,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACpB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAClB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED,4EAA4E;IAC5E,OAAO,CAAC,IAAkB;QACxB,OAAO,QAAQ,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;IAC3C,CAAC;CACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** The walks beside the resting face, with no call: the button and its pills, the player, the code a step shows, and what the next call is told was played. */
|
|
2
|
+
import type { Face } from "../face/index.js";
|
|
3
|
+
import { CodeWindow } from "../pointer/code.js";
|
|
4
|
+
import type { Person } from "../pointer/person.js";
|
|
5
|
+
import { type WalkFrame, type Walked } from "./walking.js";
|
|
6
|
+
export interface WalksOptions {
|
|
7
|
+
dock: "right" | "left";
|
|
8
|
+
/** The button's name: "Walks". */
|
|
9
|
+
label: string;
|
|
10
|
+
/** The name of the button that shows the next walks: "More walks". */
|
|
11
|
+
more: string;
|
|
12
|
+
/** Where the agent published its walks; none offered without it. */
|
|
13
|
+
url: string | undefined;
|
|
14
|
+
/** Whether a call is opening or on: no walk plays over one. */
|
|
15
|
+
inCall: () => boolean;
|
|
16
|
+
/** Send the pointer back to its corner, after the moves already queued. */
|
|
17
|
+
home: () => void;
|
|
18
|
+
/** A walk started, ended or was stopped. */
|
|
19
|
+
onWalk?: ((walked: Walked) => void) | undefined;
|
|
20
|
+
/** Send the pointer onto an element, after the moves already queued: the lines a step lights. */
|
|
21
|
+
point: (element: Element) => void;
|
|
22
|
+
/** Reduced motion: the code is written in at once. */
|
|
23
|
+
still: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare class Walks {
|
|
26
|
+
#private;
|
|
27
|
+
/** The window of code a step opens; a call's macro steps open it too. */
|
|
28
|
+
readonly code: CodeWindow;
|
|
29
|
+
constructor(document: Document, person: Person, drawn: Face, options: WalksOptions);
|
|
30
|
+
/** Where the walk playing is now; null while none plays. */
|
|
31
|
+
frame(): WalkFrame | null;
|
|
32
|
+
get playing(): boolean;
|
|
33
|
+
get paused(): boolean;
|
|
34
|
+
/** Hold the walk playing, or go on with it: the visitor's pause button. */
|
|
35
|
+
pause(): void;
|
|
36
|
+
/** The section scrolled to offers its walk, and the site's own buttons show, while no call is on and no walk plays. Called every frame. */
|
|
37
|
+
place(): void;
|
|
38
|
+
/** Stop the walk playing, if one is: the visitor clicked the face, or a call began. */
|
|
39
|
+
stop(): void;
|
|
40
|
+
/** Whether the button may show: not during a call, nor while a walk plays. */
|
|
41
|
+
available(on: boolean): void;
|
|
42
|
+
/** The walk played since the last call, once: what the next call is told. */
|
|
43
|
+
taken(): Walked | null;
|
|
44
|
+
close(): void;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=walks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walks.d.ts","sourceRoot":"","sources":["../../src/tutor/walks.ts"],"names":[],"mappings":"AAAA,+JAA+J;AAE/J,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,O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IAAI,CAE3B;IAED,6EAA6E;IAC7E,KAAK,IAAI,MAAM,GAAG,IAAI,CAIrB;IAED,KAAK,IAAI,IAAI,CAKZ;CAqBF"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/** The walks beside the resting face, with no call: the button and its pills, the player, the code a step shows, and what the next call is told was played. */
|
|
2
|
+
import { CodeWindow } from "../pointer/code.js";
|
|
3
|
+
import { Sections } from "../pointer/sections.js";
|
|
4
|
+
import { Menu } from "../pointer/menu.js";
|
|
5
|
+
import { Walking, lengthOf, publishedWalks } from "./walking.js";
|
|
6
|
+
export class Walks {
|
|
7
|
+
/** The window of code a step opens; a call's macro steps open it too. */
|
|
8
|
+
code;
|
|
9
|
+
#walking;
|
|
10
|
+
#menu;
|
|
11
|
+
#sections;
|
|
12
|
+
#drawn;
|
|
13
|
+
#person;
|
|
14
|
+
#options;
|
|
15
|
+
#list = [];
|
|
16
|
+
#played = null;
|
|
17
|
+
constructor(document, person, drawn, options) {
|
|
18
|
+
this.#person = person;
|
|
19
|
+
this.#drawn = drawn;
|
|
20
|
+
this.#options = options;
|
|
21
|
+
this.code = new CodeWindow(document, (part) => person.add(part), options.still);
|
|
22
|
+
this.#walking = new Walking(document.createElement("audio"), (walked) => this.#ended(walked), (step) => {
|
|
23
|
+
// A step that names no code keeps the window as it is; the walk's end closes it.
|
|
24
|
+
if (step === null)
|
|
25
|
+
return this.code.hide();
|
|
26
|
+
const lit = this.code.show(step.code, step.lines);
|
|
27
|
+
if (lit !== null)
|
|
28
|
+
options.point(lit);
|
|
29
|
+
});
|
|
30
|
+
this.#menu = new Menu(document, (part) => person.add(part), {
|
|
31
|
+
dock: options.dock,
|
|
32
|
+
label: options.label,
|
|
33
|
+
more: options.more,
|
|
34
|
+
face: () => ({ at: person.dock(), radius: person.radius }),
|
|
35
|
+
onPick: (index) => this.#play(index),
|
|
36
|
+
});
|
|
37
|
+
const named = (name) => this.#list.findIndex((walk) => walk.name === name);
|
|
38
|
+
this.#sections = new Sections(document, {
|
|
39
|
+
onReach: (name) => this.#menu.suggest(named(name)),
|
|
40
|
+
onPlay: (name) => this.#play(named(name)),
|
|
41
|
+
});
|
|
42
|
+
void publishedWalks(options.url ?? "").then((found) => {
|
|
43
|
+
this.#list = found;
|
|
44
|
+
this.#menu.offer(found.map((walk) => ({ title: walk.title, ms: lengthOf(walk) })));
|
|
45
|
+
this.#sections.offer(found.map((walk) => walk.name));
|
|
46
|
+
this.#menu.available(!options.inCall());
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/** Where the walk playing is now; null while none plays. */
|
|
50
|
+
frame() {
|
|
51
|
+
return this.#walking.frame();
|
|
52
|
+
}
|
|
53
|
+
get playing() {
|
|
54
|
+
return this.#walking.playing !== null;
|
|
55
|
+
}
|
|
56
|
+
get paused() {
|
|
57
|
+
return this.#walking.paused;
|
|
58
|
+
}
|
|
59
|
+
/** Hold the walk playing, or go on with it: the visitor's pause button. */
|
|
60
|
+
pause() {
|
|
61
|
+
if (this.#walking.paused)
|
|
62
|
+
this.#walking.resume();
|
|
63
|
+
else
|
|
64
|
+
this.#walking.pause();
|
|
65
|
+
}
|
|
66
|
+
/** The section scrolled to offers its walk, and the site's own buttons show, while no call is on and no walk plays. Called every frame. */
|
|
67
|
+
place() {
|
|
68
|
+
this.#sections.place(!this.#options.inCall() && !this.playing);
|
|
69
|
+
}
|
|
70
|
+
/** Stop the walk playing, if one is: the visitor clicked the face, or a call began. */
|
|
71
|
+
stop() {
|
|
72
|
+
const walked = this.#walking.stop();
|
|
73
|
+
if (walked !== null)
|
|
74
|
+
this.#ended(walked);
|
|
75
|
+
}
|
|
76
|
+
/** Whether the button may show: not during a call, nor while a walk plays. */
|
|
77
|
+
available(on) {
|
|
78
|
+
this.#menu.available(on && !this.playing);
|
|
79
|
+
}
|
|
80
|
+
/** The walk played since the last call, once: what the next call is told. */
|
|
81
|
+
taken() {
|
|
82
|
+
const played = this.#played;
|
|
83
|
+
this.#played = null;
|
|
84
|
+
return played;
|
|
85
|
+
}
|
|
86
|
+
close() {
|
|
87
|
+
this.#walking.stop();
|
|
88
|
+
this.#menu.close();
|
|
89
|
+
this.#sections.close();
|
|
90
|
+
this.code.close();
|
|
91
|
+
}
|
|
92
|
+
#play(index) {
|
|
93
|
+
const walk = this.#list[index];
|
|
94
|
+
if (walk === undefined || this.#options.inCall())
|
|
95
|
+
return;
|
|
96
|
+
this.#drawn.wake();
|
|
97
|
+
this.#drawn.listen(this.#walking.audio);
|
|
98
|
+
this.#menu.available(false);
|
|
99
|
+
this.#walking.start(walk);
|
|
100
|
+
this.#options.onWalk?.({ walk: walk.name, step: 1, of: walk.steps.length, done: false });
|
|
101
|
+
}
|
|
102
|
+
#ended(walked) {
|
|
103
|
+
this.#played = walked;
|
|
104
|
+
this.#drawn.listen(null);
|
|
105
|
+
this.#person.progress(null);
|
|
106
|
+
this.code.hide();
|
|
107
|
+
this.#options.home();
|
|
108
|
+
this.#menu.available(!this.#options.inCall());
|
|
109
|
+
this.#options.onWalk?.(walked);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=walks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walks.js","sourceRoot":"","sources":["../../src/tutor/walks.ts"],"names":[],"mappings":"AAAA,+JAA+J;AAG/J,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAA+B,MAAM,cAAc,CAAC;AAsB9F,MAAM,OAAO,KAAK;IAChB,yEAAyE;IAChE,IAAI,CAAa;IACjB,QAAQ,CAAU;IAClB,KAAK,CAAO;IACZ,SAAS,CAAW;IACpB,MAAM,CAAO;IACb,OAAO,CAAS;IAChB,QAAQ,CAAe;IAChC,KAAK,GAAmB,EAAE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cursor and macro messages it takes. */
|
|
2
|
+
/** The topic the agent sends on, and the page's `onUi` hears. */
|
|
3
|
+
export declare const UI = "pinecall.ui";
|
|
4
|
+
/**
|
|
5
|
+
* The page as the visitor sees it now: `{ text, why, lines }`, sent when it changed; after a move onto an
|
|
6
|
+
* element ended, `why` is `moved` and `at` the ref it moved to, when there was one. `lines` are what the
|
|
7
|
+
* site wrote for the agent to say, beside the element each is about.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SEEN = "page.seen";
|
|
10
|
+
/** The `why` of the `page.seen` that answers a move onto an element. */
|
|
11
|
+
export declare const MOVED = "moved";
|
|
12
|
+
/** The visitor clicked something: `{ role, name }`. */
|
|
13
|
+
export declare const CLICKED = "page.clicked";
|
|
14
|
+
/** A target the agent named is not on the page: `{ target }`. A fresh `page.seen` follows. */
|
|
15
|
+
export declare const MISSING = "page.missing";
|
|
16
|
+
/** The visitor asked to hear an element's line, with its ▶: `{ at }`, the element's ref. */
|
|
17
|
+
export declare const EXPLAIN = "page.explain";
|
|
18
|
+
/** The visitor played one of the agent's walks with no call: `{ walk, step, of, done }`, sent as the next call opens. */
|
|
19
|
+
export declare const WALKED = "page.walked";
|
|
20
|
+
/** The name the agent publishes its recorded walks under, which the page reads with no key. */
|
|
21
|
+
export declare const WALKS = "walks";
|
|
22
|
+
/**
|
|
23
|
+
* What the pointer can do. `type` fills a field with what the visitor said: it never submits a form,
|
|
24
|
+
* clicks, or leaves the page for them, and never touches a password or a card.
|
|
25
|
+
*/
|
|
26
|
+
export declare const ACTIONS: readonly ["point", "highlight", "unhighlight", "scroll_to", "here", "home", "type"];
|
|
27
|
+
export type Action = (typeof ACTIONS)[number];
|
|
28
|
+
/** What the site wrote for the agent to say about one element, and the move it is said with. */
|
|
29
|
+
export interface Line {
|
|
30
|
+
/** The element's ref. */
|
|
31
|
+
at: string;
|
|
32
|
+
say: string;
|
|
33
|
+
do: "point" | "highlight" | "scroll_to";
|
|
34
|
+
}
|
|
35
|
+
/** One move of the pointer, as the agent sends it, on `target` for the moves that take one: a ref (`e12`), or a name as the screen shows it (`Questions`). */
|
|
36
|
+
export interface Cursor {
|
|
37
|
+
type: "cursor";
|
|
38
|
+
action: Action;
|
|
39
|
+
target?: string | undefined;
|
|
40
|
+
/** What `type` writes in the field: its text, or the option of a list to choose. */
|
|
41
|
+
text?: string | undefined;
|
|
42
|
+
}
|
|
43
|
+
/** A target that is a ref of the snapshot rather than a name. */
|
|
44
|
+
export declare const A_REF: RegExp;
|
|
45
|
+
/** One move of a macro, run as its word is said. `find` names the element as the snapshot does: `["button", "Book now"]`. */
|
|
46
|
+
export interface Beat {
|
|
47
|
+
word: string;
|
|
48
|
+
/** Which time the word is said in the step, from 1; the first by default. */
|
|
49
|
+
nth?: number | undefined;
|
|
50
|
+
do: Action;
|
|
51
|
+
find?: [role: string, name: string] | undefined;
|
|
52
|
+
}
|
|
53
|
+
/** A window of code a step opens beside the page: its title and its text. */
|
|
54
|
+
export interface CodeView {
|
|
55
|
+
title: string;
|
|
56
|
+
text: string;
|
|
57
|
+
}
|
|
58
|
+
/** What a step shows beside its words: a window of code opened (`code`), closed (`null`), the lines of it lit (from 1). */
|
|
59
|
+
export interface Shown {
|
|
60
|
+
code?: CodeView | null | undefined;
|
|
61
|
+
lines?: [from: number, to: number] | undefined;
|
|
62
|
+
}
|
|
63
|
+
/** One sentence of a macro and the moves hung on its words. */
|
|
64
|
+
export interface MacroStep extends Shown {
|
|
65
|
+
say: string;
|
|
66
|
+
beats: Beat[];
|
|
67
|
+
}
|
|
68
|
+
/** A guided walk an agent was given: `macros/<name>.json` in its folder. */
|
|
69
|
+
export interface Macro {
|
|
70
|
+
name: string;
|
|
71
|
+
/** What the visitor's button says: "Site tour". The name, when the file gives none. */
|
|
72
|
+
title?: string | undefined;
|
|
73
|
+
/** When to run it, in the words the model reads: "the visitor asks to be shown around". */
|
|
74
|
+
when?: string | undefined;
|
|
75
|
+
steps: MacroStep[];
|
|
76
|
+
}
|
|
77
|
+
/** A written word of a recorded sentence, and when it is said, in ms from the start of its audio. */
|
|
78
|
+
export interface TimedWord {
|
|
79
|
+
text: string;
|
|
80
|
+
startMs: number;
|
|
81
|
+
endMs: number;
|
|
82
|
+
}
|
|
83
|
+
/** One sentence of a recorded walk, as the page plays it: its audio, when each word is said, its beats. */
|
|
84
|
+
export interface RecordedStep extends Shown {
|
|
85
|
+
say: string;
|
|
86
|
+
audio: string;
|
|
87
|
+
durationMs: number;
|
|
88
|
+
words: TimedWord[];
|
|
89
|
+
beats: Beat[];
|
|
90
|
+
}
|
|
91
|
+
/** A walk recorded in the agent's voice, published for the page to play with no call. */
|
|
92
|
+
export interface RecordedWalk {
|
|
93
|
+
name: string;
|
|
94
|
+
title: string;
|
|
95
|
+
when?: string | undefined;
|
|
96
|
+
/** The voice it was recorded in, as the gateway names it: `cartesia sonic-3 f786b574…`. */
|
|
97
|
+
voice?: string | undefined;
|
|
98
|
+
steps: RecordedStep[];
|
|
99
|
+
}
|
|
100
|
+
/** The agent asking for the page as it is now: sent when its call opens, answered with `page.seen`. */
|
|
101
|
+
export interface Look {
|
|
102
|
+
type: "look";
|
|
103
|
+
}
|
|
104
|
+
/** A step about to be said, sent just before the agent says it. */
|
|
105
|
+
export interface Step extends Shown {
|
|
106
|
+
type: "macro.step";
|
|
107
|
+
macro: string;
|
|
108
|
+
step: number;
|
|
109
|
+
say: string;
|
|
110
|
+
beats: Beat[];
|
|
111
|
+
}
|
|
112
|
+
/** A macro said to its end in a call: what it showed beside the page goes. */
|
|
113
|
+
export interface Done {
|
|
114
|
+
type: "macro.done";
|
|
115
|
+
macro: string;
|
|
116
|
+
}
|
|
117
|
+
/** What a step shows, checked; null for one that is not: a window with no title or text, lines out of order. */
|
|
118
|
+
export declare function shownOf(fields: Record<string, unknown>): Shown | null;
|
|
119
|
+
/** A message on `pinecall.ui` the tutor carries out, or null for one that is not its own (a card, choices). */
|
|
120
|
+
export declare function tutoring(data: unknown): Cursor | Step | Look | Done | null;
|
|
121
|
+
/** The lines a `page.seen` carries, each checked; anything else in it is left out. */
|
|
122
|
+
export declare function linesOf(value: unknown): Line[];
|
|
123
|
+
/** The walks a published document holds, each checked: a walk with any step that is not one is left out. */
|
|
124
|
+
export declare function walksOf(value: unknown): RecordedWalk[];
|
|
125
|
+
/** A macro as its JSON file says it, checked; it throws naming what is wrong, at the class's load. */
|
|
126
|
+
export declare function macroOf(name: string, value: unknown): Macro;
|
|
127
|
+
/** A length in ms as a clock says it: `0:38`. */
|
|
128
|
+
export declare function clock(ms: number): string;
|
|
129
|
+
/** A word as two texts are compared: lower case, letters and digits alone. */
|
|
130
|
+
export declare function normal(word: string): string;
|
|
131
|
+
/** A sentence's words, normalised, the empty ones left out. */
|
|
132
|
+
export declare function wordsOf(text: string): string[];
|
|
133
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wire/index.ts"],"names":[],"mappings":"AAAA,0HAA0H;AAM1H,iEAAiE;AACjE,eAAO,MAAM,EAAE,gBAAgB,CAAC;AAEhC;;;;GAIG;AACH,eAAO,MAAM,IAAI,cAAc,CAAC;AAChC,wEAAwE;AACxE,eAAO,MAAM,KAAK,UAAU,CAAC;AAC7B,uDAAuD;AACvD,eAAO,MAAM,OAAO,iBAAiB,CAAC;AACtC,8FAA8F;AAC9F,eAAO,MAAM,OAAO,iBAAiB,CAAC;AACtC,4FAA4F;AAC5F,eAAO,MAAM,OAAO,iBAAiB,CAAC;AACtC,yHAAyH;AACzH,eAAO,MAAM,MAAM,gBAAgB,CAAC;AACpC,+FAA+F;AAC/F,eAAO,MAAM,KAAK,UAAU,CAAC;AAE7B;;;GAGG;AACH,eAAO,MAAM,OAAO,YAAI,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAC3G,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,OAAO,CAA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