arcane-os 0.2.2 → 0.3.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/CHANGELOG.md +29 -0
- package/README.md +8 -8
- package/browser-runtime/ARCANE_SDK_BROWSER_RELEASE.json +29 -22
- package/browser-runtime/ai/ARCANE_AI_BROWSER_SPEECH_COMPONENTS.json +203 -0
- package/browser-runtime/ai/browser-kokoro-worker.mjs +11 -2
- package/browser-runtime/ai/browser-speech-artifacts.mjs +3230 -397
- package/browser-runtime/ai/browser-speech-providers.mjs +1141 -157
- package/browser-runtime/ai/browser-speech.mjs +2 -0
- package/browser-runtime/ai/browser-whisper-worker.mjs +11 -2
- package/browser-runtime/ai/model-controller.mjs +285 -95
- package/browser-runtime/ai/speech-worker-client.mjs +247 -32
- package/browser-runtime/ai/speech-worker-runtime.mjs +2310 -167
- package/browser-runtime/event-manager.mjs +1097 -1
- package/docs/architecture.md +2 -2
- package/docs/event-manager.md +155 -27
- package/docs/reference/README.md +27 -27
- package/docs/reference/ai/browser-speech-package-authority.json +835 -0
- package/docs/reference/ai/browser-speech.md +1162 -246
- package/docs/reference/ai/browser-wasm.md +18 -7
- package/docs/reference/availability-and-normalization.md +6 -3
- package/docs/reference/behavioral-testing.md +29 -6
- package/docs/reference/cli.md +117 -9
- package/docs/reference/core/arcane-ai-contracts.md +1 -1
- package/docs/reference/event-manager.md +577 -32
- package/docs/reference/inventory/package-api.json +478 -2
- package/docs/reference/inventory/runtime-components.json +108 -44
- package/docs/reference/inventory/runtime-modules.json +131 -53
- package/docs/reference/mail.md +316 -0
- package/docs/reference/protocols.md +157 -43
- package/docs/reference/runtime-components.md +258 -83
- package/docs/reference/runtime-modules.md +613 -77
- package/docs/reference/sdk-api.md +1014 -25
- package/package.json +5 -4
- package/runtime/ARCANE_RUNTIME_RELEASE.json +145 -140
- package/runtime/arcane/components/app-bar.html +34 -13
- package/runtime/arcane/components/assistant-panel.html +110 -57
- package/runtime/arcane/components/calculator.html +7 -4
- package/runtime/arcane/components/chart.html +58 -17
- package/runtime/arcane/components/chat.html +606 -136
- package/runtime/arcane/components/conversation-view.html +13 -6
- package/runtime/arcane/components/dashboard-config.html +96 -59
- package/runtime/arcane/components/data-maintenance.html +69 -14
- package/runtime/arcane/components/data-view.html +53 -7
- package/runtime/arcane/components/directory-picker.html +118 -32
- package/runtime/arcane/components/document-inspector.html +47 -10
- package/runtime/arcane/components/file-drop.html +81 -35
- package/runtime/arcane/components/file-inspector.html +72 -22
- package/runtime/arcane/components/file-manager.html +374 -79
- package/runtime/arcane/components/integration-settings.html +12 -5
- package/runtime/arcane/components/local-ai-status.html +48 -19
- package/runtime/arcane/components/markdown-document.html +161 -68
- package/runtime/arcane/components/markdown-editor.html +110 -33
- package/runtime/arcane/components/media-embed.html +8 -5
- package/runtime/arcane/components/modal.html +15 -5
- package/runtime/arcane/components/output-panel.html +28 -23
- package/runtime/arcane/components/preferences-form.html +22 -4
- package/runtime/arcane/components/record-timeline.html +18 -2
- package/runtime/arcane/components/relationship-board.html +23 -3
- package/runtime/arcane/components/screen-capture.html +10 -4
- package/runtime/arcane/components/source-code-viewer.html +76 -9
- package/runtime/arcane/components/source-explanation.html +23 -3
- package/runtime/arcane/components/speech.html +462 -384
- package/runtime/arcane/components/summary-strip.html +22 -11
- package/runtime/arcane/components/table.html +39 -21
- package/runtime/arcane/components/task-progress.html +79 -21
- package/runtime/arcane/components/terminal-workspace.html +7 -4
- package/runtime/arcane/components/theme-editor.html +7 -3
- package/runtime/arcane/components/unified-inbox.html +9 -4
- package/runtime/arcane/components/voice-transcription.html +639 -98
- package/runtime/arcane/components/weather-widget.html +5 -3
- package/runtime/arcane/components/web-navigator.html +48 -8
- package/runtime/arcane/entities/Chat.js +1 -1
- package/runtime/arcane/entities/User.js +110 -23
- package/runtime/arcane/modules/AI.js +2109 -130
- package/runtime/arcane/modules/AIProviderRuntime.js +720 -13
- package/runtime/arcane/modules/AIRuntimeState.js +109 -52
- package/runtime/arcane/modules/ApiModelDatabase.js +390 -17
- package/runtime/arcane/modules/BrowserTestSuite.js +205 -28
- package/runtime/arcane/modules/CalculatorEngine.js +63 -3
- package/runtime/arcane/modules/CommunicationAppController.js +588 -28
- package/runtime/arcane/modules/CommunicationHub.js +590 -10
- package/runtime/arcane/modules/ComponentContracts.js +470 -0
- package/runtime/arcane/modules/ConversationTimebox.js +152 -33
- package/runtime/arcane/modules/DBLS.js +40 -7
- package/runtime/arcane/modules/DBOPFS.js +35 -11
- package/runtime/arcane/modules/DataMaintenance.js +12 -2
- package/runtime/arcane/modules/Errors.js +65 -7
- package/runtime/arcane/modules/HTMLImport.js +198 -14
- package/runtime/arcane/modules/LocalAIReadinessController.js +208 -29
- package/runtime/arcane/modules/Mail.js +738 -115
- package/runtime/arcane/modules/MailOutbox.mjs +1395 -0
- package/runtime/arcane/modules/MailTransport.mjs +197 -39
- package/runtime/arcane/modules/Ollama.js +36 -1
- package/runtime/arcane/modules/OpenMeteoWeatherProvider.js +583 -7
- package/runtime/arcane/modules/PreferenceStore.js +367 -33
- package/runtime/arcane/modules/RecordReviewStore.js +322 -23
- package/runtime/arcane/modules/ScreenCapture.js +1397 -15
- package/runtime/arcane/modules/SpeechPlayback.js +438 -41
- package/runtime/arcane/modules/TerminalClient.js +277 -12
- package/runtime/arcane/modules/ThemeBootstrap.js +80 -6
- package/runtime/arcane/modules/ThemeManager.js +39 -7
- package/runtime/arcane/modules/TimeGuard.js +131 -20
- package/runtime/arcane/modules/WaitForComponent.js +386 -33
- package/schemas/arcane-lock.schema.json +2 -2
- package/src/cli/main.mjs +435 -9
- package/src/event-manager.mjs +1097 -1
- package/src/import-map.mjs +21 -3
- package/src/index.mjs +13 -0
- package/src/installed-sdk-runtime.mjs +112 -0
- package/src/mail-api.mjs +22 -0
- package/src/mail-credentials.mjs +667 -0
- package/src/mail-server.mjs +1769 -0
- package/src/mail.mjs +261 -0
- package/src/sdk-browser-runtime.mjs +85 -41
- package/src/testing-loader.mjs +7 -0
- package/src/toolchain.mjs +3 -0
- package/src/workspace.mjs +1 -1
|
@@ -1,5 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createArcaneEventSource,
|
|
3
|
+
projectArcaneDOMEvent
|
|
4
|
+
} from 'arcane-os/event-manager';
|
|
5
|
+
|
|
1
6
|
const own=(value,key)=>Object.prototype.hasOwnProperty.call(value,key);
|
|
2
7
|
|
|
8
|
+
const STT_ACTIVATION_EVENT_TYPES=Object.freeze({
|
|
9
|
+
error:'speech-stt-activation-error',
|
|
10
|
+
request:'speech-stt-activation-request'
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const STT_ACTIVATION_ERROR_CODES=Object.freeze({
|
|
14
|
+
buttonInvalid:'ARCANE_STT_ACTIVATION_BUTTON_INVALID',
|
|
15
|
+
buttonListenerFailed:'ARCANE_STT_ACTIVATION_BUTTON_LISTENER_FAILED',
|
|
16
|
+
domProjectionUnavailable:'ARCANE_STT_ACTIVATION_DOM_PROJECTION_UNAVAILABLE',
|
|
17
|
+
eventClassInvalid:'ARCANE_STT_ACTIVATION_EVENT_CLASS_INVALID',
|
|
18
|
+
eventSourceInvalid:'ARCANE_STT_ACTIVATION_EVENT_SOURCE_INVALID',
|
|
19
|
+
hostInvalid:'ARCANE_STT_ACTIVATION_HOST_INVALID',
|
|
20
|
+
onChangeInvalid:'ARCANE_STT_ACTIVATION_ON_CHANGE_INVALID',
|
|
21
|
+
presentationCallbackFailed:'ARCANE_STT_ACTIVATION_PRESENTATION_CALLBACK_FAILED',
|
|
22
|
+
requestRejected:'ARCANE_STT_ACTIVATION_REQUEST_REJECTED'
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const STT_ACTIVATION_REASONS=Object.freeze({
|
|
26
|
+
explicitRequest:'explicit-request',
|
|
27
|
+
presentationCallbackThrew:'activation-presentation-callback-threw',
|
|
28
|
+
requestRejected:'activation-request-rejected'
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
function codedError(message,code,ErrorClass=Error,cause){
|
|
32
|
+
const error=new ErrorClass(message);
|
|
33
|
+
error.code=code;
|
|
34
|
+
if(cause!==undefined){
|
|
35
|
+
error.cause=cause;
|
|
36
|
+
}
|
|
37
|
+
return error;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function projectSTTActivationEvent(
|
|
41
|
+
host,
|
|
42
|
+
occurrence,
|
|
43
|
+
EventClass,
|
|
44
|
+
options={}
|
|
45
|
+
){
|
|
46
|
+
if(typeof globalThis.CustomEvent!=='function'){
|
|
47
|
+
throw codedError(
|
|
48
|
+
'The STT activation DOM compatibility projection requires CustomEvent.',
|
|
49
|
+
STT_ACTIVATION_ERROR_CODES.domProjectionUnavailable
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
if(EventClass===globalThis.CustomEvent){
|
|
53
|
+
return projectArcaneDOMEvent(host,occurrence,options);
|
|
54
|
+
}
|
|
55
|
+
const compatibilityTarget={
|
|
56
|
+
dispatchEvent(projectedEvent){
|
|
57
|
+
const event=new EventClass(
|
|
58
|
+
projectedEvent.type,
|
|
59
|
+
{
|
|
60
|
+
detail:projectedEvent.detail,
|
|
61
|
+
bubbles:projectedEvent.bubbles,
|
|
62
|
+
composed:projectedEvent.composed,
|
|
63
|
+
cancelable:projectedEvent.cancelable
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
const accepted=host.dispatchEvent(event)!==false
|
|
67
|
+
&&!event.defaultPrevented;
|
|
68
|
+
if(!accepted&&projectedEvent.cancelable){
|
|
69
|
+
projectedEvent.preventDefault();
|
|
70
|
+
}
|
|
71
|
+
return accepted;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
return projectArcaneDOMEvent(compatibilityTarget,occurrence,options);
|
|
75
|
+
}
|
|
76
|
+
|
|
3
77
|
function record(value,label){
|
|
4
78
|
if(value===undefined){
|
|
5
79
|
return {};
|
|
@@ -327,6 +401,396 @@ function effectiveDashboardVisibility(definitions=[],visibility={}){
|
|
|
327
401
|
);
|
|
328
402
|
}
|
|
329
403
|
|
|
404
|
+
function createSTTActivationController({
|
|
405
|
+
host,
|
|
406
|
+
button,
|
|
407
|
+
onChange,
|
|
408
|
+
EventClass=globalThis.CustomEvent,
|
|
409
|
+
eventSource=null
|
|
410
|
+
}){
|
|
411
|
+
if(!host||typeof host.dispatchEvent!=='function'
|
|
412
|
+
||typeof host.requestSTTActivation!=='function'){
|
|
413
|
+
throw codedError(
|
|
414
|
+
'The STT activation host must provide dispatchEvent() and requestSTTActivation().',
|
|
415
|
+
STT_ACTIVATION_ERROR_CODES.hostInvalid,
|
|
416
|
+
TypeError
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
if(typeof EventClass!=='function'){
|
|
420
|
+
throw codedError(
|
|
421
|
+
'The STT activation event class must be a constructor.',
|
|
422
|
+
STT_ACTIVATION_ERROR_CODES.eventClassInvalid,
|
|
423
|
+
TypeError
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
if(!button
|
|
427
|
+
||typeof button.addEventListener!=='function'
|
|
428
|
+
||typeof button.removeEventListener!=='function'){
|
|
429
|
+
throw codedError(
|
|
430
|
+
'The STT activation button must provide addEventListener() and removeEventListener().',
|
|
431
|
+
STT_ACTIVATION_ERROR_CODES.buttonInvalid,
|
|
432
|
+
TypeError
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
if(typeof onChange!=='function'){
|
|
436
|
+
throw codedError(
|
|
437
|
+
'The STT activation onChange callback must be a function.',
|
|
438
|
+
STT_ACTIVATION_ERROR_CODES.onChangeInvalid,
|
|
439
|
+
TypeError
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
if(eventSource!==null
|
|
443
|
+
&&(
|
|
444
|
+
typeof eventSource!=='object'
|
|
445
|
+
||typeof eventSource.dispatch!=='function'
|
|
446
|
+
||typeof eventSource.dispose!=='function'
|
|
447
|
+
||typeof eventSource.instanceId!=='string'
|
|
448
|
+
)){
|
|
449
|
+
throw codedError(
|
|
450
|
+
'The STT activation event source must be a compatible Arcane event source.',
|
|
451
|
+
STT_ACTIVATION_ERROR_CODES.eventSourceInvalid,
|
|
452
|
+
TypeError
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
const ownsEventSource=eventSource===null;
|
|
456
|
+
const events=eventSource||createArcaneEventSource(
|
|
457
|
+
host,
|
|
458
|
+
{
|
|
459
|
+
source:'arcane.module.component-contracts.stt-activation',
|
|
460
|
+
eventTypes:Object.values(STT_ACTIVATION_EVENT_TYPES)
|
|
461
|
+
}
|
|
462
|
+
);
|
|
463
|
+
let role=null;
|
|
464
|
+
let requestPending=false;
|
|
465
|
+
let requestError='';
|
|
466
|
+
let requestGeneration=0;
|
|
467
|
+
let operationSequence=0;
|
|
468
|
+
let destroyed=false;
|
|
469
|
+
|
|
470
|
+
function visibleError(error,fallback){
|
|
471
|
+
const message=typeof error?.message==='string'
|
|
472
|
+
?error.message.trim()
|
|
473
|
+
:'';
|
|
474
|
+
return (message||fallback).slice(0,240);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
function cancellation(error){
|
|
478
|
+
return error?.name==='AbortError'
|
|
479
|
+
||[
|
|
480
|
+
'ARCANE_AI_REQUEST_ABORTED',
|
|
481
|
+
'ARCANE_AI_OPERATION_SUPERSEDED'
|
|
482
|
+
].includes(error?.code);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
function selected(){
|
|
486
|
+
return typeof role?.providerId==='string'
|
|
487
|
+
&&role.providerId.length>0
|
|
488
|
+
&&typeof role?.modelId==='string'
|
|
489
|
+
&&role.modelId.length>0;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
function action(){
|
|
493
|
+
if(!selected()){
|
|
494
|
+
return null;
|
|
495
|
+
}
|
|
496
|
+
if(role.state==='loading'){
|
|
497
|
+
return 'unload';
|
|
498
|
+
}
|
|
499
|
+
if(!role.busy&&['unloaded','error'].includes(role.state)){
|
|
500
|
+
return 'load';
|
|
501
|
+
}
|
|
502
|
+
return null;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
function label(){
|
|
506
|
+
if(requestPending){
|
|
507
|
+
return 'Requesting…';
|
|
508
|
+
}
|
|
509
|
+
if(role?.state==='loading'){
|
|
510
|
+
return 'Cancel loading';
|
|
511
|
+
}
|
|
512
|
+
if(role?.state==='unloading'){
|
|
513
|
+
return 'Canceling…';
|
|
514
|
+
}
|
|
515
|
+
if(role?.state==='error'){
|
|
516
|
+
return 'Try again';
|
|
517
|
+
}
|
|
518
|
+
return 'Start transcription';
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
function title(){
|
|
522
|
+
if(requestPending){
|
|
523
|
+
return 'Requesting transcription activation.';
|
|
524
|
+
}
|
|
525
|
+
if(role?.state==='loading'){
|
|
526
|
+
return 'Cancel loading the selected transcription service.';
|
|
527
|
+
}
|
|
528
|
+
if(role?.state==='unloading'){
|
|
529
|
+
return 'The selected transcription service is being released.';
|
|
530
|
+
}
|
|
531
|
+
if(role?.state==='error'){
|
|
532
|
+
return requestError||visibleError(
|
|
533
|
+
role.error,
|
|
534
|
+
'Retry loading the selected transcription service.'
|
|
535
|
+
);
|
|
536
|
+
}
|
|
537
|
+
return 'Start the selected transcription service.';
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
function formatProgress(progress,fallback){
|
|
541
|
+
if(!progress){
|
|
542
|
+
return fallback;
|
|
543
|
+
}
|
|
544
|
+
const amount=progress.total===null
|
|
545
|
+
?`${progress.completed} ${progress.unit}`
|
|
546
|
+
:`${progress.completed} of ${progress.total} ${progress.unit}`;
|
|
547
|
+
const heartbeat=progress.heartbeat?', active heartbeat':'';
|
|
548
|
+
return `${progress.phase}, ${amount}${heartbeat}`;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
function status(){
|
|
552
|
+
if(requestError){
|
|
553
|
+
return `Transcription activation error: ${requestError}.`;
|
|
554
|
+
}
|
|
555
|
+
if(requestPending){
|
|
556
|
+
return 'Transcription activation requested.';
|
|
557
|
+
}
|
|
558
|
+
if(role?.state==='ready'){
|
|
559
|
+
return role.busy?'Transcription busy.':'Transcription ready.';
|
|
560
|
+
}
|
|
561
|
+
if(role?.state==='loading'){
|
|
562
|
+
return `Transcription ${formatProgress(role.progress,'loading')}; Cancel is available.`;
|
|
563
|
+
}
|
|
564
|
+
if(role?.state==='unloading'){
|
|
565
|
+
return `Transcription ${formatProgress(role.progress,'releasing')}.`;
|
|
566
|
+
}
|
|
567
|
+
if(role?.state==='error'){
|
|
568
|
+
return `Transcription error: ${visibleError(role.error,'Unknown error')}.`;
|
|
569
|
+
}
|
|
570
|
+
if(role?.state==='disposed'){
|
|
571
|
+
return 'Transcription disposed.';
|
|
572
|
+
}
|
|
573
|
+
if(role?.state==='unloaded'&&selected()){
|
|
574
|
+
return 'Transcription selected and waiting to load.';
|
|
575
|
+
}
|
|
576
|
+
return 'Transcription unavailable.';
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
function visible(){
|
|
580
|
+
return selected()
|
|
581
|
+
&&role.state!=='ready'
|
|
582
|
+
&&['unloaded','loading','unloading','error'].includes(role.state);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
async function request(nextAction){
|
|
586
|
+
if(destroyed||requestPending||action()!==nextAction){
|
|
587
|
+
return false;
|
|
588
|
+
}
|
|
589
|
+
const generation=++requestGeneration;
|
|
590
|
+
requestError='';
|
|
591
|
+
const intent=Object.freeze(
|
|
592
|
+
{
|
|
593
|
+
role:'stt',
|
|
594
|
+
action:nextAction,
|
|
595
|
+
reason:'user'
|
|
596
|
+
}
|
|
597
|
+
);
|
|
598
|
+
const activationRequest=Object.freeze({intent,state:role});
|
|
599
|
+
const operationId=
|
|
600
|
+
`${events.instanceId}:stt-activation:${(++operationSequence).toString(36)}`;
|
|
601
|
+
let requestInvoked=false;
|
|
602
|
+
requestPending=true;
|
|
603
|
+
try{
|
|
604
|
+
const publication=events.dispatch(
|
|
605
|
+
STT_ACTIVATION_EVENT_TYPES.request,
|
|
606
|
+
activationRequest,
|
|
607
|
+
{
|
|
608
|
+
cancelable:true,
|
|
609
|
+
operationId,
|
|
610
|
+
publicDetail:{
|
|
611
|
+
role:'stt',
|
|
612
|
+
action:nextAction,
|
|
613
|
+
reason:STT_ACTIVATION_REASONS.explicitRequest,
|
|
614
|
+
state:role.state,
|
|
615
|
+
roleOperationId:typeof role?.operationId==='string'
|
|
616
|
+
?role.operationId
|
|
617
|
+
:null
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
);
|
|
621
|
+
if(!publication.accepted
|
|
622
|
+
||!projectSTTActivationEvent(
|
|
623
|
+
host,
|
|
624
|
+
publication.occurrence,
|
|
625
|
+
EventClass,
|
|
626
|
+
{
|
|
627
|
+
bubbles:true,
|
|
628
|
+
composed:true,
|
|
629
|
+
cancelable:true
|
|
630
|
+
}
|
|
631
|
+
)
|
|
632
|
+
||destroyed
|
|
633
|
+
||generation!==requestGeneration
|
|
634
|
+
||action()!==nextAction){
|
|
635
|
+
return false;
|
|
636
|
+
}
|
|
637
|
+
onChange();
|
|
638
|
+
if(destroyed
|
|
639
|
+
||generation!==requestGeneration
|
|
640
|
+
||action()!==nextAction){
|
|
641
|
+
return false;
|
|
642
|
+
}
|
|
643
|
+
requestInvoked=true;
|
|
644
|
+
await host.requestSTTActivation(intent);
|
|
645
|
+
if(destroyed||generation!==requestGeneration){
|
|
646
|
+
return false;
|
|
647
|
+
}
|
|
648
|
+
return true;
|
|
649
|
+
}catch(error){
|
|
650
|
+
if(destroyed||generation!==requestGeneration){
|
|
651
|
+
return false;
|
|
652
|
+
}
|
|
653
|
+
if(nextAction==='load'
|
|
654
|
+
&&cancellation(error)
|
|
655
|
+
&&['unloaded','unloading'].includes(role?.state)){
|
|
656
|
+
return false;
|
|
657
|
+
}
|
|
658
|
+
const message=visibleError(
|
|
659
|
+
error,
|
|
660
|
+
`The transcription ${nextAction} request failed.`
|
|
661
|
+
);
|
|
662
|
+
requestError=message;
|
|
663
|
+
const code=requestInvoked
|
|
664
|
+
?STT_ACTIVATION_ERROR_CODES.requestRejected
|
|
665
|
+
:STT_ACTIVATION_ERROR_CODES.presentationCallbackFailed;
|
|
666
|
+
const reason=requestInvoked
|
|
667
|
+
?STT_ACTIVATION_REASONS.requestRejected
|
|
668
|
+
:STT_ACTIVATION_REASONS.presentationCallbackThrew;
|
|
669
|
+
const errorPublication=events.dispatch(
|
|
670
|
+
STT_ACTIVATION_EVENT_TYPES.error,
|
|
671
|
+
Object.freeze(
|
|
672
|
+
{
|
|
673
|
+
request:activationRequest,
|
|
674
|
+
error,
|
|
675
|
+
message
|
|
676
|
+
}
|
|
677
|
+
),
|
|
678
|
+
{
|
|
679
|
+
operationId,
|
|
680
|
+
publicDetail:{
|
|
681
|
+
role:'stt',
|
|
682
|
+
action:nextAction,
|
|
683
|
+
code,
|
|
684
|
+
reason,
|
|
685
|
+
causeCode:typeof error?.code==='string'
|
|
686
|
+
?error.code
|
|
687
|
+
:null
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
);
|
|
691
|
+
projectSTTActivationEvent(
|
|
692
|
+
host,
|
|
693
|
+
errorPublication.occurrence,
|
|
694
|
+
EventClass,
|
|
695
|
+
{
|
|
696
|
+
bubbles:true,
|
|
697
|
+
composed:true
|
|
698
|
+
}
|
|
699
|
+
);
|
|
700
|
+
return false;
|
|
701
|
+
}finally{
|
|
702
|
+
if(!destroyed&&generation===requestGeneration){
|
|
703
|
+
requestPending=false;
|
|
704
|
+
try{
|
|
705
|
+
onChange();
|
|
706
|
+
}catch(error){
|
|
707
|
+
console.error('Unable to render STT activation state:',error);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
function activateSelectedSTT(){
|
|
714
|
+
const nextAction=action();
|
|
715
|
+
if(nextAction){
|
|
716
|
+
void request(nextAction).catch(
|
|
717
|
+
function reportSTTActivationRequestFailure(error){
|
|
718
|
+
console.error('The STT activation request could not settle.',error);
|
|
719
|
+
}
|
|
720
|
+
);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
function synchronize(nextRole){
|
|
725
|
+
if(destroyed){
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
if(role?.state!==nextRole.state
|
|
729
|
+
||role?.providerId!==nextRole.providerId
|
|
730
|
+
||role?.modelId!==nextRole.modelId
|
|
731
|
+
||role?.loaded!==nextRole.loaded
|
|
732
|
+
||role?.busy!==nextRole.busy
|
|
733
|
+
||role?.operationId!==nextRole.operationId){
|
|
734
|
+
requestGeneration+=1;
|
|
735
|
+
requestError='';
|
|
736
|
+
requestPending=false;
|
|
737
|
+
}
|
|
738
|
+
role=nextRole;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
function destroy(){
|
|
742
|
+
if(destroyed){
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
destroyed=true;
|
|
746
|
+
requestGeneration+=1;
|
|
747
|
+
requestPending=false;
|
|
748
|
+
try{
|
|
749
|
+
button.removeEventListener('click',activateSelectedSTT);
|
|
750
|
+
}catch(error){
|
|
751
|
+
throw codedError(
|
|
752
|
+
'The STT activation button listener could not be removed.',
|
|
753
|
+
STT_ACTIVATION_ERROR_CODES.buttonListenerFailed,
|
|
754
|
+
Error,
|
|
755
|
+
error
|
|
756
|
+
);
|
|
757
|
+
}finally{
|
|
758
|
+
if(ownsEventSource){
|
|
759
|
+
events.dispose();
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
try{
|
|
765
|
+
button.addEventListener('click',activateSelectedSTT);
|
|
766
|
+
}catch(error){
|
|
767
|
+
if(ownsEventSource){
|
|
768
|
+
events.dispose();
|
|
769
|
+
}
|
|
770
|
+
throw codedError(
|
|
771
|
+
'The STT activation button listener could not be installed.',
|
|
772
|
+
STT_ACTIVATION_ERROR_CODES.buttonListenerFailed,
|
|
773
|
+
Error,
|
|
774
|
+
error
|
|
775
|
+
);
|
|
776
|
+
}
|
|
777
|
+
return Object.freeze(
|
|
778
|
+
{
|
|
779
|
+
get action(){return action();},
|
|
780
|
+
get error(){return requestError;},
|
|
781
|
+
get label(){return label();},
|
|
782
|
+
get pending(){return requestPending;},
|
|
783
|
+
get selected(){return selected();},
|
|
784
|
+
get status(){return status();},
|
|
785
|
+
get title(){return title();},
|
|
786
|
+
get visible(){return visible();},
|
|
787
|
+
request,
|
|
788
|
+
synchronize,
|
|
789
|
+
destroy
|
|
790
|
+
}
|
|
791
|
+
);
|
|
792
|
+
}
|
|
793
|
+
|
|
330
794
|
const VOICE_LABELS=Object.freeze({
|
|
331
795
|
complete:'Complete Transcription',
|
|
332
796
|
description:'Record one or more segments. Each segment is transcribed after you press Stop.',
|
|
@@ -337,6 +801,7 @@ const VOICE_LABELS=Object.freeze({
|
|
|
337
801
|
});
|
|
338
802
|
|
|
339
803
|
const VOICE_MESSAGES=Object.freeze({
|
|
804
|
+
cancelled:'Transcription canceled.',
|
|
340
805
|
complete:'Complete.',
|
|
341
806
|
completeError:'Unable to complete this transcription.',
|
|
342
807
|
completing:'Completing transcription...',
|
|
@@ -354,6 +819,7 @@ const VOICE_MESSAGES=Object.freeze({
|
|
|
354
819
|
transcribed:'Transcription added. Record another segment or complete.',
|
|
355
820
|
transcribeError:'Unable to transcribe this recording.',
|
|
356
821
|
transcribing:'Transcribing this segment...',
|
|
822
|
+
transcriptReplaced:'Transcript replaced.',
|
|
357
823
|
unsupported:'Audio recording is not supported by this browser.'
|
|
358
824
|
});
|
|
359
825
|
|
|
@@ -570,10 +1036,14 @@ export {
|
|
|
570
1036
|
DASHBOARD_LABELS,
|
|
571
1037
|
MARKDOWN_FORMATS,
|
|
572
1038
|
MARKDOWN_LABELS,
|
|
1039
|
+
STT_ACTIVATION_ERROR_CODES,
|
|
1040
|
+
STT_ACTIVATION_EVENT_TYPES,
|
|
1041
|
+
STT_ACTIVATION_REASONS,
|
|
573
1042
|
VOICE_LABELS,
|
|
574
1043
|
VOICE_MESSAGES,
|
|
575
1044
|
appendTranscription,
|
|
576
1045
|
applyMarkdownFormat,
|
|
1046
|
+
createSTTActivationController,
|
|
577
1047
|
effectiveDashboardVisibility,
|
|
578
1048
|
normalizeChartOptions,
|
|
579
1049
|
normalizeChartRows,
|