-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathMakefile
More file actions
432 lines (385 loc) · 21.4 KB
/
Copy pathMakefile
File metadata and controls
432 lines (385 loc) · 21.4 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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
.PHONY: help examples example-1 example-2 example-3 example-4 example-5 example-6 example-7 example-8 example-9 example-10 example-11 example-12 example-13 example-14 example-15 example-16 example-17 example-18 example-19 example-20 example-21 example-22 example-23 example-24 example-25 example-26 example-27 example-28 example-29 example-30 example-31 example-32 example-33 example-34 example-35 example-36 example-37 example-38 test test-esm typecheck-tests lint build browser browser-serve
# Default target
help:
@printf "\033[1;36mDeepgram JavaScript SDK - Makefile Commands\033[0m\n"
@echo ""
@printf "\033[1;33mDevelopment Commands:\033[0m\n"
@printf " \033[1;32mmake lint\033[0m - Run Biome linter and formatter to check code quality\n"
@printf " \033[1;32mmake build\033[0m - Compile TypeScript to both CommonJS and ESM formats\n"
@printf " \033[1;32mmake test\033[0m - Fix wire test imports and run the test suite\n"
@printf " \033[1;32mmake test-esm\033[0m - Run ESM build validation tests\n"
@echo ""
@printf "\033[1;33mExample Commands:\033[0m\n"
@printf " \033[1;32mmake examples\033[0m - Run all example scripts (1-38) sequentially\n"
@printf " \033[1;32mmake example-N\033[0m - Run a specific example by number (e.g., make example-1)\n"
@printf " \033[1;32mmake browser\033[0m - Run browser tests\n"
@printf " \033[1;32mmake browser-serve\033[0m - Serve the browser examples for manual testing\n"
@echo ""
@printf "\033[1;33mAvailable Examples:\033[0m\n"
@printf " \033[36m1\033[0m - Authentication API Key\n"
@printf " \033[36m2\033[0m - Authentication Access Token\n"
@printf " \033[36m3\033[0m - Authentication Proxy\n"
@printf " \033[36m4\033[0m - Transcription Prerecorded URL\n"
@printf " \033[36m5\033[0m - Transcription Prerecorded File\n"
@printf " \033[36m6\033[0m - Transcription Prerecorded Callback\n"
@printf " \033[36m7\033[0m - Transcription Live WebSocket\n"
@printf " \033[36m8\033[0m - Transcription Captions\n"
@printf " \033[36m9\033[0m - Voice Agent\n"
@printf " \033[36m10\033[0m - Text-to-Speech Single\n"
@printf " \033[36m11\033[0m - Text-to-Speech Streaming\n"
@printf " \033[36m12\033[0m - Text Intelligence\n"
@printf " \033[36m13\033[0m - Management Projects\n"
@printf " \033[36m14\033[0m - Management Keys\n"
@printf " \033[36m15\033[0m - Management Members\n"
@printf " \033[36m16\033[0m - Management Invites\n"
@printf " \033[36m17\033[0m - Management Usage\n"
@printf " \033[36m18\033[0m - Management Billing\n"
@printf " \033[36m19\033[0m - Management Models\n"
@printf " \033[36m20\033[0m - On-Premises Credentials\n"
@printf " \033[36m21\033[0m - Configuration Scoped\n"
@printf " \033[36m22\033[0m - Transcription Advanced Options\n"
@printf " \033[36m23\033[0m - File Upload Types\n"
@printf " \033[36m24\033[0m - Error Handling\n"
@printf " \033[36m25\033[0m - Binary Response\n"
@printf " \033[36m26\033[0m - Transcription Live WebSocket V2\n"
@printf " \033[36m27\033[0m - Deepgram Session Header\n"
@printf " \033[36m28\033[0m - Text Intelligence Advanced\n"
@printf " \033[36m29\033[0m - Management Usage Breakdown\n"
@printf " \033[36m30\033[0m - Management Billing Detailed\n"
@printf " \033[36m31\033[0m - Management Member Permissions\n"
@printf " \033[36m32\033[0m - Management Project Models\n"
@printf " \033[36m33\033[0m - Configuration EU Endpoint\n"
@printf " \033[36m34\033[0m - Agent Custom Providers\n"
@printf " \033[36m35\033[0m - Agent Provider Combinations\n"
@printf " \033[36m36\033[0m - Agent Inject Message\n"
# Run all examples
examples:
@printf "\033[1;36mRunning all examples...\033[0m\n\n"; \
TOTAL=38; \
PASS_COUNT=0; \
FAIL_COUNT=0; \
PASSED_LIST=""; \
FAILED_LIST=""; \
ERROR_DIR=/tmp/example-errors; \
mkdir -p $$ERROR_DIR; \
\
run_example() { \
NUM=$$1; \
FILE=$$2; \
NAME=$$3; \
PERCENT=$$((NUM * 100 / TOTAL)); \
BAR_LEN=25; \
FILLED=$$((NUM * BAR_LEN / TOTAL)); \
EMPTY=$$((BAR_LEN - FILLED)); \
printf "\r\033[1;33m[%2d/%2d]\033[0m [" "$$NUM" "$$TOTAL"; \
printf "\033[32m"; \
for i in $$(seq 1 $$FILLED); do printf "█"; done; \
printf "\033[90m"; \
for i in $$(seq 1 $$EMPTY); do printf "░"; done; \
printf "\033[0m] %3d%% \033[36m%s\033[0m ... " "$$PERCENT" "$$NAME"; \
ERROR_FILE=$$ERROR_DIR/example-$$NUM.err; \
if pnpm exec tsx "$$FILE" >$$ERROR_FILE 2>&1; then \
rm -f $$ERROR_FILE; \
printf "\033[1;32m✓ PASS\033[0m\n"; \
PASS_COUNT=$$((PASS_COUNT + 1)); \
if [ -z "$$PASSED_LIST" ]; then \
PASSED_LIST="$$NUM - $$NAME"; \
else \
PASSED_LIST="$$PASSED_LIST"$$'\n'"$$NUM - $$NAME"; \
fi; \
else \
printf "\033[1;31m✗ FAIL\033[0m\n"; \
FAIL_COUNT=$$((FAIL_COUNT + 1)); \
if [ -z "$$FAILED_LIST" ]; then \
FAILED_LIST="$$NUM - $$NAME"; \
else \
FAILED_LIST="$$FAILED_LIST"$$'\n'"$$NUM - $$NAME"; \
fi; \
fi; \
}; \
\
run_example 1 "examples/01-authentication-api-key.ts" "Authentication API Key"; \
run_example 2 "examples/02-authentication-access-token.ts" "Authentication Access Token"; \
run_example 3 "examples/03-authentication-proxy.ts" "Authentication Proxy"; \
run_example 4 "examples/04-transcription-prerecorded-url.ts" "Transcription Prerecorded URL"; \
run_example 5 "examples/05-transcription-prerecorded-file.ts" "Transcription Prerecorded File"; \
run_example 6 "examples/06-transcription-prerecorded-callback.ts" "Transcription Prerecorded Callback"; \
run_example 7 "examples/07-transcription-live-websocket.ts" "Transcription Live WebSocket"; \
run_example 8 "examples/08-transcription-captions.ts" "Transcription Captions"; \
run_example 9 "examples/09-voice-agent.ts" "Voice Agent"; \
run_example 10 "examples/10-text-to-speech-single.ts" "Text-to-Speech Single"; \
run_example 11 "examples/11-text-to-speech-streaming.ts" "Text-to-Speech Streaming"; \
run_example 12 "examples/12-text-intelligence.ts" "Text Intelligence"; \
run_example 13 "examples/13-management-projects.ts" "Management Projects"; \
run_example 14 "examples/14-management-keys.ts" "Management Keys"; \
run_example 15 "examples/15-management-members.ts" "Management Members"; \
run_example 16 "examples/16-management-invites.ts" "Management Invites"; \
run_example 17 "examples/17-management-usage.ts" "Management Usage"; \
run_example 18 "examples/18-management-billing.ts" "Management Billing"; \
run_example 19 "examples/19-management-models.ts" "Management Models"; \
run_example 20 "examples/20-onprem-credentials.ts" "On-Premises Credentials"; \
run_example 21 "examples/21-configuration-scoped.ts" "Configuration Scoped"; \
run_example 22 "examples/22-transcription-advanced-options.ts" "Transcription Advanced Options"; \
run_example 23 "examples/23-file-upload-types.ts" "File Upload Types"; \
run_example 24 "examples/24-error-handling.ts" "Error Handling"; \
run_example 25 "examples/25-binary-response.ts" "Binary Response"; \
run_example 26 "examples/26-transcription-live-websocket-v2.ts" "Transcription Live WebSocket V2"; \
run_example 27 "examples/27-deepgram-session-header.ts" "Deepgram Session Header"; \
run_example 28 "examples/28-text-intelligence-advanced.ts" "Text Intelligence Advanced"; \
run_example 29 "examples/29-management-usage-breakdown.ts" "Management Usage Breakdown"; \
run_example 30 "examples/30-management-billing-detailed.ts" "Management Billing Detailed"; \
run_example 31 "examples/31-management-member-permissions.ts" "Management Member Permissions"; \
run_example 32 "examples/32-management-project-models.ts" "Management Project Models"; \
run_example 33 "examples/33-configuration-eu-endpoint.ts" "Configuration EU Endpoint"; \
run_example 34 "examples/34-agent-custom-providers.ts" "Agent Custom Providers"; \
run_example 35 "examples/35-agent-provider-combinations.ts" "Agent Provider Combinations"; \
run_example 36 "examples/36-agent-inject-message.ts" "Agent Inject Message"; \
run_example 37 "examples/37-text-to-speech-streaming-flux.ts" "Text-to-Speech Streaming Flux (v2)"; \
run_example 38 "examples/38-transcription-flux-eot.ts" "Transcription Flux End-of-Turn"; \
\
printf "\n\033[1;36m=========================================\033[0m\n"; \
printf "\033[1;36mSummary Report\033[0m\n"; \
printf "\033[1;36m=========================================\033[0m\n\n"; \
printf "\033[1;32mPassed: %d/%d\033[0m\n" "$$PASS_COUNT" "$$TOTAL"; \
if [ "$$PASS_COUNT" -gt 0 ] && [ -n "$$PASSED_LIST" ]; then \
printf "\033[1;32m ✓ Passed examples:\033[0m\n"; \
echo "$$PASSED_LIST" | awk '{printf " \033[32m%s\033[0m\n", $$0}'; \
fi; \
printf "\n"; \
printf "\033[1;31mFailed: %d/%d\033[0m\n" "$$FAIL_COUNT" "$$TOTAL"; \
if [ "$$FAIL_COUNT" -gt 0 ] && [ -n "$$FAILED_LIST" ]; then \
printf "\033[1;31m ✗ Failed examples:\033[0m\n"; \
echo "$$FAILED_LIST" | awk '{printf " \033[31m%s\033[0m\n", $$0}'; \
printf "\n\033[1;33mError Details:\033[0m\n"; \
for err_file in $$ERROR_DIR/example-*.err; do \
if [ -f "$$err_file" ]; then \
NUM=$$(basename "$$err_file" | sed 's/example-\([0-9]*\)\.err/\1/'); \
printf "\n\033[1;31m Example %d Error:\033[0m\n" "$$NUM"; \
printf "\033[90m ────────────────────────────────────────\033[0m\n"; \
sed 's/^/ /' "$$err_file" | head -20; \
if [ $$(wc -l < "$$err_file") -gt 20 ]; then \
printf " \033[90m... (truncated, see %s for full output)\033[0m\n" "$$err_file"; \
fi; \
fi; \
done; \
printf "\n"; \
rm -rf $$ERROR_DIR; \
exit 1; \
else \
printf "\033[1;32m All examples passed! 🎉\033[0m\n\n"; \
rm -rf $$ERROR_DIR; \
exit 0; \
fi
# Individual example targets
example-1:
pnpm exec tsx examples/01-authentication-api-key.ts
example-2:
pnpm exec tsx examples/02-authentication-access-token.ts
example-3:
pnpm exec tsx examples/03-authentication-proxy.ts
example-4:
pnpm exec tsx examples/04-transcription-prerecorded-url.ts
example-5:
pnpm exec tsx examples/05-transcription-prerecorded-file.ts
example-6:
pnpm exec tsx examples/06-transcription-prerecorded-callback.ts
example-7:
pnpm exec tsx examples/07-transcription-live-websocket.ts
example-8:
pnpm exec tsx examples/08-transcription-captions.ts
example-9:
pnpm exec tsx examples/09-voice-agent.ts
example-10:
pnpm exec tsx examples/10-text-to-speech-single.ts
example-11:
pnpm exec tsx examples/11-text-to-speech-streaming.ts
example-12:
pnpm exec tsx examples/12-text-intelligence.ts
example-13:
pnpm exec tsx examples/13-management-projects.ts
example-14:
pnpm exec tsx examples/14-management-keys.ts
example-15:
pnpm exec tsx examples/15-management-members.ts
example-16:
pnpm exec tsx examples/16-management-invites.ts
example-17:
pnpm exec tsx examples/17-management-usage.ts
example-18:
pnpm exec tsx examples/18-management-billing.ts
example-19:
pnpm exec tsx examples/19-management-models.ts
example-20:
pnpm exec tsx examples/20-onprem-credentials.ts
example-21:
pnpm exec tsx examples/21-configuration-scoped.ts
example-22:
pnpm exec tsx examples/22-transcription-advanced-options.ts
example-23:
pnpm exec tsx examples/23-file-upload-types.ts
example-24:
pnpm exec tsx examples/24-error-handling.ts
example-25:
pnpm exec tsx examples/25-binary-response.ts
example-26:
pnpm exec tsx examples/26-transcription-live-websocket-v2.ts
example-27:
pnpm exec tsx examples/27-deepgram-session-header.ts
example-28:
pnpm exec tsx examples/28-text-intelligence-advanced.ts
example-29:
pnpm exec tsx examples/29-management-usage-breakdown.ts
example-30:
pnpm exec tsx examples/30-management-billing-detailed.ts
example-31:
pnpm exec tsx examples/31-management-member-permissions.ts
example-32:
pnpm exec tsx examples/32-management-project-models.ts
example-33:
pnpm exec tsx examples/33-configuration-eu-endpoint.ts
example-34:
pnpm exec tsx examples/34-agent-custom-providers.ts
example-35:
pnpm exec tsx examples/35-agent-provider-combinations.ts
example-36:
pnpm exec tsx examples/36-agent-inject-message.ts
example-37:
pnpm exec tsx examples/37-text-to-speech-streaming-flux.ts
example-38:
pnpm exec tsx examples/38-transcription-flux-eot.ts
lint:
pnpm exec biome lint --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none
pnpm exec biome format --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none
$(MAKE) typecheck-tests
# Type-check the backward-compat / regen type-assertion safety nets.
# vitest strips types at runtime and `make build` only covers `src`, so the
# Equals<>/@ts-expect-error assertions in these tests would otherwise never gate
# a build. See tsconfig.typecheck.json for the (intentionally focused) scope.
typecheck-tests:
pnpm exec tsc --noEmit -p tsconfig.typecheck.json
build:
pnpm --package=typescript --package=tsup dlx tsup src/index.ts --out-dir dist/browser --format iife --global-name Deepgram --clean --platform browser
pnpm exec tsc --project ./tsconfig.cjs.json
pnpm exec tsc --project ./tsconfig.esm.json
node scripts/rename-to-esm-files.js dist/esm
node scripts/validate-esm-build.mjs
test:
node scripts/fix-wire-test-imports.js
pnpm exec vitest --project unit --run
pnpm exec vitest --project wire --run
node scripts/revert-wire-test-imports.js
test-esm:
@printf "\033[1;36mRunning ESM build tests...\033[0m\n"
pnpm exec vitest run tests/esm-build.test.ts
browser:
@if [ -n "$$CI" ]; then \
echo "CI detected: Installing Playwright browsers without system dependencies"; \
pnpm exec playwright install chromium; \
else \
echo "Local environment: Attempting to install with system dependencies (may prompt for sudo)"; \
pnpm exec playwright install chromium --with-deps 2>/dev/null || \
{ echo "Failed with --with-deps, trying without..."; pnpm exec playwright install chromium; }; \
fi
@printf "\033[1;36mRunning browser tests...\033[0m\n\n"; \
pnpm exec vitest --project browser --run --reporter=json --reporter=verbose --outputFile=/tmp/browser-test-results.json > /tmp/browser-test-output.txt 2>&1; \
TEST_EXIT_CODE=$$?; \
printf "\n\033[1;36m=========================================\033[0m\n"; \
printf "\033[1;36mSummary Report\033[0m\n"; \
printf "\033[1;36m=========================================\033[0m\n\n"; \
if [ -f /tmp/browser-test-results.json ] && command -v node >/dev/null 2>&1; then \
printf 'const fs = require("fs");\n' > /tmp/browser-summary.js; \
printf 'try {\n' >> /tmp/browser-summary.js; \
printf ' const rawData = fs.readFileSync("/tmp/browser-test-results.json", "utf8");\n' >> /tmp/browser-summary.js; \
printf ' const data = JSON.parse(rawData);\n' >> /tmp/browser-summary.js; \
printf ' const testResults = data.testResults || [];\n' >> /tmp/browser-summary.js; \
printf ' let passCount = 0;\n' >> /tmp/browser-summary.js; \
printf ' let failCount = 0;\n' >> /tmp/browser-summary.js; \
printf ' const passed = [];\n' >> /tmp/browser-summary.js; \
printf ' const failed = [];\n' >> /tmp/browser-summary.js; \
printf ' const errors = [];\n' >> /tmp/browser-summary.js; \
printf ' testResults.forEach((result, idx) => {\n' >> /tmp/browser-summary.js; \
printf ' const num = idx + 1;\n' >> /tmp/browser-summary.js; \
printf ' const filePath = result.name || "";\n' >> /tmp/browser-summary.js; \
printf ' let fileName = filePath.split("/").pop();\n' >> /tmp/browser-summary.js; \
printf ' if (fileName.endsWith(".test.ts")) {\n' >> /tmp/browser-summary.js; \
printf ' fileName = fileName.slice(0, -8);\n' >> /tmp/browser-summary.js; \
printf ' }\n' >> /tmp/browser-summary.js; \
printf ' const match = fileName.match(/^(\\d+)-(.+)/);\n' >> /tmp/browser-summary.js; \
printf ' const name = match ? match[2].replace(/-/g, " ") : fileName;\n' >> /tmp/browser-summary.js; \
printf ' const hasFailures = result.status === "failed";\n' >> /tmp/browser-summary.js; \
printf ' if (hasFailures) {\n' >> /tmp/browser-summary.js; \
printf ' failCount++;\n' >> /tmp/browser-summary.js; \
printf ' failed.push(num + " - " + name);\n' >> /tmp/browser-summary.js; \
printf ' const testCases = result.assertionResults || [];\n' >> /tmp/browser-summary.js; \
printf ' const failedTests = testCases.filter(t => t.status === "failed");\n' >> /tmp/browser-summary.js; \
printf ' if (failedTests.length > 0) {\n' >> /tmp/browser-summary.js; \
printf ' const errorMessages = failedTests.map(t => {\n' >> /tmp/browser-summary.js; \
printf ' const title = t.title || "Unknown test";\n' >> /tmp/browser-summary.js; \
printf ' const failureMessages = t.failureMessages || [];\n' >> /tmp/browser-summary.js; \
printf ' const errorText = failureMessages.length > 0 ? failureMessages[0] : "No error message available";\n' >> /tmp/browser-summary.js; \
printf ' return { num, name, title, error: errorText };\n' >> /tmp/browser-summary.js; \
printf ' });\n' >> /tmp/browser-summary.js; \
printf ' errors.push(...errorMessages);\n' >> /tmp/browser-summary.js; \
printf ' } else if (result.failureMessage) {\n' >> /tmp/browser-summary.js; \
printf ' errors.push({ num, name, title: "Test suite", error: result.failureMessage });\n' >> /tmp/browser-summary.js; \
printf ' }\n' >> /tmp/browser-summary.js; \
printf ' } else {\n' >> /tmp/browser-summary.js; \
printf ' passCount++;\n' >> /tmp/browser-summary.js; \
printf ' passed.push(num + " - " + name);\n' >> /tmp/browser-summary.js; \
printf ' }\n' >> /tmp/browser-summary.js; \
printf ' });\n' >> /tmp/browser-summary.js; \
printf ' console.log("\\033[1;32mPassed: " + passCount + "/" + testResults.length + "\\033[0m");\n' >> /tmp/browser-summary.js; \
printf ' if (passed.length > 0) {\n' >> /tmp/browser-summary.js; \
printf ' console.log("\\033[1;32m ✓ Passed tests:\\033[0m");\n' >> /tmp/browser-summary.js; \
printf ' passed.forEach(p => console.log(" \\033[32m" + p + "\\033[0m"));\n' >> /tmp/browser-summary.js; \
printf ' }\n' >> /tmp/browser-summary.js; \
printf ' console.log("");\n' >> /tmp/browser-summary.js; \
printf ' console.log("\\033[1;31mFailed: " + failCount + "/" + testResults.length + "\\033[0m");\n' >> /tmp/browser-summary.js; \
printf ' if (failed.length > 0) {\n' >> /tmp/browser-summary.js; \
printf ' console.log("\\033[1;31m ✗ Failed tests:\\033[0m");\n' >> /tmp/browser-summary.js; \
printf ' failed.forEach(f => console.log(" \\033[31m" + f + "\\033[0m"));\n' >> /tmp/browser-summary.js; \
printf ' console.log("");\n' >> /tmp/browser-summary.js; \
printf ' if (errors.length > 0) {\n' >> /tmp/browser-summary.js; \
printf ' console.log("\\033[1;33mError Details:\\033[0m");\n' >> /tmp/browser-summary.js; \
printf ' errors.forEach(err => {\n' >> /tmp/browser-summary.js; \
printf ' console.log("");\n' >> /tmp/browser-summary.js; \
printf ' console.log("\\033[1;31m Test " + err.num + " - " + err.name + "\\033[0m");\n' >> /tmp/browser-summary.js; \
printf ' console.log("\\033[1;33m " + err.title + "\\033[0m");\n' >> /tmp/browser-summary.js; \
printf ' console.log("\\033[90m ────────────────────────────────────────\\033[0m");\n' >> /tmp/browser-summary.js; \
printf ' const errorLines = err.error.split("\\n").slice(0, 15);\n' >> /tmp/browser-summary.js; \
printf ' errorLines.forEach(line => console.log(" " + line));\n' >> /tmp/browser-summary.js; \
printf ' if (err.error.split("\\n").length > 15) {\n' >> /tmp/browser-summary.js; \
printf ' console.log(" \\033[90m... (truncated, see /tmp/browser-test-output.txt for full output)\\033[0m");\n' >> /tmp/browser-summary.js; \
printf ' }\n' >> /tmp/browser-summary.js; \
printf ' });\n' >> /tmp/browser-summary.js; \
printf ' console.log("");\n' >> /tmp/browser-summary.js; \
printf ' }\n' >> /tmp/browser-summary.js; \
printf ' } else {\n' >> /tmp/browser-summary.js; \
printf ' console.log("\\033[1;32m All tests passed! 🎉\\033[0m\\n");\n' >> /tmp/browser-summary.js; \
printf ' }\n' >> /tmp/browser-summary.js; \
printf '} catch (e) {\n' >> /tmp/browser-summary.js; \
printf ' console.log("\\033[1;33mCould not parse test results: " + e.message + "\\033[0m");\n' >> /tmp/browser-summary.js; \
printf ' console.log("\\033[90mFull test output available at /tmp/browser-test-output.txt\\033[0m");\n' >> /tmp/browser-summary.js; \
printf '}\n' >> /tmp/browser-summary.js; \
node /tmp/browser-summary.js; \
fi; \
exit $$TEST_EXIT_CODE
browser-serve:
@rm -f examples/browser/deepgram.js || true
@cp dist/browser/index.global.js examples/browser/deepgram.js
@echo "" >> examples/browser/deepgram.js
@echo "// Expose Deepgram as global for browser compatibility" >> examples/browser/deepgram.js
@echo "if (typeof window !== 'undefined') {" >> examples/browser/deepgram.js
@echo " window.Deepgram = Deepgram;" >> examples/browser/deepgram.js
@echo " window.deepgram = Deepgram;" >> examples/browser/deepgram.js
@echo "}" >> examples/browser/deepgram.js
@echo "Starting proxy server on port 8001..."
@node scripts/proxy-server.js & \
PROXY_PID=$$!; \
echo "Starting http-server on port 8000..."; \
pnpx http-server -p 8000 examples/browser & \
HTTP_SERVER_PID=$$!; \
trap "kill $$PROXY_PID $$HTTP_SERVER_PID 2>/dev/null; exit" EXIT INT TERM; \
echo "Servers started. Proxy: http://localhost:8001, Examples: http://localhost:8000"; \
echo "Press CTRL-C to stop both servers"; \
wait $$PROXY_PID $$HTTP_SERVER_PID