-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvxsuite.patch
More file actions
255 lines (231 loc) · 7.86 KB
/
vxsuite.patch
File metadata and controls
255 lines (231 loc) · 7.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
diff --git a/apps/mark/backend/src/util/print_ballot.tsx b/apps/mark/backend/src/util/print_ballot.tsx
index 933f00d15..8d2367049 100644
--- a/apps/mark/backend/src/util/print_ballot.tsx
+++ b/apps/mark/backend/src/util/print_ballot.tsx
@@ -112,7 +112,8 @@ async function printMarkOverlay(p: PrintBallotProps): Promise<void> {
election,
p.ballotStyleId,
p.votes,
- p.store.getPrintCalibration()
+ p.store.getPrintCalibration(),
+ undefined
);
return p.printer.print({
diff --git a/apps/scan/backend/src/server.ts b/apps/scan/backend/src/server.ts
index 3c995d047..ae5b91883 100644
--- a/apps/scan/backend/src/server.ts
+++ b/apps/scan/backend/src/server.ts
@@ -90,28 +90,10 @@ export async function start({
nodeEnv: NODE_ENV,
});
- if (audioInfo.usb) {
- const resultDefaultAudio = await setDefaultAudio(audioInfo.usb.name, {
- logger,
- nodeEnv: NODE_ENV,
- });
- resultDefaultAudio.assertOk('unable to set USB audio as default output');
-
- // Screen reader volume levels are calibrated against a maximum system
- // volume setting:
- const resultVolume = await setAudioVolume({
- logger,
- nodeEnv: NODE_ENV,
- sinkName: audioInfo.usb.name,
- volumePct: 100,
- });
- resultVolume.assertOk('unable to set USB audio volume');
- } else {
- void logger.logAsCurrentRole(LogEventId.AudioDeviceMissing, {
- message: 'USB audio device not detected.',
- disposition: 'failure',
- });
- }
+ void logger.logAsCurrentRole(LogEventId.AudioDeviceMissing, {
+ message: 'USB audio device not detected.',
+ disposition: 'failure',
+ });
const audioPlayer = new AudioPlayer(NODE_ENV, logger, audioInfo.builtin.name);
diff --git a/libs/backend/src/system_call/get_audio_info.ts b/libs/backend/src/system_call/get_audio_info.ts
index b00654cf1..1499c0a07 100644
--- a/libs/backend/src/system_call/get_audio_info.ts
+++ b/libs/backend/src/system_call/get_audio_info.ts
@@ -31,11 +31,17 @@ const PactlSinkListSchema = z.array(
})
);
+const MOCK_AUDIO_INFO: AudioInfo = {
+ builtin: { headphonesActive: false, name: 'mock.builtin.stereo' },
+};
+
/** Get current system audio status. */
export async function getAudioInfo(ctx: {
logger: Logger;
nodeEnv: typeof NODE_ENV;
}): Promise<AudioInfo> {
+ return MOCK_AUDIO_INFO;
+
const { logger, nodeEnv } = ctx;
let errorOutput: string;
let commandOutput: string;
diff --git a/libs/hmpb/src/marking.test.ts b/libs/hmpb/src/marking.test.ts
index 025c6e183..6c01ee21f 100644
--- a/libs/hmpb/src/marking.test.ts
+++ b/libs/hmpb/src/marking.test.ts
@@ -26,7 +26,8 @@ test('places marks consistently', async () => {
election.unsafeUnwrap(),
fixture.ballotStyleId,
fixture.votes,
- { offsetMmX: 0, offsetMmY: 0 }
+ { offsetMmX: 0, offsetMmY: 0 },
+ undefined
);
const ballotBuf = fs.readFileSync(fixture.blankBallotPath);
diff --git a/libs/hmpb/src/marking.ts b/libs/hmpb/src/marking.ts
index 4bcd1f0e8..edc6043b3 100644
--- a/libs/hmpb/src/marking.ts
+++ b/libs/hmpb/src/marking.ts
@@ -10,7 +10,7 @@ import {
import fontKit from '@pdf-lib/fontkit';
import fs from 'node:fs';
-import { assert } from '@votingworks/basics';
+import { assert, throwIllegalValue } from '@votingworks/basics';
import {
ballotPaperDimensions,
Candidate,
@@ -60,6 +60,13 @@ const markSizeHalf = [markSize[0] * 0.5, markSize[1] * 0.5] as const;
const writeInFontSizeDefault = 12;
const writeInFontSizeReduced = 10;
+export type DrawCallbackResult = 'draw' | 'ignore';
+
+export interface DrawCallback {
+ (type: 'bubble', position: GridPosition, vote: Vote[number]): DrawCallbackResult;
+ (type: 'write-in-text', position: GridPosition, vote: Vote[number]): DrawCallbackResult;
+}
+
/**
* Generates a PDF with bubble marks in the expected positions for the given
* ballot style and corresponding votes.
@@ -74,7 +81,8 @@ export async function generateMarkOverlay(
ballotStyleId: string,
votes: VotesDict,
calibration: PrintCalibration,
- baseBallotPdf?: Uint8Array
+ baseBallotPdf: Uint8Array | undefined,
+ onDraw: DrawCallback = () => 'draw'
): Promise<Uint8Array> {
assert(
election.gridLayouts,
@@ -117,7 +125,7 @@ export async function generateMarkOverlay(
assert(
basePageSize.width === pageSize[0] && basePageSize.height === pageSize[1],
`base PDF size ([${basePageSize.width},${basePageSize.height}]) does ` +
- `not match expected (${pageSize})`
+ `not match expected (${pageSize})`
);
}
@@ -153,10 +161,23 @@ export async function generateMarkOverlay(
];
// Draw bubble mark using pdf-lib
- bubbleMark(page, [
- bubbleCenter[0] - markSizeHalf[0],
- pageSize[1] - bubbleCenter[1] + markSizeHalf[1],
- ]);
+ const bubbleDrawResult = onDraw('bubble', pos, mark.vote);
+ switch (bubbleDrawResult) {
+ case 'ignore': {
+ break;
+ }
+
+ case 'draw': {
+ bubbleMark(page, [
+ bubbleCenter[0] - markSizeHalf[0],
+ pageSize[1] - bubbleCenter[1] + markSizeHalf[1],
+ ]);
+ break;
+ }
+
+ default:
+ throwIllegalValue(bubbleDrawResult)
+ }
if (!mark.writeInName) continue;
@@ -178,12 +199,25 @@ export async function generateMarkOverlay(
origin[1] += 0.5 * (areaSize[1] - fontSize);
- page.drawText(name, {
- font: fontRobotoBold,
- size: fontSize,
- x: origin[0],
- y: pageSize[1] - origin[1] - fontSize,
- });
+ const writeInTextDrawResult = onDraw('write-in-text', pos, mark.vote);
+ switch (writeInTextDrawResult) {
+ case 'ignore': {
+ break;
+ }
+
+ case 'draw': {
+ page.drawText(name, {
+ font: fontRobotoBold,
+ size: fontSize,
+ x: origin[0],
+ y: pageSize[1] - origin[1] - fontSize,
+ });
+ break;
+ }
+
+ default:
+ throwIllegalValue(writeInTextDrawResult)
+ }
}
// Make sure we have an even number of pages, to match print order of the base
@@ -276,8 +310,8 @@ function bubbleMark(page: PDFPage, originTopLeft: [number, number]): void {
}
type MarkInfo =
- | { writeInName?: undefined }
- | { writeInArea: Rect; writeInName: string };
+ | { vote: Vote[number]; writeInName?: undefined }
+ | { vote: Vote[number]; writeInArea: Rect; writeInName: string };
/**
* Determines if this grid position should be marked based on the votes.
@@ -297,7 +331,7 @@ function markInfo(
// Handle yes/no votes
if (contest.type === 'yesno') {
assert(gridPos.type === 'option');
- if (vote === gridPos.optionId) return {};
+ if (vote === gridPos.optionId) return { vote };
continue;
}
// For candidate contests only
@@ -306,6 +340,7 @@ function markInfo(
if (gridPos.type === 'write-in') {
if (gridPos.writeInIndex === candidateVote.writeInIndex) {
return {
+ vote,
writeInArea: gridPos.writeInArea,
writeInName: candidateVote.name,
};
@@ -315,7 +350,7 @@ function markInfo(
}
if (voteMatchesGridPosition(candidateVote, gridPos, layout.gridPositions)) {
- return {};
+ return { vote };
}
}
diff --git a/script/bootstrap b/script/bootstrap
index 1a8304cfc..09defe092 100755
--- a/script/bootstrap
+++ b/script/bootstrap
@@ -2,17 +2,14 @@
set -euo pipefail
-local_user=`logname`
-local_user_home_dir=$( getent passwd "${local_user}" | cut -d: -f6 )
-
# Make sure PATH includes cargo and /sbin
-export PATH="${local_user_home_dir}/.cargo/bin:${PATH}:/sbin/"
+export PATH="${HOME}/.cargo/bin:${PATH}:/sbin/"
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
for app in ${DIR}/../apps/*/frontend ${DIR}/../apps/*/backend; do
if [ -d "${app}" ]; then
- make -C "${app}" bootstrap
+ make -C "${app}" -n bootstrap && make -C "${app}" bootstrap
fi
done