@matreshka/bff 0.38.0 → 0.40.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.
Files changed (31) hide show
  1. package/dist/components/file-picker.d.ts +37 -0
  2. package/dist/components/file-picker.js +78 -0
  3. package/dist/components/index.d.ts +1 -1
  4. package/dist/components/index.js +1 -1
  5. package/dist/components/inputs/input-component.d.ts +1 -1
  6. package/dist/core/actions/context-local-action-config.d.ts +13 -0
  7. package/dist/core/actions/context-local-action-config.js +7 -0
  8. package/dist/core/actions/dec-context-value.d.ts +7 -5
  9. package/dist/core/actions/dec-context-value.js +6 -2
  10. package/dist/core/actions/inc-context-value.d.ts +7 -5
  11. package/dist/core/actions/inc-context-value.js +6 -2
  12. package/dist/core/actions/set-context.d.ts +12 -4
  13. package/dist/core/actions/set-context.js +6 -1
  14. package/dist/core/actions/toggle-context-value.d.ts +7 -4
  15. package/dist/core/actions/toggle-context-value.js +6 -1
  16. package/dist/core/context/context-ref.d.ts +45 -11
  17. package/dist/core/context/context.d.ts +46 -10
  18. package/dist/core/types/context-value-ref.d.ts +23 -24
  19. package/dist/platforms/client-platform.d.ts +16 -0
  20. package/dist/platforms/client-platform.js +24 -0
  21. package/dist/platforms/index.d.ts +3 -0
  22. package/dist/platforms/index.js +3 -0
  23. package/dist/platforms/local-file.d.ts +54 -0
  24. package/dist/platforms/local-file.js +106 -0
  25. package/dist/platforms/media-stream-ref.d.ts +29 -0
  26. package/dist/platforms/media-stream-ref.js +78 -0
  27. package/dist/platforms/recording.d.ts +58 -0
  28. package/dist/platforms/recording.js +203 -0
  29. package/package.json +2 -2
  30. package/dist/components/file-upload-area.d.ts +0 -79
  31. package/dist/components/file-upload-area.js +0 -135
@@ -1,7 +1,9 @@
1
- import type { JsonObject } from "@matreshka/client-bff-protocol/types/json";
2
1
  import type { Observable } from "rxjs";
3
- import { z } from "zod";
2
+ import type { ContextLocalActionConfig } from "../actions/context-local-action-config";
3
+ import type { DecContextValue } from "../actions/dec-context-value";
4
+ import type { IncContextValue } from "../actions/inc-context-value";
4
5
  import type { SetContext } from "../actions/set-context";
6
+ import type { ToggleContextValue } from "../actions/toggle-context-value";
5
7
  import { AnySchemaContextRef, ContextRef, ContextRefValueType } from "../context/context-ref";
6
8
  import type { ContextUpdateDelivery } from "./context-update-delivery";
7
9
  /** Общая часть ref-типов по значению: маркер типа, чтение и запись. */
@@ -32,30 +34,11 @@ export type ContextRefOfValue<ValueType> = ValueRefBase<ValueType> & ContextRef<
32
34
  * Ref `R` совместим с ожидаемым типом значения `ValueType` (проверка на call site).
33
35
  */
34
36
  export type CompatibleContextRefOfValue<ValueType, R extends AnySchemaContextRef> = ValueType extends ContextRefValueType<R> ? R : never;
35
- /**
36
- * Эталонный writable ref для значения `ValueType`: путь `k` гарантированно есть
37
- * в schema. Из него выводится `local`, так что при добавлении
38
- * методов в `ContextRef.local` типы вручную переписывать не нужно.
39
- */
40
- type WritableReferenceRef<ValueType> = ContextRef<{
41
- k: Exclude<ValueType, undefined>;
42
- } extends infer C extends JsonObject ? C : never, "k", z.ZodObject<{
43
- k: z.ZodType<Exclude<ValueType, undefined>, Exclude<ValueType, undefined>>;
44
- }>>;
45
- /**
46
- * Стирает привязку `SetContext` к конкретному контексту/schema, остальные
47
- * сигнатуры `local` остаются как у `ContextRef.local`.
48
- */
49
- type EraseLocalContext<Local> = {
50
- [K in keyof Local]: Local[K] extends (...args: infer Args) => infer Result ? Result extends SetContext<any, any> ? (...args: Args) => SetContext<any, any> : Local[K] : Local[K];
51
- };
52
37
  /**
53
38
  * Writable-ref с известным типом значения без generic по ref.
54
39
  *
55
- * Структурно совместим с `ContextRef` (остальные члены берутся из
56
- * `ContextRef<any, any, any>`), а `local` берётся из `ContextRef.local`
57
- * для эталонного writable ref, поэтому ref с путём вне schema не пройдёт
58
- * проверку на call site.
40
+ * `local.set` с optional config — sync-on ветка; ref с путём вне schema
41
+ * (только `sync: false`) на call site не пройдёт.
59
42
  *
60
43
  * @example
61
44
  * ```ts
@@ -65,8 +48,24 @@ type EraseLocalContext<Local> = {
65
48
  * }
66
49
  * ```
67
50
  */
51
+ type WritableLocalByValue<ValueType> = {
52
+ set(value: ValueOrContextRef<Exclude<ValueType, undefined>>, config?: ContextLocalActionConfig & {
53
+ sync?: true;
54
+ }): SetContext<any, any>;
55
+ } & ([Exclude<ValueType, undefined>] extends [boolean] ? {
56
+ toggle(config?: ContextLocalActionConfig & {
57
+ sync?: true;
58
+ }): ToggleContextValue;
59
+ } : {}) & ([Exclude<ValueType, undefined>] extends [number] ? {
60
+ inc(step?: ValueOrContextRef<number>, config?: ContextLocalActionConfig & {
61
+ sync?: true;
62
+ }): IncContextValue;
63
+ dec(step?: ValueOrContextRef<number>, config?: ContextLocalActionConfig & {
64
+ sync?: true;
65
+ }): DecContextValue;
66
+ } : {});
68
67
  export type WritableContextRefOfValue<ValueType> = ContextRefOfValue<ValueType> & {
69
- readonly local: EraseLocalContext<WritableReferenceRef<ValueType>["local"]>;
68
+ readonly local: WritableLocalByValue<ValueType>;
70
69
  };
71
70
  /** Статическое значение или ссылка на совместимое значение в контексте. */
72
71
  export type ValueOrContextRef<ValueType> = ValueType | ContextRefOfValue<Exclude<ValueType, undefined>>;
@@ -1,6 +1,9 @@
1
+ import type { DisplayMediaStreamOptions, MediaStreamConstraints } from "@matreshka/client-bff-protocol/types/media-stream-constraints";
1
2
  import { Observable } from "rxjs";
2
3
  import { Audio, MediaConfig, Video } from "./media";
4
+ import { MediaStreamRef } from "./media-stream-ref";
3
5
  import { Platform } from "./platform";
6
+ import { Recording, type RecordingConfig } from "./recording";
4
7
  /**
5
8
  * Абстрактный класс, реализующий любую клиентскую платформу.
6
9
  */
@@ -15,4 +18,17 @@ export declare abstract class ClientPlatform extends Platform {
15
18
  * `Video.id` — ключ реестра, который позже сможет забрать видеокомпонент.
16
19
  */
17
20
  createVideo(config?: MediaConfig): Observable<Video>;
21
+ /**
22
+ * Запрашивает `MediaStream` через `navigator.mediaDevices.getUserMedia`.
23
+ * Поток живёт на клиенте; BFF получает {@link MediaStreamRef}.
24
+ */
25
+ getUserMedia(constraints?: MediaStreamConstraints): Observable<MediaStreamRef>;
26
+ /**
27
+ * Запрашивает захват экрана через `navigator.mediaDevices.getDisplayMedia`.
28
+ */
29
+ getDisplayMedia(options?: DisplayMediaStreamOptions): Observable<MediaStreamRef>;
30
+ /**
31
+ * Создаёт сессию `MediaRecorder` на клиенте поверх одного или нескольких потоков.
32
+ */
33
+ createRecording(config: RecordingConfig): Observable<Recording>;
18
34
  }
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ClientPlatform = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const media_1 = require("./media");
6
+ const media_stream_ref_1 = require("./media-stream-ref");
6
7
  const platform_1 = require("./platform");
8
+ const recording_1 = require("./recording");
7
9
  /**
8
10
  * Абстрактный класс, реализующий любую клиентскую платформу.
9
11
  */
@@ -24,5 +26,27 @@ class ClientPlatform extends platform_1.Platform {
24
26
  const video = new media_1.Video(this.client, config);
25
27
  return video.open().pipe((0, rxjs_1.map)(() => video));
26
28
  }
29
+ /**
30
+ * Запрашивает `MediaStream` через `navigator.mediaDevices.getUserMedia`.
31
+ * Поток живёт на клиенте; BFF получает {@link MediaStreamRef}.
32
+ */
33
+ getUserMedia(constraints) {
34
+ const stream = new media_stream_ref_1.MediaStreamRef(this.client);
35
+ return stream.openUserMedia(constraints);
36
+ }
37
+ /**
38
+ * Запрашивает захват экрана через `navigator.mediaDevices.getDisplayMedia`.
39
+ */
40
+ getDisplayMedia(options) {
41
+ const stream = new media_stream_ref_1.MediaStreamRef(this.client);
42
+ return stream.openDisplayMedia(options);
43
+ }
44
+ /**
45
+ * Создаёт сессию `MediaRecorder` на клиенте поверх одного или нескольких потоков.
46
+ */
47
+ createRecording(config) {
48
+ const recording = new recording_1.Recording(this.client, config);
49
+ return recording.open().pipe((0, rxjs_1.map)(() => recording));
50
+ }
27
51
  }
28
52
  exports.ClientPlatform = ClientPlatform;
@@ -2,12 +2,15 @@ export * from "./android-platform";
2
2
  export * from "./browser-platform";
3
3
  export * from "./client-platform";
4
4
  export * from "./ios-platform";
5
+ export * from "./local-file";
5
6
  export * from "./max-mini-app-platform";
6
7
  export * from "./media";
8
+ export * from "./media-stream-ref";
7
9
  export * from "./mobile-platform";
8
10
  export * from "./platform";
9
11
  export * from "./popover-show";
10
12
  export * from "./pwa-platform";
13
+ export * from "./recording";
11
14
  export * from "./server-platform";
12
15
  export * from "./telegram-mini-app-platform";
13
16
  export * from "./utils/client-platform";
@@ -18,12 +18,15 @@ __exportStar(require("./android-platform"), exports);
18
18
  __exportStar(require("./browser-platform"), exports);
19
19
  __exportStar(require("./client-platform"), exports);
20
20
  __exportStar(require("./ios-platform"), exports);
21
+ __exportStar(require("./local-file"), exports);
21
22
  __exportStar(require("./max-mini-app-platform"), exports);
22
23
  __exportStar(require("./media"), exports);
24
+ __exportStar(require("./media-stream-ref"), exports);
23
25
  __exportStar(require("./mobile-platform"), exports);
24
26
  __exportStar(require("./platform"), exports);
25
27
  __exportStar(require("./popover-show"), exports);
26
28
  __exportStar(require("./pwa-platform"), exports);
29
+ __exportStar(require("./recording"), exports);
27
30
  __exportStar(require("./server-platform"), exports);
28
31
  __exportStar(require("./telegram-mini-app-platform"), exports);
29
32
  __exportStar(require("./utils/client-platform"), exports);
@@ -0,0 +1,54 @@
1
+ import { MediaKind } from "@matreshka/client-bff-protocol/enums/media-kind";
2
+ import { Observable } from "rxjs";
3
+ import type { Client } from "../core/client";
4
+ export { MediaKind };
5
+ export declare class LocalFileUploadProgress {
6
+ readonly progress: number;
7
+ constructor(progress: number);
8
+ }
9
+ export declare class LocalFileUploadResponse {
10
+ readonly response: unknown;
11
+ constructor(response: unknown);
12
+ }
13
+ export type LocalFileUploadEvent = LocalFileUploadProgress | LocalFileUploadResponse;
14
+ export type LocalFileUploadOptions = {
15
+ url: string;
16
+ fieldName?: string;
17
+ headers?: Record<string, string>;
18
+ fields?: Record<string, string>;
19
+ };
20
+ export type LocalFileInit = {
21
+ id: string;
22
+ url: string;
23
+ type: string;
24
+ size: number;
25
+ name: string;
26
+ lastModified: number;
27
+ duration?: number;
28
+ kind?: MediaKind;
29
+ };
30
+ /**
31
+ * Handle на клиентский blob/File: upload и destroy с BFF.
32
+ */
33
+ export declare class LocalFile {
34
+ private readonly client;
35
+ readonly id: string;
36
+ readonly name: string;
37
+ readonly type: string;
38
+ readonly size: number;
39
+ readonly lastModified: number;
40
+ readonly url: string;
41
+ readonly duration?: number;
42
+ readonly kind?: MediaKind;
43
+ private destroyed;
44
+ constructor(client: Client, init: LocalFileInit);
45
+ /**
46
+ * POST multipart на endpoint. Эмитит progress, затем response, затем complete.
47
+ * Отписка всех observers abort'ит загрузку на клиенте.
48
+ */
49
+ upload(options: LocalFileUploadOptions): Observable<LocalFileUploadEvent>;
50
+ /** Освобождает blob на клиенте. */
51
+ destroy(): Observable<void>;
52
+ private assertAlive;
53
+ private markDestroyed;
54
+ }
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LocalFile = exports.LocalFileUploadResponse = exports.LocalFileUploadProgress = exports.MediaKind = void 0;
4
+ const media_kind_1 = require("@matreshka/client-bff-protocol/enums/media-kind");
5
+ Object.defineProperty(exports, "MediaKind", { enumerable: true, get: function () { return media_kind_1.MediaKind; } });
6
+ const local_file_destroy_message_1 = require("@matreshka/client-bff-protocol/messages/bff-to-client/platforms/local-file-destroy-message");
7
+ const local_file_upload_abort_message_1 = require("@matreshka/client-bff-protocol/messages/bff-to-client/platforms/local-file-upload-abort-message");
8
+ const local_file_upload_message_1 = require("@matreshka/client-bff-protocol/messages/bff-to-client/platforms/local-file-upload-message");
9
+ const local_file_upload_progress_message_1 = require("@matreshka/client-bff-protocol/messages/client-to-bff/platforms/local-file-upload-progress-message");
10
+ const local_file_upload_success_message_1 = require("@matreshka/client-bff-protocol/messages/client-to-bff/platforms/local-file-upload-success-message");
11
+ const rxjs_1 = require("rxjs");
12
+ const zod_1 = require("zod");
13
+ const targeted_client_platform_action_1 = require("./utils/targeted-client-platform-action");
14
+ const targeted_client_platform_stream_1 = require("./utils/targeted-client-platform-stream");
15
+ class LocalFileUploadProgress {
16
+ constructor(progress) {
17
+ this.progress = progress;
18
+ }
19
+ }
20
+ exports.LocalFileUploadProgress = LocalFileUploadProgress;
21
+ class LocalFileUploadResponse {
22
+ constructor(response) {
23
+ this.response = response;
24
+ }
25
+ }
26
+ exports.LocalFileUploadResponse = LocalFileUploadResponse;
27
+ const localFileInitSchema = zod_1.z.strictObject({
28
+ id: zod_1.z.string(),
29
+ url: zod_1.z.string().refine((val) => val.startsWith("blob:"), {
30
+ message: "url must be a blob",
31
+ }),
32
+ type: zod_1.z.string(),
33
+ size: zod_1.z.number(),
34
+ name: zod_1.z.string(),
35
+ lastModified: zod_1.z.number(),
36
+ duration: zod_1.z.number().optional(),
37
+ kind: zod_1.z.enum(media_kind_1.MediaKind).optional(),
38
+ });
39
+ /**
40
+ * Handle на клиентский blob/File: upload и destroy с BFF.
41
+ */
42
+ class LocalFile {
43
+ constructor(client, init) {
44
+ this.client = client;
45
+ this.destroyed = false;
46
+ const safe = localFileInitSchema.parse(init);
47
+ this.id = safe.id;
48
+ this.name = safe.name;
49
+ this.type = safe.type;
50
+ this.size = safe.size;
51
+ this.lastModified = safe.lastModified;
52
+ this.url = safe.url;
53
+ this.duration = safe.duration;
54
+ this.kind = safe.kind;
55
+ }
56
+ /**
57
+ * POST multipart на endpoint. Эмитит progress, затем response, затем complete.
58
+ * Отписка всех observers abort'ит загрузку на клиенте.
59
+ */
60
+ upload(options) {
61
+ this.assertAlive();
62
+ return (0, targeted_client_platform_stream_1.targetedClientPlatformStream)(this.client, {
63
+ outgoingMessage: (scope) => new local_file_upload_message_1.LocalFileUploadMessage(scope, {
64
+ fileId: this.id,
65
+ url: options.url,
66
+ fieldName: options.fieldName,
67
+ headers: options.headers,
68
+ fields: options.fields,
69
+ }),
70
+ parseItem: (unsafeMessage) => {
71
+ if (unsafeMessage instanceof local_file_upload_progress_message_1.LocalFileUploadProgressMessage) {
72
+ const progress = zod_1.z
73
+ .number()
74
+ .min(0)
75
+ .max(100)
76
+ .parse(unsafeMessage.payload.progress);
77
+ return new LocalFileUploadProgress(progress);
78
+ }
79
+ if (unsafeMessage instanceof local_file_upload_success_message_1.LocalFileUploadSuccessMessage) {
80
+ return new LocalFileUploadResponse(unsafeMessage.payload.response);
81
+ }
82
+ },
83
+ onTeardown: (scope, client) => {
84
+ client.outcomingMessage$.next(new local_file_upload_abort_message_1.LocalFileUploadAbortMessage(scope));
85
+ },
86
+ });
87
+ }
88
+ /** Освобождает blob на клиенте. */
89
+ destroy() {
90
+ if (this.destroyed) {
91
+ return (0, rxjs_1.of)(undefined);
92
+ }
93
+ return (0, targeted_client_platform_action_1.targetedClientPlatformAction)(this.client, {
94
+ outgoingMessage: (scope) => new local_file_destroy_message_1.LocalFileDestroyMessage(scope, { fileId: this.id }),
95
+ }).pipe((0, rxjs_1.tap)(() => this.markDestroyed()));
96
+ }
97
+ assertAlive() {
98
+ if (this.destroyed) {
99
+ throw new Error(`LocalFile ${this.id} has been destroyed`);
100
+ }
101
+ }
102
+ markDestroyed() {
103
+ this.destroyed = true;
104
+ }
105
+ }
106
+ exports.LocalFile = LocalFile;
@@ -0,0 +1,29 @@
1
+ import { MediaKind } from "@matreshka/client-bff-protocol/enums/media-kind";
2
+ import type { DisplayMediaStreamOptions, MediaStreamConstraints } from "@matreshka/client-bff-protocol/types/media-stream-constraints";
3
+ import { Observable } from "rxjs";
4
+ import type { Client } from "../core/client";
5
+ export type { DisplayMediaStreamOptions, MediaStreamConstraints };
6
+ export type MediaStreamTrackInfo = {
7
+ kind: MediaKind;
8
+ label?: string;
9
+ settings?: Record<string, unknown>;
10
+ };
11
+ /**
12
+ * Ссылка на `MediaStream` на клиенте. Сам поток не сериализуется.
13
+ */
14
+ export declare class MediaStreamRef {
15
+ private readonly client;
16
+ readonly id: string;
17
+ private stopped;
18
+ private trackInfos;
19
+ constructor(client: Client);
20
+ get tracks(): readonly MediaStreamTrackInfo[];
21
+ /** Останавливает треки на клиенте и снимает поток из реестра. */
22
+ stop(): Observable<void>;
23
+ /** @internal */
24
+ openUserMedia(constraints?: MediaStreamConstraints): Observable<this>;
25
+ /** @internal */
26
+ openDisplayMedia(options?: DisplayMediaStreamOptions): Observable<this>;
27
+ private open;
28
+ private markStopped;
29
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MediaStreamRef = void 0;
4
+ const media_kind_1 = require("@matreshka/client-bff-protocol/enums/media-kind");
5
+ const platform_get_display_media_message_1 = require("@matreshka/client-bff-protocol/messages/bff-to-client/platforms/platform-get-display-media-message");
6
+ const platform_get_user_media_message_1 = require("@matreshka/client-bff-protocol/messages/bff-to-client/platforms/platform-get-user-media-message");
7
+ const platform_media_stream_stop_message_1 = require("@matreshka/client-bff-protocol/messages/bff-to-client/platforms/platform-media-stream-stop-message");
8
+ const platform_media_stream_success_message_1 = require("@matreshka/client-bff-protocol/messages/client-to-bff/platforms/platform-media-stream-success-message");
9
+ const rxjs_1 = require("rxjs");
10
+ const zod_1 = require("zod");
11
+ const targeted_client_platform_action_1 = require("./utils/targeted-client-platform-action");
12
+ const trackInfoSchema = zod_1.z.strictObject({
13
+ kind: zod_1.z.enum(media_kind_1.MediaKind),
14
+ label: zod_1.z.string().optional(),
15
+ settings: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
16
+ });
17
+ const mediaStreamSuccessSchema = zod_1.z.strictObject({
18
+ streamId: zod_1.z.string(),
19
+ tracks: zod_1.z.array(trackInfoSchema),
20
+ });
21
+ /**
22
+ * Ссылка на `MediaStream` на клиенте. Сам поток не сериализуется.
23
+ */
24
+ class MediaStreamRef {
25
+ constructor(client) {
26
+ this.client = client;
27
+ this.id = "media-stream-" + crypto.randomUUID();
28
+ this.stopped = false;
29
+ this.trackInfos = [];
30
+ }
31
+ get tracks() {
32
+ return this.trackInfos;
33
+ }
34
+ /** Останавливает треки на клиенте и снимает поток из реестра. */
35
+ stop() {
36
+ if (this.stopped) {
37
+ return (0, rxjs_1.of)(undefined);
38
+ }
39
+ return (0, targeted_client_platform_action_1.targetedClientPlatformAction)(this.client, {
40
+ outgoingMessage: (scope) => new platform_media_stream_stop_message_1.PlatformMediaStreamStopMessage(scope, { streamId: this.id }),
41
+ }).pipe((0, rxjs_1.tap)(() => this.markStopped()));
42
+ }
43
+ /** @internal */
44
+ openUserMedia(constraints) {
45
+ return this.open((scope) => new platform_get_user_media_message_1.PlatformGetUserMediaMessage(scope, {
46
+ streamId: this.id,
47
+ constraints,
48
+ }));
49
+ }
50
+ /** @internal */
51
+ openDisplayMedia(options) {
52
+ return this.open((scope) => new platform_get_display_media_message_1.PlatformGetDisplayMediaMessage(scope, {
53
+ streamId: this.id,
54
+ options,
55
+ }));
56
+ }
57
+ open(outgoingMessage) {
58
+ return (0, targeted_client_platform_action_1.targetedClientPlatformAction)(this.client, {
59
+ outgoingMessage,
60
+ parseSuccess: (unsafeMessage) => {
61
+ if (!(unsafeMessage instanceof platform_media_stream_success_message_1.PlatformMediaStreamSuccessMessage)) {
62
+ return;
63
+ }
64
+ const payload = mediaStreamSuccessSchema.parse(unsafeMessage.payload);
65
+ if (payload.streamId !== this.id) {
66
+ throw new Error(`Unexpected streamId ${payload.streamId}, expected ${this.id}`);
67
+ }
68
+ this.trackInfos = payload.tracks;
69
+ return this;
70
+ },
71
+ });
72
+ }
73
+ markStopped() {
74
+ this.stopped = true;
75
+ this.trackInfos = [];
76
+ }
77
+ }
78
+ exports.MediaStreamRef = MediaStreamRef;
@@ -0,0 +1,58 @@
1
+ import { MediaKind } from "@matreshka/client-bff-protocol/enums/media-kind";
2
+ import { Observable } from "rxjs";
3
+ import { ServerAction, type ServerActionHandler } from "../components/actions/server-action";
4
+ import { LocalAction } from "../core/actions/local-action";
5
+ import type { Client } from "../core/client";
6
+ import type { Componentable } from "../core/types/componentable";
7
+ import { LocalFile } from "./local-file";
8
+ import type { MediaStreamRef } from "./media-stream-ref";
9
+ export { MediaKind };
10
+ export type RecordingProgressPayload = {
11
+ duration: number;
12
+ };
13
+ export type RecordingErrorPayload = {
14
+ message: string;
15
+ };
16
+ /** Одно действие или массив локальных и серверных, как у Media. */
17
+ export type RecordingAction<Payload> = ServerAction<Componentable, Payload> | ServerActionHandler<Componentable, Payload> | LocalAction;
18
+ export type RecordingActionList<Payload> = RecordingAction<Payload> | RecordingAction<Payload>[];
19
+ export type RecordingEventConfig = {
20
+ onStart?: RecordingActionList<RecordingProgressPayload>;
21
+ onPause?: RecordingActionList<RecordingProgressPayload>;
22
+ onResume?: RecordingActionList<RecordingProgressPayload>;
23
+ onStop?: RecordingActionList<RecordingProgressPayload>;
24
+ onError?: RecordingActionList<RecordingErrorPayload>;
25
+ onTimeUpdate?: RecordingActionList<RecordingProgressPayload>;
26
+ };
27
+ export type RecordingConfig = RecordingEventConfig & {
28
+ streams: MediaStreamRef | MediaStreamRef[];
29
+ mimeType?: string;
30
+ };
31
+ /**
32
+ * Сессия `MediaRecorder` на клиенте поверх одного или нескольких `MediaStreamRef`.
33
+ */
34
+ export declare class Recording {
35
+ private readonly client;
36
+ readonly id: string;
37
+ private readonly handlers;
38
+ private readonly streamIds;
39
+ private readonly mimeType?;
40
+ private sessionSubscription?;
41
+ private clientDestroySubscription?;
42
+ private ended;
43
+ constructor(client: Client, config: RecordingConfig);
44
+ start(): Observable<void>;
45
+ pause(): Observable<void>;
46
+ resume(): Observable<void>;
47
+ stop(): Observable<LocalFile>;
48
+ destroy(): Observable<void>;
49
+ /** @internal */
50
+ open(): Observable<void>;
51
+ private send;
52
+ private bindEvents;
53
+ private parseAction;
54
+ private serializeInteractions;
55
+ private startSession;
56
+ private emit;
57
+ private endSession;
58
+ }