@pinecall/dot 0.11.24 → 0.11.26
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 +135 -59
- package/dist/agent/index.d.ts +3 -2
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +2 -1
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/tutor.d.ts +8 -10
- package/dist/agent/tutor.d.ts.map +1 -1
- package/dist/agent/tutor.js +71 -74
- package/dist/agent/tutor.js.map +1 -1
- package/dist/agent/walks.d.ts +19 -0
- package/dist/agent/walks.d.ts.map +1 -0
- package/dist/agent/walks.js +89 -0
- package/dist/agent/walks.js.map +1 -0
- package/dist/page/page.d.ts +2 -2
- package/dist/page/page.d.ts.map +1 -1
- package/dist/page/page.js +5 -5
- package/dist/page/page.js.map +1 -1
- package/dist/page/roles.d.ts +2 -0
- package/dist/page/roles.d.ts.map +1 -1
- package/dist/page/roles.js +21 -2
- package/dist/page/roles.js.map +1 -1
- package/dist/pointer/asking.d.ts +25 -0
- package/dist/pointer/asking.d.ts.map +1 -0
- package/dist/pointer/asking.js +82 -0
- package/dist/pointer/asking.js.map +1 -0
- package/dist/pointer/flight.d.ts +28 -0
- package/dist/pointer/flight.d.ts.map +1 -1
- package/dist/pointer/flight.js +93 -7
- package/dist/pointer/flight.js.map +1 -1
- package/dist/pointer/frames.d.ts +28 -0
- package/dist/pointer/frames.d.ts.map +1 -0
- package/dist/pointer/frames.js +66 -0
- package/dist/pointer/frames.js.map +1 -0
- package/dist/pointer/icons.d.ts +8 -0
- package/dist/pointer/icons.d.ts.map +1 -0
- package/dist/pointer/icons.js +15 -0
- package/dist/pointer/icons.js.map +1 -0
- package/dist/pointer/menu.d.ts +3 -0
- package/dist/pointer/menu.d.ts.map +1 -1
- package/dist/pointer/menu.js +26 -6
- package/dist/pointer/menu.js.map +1 -1
- package/dist/pointer/person.d.ts +13 -2
- package/dist/pointer/person.d.ts.map +1 -1
- package/dist/pointer/person.js +47 -41
- package/dist/pointer/person.js.map +1 -1
- package/dist/pointer/pressing.d.ts +6 -0
- package/dist/pointer/pressing.d.ts.map +1 -0
- package/dist/pointer/pressing.js +32 -0
- package/dist/pointer/pressing.js.map +1 -0
- package/dist/pointer/typing.d.ts +5 -3
- package/dist/pointer/typing.d.ts.map +1 -1
- package/dist/pointer/typing.js +46 -15
- package/dist/pointer/typing.js.map +1 -1
- package/dist/server/index.d.ts +34 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +108 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/questions.d.ts +30 -0
- package/dist/server/questions.d.ts.map +1 -0
- package/dist/server/questions.js +136 -0
- package/dist/server/questions.js.map +1 -0
- package/dist/server/saying.d.ts +31 -0
- package/dist/server/saying.d.ts.map +1 -0
- package/dist/server/saying.js +124 -0
- package/dist/server/saying.js.map +1 -0
- package/dist/tutor/acting.d.ts +42 -0
- package/dist/tutor/acting.d.ts.map +1 -0
- package/dist/tutor/acting.js +180 -0
- package/dist/tutor/acting.js.map +1 -0
- package/dist/tutor/aloud.d.ts +50 -0
- package/dist/tutor/aloud.d.ts.map +1 -0
- package/dist/tutor/aloud.js +288 -0
- package/dist/tutor/aloud.js.map +1 -0
- package/dist/tutor/ask.d.ts +49 -0
- package/dist/tutor/ask.d.ts.map +1 -0
- package/dist/tutor/ask.js +47 -0
- package/dist/tutor/ask.js.map +1 -0
- package/dist/tutor/listening.d.ts +17 -0
- package/dist/tutor/listening.d.ts.map +1 -0
- package/dist/tutor/listening.js +66 -0
- package/dist/tutor/listening.js.map +1 -0
- package/dist/tutor/options.d.ts +37 -1
- package/dist/tutor/options.d.ts.map +1 -1
- package/dist/tutor/options.js +1 -1
- package/dist/tutor/options.js.map +1 -1
- package/dist/tutor/reading.d.ts +58 -0
- package/dist/tutor/reading.d.ts.map +1 -0
- package/dist/tutor/reading.js +193 -0
- package/dist/tutor/reading.js.map +1 -0
- package/dist/tutor/text.d.ts +16 -0
- package/dist/tutor/text.d.ts.map +1 -0
- package/dist/tutor/text.js +119 -0
- package/dist/tutor/text.js.map +1 -0
- package/dist/tutor/tutor.d.ts +2 -9
- package/dist/tutor/tutor.d.ts.map +1 -1
- package/dist/tutor/tutor.js +109 -87
- package/dist/tutor/tutor.js.map +1 -1
- package/dist/tutor/walking.d.ts +20 -6
- package/dist/tutor/walking.d.ts.map +1 -1
- package/dist/tutor/walking.js +125 -25
- package/dist/tutor/walking.js.map +1 -1
- package/dist/tutor/walks.d.ts +33 -0
- package/dist/tutor/walks.d.ts.map +1 -1
- package/dist/tutor/walks.js +116 -10
- package/dist/tutor/walks.js.map +1 -1
- package/dist/wire/acts.d.ts +60 -0
- package/dist/wire/acts.d.ts.map +1 -0
- package/dist/wire/acts.js +120 -0
- package/dist/wire/acts.js.map +1 -0
- package/dist/wire/ask.d.ts +132 -0
- package/dist/wire/ask.d.ts.map +1 -0
- package/dist/wire/ask.js +102 -0
- package/dist/wire/ask.js.map +1 -0
- package/dist/wire/index.d.ts +26 -8
- package/dist/wire/index.d.ts.map +1 -1
- package/dist/wire/index.js +62 -11
- package/dist/wire/index.js.map +1 -1
- package/docs/macros.md +53 -3
- package/docs/write-a-tutor.md +26 -2
- package/package.json +8 -4
package/dist/tutor/options.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
/** What a page gives `tutor()`: where it rests, its colour and shape, whose words show, the walks it plays, and the views of its own tools. */
|
|
1
|
+
/** What a page gives `tutor()`: where it rests, its colour and shape, whose words show, the walks it plays, and the views of its own tools; and the tutor it hands back. */
|
|
2
2
|
import type { Shape } from "../face/shape.js";
|
|
3
|
+
import type { DoorRequest } from "../wire/ask.js";
|
|
3
4
|
import type { Captions } from "./captions.js";
|
|
4
5
|
import type { Views } from "./views.js";
|
|
5
6
|
import type { Walked } from "./walking.js";
|
|
@@ -26,8 +27,16 @@ export interface TutorOptions {
|
|
|
26
27
|
walks?: string | undefined;
|
|
27
28
|
stop?: string | undefined;
|
|
28
29
|
pause?: string | undefined;
|
|
30
|
+
/** The buttons that take a walk a sentence back and on: "Back", "Next". */
|
|
31
|
+
back?: string | undefined;
|
|
32
|
+
next?: string | undefined;
|
|
29
33
|
close?: string | undefined;
|
|
30
34
|
more?: string | undefined;
|
|
35
|
+
ask?: string | undefined;
|
|
36
|
+
askAgent?: string | undefined;
|
|
37
|
+
looking?: string | undefined;
|
|
38
|
+
notHere?: string | undefined;
|
|
39
|
+
forAgent?: string | undefined;
|
|
31
40
|
} | undefined;
|
|
32
41
|
/** Where the agent published its recorded walks (`GET …/v1/agents/{slug}/public/walks`): a button beside the face plays them with no call. */
|
|
33
42
|
walks?: string | undefined;
|
|
@@ -38,5 +47,32 @@ export interface TutorOptions {
|
|
|
38
47
|
* times, the booking form, a piece of code. Read each time a tool finishes, so a page may set it late.
|
|
39
48
|
*/
|
|
40
49
|
views?: Views | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* The site's door, on its own server, answered by `@pinecall/dot/server`'s `answer()`: what the visitor
|
|
52
|
+
* typed decided (`{ decide }`), the row of a table a walk read that answers them (`{ row }`), a walk's
|
|
53
|
+
* sentence with slots recorded (`{ say }`). Given, the walks' menu has a field: "Ask me to show you…".
|
|
54
|
+
*/
|
|
55
|
+
ask?: ((request: DoorRequest) => Promise<unknown>) | undefined;
|
|
56
|
+
/** With `ask`, the field in the walks' menu; false leaves it out, for a door that only reads the page aloud. Default true. */
|
|
57
|
+
typing?: boolean | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* The page read aloud in the agent's voice, with no call: what it marks `data-pinecall-read`, the part read lit and
|
|
60
|
+
* pointed at, its examples (`data-pinecall-press`) pressed on the way. The title of its pill, first in the walks' menu:
|
|
61
|
+
* "Leer el capítulo". Each part is recorded by the site's door (`{ read }`), so it takes `ask`.
|
|
62
|
+
*/
|
|
63
|
+
reading?: string | undefined;
|
|
64
|
+
/** What they typed, for a question the page cannot show: the site takes it to the agent (a call, it written in). */
|
|
65
|
+
onTalk?: ((message: string) => void) | undefined;
|
|
66
|
+
}
|
|
67
|
+
export interface Tutor {
|
|
68
|
+
/** A message the agent sent on `pinecall.ui`: true when it was the tutor's to carry out, false for a card or choices. */
|
|
69
|
+
take(data: unknown): boolean;
|
|
70
|
+
/** Let the face hear the voice: call it from the click that starts the call. */
|
|
71
|
+
wake(): void;
|
|
72
|
+
/** Read the page aloud (`reading`), from the visitor's click: a button of the site's own. */
|
|
73
|
+
read(): void;
|
|
74
|
+
/** Stop the walk or the reading playing, if one is: the site's own reason to (the visitor took over). */
|
|
75
|
+
stop(): void;
|
|
76
|
+
close(): void;
|
|
41
77
|
}
|
|
42
78
|
//# sourceMappingURL=options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/tutor/options.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/tutor/options.ts"],"names":[],"mappings":"AAAA,4KAA4K;AAE5K,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,WAAW,YAAY;IAC3B,+CAA+C;IAC/C,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;IACpC,oFAAoF;IACpF,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,kEAAkE;IAClE,OAAO,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IACnC,iHAAiH;IACjH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,sEAAsE;IACtE,K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OAIG;IACH,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAC/D,8HAA8H;IAC9H,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,oHAAoH;IACpH,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CAClD;AACD,MAAM,WAAW,KAAK;IACpB,yHAAyH;IACzH,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IAC7B,gFAAgF;IAChF,IAAI,IAAI,IAAI,CAAC;IACb,6FAA6F;IAC7F,IAAI,IAAI,IAAI,CAAC;IACb,yGAAyG;IACzG,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,IAAI,IAAI,CAAC;CACf"}
|
package/dist/tutor/options.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/** What a page gives `tutor()`: where it rests, its colour and shape, whose words show, the walks it plays, and the views of its own tools. */
|
|
1
|
+
/** What a page gives `tutor()`: where it rests, its colour and shape, whose words show, the walks it plays, and the views of its own tools; and the tutor it hands back. */
|
|
2
2
|
export {};
|
|
3
3
|
//# sourceMappingURL=options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/tutor/options.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/tutor/options.ts"],"names":[],"mappings":"AAAA,4KAA4K"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** A page read aloud with no call: what the site marks `data-pinecall-read`, part by part, in the agent's voice, the part read lit and pointed at; its examples pressed on the way. */
|
|
2
|
+
import type { RecordedWalk, WalkStep } from "../wire/index.js";
|
|
3
|
+
export { QUIET_ATTRIBUTE, lineIn, piecesOf, textOf, wordsOf } from "./text.js";
|
|
4
|
+
export declare const READ_ATTRIBUTE = "data-pinecall-read";
|
|
5
|
+
export declare const PRESS_ATTRIBUTE = "data-pinecall-press";
|
|
6
|
+
/** On a field: the words typed into it when the reading reaches it, the page's own example (a chat's question); the `data-pinecall-press` after it sends it. */
|
|
7
|
+
export declare const TYPE_ATTRIBUTE = "data-pinecall-type";
|
|
8
|
+
/** On a chat's send button: the dot talks to what it sends to, turn by turn, until it gets this (or the chat ends). */
|
|
9
|
+
export declare const GOAL_ATTRIBUTE = "data-pinecall-goal";
|
|
10
|
+
/** On each turn of a chat talked to: whose it is, `agent`, `caller` or another (a tool the agent used, `end`); all but the caller's read aloud as they come, by their `data-pinecall-say` when they have one. */
|
|
11
|
+
export declare const SAID_ATTRIBUTE = "data-pinecall-said";
|
|
12
|
+
/** On the output of a talk that is a spoken call: the agent is heard there, so its turns are not read aloud; the dot's own lines are said into it. */
|
|
13
|
+
export declare const HEARD_ATTRIBUTE = "data-pinecall-heard";
|
|
14
|
+
/** The event a spoken call's output is told the dot's line by, as the line starts: `detail.text`, `detail.audio` (its recording's URL) and `detail.durationMs`; the site plays it into the call. */
|
|
15
|
+
export declare const SAYING_EVENT = "pinecall-saying";
|
|
16
|
+
/** The line an element is said as, instead of what it shows: the same the agent says in a call. */
|
|
17
|
+
export declare const SAY_ATTRIBUTE = "data-pinecall-say";
|
|
18
|
+
/** What an example's output shows, said pointing at it once it answered. */
|
|
19
|
+
export declare const THEN_ATTRIBUTE = "data-pinecall-then";
|
|
20
|
+
/** On an example's button: the id of a list of notes on its output, each `data-pinecall-find` a text (or `/a regex/`) of a line of it. */
|
|
21
|
+
export declare const NOTES_ATTRIBUTE = "data-pinecall-notes";
|
|
22
|
+
export declare const FIND_ATTRIBUTE = "data-pinecall-find";
|
|
23
|
+
/** On an example's button: its output, when no note of the page's covers it, explained by the site's door; its value names the command. */
|
|
24
|
+
export declare const EXPLAIN_ATTRIBUTE = "data-pinecall-explain";
|
|
25
|
+
/** On an output while its notes are read, for the site to widen it: a box that scrolls shows whole. */
|
|
26
|
+
export declare const READING_ATTRIBUTE = "data-pinecall-reading";
|
|
27
|
+
/** The name a page read aloud plays under. */
|
|
28
|
+
export declare const READ_WALK = "read";
|
|
29
|
+
/** A step about an example's output: the output, and the text of the line it is about; null, the output whole. */
|
|
30
|
+
export interface AboutOutput {
|
|
31
|
+
output: Element;
|
|
32
|
+
find: string | null;
|
|
33
|
+
}
|
|
34
|
+
/** Words typed into a field as a sentence is said. */
|
|
35
|
+
export interface Typed {
|
|
36
|
+
field: Element;
|
|
37
|
+
text: string;
|
|
38
|
+
}
|
|
39
|
+
/** A page as it is read: its steps, the element each is about, which are about an output, the goal a step talks for, what is typed as one is said, and the call one is said into. */
|
|
40
|
+
export interface Reading {
|
|
41
|
+
walk: RecordedWalk;
|
|
42
|
+
at: Element[];
|
|
43
|
+
outputs: (AboutOutput | undefined)[];
|
|
44
|
+
goals: WeakMap<WalkStep, string>;
|
|
45
|
+
typed: WeakMap<WalkStep, Typed>;
|
|
46
|
+
spoken: WeakMap<WalkStep, Element>;
|
|
47
|
+
}
|
|
48
|
+
/** The page as it reads now, under the title the menu shows it with; null when it marks nothing to read. */
|
|
49
|
+
export declare function readingOf(document: Document, title: string): Reading | null;
|
|
50
|
+
/** The reading from where the page is scrolled to: from its first part not above what is seen; whole when that is its first. */
|
|
51
|
+
export declare function fromHere(reading: Reading): Reading;
|
|
52
|
+
/** The name a step calls an example by: its label, its placeholder, its words. */
|
|
53
|
+
export declare const labelOf: (element: Element) => string;
|
|
54
|
+
/** An example's output: what it controls (`aria-controls`), else itself. */
|
|
55
|
+
export declare function outputOf(element: Element): Element;
|
|
56
|
+
/** The language an output's page is in, for the door; none when the page does not say. */
|
|
57
|
+
export declare const languageOf: (element: Element) => string | undefined;
|
|
58
|
+
//# sourceMappingURL=reading.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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E,YAAY,CAAC;IACnB,EAAE,EAAE,OAAO,EAAE,CAAC;IACd,OAAO,EAAE,CAAC,WAAW,GAAG,SAAS,CAAC,EAAE,CAAC;IACrC,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAChC,MAAM,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;CACpC;AAuBD,4GAA4G;AAC5G,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAuF3E;AAKD,gIAAgI;AAChI,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAIlD;AAED,kFAAkF;AAClF,eAAO,MAAM,OAAO,YAAa,OAAO,KAAG,MAAkH,CAAC;AAE9J,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAGlD;AAED,0FAA0F;AAC1F,eAAO,MAAM,UAAU,YAAa,OAAO,KAAG,MAAM,GAAG,SAAoE,CAAC"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/** A page read aloud with no call: what the site marks `data-pinecall-read`, part by part, in the agent's voice, the part read lit and pointed at; its examples pressed on the way. */
|
|
2
|
+
//
|
|
3
|
+
// The site marks a container `data-pinecall-read`: its headings, paragraphs, items and captions are read
|
|
4
|
+
// in the page's order, as written. Each is recorded in the agent's voice when the reading reaches it, by
|
|
5
|
+
// the site's door (`{ read }`), the next one asked for while one plays; a part longer than the voice takes
|
|
6
|
+
// at once is read a few sentences at a time. A field marked `data-pinecall-type` is an example the page
|
|
7
|
+
// types: its value is typed into it when the reading reaches it, and the button marked `data-pinecall-press`
|
|
8
|
+
// after it sends it, in any form (the page's own example, not the visitor's). A button marked
|
|
9
|
+
// `data-pinecall-press` in it is an example:
|
|
10
|
+
// pressed when the reading reaches it (its value, when it has one, said first), and the reading waits for
|
|
11
|
+
// what the button controls (`aria-controls`) to answer and not be busy, then says its `data-pinecall-then`
|
|
12
|
+
// (what the output shows) pointing at it, and each note of its `data-pinecall-notes` list pointing at the
|
|
13
|
+
// line of the output the note finds (`data-pinecall-find`): the output lit line by line, as a person
|
|
14
|
+
// reads a result with a finger on it. A button marked `data-pinecall-explain` with no notes of its own
|
|
15
|
+
// has its output explained by the site's door (`{ explain }`, the agent's model) once it answered, the
|
|
16
|
+
// notes it gives read the same way, in the place of its `data-pinecall-then` (said when the model gives none). Under `data-pinecall-quiet` nothing is read (code, a legend),
|
|
17
|
+
// though a button marked to press there is still pressed. An element with `data-pinecall-say` is said
|
|
18
|
+
// as that line, written to be heard, instead of what it shows; the parts inside it are not read again. A heading that
|
|
19
|
+
// shares its box with one text alone (a card: its title and its words) is read with it, "Title. Words",
|
|
20
|
+
// and the whole box lit: a title said alone, then its words, sounds like two things. A frame of the site's own
|
|
21
|
+
// (a chat, a widget) is read in its place, as a page: what its page marks `data-pinecall-read`. A send button
|
|
22
|
+
// marked `data-pinecall-goal` is a chat the dot talks to: it asks the door for its line, says it as it types it
|
|
23
|
+
// (the letters paced to the recording), sends it, reads the agent's answer aloud (`data-pinecall-said` on each turn), and goes on until it has what it came
|
|
24
|
+
// for, the chat read as it goes. Any chat's answer (`data-pinecall-said="agent"`) is read as it came
|
|
25
|
+
// once the press that drew it out is done, before the notes on it. A page read with its top scrolled away is read from the first part
|
|
26
|
+
// still in view (`fromHere`): a person who comes back to the middle of a chapter goes on from there.
|
|
27
|
+
import { boxOf, frameOf, pageOf } from "../pointer/frames.js";
|
|
28
|
+
import { seenOf } from "../pointer/flight.js";
|
|
29
|
+
import { QUIET_ATTRIBUTE, piecesOf, seen, wordsOf } from "./text.js";
|
|
30
|
+
export { QUIET_ATTRIBUTE, lineIn, piecesOf, textOf, wordsOf } from "./text.js";
|
|
31
|
+
export const READ_ATTRIBUTE = "data-pinecall-read";
|
|
32
|
+
export const PRESS_ATTRIBUTE = "data-pinecall-press";
|
|
33
|
+
/** On a field: the words typed into it when the reading reaches it, the page's own example (a chat's question); the `data-pinecall-press` after it sends it. */
|
|
34
|
+
export const TYPE_ATTRIBUTE = "data-pinecall-type";
|
|
35
|
+
/** On a chat's send button: the dot talks to what it sends to, turn by turn, until it gets this (or the chat ends). */
|
|
36
|
+
export const GOAL_ATTRIBUTE = "data-pinecall-goal";
|
|
37
|
+
/** On each turn of a chat talked to: whose it is, `agent`, `caller` or another (a tool the agent used, `end`); all but the caller's read aloud as they come, by their `data-pinecall-say` when they have one. */
|
|
38
|
+
export const SAID_ATTRIBUTE = "data-pinecall-said";
|
|
39
|
+
/** On the output of a talk that is a spoken call: the agent is heard there, so its turns are not read aloud; the dot's own lines are said into it. */
|
|
40
|
+
export const HEARD_ATTRIBUTE = "data-pinecall-heard";
|
|
41
|
+
/** The event a spoken call's output is told the dot's line by, as the line starts: `detail.text`, `detail.audio` (its recording's URL) and `detail.durationMs`; the site plays it into the call. */
|
|
42
|
+
export const SAYING_EVENT = "pinecall-saying";
|
|
43
|
+
/** The line an element is said as, instead of what it shows: the same the agent says in a call. */
|
|
44
|
+
export const SAY_ATTRIBUTE = "data-pinecall-say";
|
|
45
|
+
/** What an example's output shows, said pointing at it once it answered. */
|
|
46
|
+
export const THEN_ATTRIBUTE = "data-pinecall-then";
|
|
47
|
+
/** On an example's button: the id of a list of notes on its output, each `data-pinecall-find` a text (or `/a regex/`) of a line of it. */
|
|
48
|
+
export const NOTES_ATTRIBUTE = "data-pinecall-notes";
|
|
49
|
+
export const FIND_ATTRIBUTE = "data-pinecall-find";
|
|
50
|
+
/** On an example's button: its output, when no note of the page's covers it, explained by the site's door; its value names the command. */
|
|
51
|
+
export const EXPLAIN_ATTRIBUTE = "data-pinecall-explain";
|
|
52
|
+
/** On an output while its notes are read, for the site to widen it: a box that scrolls shows whole. */
|
|
53
|
+
export const READING_ATTRIBUTE = "data-pinecall-reading";
|
|
54
|
+
/** The name a page read aloud plays under. */
|
|
55
|
+
export const READ_WALK = "read";
|
|
56
|
+
/** The parts of a container a person reads out, each once: the outermost when one holds another. */
|
|
57
|
+
const PARTS = "h1, h2, h3, h4, h5, h6, p, li, dt, dd, figcaption, blockquote, caption";
|
|
58
|
+
/** The parts of `box` a person reads, outermost, in order. */
|
|
59
|
+
function partsIn(box) {
|
|
60
|
+
return [...box.querySelectorAll(PARTS)].filter((part) => seen(part) && part.closest(`[${QUIET_ATTRIBUTE}]`) === null && !box.contains(part.parentElement?.closest(PARTS) ?? null));
|
|
61
|
+
}
|
|
62
|
+
/** A heading and the one text it shares its box with, as one: the box and "Title. Words"; null when it is not one. */
|
|
63
|
+
function card(heading, root) {
|
|
64
|
+
const box = heading.parentElement;
|
|
65
|
+
if (box === null || box === root || !root.contains(box) || !/^H[1-6]$/.test(heading.tagName))
|
|
66
|
+
return null;
|
|
67
|
+
const parts = partsIn(box);
|
|
68
|
+
const words = parts[1];
|
|
69
|
+
if (parts.length !== 2 || parts[0] !== heading || words === undefined)
|
|
70
|
+
return null;
|
|
71
|
+
const title = wordsOf(heading);
|
|
72
|
+
return { box, words, text: `${title}${/[.!?:…]$/.test(title) ? "" : "."} ${wordsOf(words)}` };
|
|
73
|
+
}
|
|
74
|
+
/** The containers of `document` that are read, outermost. */
|
|
75
|
+
function rootsOf(document) {
|
|
76
|
+
return [...document.querySelectorAll(`[${READ_ATTRIBUTE}]`)].filter((root) => root.parentElement?.closest(`[${READ_ATTRIBUTE}]`) == null);
|
|
77
|
+
}
|
|
78
|
+
/** The page as it reads now, under the title the menu shows it with; null when it marks nothing to read. */
|
|
79
|
+
export function readingOf(document, title) {
|
|
80
|
+
const steps = [];
|
|
81
|
+
const at = [];
|
|
82
|
+
const outputs = [];
|
|
83
|
+
const goals = new WeakMap();
|
|
84
|
+
const typed = new WeakMap();
|
|
85
|
+
const spoken = new WeakMap();
|
|
86
|
+
/** A field marked to type, typed as the next press's line is said. */
|
|
87
|
+
let pending = null;
|
|
88
|
+
/** The words of a card, read with its title. */
|
|
89
|
+
const read = new Set();
|
|
90
|
+
const line = (text, element, about) => {
|
|
91
|
+
const said = [];
|
|
92
|
+
for (const piece of piecesOf(text.replace(/\s+/g, " ").trim())) {
|
|
93
|
+
const step = { say: piece, beats: [], live: true };
|
|
94
|
+
steps.push(step);
|
|
95
|
+
said.push(step);
|
|
96
|
+
at.push(element);
|
|
97
|
+
outputs[at.length - 1] = about;
|
|
98
|
+
}
|
|
99
|
+
return said;
|
|
100
|
+
};
|
|
101
|
+
const scan = (root) => {
|
|
102
|
+
for (const element of root.querySelectorAll(`${PARTS}, [${PRESS_ATTRIBUTE}], [${TYPE_ATTRIBUTE}], [${SAY_ATTRIBUTE}], iframe`)) {
|
|
103
|
+
if (!seen(element))
|
|
104
|
+
continue;
|
|
105
|
+
// A frame of the site's own is read in its place, as a page is: what its page marks.
|
|
106
|
+
if (element.tagName === "IFRAME") {
|
|
107
|
+
const page = pageOf(element);
|
|
108
|
+
if (page !== null)
|
|
109
|
+
rootsOf(page).forEach(scan);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
if (element.hasAttribute(TYPE_ATTRIBUTE)) {
|
|
113
|
+
pending = { field: element, text: element.getAttribute(TYPE_ATTRIBUTE) ?? "" };
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (element.hasAttribute(PRESS_ATTRIBUTE)) {
|
|
117
|
+
const goal = element.getAttribute(GOAL_ATTRIBUTE);
|
|
118
|
+
// Its line is said pointing at the field typed in meanwhile; a chat's, at the chat itself; a call's (an output
|
|
119
|
+
// the agent is heard in), at the button that opens it; else at the button.
|
|
120
|
+
const shown = pending?.field ?? (goal && !outputOf(element).hasAttribute(HEARD_ATTRIBUTE) ? (frameOf(element.ownerDocument) ?? outputOf(element)) : element);
|
|
121
|
+
const said = line(element.getAttribute(PRESS_ATTRIBUTE) ?? "", shown);
|
|
122
|
+
if (pending !== null) {
|
|
123
|
+
// Typed as the line is said; with no line to say, typed on its own.
|
|
124
|
+
if (said[0] !== undefined)
|
|
125
|
+
typed.set(said[0], pending);
|
|
126
|
+
else {
|
|
127
|
+
steps.push({ fill: labelOf(pending.field), with: pending.text });
|
|
128
|
+
at.push(pending.field);
|
|
129
|
+
}
|
|
130
|
+
pending = null;
|
|
131
|
+
}
|
|
132
|
+
const press = { press: labelOf(element) };
|
|
133
|
+
steps.push(press);
|
|
134
|
+
at.push(element);
|
|
135
|
+
// A button with a goal: the dot talks to what it sends to when it reaches it (`ReadAloud`); nothing is said of it before.
|
|
136
|
+
if (goal !== null && goal !== "") {
|
|
137
|
+
goals.set(press, goal);
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
const output = outputOf(element);
|
|
141
|
+
line(element.getAttribute(THEN_ATTRIBUTE) ?? "", output, { output, find: null });
|
|
142
|
+
// Each note on the output, said pointing at the line it finds; one that finds none is left out as it is reached.
|
|
143
|
+
const notes = element.getAttribute(NOTES_ATTRIBUTE);
|
|
144
|
+
for (const note of (notes === null ? null : document.getElementById(notes))?.children ?? []) {
|
|
145
|
+
const find = note.getAttribute(FIND_ATTRIBUTE);
|
|
146
|
+
if (find !== null && find !== "")
|
|
147
|
+
line(note.textContent ?? "", output, { output, find });
|
|
148
|
+
}
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
// Inside a part said as its own line, nothing is read again; quiet, nothing at all.
|
|
152
|
+
const told = element.parentElement?.closest(`[${SAY_ATTRIBUTE}]`) ?? null;
|
|
153
|
+
if ((told !== null && root.contains(told)) || element.closest(`[${QUIET_ATTRIBUTE}]`) !== null)
|
|
154
|
+
continue;
|
|
155
|
+
// A chat's turns (a tool's line among them) are read as the dot talks to it, not as the page.
|
|
156
|
+
if (element.closest(`[${SAID_ATTRIBUTE}]`) !== null)
|
|
157
|
+
continue;
|
|
158
|
+
if (element.hasAttribute(SAY_ATTRIBUTE)) {
|
|
159
|
+
line(element.getAttribute(SAY_ATTRIBUTE) ?? "", element);
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
// A part inside another part of the same container is read with it.
|
|
163
|
+
const holder = element.parentElement?.closest(PARTS) ?? null;
|
|
164
|
+
if ((holder !== null && root.contains(holder)) || read.has(element))
|
|
165
|
+
continue;
|
|
166
|
+
const together = card(element, root);
|
|
167
|
+
if (together !== null)
|
|
168
|
+
read.add(together.words);
|
|
169
|
+
line(together?.text ?? wordsOf(element), together?.box ?? element);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
rootsOf(document).forEach(scan);
|
|
173
|
+
return steps.length === 0 ? null : { walk: { name: READ_WALK, title, steps }, at, outputs, goals, typed, spoken };
|
|
174
|
+
}
|
|
175
|
+
/** How far above what is seen a part may start and still be where the reading begins, in px. */
|
|
176
|
+
const JUST_ABOVE = 8;
|
|
177
|
+
/** The reading from where the page is scrolled to: from its first part not above what is seen; whole when that is its first. */
|
|
178
|
+
export function fromHere(reading) {
|
|
179
|
+
const first = reading.at.findIndex((element) => boxOf(element).bottom > seenOf(element).top + JUST_ABOVE);
|
|
180
|
+
if (first <= 0)
|
|
181
|
+
return reading;
|
|
182
|
+
return { ...reading, walk: { ...reading.walk, steps: reading.walk.steps.slice(first) }, at: reading.at.slice(first), outputs: reading.outputs.slice(first) };
|
|
183
|
+
}
|
|
184
|
+
/** The name a step calls an example by: its label, its placeholder, its words. */
|
|
185
|
+
export const labelOf = (element) => element.getAttribute("aria-label") ?? element.getAttribute("placeholder") ?? wordsOf(element) ?? "field";
|
|
186
|
+
/** An example's output: what it controls (`aria-controls`), else itself. */
|
|
187
|
+
export function outputOf(element) {
|
|
188
|
+
const controls = element.getAttribute("aria-controls");
|
|
189
|
+
return (controls === null ? null : element.ownerDocument.getElementById(controls)) ?? element;
|
|
190
|
+
}
|
|
191
|
+
/** The language an output's page is in, for the door; none when the page does not say. */
|
|
192
|
+
export const languageOf = (element) => element.ownerDocument.documentElement.lang || undefined;
|
|
193
|
+
//# sourceMappingURL=reading.js.map
|
|
@@ -0,0 +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O,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,GAAG,UAAU,CAAC,CAAC;IAC1G,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,OAAO,CAAC;IAC/B,OAAO,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;AAC/J,CAAC;AAED,kFAAkF;AAClF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,OAAgB,EAAU,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC;AAE9J,4EAA4E;AAC5E,MAAM,UAAU,QAAQ,CAAC,OAAgB;IACvC,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;IACvD,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,IAAI,OAAO,CAAC;AAChG,CAAC;AAED,0FAA0F;AAC1F,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAgB,EAAsB,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,IAAI,IAAI,SAAS,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** A page's text as a person reads it: the words of an element, an output line by line, the line a note finds, and a text cut into recordings. */
|
|
2
|
+
/** Under it nothing is read (code, a legend), though an example marked to press or type there is still done. */
|
|
3
|
+
export declare const QUIET_ATTRIBUTE = "data-pinecall-quiet";
|
|
4
|
+
/** The nearest box of `element`, within `within`, that is a line of its own: not a run of words (a span, a code) inside one. */
|
|
5
|
+
export declare function blockOf(element: Element, within: Element): Element;
|
|
6
|
+
/** What an output shows, line by line: each box of its own on a line, the words inside it as written. Hidden parts left out. */
|
|
7
|
+
export declare function textOf(output: Element): string;
|
|
8
|
+
/** The line of `output` that holds `find`, a text in any case and spacing or `/a regex/flags`: the innermost box that holds it; null when none does. */
|
|
9
|
+
export declare function lineIn(output: Element, find: string): Element | null;
|
|
10
|
+
/** Whether a person sees `element`: not hidden, not left out for the tutor. */
|
|
11
|
+
export declare function seen(element: Element): boolean;
|
|
12
|
+
/** The words a person reads out of `element`, on one line: its text, without what is quiet or hidden inside it. */
|
|
13
|
+
export declare function wordsOf(element: Element): string;
|
|
14
|
+
/** A text as it is recorded: whole when it fits, else a few sentences at a time, `longest` characters at most each. */
|
|
15
|
+
export declare function piecesOf(text: string, longest?: number): string[];
|
|
16
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/tutor/text.ts"],"names":[],"mappings":"AAAA,kJAAkJ;AAIlJ,gHAAgH;AAChH,eAAO,MAAM,eAAe,wBAAwB,CAAC;AAMrD,gIAAgI;AAChI,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAQlE;AAED,gIAAgI;AAChI,wBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAuB9C;AAKD,wJAAwJ;AACxJ,wBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAcpE;AAED,+EAA+E;AAC/E,wBAAgB,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAI9C;AAED,mHAAmH;AACnH,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAUhD;AAED,uHAAuH;AACvH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,SAAU,GAAG,MAAM,EAAE,CAalE"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/** A page's text as a person reads it: the words of an element, an output line by line, the line a note finds, and a text cut into recordings. */
|
|
2
|
+
import { isElement } from "../pointer/frames.js";
|
|
3
|
+
/** Under it nothing is read (code, a legend), though an example marked to press or type there is still done. */
|
|
4
|
+
export const QUIET_ATTRIBUTE = "data-pinecall-quiet";
|
|
5
|
+
/** The most characters one recording takes: a few sentences. */
|
|
6
|
+
const LONGEST = 480;
|
|
7
|
+
const INLINE = new Set(["SPAN", "CODE", "B", "I", "EM", "STRONG", "A", "SMALL", "KBD", "U", "S", "MARK", "TIME", "SUB", "SUP", "ABBR"]);
|
|
8
|
+
/** The nearest box of `element`, within `within`, that is a line of its own: not a run of words (a span, a code) inside one. */
|
|
9
|
+
export function blockOf(element, within) {
|
|
10
|
+
let node = element;
|
|
11
|
+
while (node !== within && node.parentElement !== null) {
|
|
12
|
+
const display = node.ownerDocument.defaultView?.getComputedStyle(node).display ?? "";
|
|
13
|
+
if (!INLINE.has(node.tagName) && !display.startsWith("inline") && display !== "contents")
|
|
14
|
+
return node;
|
|
15
|
+
node = node.parentElement;
|
|
16
|
+
}
|
|
17
|
+
return node;
|
|
18
|
+
}
|
|
19
|
+
/** What an output shows, line by line: each box of its own on a line, the words inside it as written. Hidden parts left out. */
|
|
20
|
+
export function textOf(output) {
|
|
21
|
+
const lines = [];
|
|
22
|
+
const walk = (node, line) => {
|
|
23
|
+
for (const child of node.childNodes) {
|
|
24
|
+
// By node type, not `instanceof`: a frame's nodes are of the frame's window.
|
|
25
|
+
if (child.nodeType === 3)
|
|
26
|
+
line.push(child.textContent ?? "");
|
|
27
|
+
else if (isElement(child) && seen(child) && !child.matches("script, style, template")) {
|
|
28
|
+
// A span laid out as a block (a cell of a row) is a line of its own; one in a run of words is not.
|
|
29
|
+
const display = child.ownerDocument.defaultView?.getComputedStyle(child).display ?? "";
|
|
30
|
+
const inline = display === "" ? INLINE.has(child.tagName) : display.startsWith("inline");
|
|
31
|
+
if (inline)
|
|
32
|
+
walk(child, line);
|
|
33
|
+
else {
|
|
34
|
+
const own = [];
|
|
35
|
+
walk(child, own);
|
|
36
|
+
lines.push(own.join("").replace(/\s+/g, " ").trim());
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const top = [];
|
|
42
|
+
walk(output, top);
|
|
43
|
+
const first = top.join("").replace(/\s+/g, " ").trim();
|
|
44
|
+
return [first, ...lines].filter((line) => line !== "").join("\n");
|
|
45
|
+
}
|
|
46
|
+
/** A text as two are compared for a note: one space between words, in lower case. */
|
|
47
|
+
const flat = (text) => text.replace(/\s+/g, " ").trim().toLowerCase();
|
|
48
|
+
/** The line of `output` that holds `find`, a text in any case and spacing or `/a regex/flags`: the innermost box that holds it; null when none does. */
|
|
49
|
+
export function lineIn(output, find) {
|
|
50
|
+
const expr = /^\/(.+)\/([a-z]*)$/.exec(find);
|
|
51
|
+
let matches;
|
|
52
|
+
try {
|
|
53
|
+
const regex = expr === null ? null : new RegExp(expr[1] ?? "", (expr[2] ?? "").replace("g", ""));
|
|
54
|
+
const wanted = flat(find);
|
|
55
|
+
matches = regex === null ? (text) => flat(text).includes(wanted) : (text) => regex.test(text);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
const holding = [...output.querySelectorAll("*")].filter((element) => matches(element.textContent ?? ""));
|
|
61
|
+
const innermost = holding.find((element) => !holding.some((other) => other !== element && element.contains(other)));
|
|
62
|
+
if (innermost === undefined)
|
|
63
|
+
return matches(output.textContent ?? "") ? output : null;
|
|
64
|
+
return blockOf(innermost, output);
|
|
65
|
+
}
|
|
66
|
+
/** Whether a person sees `element`: not hidden, not left out for the tutor. */
|
|
67
|
+
export function seen(element) {
|
|
68
|
+
if (element.closest("[hidden], [aria-hidden='true'], [data-pinecall-skip]") !== null)
|
|
69
|
+
return false;
|
|
70
|
+
const style = element.ownerDocument.defaultView?.getComputedStyle(element);
|
|
71
|
+
return style === undefined || (style.display !== "none" && style.visibility !== "hidden");
|
|
72
|
+
}
|
|
73
|
+
/** The words a person reads out of `element`, on one line: its text, without what is quiet or hidden inside it. */
|
|
74
|
+
export function wordsOf(element) {
|
|
75
|
+
const document = element.ownerDocument;
|
|
76
|
+
const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
|
|
77
|
+
let text = "";
|
|
78
|
+
for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) {
|
|
79
|
+
const parent = node.parentElement;
|
|
80
|
+
if (parent === null || parent.closest(`[${QUIET_ATTRIBUTE}]`) !== null || !seen(parent) || parent.matches("script, style, template"))
|
|
81
|
+
continue;
|
|
82
|
+
text += node.textContent ?? "";
|
|
83
|
+
}
|
|
84
|
+
return text.replace(/\s+/g, " ").trim();
|
|
85
|
+
}
|
|
86
|
+
/** A text as it is recorded: whole when it fits, else a few sentences at a time, `longest` characters at most each. */
|
|
87
|
+
export function piecesOf(text, longest = LONGEST) {
|
|
88
|
+
if (text.length <= longest)
|
|
89
|
+
return text === "" ? [] : [text];
|
|
90
|
+
const sentences = text.split(/(?<=[.!?…:;])\s+/);
|
|
91
|
+
const pieces = [];
|
|
92
|
+
let piece = "";
|
|
93
|
+
for (const sentence of sentences.flatMap((one) => (one.length <= longest ? [one] : cut(one, longest)))) {
|
|
94
|
+
if (piece !== "" && piece.length + 1 + sentence.length > longest) {
|
|
95
|
+
pieces.push(piece);
|
|
96
|
+
piece = sentence;
|
|
97
|
+
}
|
|
98
|
+
else
|
|
99
|
+
piece = piece === "" ? sentence : `${piece} ${sentence}`;
|
|
100
|
+
}
|
|
101
|
+
if (piece !== "")
|
|
102
|
+
pieces.push(piece);
|
|
103
|
+
return pieces;
|
|
104
|
+
}
|
|
105
|
+
/** A sentence longer than a recording, cut between its words. */
|
|
106
|
+
function cut(sentence, longest) {
|
|
107
|
+
const pieces = [];
|
|
108
|
+
let piece = "";
|
|
109
|
+
for (const word of sentence.split(" ")) {
|
|
110
|
+
if (piece !== "" && piece.length + 1 + word.length > longest) {
|
|
111
|
+
pieces.push(piece);
|
|
112
|
+
piece = word;
|
|
113
|
+
}
|
|
114
|
+
else
|
|
115
|
+
piece = piece === "" ? word : `${piece} ${word}`;
|
|
116
|
+
}
|
|
117
|
+
return piece === "" ? pieces : [...pieces, piece];
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/tutor/text.ts"],"names":[],"mappings":"AAAA,kJAAkJ;AAElJ,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,gHAAgH;AAChH,MAAM,CAAC,MAAM,eAAe,GAAG,qBAAqB,CAAC;AACrD,gEAAgE;AAChE,MAAM,OAAO,GAAG,GAAG,CAAC;AAEpB,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAExI,gIAAgI;AAChI,MAAM,UAAU,OAAO,CAAC,OAAgB,EAAE,MAAe;IACvD,IAAI,IAAI,GAAG,OAAO,CAAC;IACnB,OAAO,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI,EAAE,CAAC;QACtD,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,gBAAgB,CAAC,IAAI,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KAAK,CAAC,CAAC;AACpD,CAAC"}
|
package/dist/tutor/tutor.d.ts
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
/** The tutor on a page: the person with its pointer and face, what it sends of the page, and every move the agent asks for. */
|
|
2
2
|
import { type RoomStore } from "@pinecall/room";
|
|
3
|
-
import type { TutorOptions } from "./options.js";
|
|
4
|
-
export type { TutorOptions } from "./options.js";
|
|
5
|
-
export interface Tutor {
|
|
6
|
-
/** A message the agent sent on `pinecall.ui`: true when it was the tutor's to carry out, false for a card or choices. */
|
|
7
|
-
take(data: unknown): boolean;
|
|
8
|
-
/** Let the face hear the voice: call it from the click that starts the call. */
|
|
9
|
-
wake(): void;
|
|
10
|
-
close(): void;
|
|
11
|
-
}
|
|
3
|
+
import type { Tutor, TutorOptions } from "./options.js";
|
|
4
|
+
export type { Tutor, TutorOptions } from "./options.js";
|
|
12
5
|
/** Put the tutor on the page, moving with `call`. Nothing is sent until the call is live. */
|
|
13
6
|
export declare function tutor(call: RoomStore, options?: TutorOptions): Tutor;
|
|
14
7
|
//# sourceMappingURL=tutor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tutor.d.ts","sourceRoot":"","sources":["../../src/tutor/tutor.ts"],"names":[],"mappings":"AAAA,+HAA+H;
|
|
1
|
+
{"version":3,"file":"tutor.d.ts","sourceRoot":"","sources":["../../src/tutor/tutor.ts"],"names":[],"mappings":"AAAA,+HAA+H;AAU/H,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAiBjE,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAIxD,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AASxD,6FAA6F;AAC7F,wBAAgB,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,GAAE,YAAiB,GAAG,KAAK,CA+VxE"}
|