@dadan-mvp/record-sdk 0.0.0-stage → 0.1.1
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/README.md +42 -3
- package/dist/chunk-DBC6WGEP.js +49 -0
- package/dist/chunk-DBC6WGEP.js.map +1 -0
- package/dist/index.cjs +1026 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +230 -0
- package/dist/index.d.ts +230 -0
- package/dist/index.js +929 -0
- package/dist/index.js.map +1 -0
- package/dist/is-supported.cjs +74 -0
- package/dist/is-supported.cjs.map +1 -0
- package/dist/is-supported.d.cts +8 -0
- package/dist/is-supported.d.ts +8 -0
- package/dist/is-supported.js +9 -0
- package/dist/is-supported.js.map +1 -0
- package/package.json +40 -4
package/README.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# `@dadan-mvp/record-sdk`
|
|
2
|
+
|
|
3
|
+
Headless Dadan Record SDK — capture, upload (TUS), and session events. **No UI, no iframe.**
|
|
4
|
+
|
|
5
|
+
For the default in-page recorder use [`@dadan-mvp/record-sdk-ui`](../record-sdk-ui) or a framework package (`-react` / `-vue` / `-angular`).
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @dadan-mvp/record-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Headless
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { createRecorder, isSupported } from "@dadan-mvp/record-sdk";
|
|
17
|
+
|
|
18
|
+
const support = await isSupported();
|
|
19
|
+
if (!support.supported) throw new Error(support.error);
|
|
20
|
+
|
|
21
|
+
const recorder = await createRecorder({
|
|
22
|
+
mode: "custom",
|
|
23
|
+
publicAppId, // SDK mints uploadToken; Origin must be allowlisted
|
|
24
|
+
videoTitle: "My recording", // optional
|
|
25
|
+
// folderId / teamId optional — else app defaults from session
|
|
26
|
+
uploadToken,
|
|
27
|
+
environment: "sandbox",
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
recorder.configureButton().on("upload-complete", (video) => {
|
|
31
|
+
console.log(video);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
recorder.open({ mode: "both" });
|
|
35
|
+
// Drive your own UI, or pair with @dadan-mvp/record-sdk-ui createInstance.
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## With default UI
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { createInstance } from "@dadan-mvp/record-sdk-ui";
|
|
42
|
+
```
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// src/is-supported.ts
|
|
2
|
+
async function isSupported() {
|
|
3
|
+
const reasons = [];
|
|
4
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
5
|
+
return {
|
|
6
|
+
supported: false,
|
|
7
|
+
error: "Record SDK requires a browser environment",
|
|
8
|
+
reasons: ["no-window"]
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
if (!window.isSecureContext) reasons.push("insecure-context");
|
|
12
|
+
if (!navigator.mediaDevices) {
|
|
13
|
+
reasons.push("no-media-devices");
|
|
14
|
+
} else if (typeof navigator.mediaDevices.getUserMedia !== "function") {
|
|
15
|
+
reasons.push("no-getUserMedia");
|
|
16
|
+
}
|
|
17
|
+
if (typeof MediaRecorder === "undefined") reasons.push("no-MediaRecorder");
|
|
18
|
+
if (reasons.length > 0) {
|
|
19
|
+
return {
|
|
20
|
+
supported: false,
|
|
21
|
+
error: `Record SDK not supported: ${reasons.join(", ")}`,
|
|
22
|
+
reasons
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return { supported: true };
|
|
26
|
+
}
|
|
27
|
+
async function isModeSupported(mode) {
|
|
28
|
+
const base = await isSupported();
|
|
29
|
+
if (!base.supported) return base;
|
|
30
|
+
const reasons = [];
|
|
31
|
+
const needsDisplay = mode === "screen" || mode === "both";
|
|
32
|
+
if (needsDisplay && typeof navigator.mediaDevices?.getDisplayMedia !== "function") {
|
|
33
|
+
reasons.push("no-getDisplayMedia");
|
|
34
|
+
}
|
|
35
|
+
if (reasons.length > 0) {
|
|
36
|
+
return {
|
|
37
|
+
supported: false,
|
|
38
|
+
error: `Mode "${mode}" not supported: ${reasons.join(", ")}`,
|
|
39
|
+
reasons
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return { supported: true };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
isSupported,
|
|
47
|
+
isModeSupported
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=chunk-DBC6WGEP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/is-supported.ts"],"sourcesContent":["import type { IsSupportedResult, RecordingMode } from \"@dadan-mvp/sdk-protocol\";\r\n\r\n/** Hard requirements shared by all recording modes. */\r\nexport async function isSupported(): Promise<IsSupportedResult> {\r\n const reasons: string[] = [];\r\n if (typeof window === \"undefined\" || typeof document === \"undefined\") {\r\n return {\r\n supported: false,\r\n error: \"Record SDK requires a browser environment\",\r\n reasons: [\"no-window\"],\r\n };\r\n }\r\n if (!window.isSecureContext) reasons.push(\"insecure-context\");\r\n if (!navigator.mediaDevices) {\r\n reasons.push(\"no-media-devices\");\r\n } else if (typeof navigator.mediaDevices.getUserMedia !== \"function\") {\r\n reasons.push(\"no-getUserMedia\");\r\n }\r\n if (typeof MediaRecorder === \"undefined\") reasons.push(\"no-MediaRecorder\");\r\n if (reasons.length > 0) {\r\n return {\r\n supported: false,\r\n error: `Record SDK not supported: ${reasons.join(\", \")}`,\r\n reasons,\r\n };\r\n }\r\n return { supported: true };\r\n}\r\n\r\n/** Soft check for a specific mode (e.g. screen needs display-capture). */\r\nexport async function isModeSupported(\r\n mode: RecordingMode\r\n): Promise<IsSupportedResult> {\r\n const base = await isSupported();\r\n if (!base.supported) return base;\r\n\r\n const reasons: string[] = [];\r\n const needsDisplay = mode === \"screen\" || mode === \"both\";\r\n if (\r\n needsDisplay &&\r\n typeof navigator.mediaDevices?.getDisplayMedia !== \"function\"\r\n ) {\r\n reasons.push(\"no-getDisplayMedia\");\r\n }\r\n if (reasons.length > 0) {\r\n return {\r\n supported: false,\r\n error: `Mode \"${mode}\" not supported: ${reasons.join(\", \")}`,\r\n reasons,\r\n };\r\n }\r\n return { supported: true };\r\n}\r\n"],"mappings":";AAGA,eAAsB,cAA0C;AAC9D,QAAM,UAAoB,CAAC;AAC3B,MAAI,OAAO,WAAW,eAAe,OAAO,aAAa,aAAa;AACpE,WAAO;AAAA,MACL,WAAW;AAAA,MACX,OAAO;AAAA,MACP,SAAS,CAAC,WAAW;AAAA,IACvB;AAAA,EACF;AACA,MAAI,CAAC,OAAO,gBAAiB,SAAQ,KAAK,kBAAkB;AAC5D,MAAI,CAAC,UAAU,cAAc;AAC3B,YAAQ,KAAK,kBAAkB;AAAA,EACjC,WAAW,OAAO,UAAU,aAAa,iBAAiB,YAAY;AACpE,YAAQ,KAAK,iBAAiB;AAAA,EAChC;AACA,MAAI,OAAO,kBAAkB,YAAa,SAAQ,KAAK,kBAAkB;AACzE,MAAI,QAAQ,SAAS,GAAG;AACtB,WAAO;AAAA,MACL,WAAW;AAAA,MACX,OAAO,6BAA6B,QAAQ,KAAK,IAAI,CAAC;AAAA,MACtD;AAAA,IACF;AAAA,EACF;AACA,SAAO,EAAE,WAAW,KAAK;AAC3B;AAGA,eAAsB,gBACpB,MAC4B;AAC5B,QAAM,OAAO,MAAM,YAAY;AAC/B,MAAI,CAAC,KAAK,UAAW,QAAO;AAE5B,QAAM,UAAoB,CAAC;AAC3B,QAAM,eAAe,SAAS,YAAY,SAAS;AACnD,MACE,gBACA,OAAO,UAAU,cAAc,oBAAoB,YACnD;AACA,YAAQ,KAAK,oBAAoB;AAAA,EACnC;AACA,MAAI,QAAQ,SAAS,GAAG;AACtB,WAAO;AAAA,MACL,WAAW;AAAA,MACX,OAAO,SAAS,IAAI,oBAAoB,QAAQ,KAAK,IAAI,CAAC;AAAA,MAC1D;AAAA,IACF;AAAA,EACF;AACA,SAAO,EAAE,WAAW,KAAK;AAC3B;","names":[]}
|