@iyulab/lowline-form 0.10.0 → 0.12.0
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 +19 -1
- package/dist/bundle/lowline-form.bundle.js +1162 -1010
- package/dist/client.d.ts +19 -2
- package/dist/client.js +6 -3
- package/dist/draft.d.ts +29 -5
- package/dist/draft.js +38 -7
- package/dist/headless.d.ts +2 -2
- package/dist/lowline-form.d.ts +24 -3
- package/dist/lowline-form.js +54 -6
- package/dist/session.d.ts +54 -4
- package/dist/session.js +108 -10
- package/package.json +5 -5
package/dist/client.d.ts
CHANGED
|
@@ -5,6 +5,14 @@ export declare class LowlineError extends Error {
|
|
|
5
5
|
readonly status: number;
|
|
6
6
|
constructor(status: number, message: string);
|
|
7
7
|
}
|
|
8
|
+
/** Something a person showed rather than wrote — a photo, a scan — sent to the host's model with a fill request. */
|
|
9
|
+
export interface Attachment {
|
|
10
|
+
/** Its media type, such as `image/jpeg` or `application/pdf`. */
|
|
11
|
+
mediaType: string;
|
|
12
|
+
/** Its bytes, base64. */
|
|
13
|
+
data: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
}
|
|
8
16
|
/** A threshold chosen on a replay of the settled records, and what the replay saw at it. */
|
|
9
17
|
export interface ThresholdChoice {
|
|
10
18
|
threshold: number;
|
|
@@ -43,6 +51,12 @@ export interface FieldReport {
|
|
|
43
51
|
coarseSimilar?: ThresholdChoice;
|
|
44
52
|
similar?: ThresholdChoice;
|
|
45
53
|
similarOffered: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* For a judgement from outside the records: the score from which it is trusted, chosen from the cases it answered and
|
|
56
|
+
* people settled (its `promise` is the precision to expect of the next answers at or above it); absent while too few
|
|
57
|
+
* cases are settled for one to stand.
|
|
58
|
+
*/
|
|
59
|
+
judgement?: ThresholdChoice;
|
|
46
60
|
promiseOver: number;
|
|
47
61
|
/** How many checks — answers held back while a person wrote the value — are among the records. */
|
|
48
62
|
checks: number;
|
|
@@ -68,8 +82,11 @@ export declare class LowlineClient {
|
|
|
68
82
|
id: string;
|
|
69
83
|
settledAt: string;
|
|
70
84
|
}>;
|
|
71
|
-
/**
|
|
72
|
-
|
|
85
|
+
/**
|
|
86
|
+
* What the host's model makes of `text` and of what the person showed (`attachments`) for the fields of record values
|
|
87
|
+
* still empty — 404 when the host gave no model.
|
|
88
|
+
*/
|
|
89
|
+
fill(form: string, values: Values, text: string, attachments?: Attachment[]): Promise<Proposal[]>;
|
|
73
90
|
/**
|
|
74
91
|
* What the host's model judged for the decided fields of record `id` the records could not answer
|
|
75
92
|
* (`needs-judgement`) — 404 when the host gave no model.
|
package/dist/client.js
CHANGED
|
@@ -27,9 +27,12 @@ export class LowlineClient {
|
|
|
27
27
|
settle(form, id, draft, saved) {
|
|
28
28
|
return this.post(form, 'settle', { id, saved, draft });
|
|
29
29
|
}
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
/**
|
|
31
|
+
* What the host's model makes of `text` and of what the person showed (`attachments`) for the fields of record values
|
|
32
|
+
* still empty — 404 when the host gave no model.
|
|
33
|
+
*/
|
|
34
|
+
fill(form, values, text, attachments) {
|
|
35
|
+
return this.post(form, 'fill', attachments?.length ? { values, text, attachments } : { values, text });
|
|
33
36
|
}
|
|
34
37
|
/**
|
|
35
38
|
* What the host's model judged for the decided fields of record `id` the records could not answer
|
package/dist/draft.d.ts
CHANGED
|
@@ -10,13 +10,27 @@ export interface Suggestion {
|
|
|
10
10
|
}
|
|
11
11
|
/** The layer of the decider an answer came from. */
|
|
12
12
|
export type Layer = 'key' | 'similar' | 'judgement';
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* What the host knows of the answer it shows or holds back, beyond its value: the layer that gave it, what it promised,
|
|
15
|
+
* and — for a judgement from outside the records — the score it gave it on its own scale.
|
|
16
|
+
*/
|
|
14
17
|
export interface Reported {
|
|
15
18
|
layer?: Layer | null;
|
|
16
19
|
promise?: number;
|
|
20
|
+
score?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Whether the promise of the answer shown was displayed beside it, and the probability it was drawn to be displayed with
|
|
24
|
+
* — fixed before the draw: 1 for a form that always displays it, 0 for one that never does.
|
|
25
|
+
*/
|
|
26
|
+
export interface PromiseShown {
|
|
27
|
+
shown: boolean;
|
|
28
|
+
probability: number;
|
|
17
29
|
}
|
|
18
30
|
interface Track extends Reported {
|
|
19
31
|
shown?: Suggestion;
|
|
32
|
+
/** Whether the promise of the suggestion shown was displayed beside it. */
|
|
33
|
+
promise_shown?: PromiseShown;
|
|
20
34
|
declined?: boolean;
|
|
21
35
|
held?: number;
|
|
22
36
|
/** The answer held back for a check, kept so the record can say what the person was not shown. */
|
|
@@ -32,9 +46,10 @@ interface Track extends Reported {
|
|
|
32
46
|
*
|
|
33
47
|
* Written as the engine reads it: `{ opened, fields: { field: { shown, declined, held } } }`, and — only what was
|
|
34
48
|
* reported — `opened_at`, `saved_at` (milliseconds on one steady clock), `arrival` (the fields in the order their values
|
|
35
|
-
* arrived), `by` and `batch`, and in a field `layer`, `promise`, `at` and `withheld`.
|
|
49
|
+
* arrived), `by` and `batch`, and in a field `layer`, `promise`, `score`, `promise_shown`, `at` and `withheld`.
|
|
36
50
|
*/
|
|
37
51
|
export declare class Draft {
|
|
52
|
+
#private;
|
|
38
53
|
readonly opened: Values;
|
|
39
54
|
readonly fields: Record<string, Track>;
|
|
40
55
|
private openedAt?;
|
|
@@ -44,15 +59,24 @@ export declare class Draft {
|
|
|
44
59
|
private batch?;
|
|
45
60
|
/** A record opened holding `values` — none for a new one. Empty values are left out. */
|
|
46
61
|
constructor(values?: Values);
|
|
47
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* A suggestion came into view for the field. It is turned down if the person turned its value down before in this
|
|
64
|
+
* record — even with other suggestions shown since.
|
|
65
|
+
*/
|
|
48
66
|
show(field: string, suggestion: Suggestion, reported?: Reported): void;
|
|
49
67
|
/**
|
|
50
68
|
* The field's answer is held back for a check, drawn with `probability`: what the person settles is checked.
|
|
51
|
-
* `withheld` is the answer not shown, with its layer and
|
|
69
|
+
* `withheld` is the answer not shown, with its layer, promise and score, for the record to say what was held back.
|
|
52
70
|
*/
|
|
53
71
|
hold(field: string, probability: number, withheld?: {
|
|
54
72
|
suggestion: Suggestion;
|
|
55
73
|
} & Reported): void;
|
|
74
|
+
/**
|
|
75
|
+
* Whether the promise of the suggestion shown for the field was displayed beside it, drawn with `probability` (fixed
|
|
76
|
+
* before the draw: 1 for always, 0 for never). It stands until another suggestion is shown or the answer is held back
|
|
77
|
+
* for a check. False, changing nothing, when no suggestion is shown.
|
|
78
|
+
*/
|
|
79
|
+
showPromise(field: string, shown: boolean, probability: number): boolean;
|
|
56
80
|
/** The record was opened at `ms` on the session's clock (a steady clock in milliseconds: only differences are read). */
|
|
57
81
|
openAt(ms: number): void;
|
|
58
82
|
/** The record is being saved at `ms` on the same clock. */
|
|
@@ -68,7 +92,7 @@ export declare class Draft {
|
|
|
68
92
|
private report;
|
|
69
93
|
/** The person turned down the suggestion in view; false, changing nothing, when none was shown. */
|
|
70
94
|
decline(field: string): boolean;
|
|
71
|
-
/** Whether `suggestion` is the one in view for the field and the person turned it down. */
|
|
95
|
+
/** Whether `suggestion` is the one in view for the field and the person turned it down — now or before, in this record. */
|
|
72
96
|
declined(field: string, suggestion: Suggestion): boolean;
|
|
73
97
|
shown(field: string): Suggestion | undefined;
|
|
74
98
|
held(field: string): number | undefined;
|
package/dist/draft.js
CHANGED
|
@@ -6,20 +6,29 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Written as the engine reads it: `{ opened, fields: { field: { shown, declined, held } } }`, and — only what was
|
|
8
8
|
* reported — `opened_at`, `saved_at` (milliseconds on one steady clock), `arrival` (the fields in the order their values
|
|
9
|
-
* arrived), `by` and `batch`, and in a field `layer`, `promise`, `at` and `withheld`.
|
|
9
|
+
* arrived), `by` and `batch`, and in a field `layer`, `promise`, `score`, `promise_shown`, `at` and `withheld`.
|
|
10
10
|
*/
|
|
11
11
|
export class Draft {
|
|
12
|
+
/** The values the person turned down, by field: for this record, each stays turned down whatever is shown between. */
|
|
13
|
+
#turnedDown;
|
|
12
14
|
/** A record opened holding `values` — none for a new one. Empty values are left out. */
|
|
13
15
|
constructor(values = {}) {
|
|
14
16
|
this.fields = {};
|
|
15
17
|
this.arrival = [];
|
|
18
|
+
/** The values the person turned down, by field: for this record, each stays turned down whatever is shown between. */
|
|
19
|
+
this.#turnedDown = new Map();
|
|
16
20
|
this.opened = Object.fromEntries(Object.entries(values).filter(([, v]) => !isEmpty(v)));
|
|
17
21
|
}
|
|
18
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* A suggestion came into view for the field. It is turned down if the person turned its value down before in this
|
|
24
|
+
* record — even with other suggestions shown since.
|
|
25
|
+
*/
|
|
19
26
|
show(field, suggestion, reported = {}) {
|
|
20
27
|
const track = (this.fields[field] ??= {});
|
|
21
|
-
if (!sameSuggestion(track.shown, suggestion))
|
|
22
|
-
track.declined =
|
|
28
|
+
if (!sameSuggestion(track.shown, suggestion)) {
|
|
29
|
+
track.declined = this.#turnedDown.get(field)?.has(suggestion.value) === true;
|
|
30
|
+
delete track.promise_shown;
|
|
31
|
+
}
|
|
23
32
|
track.shown = { ...suggestion };
|
|
24
33
|
delete track.held;
|
|
25
34
|
delete track.withheld;
|
|
@@ -27,7 +36,7 @@ export class Draft {
|
|
|
27
36
|
}
|
|
28
37
|
/**
|
|
29
38
|
* The field's answer is held back for a check, drawn with `probability`: what the person settles is checked.
|
|
30
|
-
* `withheld` is the answer not shown, with its layer and
|
|
39
|
+
* `withheld` is the answer not shown, with its layer, promise and score, for the record to say what was held back.
|
|
31
40
|
*/
|
|
32
41
|
hold(field, probability, withheld) {
|
|
33
42
|
if (!(probability > 0 && probability <= 1))
|
|
@@ -42,6 +51,21 @@ export class Draft {
|
|
|
42
51
|
}
|
|
43
52
|
this.fields[field] = track;
|
|
44
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Whether the promise of the suggestion shown for the field was displayed beside it, drawn with `probability` (fixed
|
|
56
|
+
* before the draw: 1 for always, 0 for never). It stands until another suggestion is shown or the answer is held back
|
|
57
|
+
* for a check. False, changing nothing, when no suggestion is shown.
|
|
58
|
+
*/
|
|
59
|
+
showPromise(field, shown, probability) {
|
|
60
|
+
if (!(probability >= 0 && probability <= 1) || (shown ? probability === 0 : probability === 1)) {
|
|
61
|
+
throw new RangeError(`a promise ${shown ? 'shown' : 'not shown'} with probability ${probability} is not possible`);
|
|
62
|
+
}
|
|
63
|
+
const track = this.fields[field];
|
|
64
|
+
if (!track?.shown)
|
|
65
|
+
return false;
|
|
66
|
+
track.promise_shown = { shown, probability };
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
45
69
|
/** The record was opened at `ms` on the session's clock (a steady clock in milliseconds: only differences are read). */
|
|
46
70
|
openAt(ms) {
|
|
47
71
|
this.openedAt = whole(ms);
|
|
@@ -68,7 +92,7 @@ export class Draft {
|
|
|
68
92
|
inBatch(id) {
|
|
69
93
|
this.batch = id;
|
|
70
94
|
}
|
|
71
|
-
report(track, { layer, promise }) {
|
|
95
|
+
report(track, { layer, promise, score }) {
|
|
72
96
|
if (layer)
|
|
73
97
|
track.layer = layer;
|
|
74
98
|
else
|
|
@@ -77,6 +101,10 @@ export class Draft {
|
|
|
77
101
|
track.promise = promise;
|
|
78
102
|
else
|
|
79
103
|
delete track.promise;
|
|
104
|
+
if (score !== undefined)
|
|
105
|
+
track.score = score;
|
|
106
|
+
else
|
|
107
|
+
delete track.score;
|
|
80
108
|
}
|
|
81
109
|
/** The person turned down the suggestion in view; false, changing nothing, when none was shown. */
|
|
82
110
|
decline(field) {
|
|
@@ -84,9 +112,12 @@ export class Draft {
|
|
|
84
112
|
if (!track?.shown)
|
|
85
113
|
return false;
|
|
86
114
|
track.declined = true;
|
|
115
|
+
const values = this.#turnedDown.get(field) ?? new Set();
|
|
116
|
+
values.add(track.shown.value);
|
|
117
|
+
this.#turnedDown.set(field, values);
|
|
87
118
|
return true;
|
|
88
119
|
}
|
|
89
|
-
/** Whether `suggestion` is the one in view for the field and the person turned it down. */
|
|
120
|
+
/** Whether `suggestion` is the one in view for the field and the person turned it down — now or before, in this record. */
|
|
90
121
|
declined(field, suggestion) {
|
|
91
122
|
const track = this.fields[field];
|
|
92
123
|
return track?.declined === true && sameSuggestion(track.shown, suggestion);
|
package/dist/headless.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { Draft, valuesOf, type Suggestion, type Value, type Values } from './draft.js';
|
|
1
|
+
export { Draft, valuesOf, type PromiseShown, type Suggestion, type Value, type Values } from './draft.js';
|
|
2
2
|
export { Session, englishStrings, type Abstain, type Basis, type FieldState, type Proposal, type Round, type Strings } from './session.js';
|
|
3
|
-
export { LowlineClient, LowlineError, type FieldReport, type ThresholdChoice } from './client.js';
|
|
3
|
+
export { LowlineClient, LowlineError, type Attachment, type FieldReport, type ThresholdChoice } from './client.js';
|
package/dist/lowline-form.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
import '@formdown/ui';
|
|
3
|
+
import { type Attachment } from './client.js';
|
|
3
4
|
import { type Values } from './draft.js';
|
|
4
5
|
import { type Strings } from './session.js';
|
|
5
6
|
/**
|
|
@@ -27,8 +28,27 @@ export declare class LowlineForm extends LitElement {
|
|
|
27
28
|
data: Record<string, unknown>;
|
|
28
29
|
/** How often a field's answer is held back to check it, from 0 to 1. */
|
|
29
30
|
rate: number;
|
|
31
|
+
/**
|
|
32
|
+
* The probability the host drew this record with to be settled again by a second person — an audit — from 0 (not
|
|
33
|
+
* audited, the default) to 1. Audited, the form shows none of what the first settler or the decider said: the decided
|
|
34
|
+
* fields' answers are held back with it as checks. Open the record with only the values it does not decide, and name
|
|
35
|
+
* the second person with `settled-by`.
|
|
36
|
+
*/
|
|
37
|
+
audit: number;
|
|
30
38
|
/** The words the form shows, in the host's language. */
|
|
31
39
|
strings: Strings;
|
|
40
|
+
/**
|
|
41
|
+
* Whether a suggestion the engine allows to go in unasked is put in as the field's starting value. Off by default: a
|
|
42
|
+
* value in a field reads as the person's own, so a suggestion stays beside the field until the person takes it. A host
|
|
43
|
+
* that turns it on puts values in before anyone looks, and a value put in and saved unchanged is settled as taken.
|
|
44
|
+
*/
|
|
45
|
+
prefill: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* How often a suggestion's promise — how often a suggestion like it has been right, as a count out of ten — is shown
|
|
48
|
+
* beside it, from 0 to 1. Off (0) by default. Drawn once for each suggestion shown, and the draw is sent with the save,
|
|
49
|
+
* so a host can measure whether showing it helps people settle rightly before turning it on for everyone.
|
|
50
|
+
*/
|
|
51
|
+
promiseRate: number;
|
|
32
52
|
/** Who is writing, as an opaque id the host gives — one person, one id; not a name. Sent with the save when set. */
|
|
33
53
|
settledBy: string;
|
|
34
54
|
/** The batch the record is written in, when several come at once from one source. Sent with the save when set. */
|
|
@@ -61,10 +81,11 @@ export declare class LowlineForm extends LitElement {
|
|
|
61
81
|
}>;
|
|
62
82
|
private settleWith;
|
|
63
83
|
/**
|
|
64
|
-
* Fills the record from `text` — what the person wrote
|
|
65
|
-
* value it gives is offered in its field for the person to take. Nothing is put in
|
|
84
|
+
* Fills the record from `text` — what the person wrote — and `attachments` — what they showed: a photo, a scan —
|
|
85
|
+
* through the host's model: each value it gives is offered in its field for the person to take. Nothing is put in
|
|
86
|
+
* on its own.
|
|
66
87
|
*/
|
|
67
|
-
fill(text: string): Promise<void>;
|
|
88
|
+
fill(text: string, attachments?: Attachment[]): Promise<void>;
|
|
68
89
|
/** Asks again what to show for the decided fields still open. */
|
|
69
90
|
ask(): Promise<void>;
|
|
70
91
|
/**
|
package/dist/lowline-form.js
CHANGED
|
@@ -39,8 +39,27 @@ let LowlineForm = class LowlineForm extends LitElement {
|
|
|
39
39
|
this.data = {};
|
|
40
40
|
/** How often a field's answer is held back to check it, from 0 to 1. */
|
|
41
41
|
this.rate = 0.05;
|
|
42
|
+
/**
|
|
43
|
+
* The probability the host drew this record with to be settled again by a second person — an audit — from 0 (not
|
|
44
|
+
* audited, the default) to 1. Audited, the form shows none of what the first settler or the decider said: the decided
|
|
45
|
+
* fields' answers are held back with it as checks. Open the record with only the values it does not decide, and name
|
|
46
|
+
* the second person with `settled-by`.
|
|
47
|
+
*/
|
|
48
|
+
this.audit = 0;
|
|
42
49
|
/** The words the form shows, in the host's language. */
|
|
43
50
|
this.strings = englishStrings;
|
|
51
|
+
/**
|
|
52
|
+
* Whether a suggestion the engine allows to go in unasked is put in as the field's starting value. Off by default: a
|
|
53
|
+
* value in a field reads as the person's own, so a suggestion stays beside the field until the person takes it. A host
|
|
54
|
+
* that turns it on puts values in before anyone looks, and a value put in and saved unchanged is settled as taken.
|
|
55
|
+
*/
|
|
56
|
+
this.prefill = false;
|
|
57
|
+
/**
|
|
58
|
+
* How often a suggestion's promise — how often a suggestion like it has been right, as a count out of ten — is shown
|
|
59
|
+
* beside it, from 0 to 1. Off (0) by default. Drawn once for each suggestion shown, and the draw is sent with the save,
|
|
60
|
+
* so a host can measure whether showing it helps people settle rightly before turning it on for everyone.
|
|
61
|
+
*/
|
|
62
|
+
this.promiseRate = 0;
|
|
44
63
|
/** Who is writing, as an opaque id the host gives — one person, one id; not a name. Sent with the save when set. */
|
|
45
64
|
this.settledBy = '';
|
|
46
65
|
/** The batch the record is written in, when several come at once from one source. Sent with the save when set. */
|
|
@@ -60,6 +79,8 @@ let LowlineForm = class LowlineForm extends LitElement {
|
|
|
60
79
|
const formdown = this.formdown;
|
|
61
80
|
if (formdown)
|
|
62
81
|
formdown.updateData({ ...formdown.data, [field]: value });
|
|
82
|
+
// A value taken is one the records can answer from: ask again, as after a value typed.
|
|
83
|
+
this.changed();
|
|
63
84
|
};
|
|
64
85
|
this.declined = (event) => {
|
|
65
86
|
const { field } = event.detail;
|
|
@@ -80,11 +101,26 @@ let LowlineForm = class LowlineForm extends LitElement {
|
|
|
80
101
|
this.client = new LowlineClient(this.src);
|
|
81
102
|
this.canJudge = true;
|
|
82
103
|
}
|
|
83
|
-
if (changed.has('record') ||
|
|
104
|
+
if (changed.has('record') ||
|
|
105
|
+
changed.has('form') ||
|
|
106
|
+
changed.has('data') ||
|
|
107
|
+
changed.has('content') ||
|
|
108
|
+
changed.has('audit')) {
|
|
84
109
|
// The values it was opened with are taken before anything is suggested or put in.
|
|
85
110
|
this.session = new Session(this.record, valuesOf(this.data), this.rate, Math.random, this.strings);
|
|
111
|
+
this.session.prefills = this.prefill;
|
|
112
|
+
this.session.promises = this.promiseRate;
|
|
113
|
+
this.session.audit = this.audit;
|
|
86
114
|
this.fieldStates = {};
|
|
87
115
|
}
|
|
116
|
+
else if (this.session) {
|
|
117
|
+
if (changed.has('prefill'))
|
|
118
|
+
this.session.prefills = this.prefill;
|
|
119
|
+
if (changed.has('promiseRate'))
|
|
120
|
+
this.session.promises = this.promiseRate;
|
|
121
|
+
if (changed.has('strings'))
|
|
122
|
+
this.session.strings = this.strings;
|
|
123
|
+
}
|
|
88
124
|
}
|
|
89
125
|
updated(changed) {
|
|
90
126
|
if (changed.has('record') || changed.has('form') || changed.has('content'))
|
|
@@ -127,19 +163,22 @@ let LowlineForm = class LowlineForm extends LitElement {
|
|
|
127
163
|
return saved;
|
|
128
164
|
}
|
|
129
165
|
/**
|
|
130
|
-
* Fills the record from `text` — what the person wrote
|
|
131
|
-
* value it gives is offered in its field for the person to take. Nothing is put in
|
|
166
|
+
* Fills the record from `text` — what the person wrote — and `attachments` — what they showed: a photo, a scan —
|
|
167
|
+
* through the host's model: each value it gives is offered in its field for the person to take. Nothing is put in
|
|
168
|
+
* on its own.
|
|
132
169
|
*/
|
|
133
|
-
async fill(text) {
|
|
170
|
+
async fill(text, attachments) {
|
|
134
171
|
const session = this.session;
|
|
135
172
|
if (!session || !this.form)
|
|
136
173
|
return;
|
|
137
|
-
const proposals = await this.client.fill(this.form, this.values(), text);
|
|
174
|
+
const proposals = await this.client.fill(this.form, this.values(), text, attachments);
|
|
138
175
|
if (session !== this.session)
|
|
139
176
|
return;
|
|
140
177
|
this.fieldStates = session.applyFill(proposals);
|
|
141
178
|
if (this.formdown)
|
|
142
179
|
this.formdown.fieldStates = this.fieldStates;
|
|
180
|
+
// The fields the writing did not fill keep what the records say of them.
|
|
181
|
+
void this.ask();
|
|
143
182
|
}
|
|
144
183
|
/** Asks again what to show for the decided fields still open. */
|
|
145
184
|
async ask() {
|
|
@@ -169,7 +208,7 @@ let LowlineForm = class LowlineForm extends LitElement {
|
|
|
169
208
|
session.took(this.values());
|
|
170
209
|
}
|
|
171
210
|
formdown.fieldStates = this.fieldStates;
|
|
172
|
-
if (this.canJudge)
|
|
211
|
+
if (this.canJudge && !session.auditing)
|
|
173
212
|
void this.judge(session, values, shown);
|
|
174
213
|
}
|
|
175
214
|
/**
|
|
@@ -219,9 +258,18 @@ __decorate([
|
|
|
219
258
|
__decorate([
|
|
220
259
|
property({ type: Number })
|
|
221
260
|
], LowlineForm.prototype, "rate", void 0);
|
|
261
|
+
__decorate([
|
|
262
|
+
property({ type: Number })
|
|
263
|
+
], LowlineForm.prototype, "audit", void 0);
|
|
222
264
|
__decorate([
|
|
223
265
|
property({ attribute: false })
|
|
224
266
|
], LowlineForm.prototype, "strings", void 0);
|
|
267
|
+
__decorate([
|
|
268
|
+
property({ type: Boolean })
|
|
269
|
+
], LowlineForm.prototype, "prefill", void 0);
|
|
270
|
+
__decorate([
|
|
271
|
+
property({ type: Number, attribute: 'promise-rate' })
|
|
272
|
+
], LowlineForm.prototype, "promiseRate", void 0);
|
|
225
273
|
__decorate([
|
|
226
274
|
property({ attribute: 'settled-by' })
|
|
227
275
|
], LowlineForm.prototype, "settledBy", void 0);
|
package/dist/session.d.ts
CHANGED
|
@@ -27,10 +27,12 @@ export interface Proposal {
|
|
|
27
27
|
together?: string | null;
|
|
28
28
|
/**
|
|
29
29
|
* How often an answer of this kind for this field has been right — the replay's precision at the threshold the
|
|
30
|
-
* suggestion was held to. Absent with no suggestion, for a
|
|
31
|
-
* were chosen.
|
|
30
|
+
* suggestion was held to. Absent with no suggestion, for a value from elsewhere, for a judgement until the score it
|
|
31
|
+
* is trusted from was chosen from the records, and before thresholds were chosen.
|
|
32
32
|
*/
|
|
33
33
|
promise?: number;
|
|
34
|
+
/** For a judgement from outside the records: the score it gave the suggestion, on its own scale. The draft keeps it. */
|
|
35
|
+
score?: number;
|
|
34
36
|
/** Whether the field takes several values: it is settled as a set, which cannot be a check, so none is drawn for it. */
|
|
35
37
|
several?: boolean;
|
|
36
38
|
}
|
|
@@ -53,6 +55,18 @@ export interface Strings {
|
|
|
53
55
|
fromJudgement: string;
|
|
54
56
|
/** The note of a value filled in from what the person wrote. */
|
|
55
57
|
fromWriting: string;
|
|
58
|
+
/**
|
|
59
|
+
* The note of an empty decided field shown no suggestion, by why: a field is never left looking like one that is not
|
|
60
|
+
* decided. An empty text shows no note for that reason.
|
|
61
|
+
*/
|
|
62
|
+
abstain: Record<Abstain, string>;
|
|
63
|
+
/** The note of an empty decided field a judgement was asked for and gave nothing the form can show. */
|
|
64
|
+
judgedNothing: string;
|
|
65
|
+
/**
|
|
66
|
+
* How often a suggestion like the one shown has been right, as a count out of ten — `{right}` is filled in. Said only
|
|
67
|
+
* when the host turns the display on (`promises`), after where the suggestion comes from.
|
|
68
|
+
*/
|
|
69
|
+
promise: string;
|
|
56
70
|
}
|
|
57
71
|
export declare const englishStrings: Strings;
|
|
58
72
|
/** What the form does with one round of proposals: what each field shows, and the values to put in unasked. */
|
|
@@ -69,7 +83,8 @@ export declare class Session {
|
|
|
69
83
|
readonly id: string;
|
|
70
84
|
readonly rate: number;
|
|
71
85
|
private readonly random;
|
|
72
|
-
|
|
86
|
+
/** The words the form shows; a host may change them while a record is written, and the next round says them. */
|
|
87
|
+
strings: Strings;
|
|
73
88
|
/** A steady clock in milliseconds (`performance.now()` by default): the record's times are read from it. */
|
|
74
89
|
private readonly clock;
|
|
75
90
|
draft: Draft;
|
|
@@ -78,11 +93,37 @@ export declare class Session {
|
|
|
78
93
|
private filled;
|
|
79
94
|
/** What filling from the person's writing offers, by field, until the person picks it or turns it down. */
|
|
80
95
|
private written;
|
|
96
|
+
/** Why filling from the person's writing gave a field nothing to offer, by field, until it offers one. */
|
|
97
|
+
private unfilled;
|
|
81
98
|
/** The judgement asked for each field, by what it reads; `null` while the host is still judging. */
|
|
82
99
|
private judgements;
|
|
100
|
+
/**
|
|
101
|
+
* Whether a suggestion the engine allows to go in unasked (`prefill`) is put in as the field's starting value. Off, it
|
|
102
|
+
* stays beside the field until the person takes it.
|
|
103
|
+
*/
|
|
104
|
+
prefills: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* How often the promise of a suggestion is shown beside it, from 0 (never — the default) to 1 (always). Drawn once for
|
|
107
|
+
* each suggestion a field shows, and the draw goes into the draft — so the records can tell whether seeing it changed
|
|
108
|
+
* what people settled. A value outside 0 to 1 shows none.
|
|
109
|
+
*/
|
|
110
|
+
promises: number;
|
|
111
|
+
/**
|
|
112
|
+
* The probability this record was drawn with to be settled again by a second person — an audit — or 0 (the default)
|
|
113
|
+
* for a record written as usual. Above 0 and at most 1, the person is shown nothing the first settler or the decider
|
|
114
|
+
* said: every decided field's answer is held back with this probability (a check), and no other suggestion, note or
|
|
115
|
+
* judgement is shown. The host draws the record and opens it with only the values it did not decide.
|
|
116
|
+
*/
|
|
117
|
+
audit: number;
|
|
118
|
+
/** Whether the record is being audited: `audit` is a probability above 0 and at most 1. */
|
|
119
|
+
get auditing(): boolean;
|
|
120
|
+
/** The promise draw of the suggestion each field shows: whether its promise is shown. */
|
|
121
|
+
private promised;
|
|
83
122
|
/** The values the form held when it was last looked at, to tell which fields' values arrived since. */
|
|
84
123
|
private seen;
|
|
85
|
-
constructor(id: string, opened: Values, rate?: number, random?: () => number,
|
|
124
|
+
constructor(id: string, opened: Values, rate?: number, random?: () => number,
|
|
125
|
+
/** The words the form shows; a host may change them while a record is written, and the next round says them. */
|
|
126
|
+
strings?: Strings,
|
|
86
127
|
/** A steady clock in milliseconds (`performance.now()` by default): the record's times are read from it. */
|
|
87
128
|
clock?: () => number);
|
|
88
129
|
/**
|
|
@@ -131,6 +172,15 @@ export declare class Session {
|
|
|
131
172
|
saved(values: Values): void;
|
|
132
173
|
/** Whether the field's answer is held back now — drawn the first time a checkable value is proposed for it. */
|
|
133
174
|
private draw;
|
|
175
|
+
/** How often promises are shown: `promises` when it is one, else never. */
|
|
176
|
+
private promiseRate;
|
|
177
|
+
/** Whether the promise of the field's suggestion `value` is shown — drawn the first time that suggestion is shown. */
|
|
178
|
+
private promiseShown;
|
|
179
|
+
/**
|
|
180
|
+
* A promise as a count out of ten, rounded down: a promise is never said higher than the records bear it out, and a
|
|
181
|
+
* count reads more plainly than a percentage.
|
|
182
|
+
*/
|
|
183
|
+
private promiseNote;
|
|
134
184
|
/** Where the suggestion comes from, in words. A field's value is shown as the record holds it now. */
|
|
135
185
|
private note;
|
|
136
186
|
}
|