@startsimpli/integrations 0.2.168 → 0.2.169
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/package.json +4 -4
- package/src/native/app/config/links.ts +4 -1
- package/src/native/app/services.ts +7 -0
- package/src/native/converse/__tests__/meetingIO.test.ts +34 -2
- package/src/native/converse/io.ts +19 -1
- package/src/native/recording/__tests__/deeplink.test.ts +16 -0
- package/src/native/recording/deeplink.ts +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startsimpli/integrations",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.169",
|
|
4
4
|
"description": "Provider-agnostic types, API clients, hooks, and UI primitives for email + calendar integrations across StartSimpli apps, plus foundry customer email (subpath ./comms).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://startsimpli.com",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"react-native": ">=0.74.0",
|
|
51
51
|
"@startsimpli/ui-native": ">=0.1.12",
|
|
52
52
|
"react-native-safe-area-context": ">=4.0.0",
|
|
53
|
+
"@startsimpli/auth": "^0.4.53",
|
|
53
54
|
"@startsimpli/utils": "^0.4.19",
|
|
54
|
-
"@startsimpli/ui": "^0.4.
|
|
55
|
-
"@startsimpli/auth": "^0.4.53"
|
|
55
|
+
"@startsimpli/ui": "^0.4.183"
|
|
56
56
|
},
|
|
57
57
|
"peerDependenciesMeta": {
|
|
58
58
|
"react": {
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"react-native": "0.85.3",
|
|
100
100
|
"react-native-safe-area-context": "~5.7.0",
|
|
101
101
|
"@startsimpli/llm": "0.4.31",
|
|
102
|
-
"@startsimpli/ui": "0.4.
|
|
102
|
+
"@startsimpli/ui": "0.4.183",
|
|
103
103
|
"@startsimpli/ui-native": "0.1.14",
|
|
104
104
|
"@startsimpli/auth": "0.4.53",
|
|
105
105
|
"@startsimpli/utils": "0.4.19"
|
|
@@ -6,6 +6,8 @@ export type LinkAction =
|
|
|
6
6
|
| { kind: 'record'; autostop?: number }
|
|
7
7
|
/** `<scheme>://briefing` (the morning notification): open the GO screen and play today's briefing. */
|
|
8
8
|
| { kind: 'briefing' }
|
|
9
|
+
/** `<scheme>://converse` (a Siri Shortcut's Open URL): open Converse and start a meeting. */
|
|
10
|
+
| { kind: 'converse' }
|
|
9
11
|
| { kind: 'open'; tab: string; id?: string };
|
|
10
12
|
|
|
11
13
|
export interface LinkResolver {
|
|
@@ -33,7 +35,7 @@ function routeMatcher(pattern: string): (path: string) => string | null {
|
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
|
-
* The one deep-link table: `<scheme>://record[?autostop=N]`, `<scheme>://briefing`, `<scheme>://tab/<key>[/<id>]`,
|
|
38
|
+
* The one deep-link table: `<scheme>://record[?autostop=N]`, `<scheme>://briefing`, `<scheme>://converse`, `<scheme>://tab/<key>[/<id>]`,
|
|
37
39
|
* `<scheme>://entity/<type>/<id>`, `<scheme>://<key>[/<id>]`, plus the config's own `links.routes`; the same
|
|
38
40
|
* paths on `https://<host>/...` for each host in `links.hosts` (universal links).
|
|
39
41
|
*/
|
|
@@ -62,6 +64,7 @@ export function createLinkResolver(config: LinkConfig): LinkResolver {
|
|
|
62
64
|
return Number.isFinite(seconds) && seconds > 0 ? { kind: 'record', autostop: seconds } : { kind: 'record' };
|
|
63
65
|
}
|
|
64
66
|
if (head === 'briefing' && segs.length === 1 && config.features.briefing && config.features.recording) return { kind: 'briefing' };
|
|
67
|
+
if (head === 'converse' && segs.length === 1 && config.features.converse) return { kind: 'converse' };
|
|
65
68
|
for (const r of routes) {
|
|
66
69
|
const id = r.match(path);
|
|
67
70
|
if (id !== null) return { kind: 'open', tab: r.tab, id };
|
|
@@ -139,6 +139,13 @@ export function createFoundryServices(deps: { config: FoundryAppConfig; device:
|
|
|
139
139
|
const phase = briefing?.controller.getState().phase;
|
|
140
140
|
if (phase !== 'playing' && phase !== 'loading') void briefing?.controller.start();
|
|
141
141
|
},
|
|
142
|
+
openConverse: () => {
|
|
143
|
+
// A Siri Shortcut's link: land on Converse and start the meeting; one already running is left alone.
|
|
144
|
+
const key = config.tabs.find((t) => t.screen === 'converse')?.key;
|
|
145
|
+
if (key) open(key);
|
|
146
|
+
const phase = converse?.controller.getState().phase;
|
|
147
|
+
if (phase === 'idle' || phase === 'ended' || phase === 'stopped') converse?.controller.start();
|
|
148
|
+
},
|
|
142
149
|
resolver: createLinkResolver(config),
|
|
143
150
|
getPhase: () => recording?.recorder.getState().phase ?? 'idle',
|
|
144
151
|
go: (o) => recording?.recorder.go(o),
|
|
@@ -4,7 +4,7 @@ import { createMeetingController } from '../../../corpus/converse/meeting';
|
|
|
4
4
|
import { resolveMeetingConfig } from '../../../corpus/converse/meeting-config';
|
|
5
5
|
import { createNativeMeetingApi } from '../api';
|
|
6
6
|
import { createFakeMeeting } from '../fake';
|
|
7
|
-
import { createMeetingIO, dbToLevel } from '../io';
|
|
7
|
+
import { createMeetingIO, dbToLevel, PAUSED_REPLAY_MS } from '../io';
|
|
8
8
|
import { statusLine } from '../format';
|
|
9
9
|
|
|
10
10
|
const LOUD = -10; // dBFS, well above the 0.02 speech level
|
|
@@ -27,6 +27,7 @@ function rig(over: { permission?: 'granted' | 'denied' } = {}) {
|
|
|
27
27
|
play: vi.fn(async () => undefined), stop: vi.fn(async () => { ps = { ...ps, phase: 'idle' }; ls.forEach((l) => l(ps)); }),
|
|
28
28
|
handoffToRecording: vi.fn(async () => undefined),
|
|
29
29
|
};
|
|
30
|
+
const pausePlayback = () => { ps = { ...ps, phase: 'paused' }; ls.forEach((l) => l(ps)); };
|
|
30
31
|
const finishPlayback = () => { ps = { ...ps, phase: 'ended' }; ls.forEach((l) => l(ps)); };
|
|
31
32
|
const removeFile = vi.fn(async () => undefined);
|
|
32
33
|
const api = { replySource: vi.fn(async () => ({ uri: 'http://x/a.mp3', headers: { authorization: 'Bearer t' } })), turn: vi.fn(), end: vi.fn() };
|
|
@@ -34,7 +35,7 @@ function rig(over: { permission?: 'granted' | 'denied' } = {}) {
|
|
|
34
35
|
const io = createMeetingIO({ api: api as never, audio, speaker: speaker as never, removeFile, ensurePermission: async () => over.permission ?? 'granted', now: () => clock, onBroken: (h) => { broken = h; } });
|
|
35
36
|
/** Feed one level reading per 100 ms of fake time. */
|
|
36
37
|
const feed = (db: number, ms: number) => { for (let t = 0; t < ms; t += 100) { clock += 100; onLevel(db); } };
|
|
37
|
-
return { io, audio, speaker, removeFile, api, feed, finishPlayback, starts, breakIt: () => broken(), config: resolveMeetingConfig() };
|
|
38
|
+
return { io, audio, speaker, removeFile, api, feed, finishPlayback, pausePlayback, starts, breakIt: () => broken(), config: resolveMeetingConfig() };
|
|
38
39
|
}
|
|
39
40
|
const tick = () => new Promise((r) => setTimeout(r, 0));
|
|
40
41
|
const settle = async () => { for (let i = 0; i < 6; i += 1) await tick(); };
|
|
@@ -120,6 +121,37 @@ describe('speak', () => {
|
|
|
120
121
|
expect(done).toBe(true);
|
|
121
122
|
});
|
|
122
123
|
|
|
124
|
+
it('a reply the system paused and nobody resumed is played again, not waited on forever', async () => {
|
|
125
|
+
vi.useFakeTimers();
|
|
126
|
+
try {
|
|
127
|
+
const r = rig();
|
|
128
|
+
const p = r.io.speak(reply, new AbortController().signal, r.config);
|
|
129
|
+
await vi.advanceTimersByTimeAsync(1);
|
|
130
|
+
r.pausePlayback();
|
|
131
|
+
await vi.advanceTimersByTimeAsync(PAUSED_REPLAY_MS - 1);
|
|
132
|
+
expect(r.speaker.play).toHaveBeenCalledTimes(1);
|
|
133
|
+
await vi.advanceTimersByTimeAsync(2);
|
|
134
|
+
expect(r.speaker.play).toHaveBeenCalledTimes(2);
|
|
135
|
+
r.finishPlayback();
|
|
136
|
+
await p;
|
|
137
|
+
} finally { vi.useRealTimers(); }
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('a pause that resumes in time is left alone', async () => {
|
|
141
|
+
vi.useFakeTimers();
|
|
142
|
+
try {
|
|
143
|
+
const r = rig();
|
|
144
|
+
const p = r.io.speak(reply, new AbortController().signal, r.config);
|
|
145
|
+
await vi.advanceTimersByTimeAsync(1);
|
|
146
|
+
r.pausePlayback();
|
|
147
|
+
await vi.advanceTimersByTimeAsync(1000);
|
|
148
|
+
r.finishPlayback();
|
|
149
|
+
await vi.advanceTimersByTimeAsync(PAUSED_REPLAY_MS * 2);
|
|
150
|
+
await p;
|
|
151
|
+
expect(r.speaker.play).toHaveBeenCalledTimes(1);
|
|
152
|
+
} finally { vi.useRealTimers(); }
|
|
153
|
+
});
|
|
154
|
+
|
|
123
155
|
it('abort cuts the reply off and resolves', async () => {
|
|
124
156
|
const r = rig();
|
|
125
157
|
const ctl = new AbortController();
|
|
@@ -26,6 +26,9 @@ export interface MeetingSpeaker {
|
|
|
26
26
|
/** Mic level from the recorder's metering: dBFS -> linear 0..1, what `speechLevel` is measured in. */
|
|
27
27
|
export const dbToLevel = (db: number) => (db <= -100 ? 0 : 10 ** (Math.min(db, 0) / 20));
|
|
28
28
|
|
|
29
|
+
/** A reply paused by the system (AirPods leaving, a call) and not resumed within this long is played again from the start. */
|
|
30
|
+
export const PAUSED_REPLAY_MS = 4000;
|
|
31
|
+
|
|
29
32
|
export function createMeetingIO(deps: {
|
|
30
33
|
api: NativeMeetingApi;
|
|
31
34
|
audio: RecorderAudio;
|
|
@@ -107,7 +110,21 @@ export function createMeetingIO(deps: {
|
|
|
107
110
|
const source = await deps.api.replySource(reply);
|
|
108
111
|
let done: () => void = () => undefined;
|
|
109
112
|
const finished = new Promise<void>((resolve) => { done = resolve; });
|
|
110
|
-
|
|
113
|
+
// A meeting has no pause button: if iOS paused the reply (AirPods removed, a call) and it is not resumed, say it
|
|
114
|
+
// again on whatever route is now active instead of waiting forever.
|
|
115
|
+
let pausedTimer: ReturnType<typeof setTimeout> | null = null;
|
|
116
|
+
const clearPaused = () => { if (pausedTimer) { clearTimeout(pausedTimer); pausedTimer = null; } };
|
|
117
|
+
const unsub = deps.speaker.subscribe((p) => {
|
|
118
|
+
if (p.phase === 'ended' || p.phase === 'idle' || p.phase === 'failed') { clearPaused(); done(); return; }
|
|
119
|
+
if (p.phase === 'paused' && !pausedTimer && !signal.aborted) {
|
|
120
|
+
pausedTimer = setTimeout(() => {
|
|
121
|
+
pausedTimer = null;
|
|
122
|
+
if (signal.aborted || deps.speaker.getState().phase !== 'paused') return;
|
|
123
|
+
log('replay-after-pause');
|
|
124
|
+
void deps.speaker.play(source).catch(() => done());
|
|
125
|
+
}, PAUSED_REPLAY_MS);
|
|
126
|
+
} else if (p.phase !== 'paused') clearPaused();
|
|
127
|
+
});
|
|
111
128
|
const onAbort = () => { void deps.speaker.stop().catch(() => undefined); done(); };
|
|
112
129
|
signal.addEventListener('abort', onAbort, { once: true });
|
|
113
130
|
try {
|
|
@@ -115,6 +132,7 @@ export function createMeetingIO(deps: {
|
|
|
115
132
|
if (!signal.aborted) await finished;
|
|
116
133
|
} finally {
|
|
117
134
|
unsub();
|
|
135
|
+
clearPaused();
|
|
118
136
|
signal.removeEventListener('abort', onAbort);
|
|
119
137
|
}
|
|
120
138
|
},
|
|
@@ -125,3 +125,19 @@ describe('deep link tandemgo://briefing', () => {
|
|
|
125
125
|
expect(openBriefing).toHaveBeenCalledTimes(1);
|
|
126
126
|
});
|
|
127
127
|
});
|
|
128
|
+
|
|
129
|
+
describe('deep link tandemgo://converse', () => {
|
|
130
|
+
const withConverse = createLinkResolver(resolveFoundryApp({ app: { name: 'Tandem Go', scheme: 'tandemgo' }, tenant: { url: 'https://t.example.com' }, features: { converse: true } }));
|
|
131
|
+
it('resolves only when features.converse is on', () => {
|
|
132
|
+
expect(withConverse.resolve('tandemgo://converse')).toEqual({ kind: 'converse' });
|
|
133
|
+
expect(resolver.resolve('tandemgo://converse')).toBeNull();
|
|
134
|
+
});
|
|
135
|
+
it('waits for the session, then opens Converse once', async () => {
|
|
136
|
+
const openConverse = vi.fn();
|
|
137
|
+
const link = createDeepLink({ resolver: withConverse, openConverse, log: vi.fn() });
|
|
138
|
+
link.handle('tandemgo://converse');
|
|
139
|
+
expect(openConverse).not.toHaveBeenCalled();
|
|
140
|
+
await link.sessionReady();
|
|
141
|
+
expect(openConverse).toHaveBeenCalledTimes(1);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
@@ -14,6 +14,8 @@ export function createDeepLink(deps: {
|
|
|
14
14
|
open?: (tab: string, id?: string) => void;
|
|
15
15
|
/** Open the GO screen and play today's briefing (the morning notification's link). */
|
|
16
16
|
openBriefing?: () => void;
|
|
17
|
+
/** Open Converse and start a meeting (a Siri Shortcut's link). */
|
|
18
|
+
openConverse?: () => void;
|
|
17
19
|
log?: (event: string, fields?: Record<string, unknown>) => void;
|
|
18
20
|
}) {
|
|
19
21
|
const log = deps.log ?? (() => undefined);
|
|
@@ -26,6 +28,11 @@ export function createDeepLink(deps: {
|
|
|
26
28
|
deps.openBriefing?.();
|
|
27
29
|
return;
|
|
28
30
|
}
|
|
31
|
+
if (action.kind === 'converse') {
|
|
32
|
+
log('deeplink', { url, action: 'converse' });
|
|
33
|
+
deps.openConverse?.();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
29
36
|
if (action.kind === 'open') {
|
|
30
37
|
log('deeplink', { url, action: 'open', tab: action.tab, id: action.id });
|
|
31
38
|
deps.open?.(action.tab, action.id);
|