@ttt-productions/file-input 0.11.4 → 0.11.5
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-media-duration.d.ts","sourceRoot":"","sources":["../../src/lib/validate-media-duration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate-media-duration.d.ts","sourceRoot":"","sources":["../../src/lib/validate-media-duration.ts"],"names":[],"mappings":"AAEA,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAuChG"}
|
|
@@ -1,18 +1,38 @@
|
|
|
1
|
+
import { resolveInfiniteDuration } from "@ttt-productions/media-viewer";
|
|
1
2
|
export async function validateMediaDuration(file, maxDurationSec) {
|
|
2
3
|
return new Promise((resolve) => {
|
|
3
4
|
const el = document.createElement(file.type.startsWith("video/") ? "video" : "audio");
|
|
4
5
|
el.preload = "metadata";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// Fail open on client (backend can enforce again).
|
|
6
|
+
let settled = false;
|
|
7
|
+
const finish = (ok) => {
|
|
8
|
+
if (settled)
|
|
9
|
+
return;
|
|
10
|
+
settled = true;
|
|
11
11
|
try {
|
|
12
12
|
URL.revokeObjectURL(el.src);
|
|
13
13
|
}
|
|
14
14
|
catch { }
|
|
15
|
-
resolve(
|
|
15
|
+
resolve(ok);
|
|
16
|
+
};
|
|
17
|
+
el.onloadedmetadata = () => {
|
|
18
|
+
if (Number.isFinite(el.duration)) {
|
|
19
|
+
finish(el.duration <= maxDurationSec);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
// Chromium MediaRecorder blobs (recorded audio/video) report duration
|
|
23
|
+
// Infinity at loadedmetadata — `Infinity <= max` falsely rejected every
|
|
24
|
+
// recording (live 2026-07-19: a 5s clip red-texted as "over 60s").
|
|
25
|
+
// Resolve the REAL duration via the shared seek workaround; if it still
|
|
26
|
+
// cannot be determined, fail OPEN — recordings are hard-capped by the
|
|
27
|
+
// RecordDialog timer and the backend enforces duration again at
|
|
28
|
+
// processing (same rationale as the onerror fail-open below).
|
|
29
|
+
void resolveInfiniteDuration(el).then((duration) => {
|
|
30
|
+
finish(duration === null ? true : duration <= maxDurationSec);
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
el.onerror = () => {
|
|
34
|
+
// Fail open on client (backend can enforce again).
|
|
35
|
+
finish(true);
|
|
16
36
|
};
|
|
17
37
|
el.src = URL.createObjectURL(file);
|
|
18
38
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-media-duration.js","sourceRoot":"","sources":["../../src/lib/validate-media-duration.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,IAAU,EAAE,cAAsB;
|
|
1
|
+
{"version":3,"file":"validate-media-duration.js","sourceRoot":"","sources":["../../src/lib/validate-media-duration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAExE,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,IAAU,EAAE,cAAsB;IAC5E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACtF,EAAE,CAAC,OAAO,GAAG,UAAU,CAAC;QAExB,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,MAAM,MAAM,GAAG,CAAC,EAAW,EAAE,EAAE;YAC7B,IAAI,OAAO;gBAAE,OAAO;YACpB,OAAO,GAAG,IAAI,CAAC;YACf,IAAI,CAAC;gBACH,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;YAC9B,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;YACV,OAAO,CAAC,EAAE,CAAC,CAAC;QACd,CAAC,CAAC;QAEF,EAAE,CAAC,gBAAgB,GAAG,GAAG,EAAE;YACzB,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACjC,MAAM,CAAC,EAAE,CAAC,QAAQ,IAAI,cAAc,CAAC,CAAC;gBACtC,OAAO;YACT,CAAC;YACD,sEAAsE;YACtE,wEAAwE;YACxE,mEAAmE;YACnE,wEAAwE;YACxE,sEAAsE;YACtE,gEAAgE;YAChE,8DAA8D;YAC9D,KAAK,uBAAuB,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACjD,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,IAAI,cAAc,CAAC,CAAC;YAChE,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,EAAE,CAAC,OAAO,GAAG,GAAG,EAAE;YAChB,mDAAmD;YACnD,MAAM,CAAC,IAAI,CAAC,CAAC;QACf,CAAC,CAAC;QAEF,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { resolveInfiniteDuration } from \"@ttt-productions/media-viewer\";\n\nexport async function validateMediaDuration(file: File, maxDurationSec: number): Promise<boolean> {\n return new Promise((resolve) => {\n const el = document.createElement(file.type.startsWith(\"video/\") ? \"video\" : \"audio\");\n el.preload = \"metadata\";\n\n let settled = false;\n const finish = (ok: boolean) => {\n if (settled) return;\n settled = true;\n try {\n URL.revokeObjectURL(el.src);\n } catch {}\n resolve(ok);\n };\n\n el.onloadedmetadata = () => {\n if (Number.isFinite(el.duration)) {\n finish(el.duration <= maxDurationSec);\n return;\n }\n // Chromium MediaRecorder blobs (recorded audio/video) report duration\n // Infinity at loadedmetadata — `Infinity <= max` falsely rejected every\n // recording (live 2026-07-19: a 5s clip red-texted as \"over 60s\").\n // Resolve the REAL duration via the shared seek workaround; if it still\n // cannot be determined, fail OPEN — recordings are hard-capped by the\n // RecordDialog timer and the backend enforces duration again at\n // processing (same rationale as the onerror fail-open below).\n void resolveInfiniteDuration(el).then((duration) => {\n finish(duration === null ? true : duration <= maxDurationSec);\n });\n };\n\n el.onerror = () => {\n // Fail open on client (backend can enforce again).\n finish(true);\n };\n\n el.src = URL.createObjectURL(file);\n });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttt-productions/file-input",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.5",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/ttt-productions/ttt-packages.git",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"prepublishOnly": "npm run clean && npm run build"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ttt-productions/ui-core": "^0.11.
|
|
34
|
+
"@ttt-productions/ui-core": "^0.11.8",
|
|
35
35
|
"@ttt-productions/media-schemas": "^0.14.2",
|
|
36
|
-
"@ttt-productions/media-viewer": "^0.10.
|
|
36
|
+
"@ttt-productions/media-viewer": "^0.10.5",
|
|
37
37
|
"react-easy-crop": "^5.5.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|