@kanorio/elements 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +57 -2
- package/dist/MediaPlayer-MWIDJORE.js +2 -0
- package/dist/MediaPlayer-STITRANS.js +13 -0
- package/dist/PDFViewerFull-HIUSAO57.js +13 -0
- package/dist/PDFViewerFull-L7VMOAMU.js +28062 -0
- package/dist/altcha-DSOKKAAV.js +3153 -0
- package/dist/altcha-FLBUR2LJ.js +4 -0
- package/dist/ar-4CBE4BWH.js +1233 -0
- package/dist/ar-6G7ZVSQ3.js +2 -0
- package/dist/ar-XCPH4WO5.js +98 -0
- package/dist/ar-ZVJL6XGE.js +2 -0
- package/dist/bg-4WPFSAMC.js +2 -0
- package/dist/bg-BKFL64I6.js +98 -0
- package/dist/bg-CB273F4D.js +1233 -0
- package/dist/bg-HCH4LMEX.js +2 -0
- package/dist/bn-HLYDEXHQ.js +1233 -0
- package/dist/bn-HVEVBAGM.js +98 -0
- package/dist/bn-OY7YGJIT.js +2 -0
- package/dist/bn-XX3O4VQB.js +2 -0
- package/dist/chunk-2UBPQBQI.js +1848 -0
- package/dist/chunk-5OB57Z46.js +23620 -0
- package/dist/chunk-6LJZ4HRF.js +1350 -0
- package/dist/chunk-6TUB24LJ.js +415 -0
- package/dist/chunk-74RRJOB4.js +15 -0
- package/dist/chunk-7TNRMVML.js +2 -0
- package/dist/chunk-BH27SBYG.js +2 -0
- package/dist/chunk-BQU7QZGC.js +4 -0
- package/dist/chunk-CHSZMJ5D.js +15103 -0
- package/dist/chunk-DDKQOHPW.js +930 -0
- package/dist/chunk-E5ZVE4VL.js +5 -0
- package/dist/chunk-FGBB7FT5.js +4 -0
- package/dist/chunk-FSH5K5FU.js +57 -0
- package/dist/chunk-G3PMV62Z.js +36 -0
- package/dist/chunk-IUB5YLUU.js +1538 -0
- package/dist/chunk-J7AP6FJF.js +8616 -0
- package/dist/chunk-LKOMEUNH.js +72 -0
- package/dist/chunk-NB57OIQA.js +2 -0
- package/dist/chunk-NLJE74VA.js +2 -0
- package/dist/chunk-NQBPWU5Z.js +15 -0
- package/dist/chunk-OJQYDPRD.js +39 -0
- package/dist/chunk-PDKFEXLU.js +59 -0
- package/dist/chunk-POG53MIA.js +2 -0
- package/dist/chunk-PXABHOW4.js +10871 -0
- package/dist/chunk-QDUG7UMV.js +363 -0
- package/dist/chunk-RFBBAUMM.js +2 -0
- package/dist/chunk-RJTKNOYT.js +67 -0
- package/dist/chunk-VH4656UY.js +2 -0
- package/dist/chunk-XAORGJWX.js +2 -0
- package/dist/chunk-Y77XXKLY.js +1858 -0
- package/dist/cs-EDLILQAV.js +1233 -0
- package/dist/cs-EOBDWVFI.js +2 -0
- package/dist/cs-Q732FDDB.js +98 -0
- package/dist/cs-UO3FC3H4.js +2 -0
- package/dist/da-43RMOYSN.js +98 -0
- package/dist/da-ANHSL3GD.js +2 -0
- package/dist/da-RBW34GCF.js +2 -0
- package/dist/da-SJ7YQT4L.js +1233 -0
- package/dist/de-2D2GW24Z.js +2 -0
- package/dist/de-5WGC4CMF.js +1233 -0
- package/dist/de-CPU2ARG7.js +98 -0
- package/dist/de-GVWNGUWZ.js +2 -0
- package/dist/deliverables-QUJISOBO.js +98 -0
- package/dist/deliverables-Z6ZBT6D3.js +2046 -0
- package/dist/el-FRNBHLQF.js +98 -0
- package/dist/el-HCBWOOCJ.js +1233 -0
- package/dist/el-KK7DBDUW.js +2 -0
- package/dist/el-SK362ZEN.js +2 -0
- package/dist/elements.css +2 -0
- package/dist/en-AU-BQA3DX35.js +1233 -0
- package/dist/en-AU-VZAXNXRA.js +2 -0
- package/dist/en-CA-T2VRZJVQ.js +2 -0
- package/dist/en-CA-ZWY5HD2Z.js +1233 -0
- package/dist/en-GB-CH3IGZSE.js +1233 -0
- package/dist/en-GB-MZQ2MGOR.js +2 -0
- package/dist/en-M24TV37U.js +2 -0
- package/dist/en-OURP64TI.js +2 -0
- package/dist/en-US-VWMNQOMN.js +2 -0
- package/dist/en-US-WJZ2OBFI.js +1233 -0
- package/dist/en-USCPKTM6.js +1233 -0
- package/dist/en-YND44PUO.js +98 -0
- package/dist/errors-7SQHRWKX.js +77 -0
- package/dist/errors-S6NFCUG2.js +2 -0
- package/dist/es-419-EMD4NA5M.js +2 -0
- package/dist/es-419-GPBJSXLV.js +2 -0
- package/dist/es-419-S6IHEZ4E.js +1233 -0
- package/dist/es-419-XPZOWYCA.js +98 -0
- package/dist/es-ES-EGMSPSY2.js +1233 -0
- package/dist/es-ES-U6NF6JHU.js +2 -0
- package/dist/es-es-ILD7QLKC.js +98 -0
- package/dist/es-es-MPX25JA6.js +2 -0
- package/dist/fa-5J3M6LW4.js +2 -0
- package/dist/fa-OC7ZPRF2.js +98 -0
- package/dist/fa-OFIO7IXD.js +1233 -0
- package/dist/fa-ZTPM4LEB.js +2 -0
- package/dist/fi-2V2STXSQ.js +2 -0
- package/dist/fi-7J4LPMG2.js +98 -0
- package/dist/fi-FMEAITYP.js +1233 -0
- package/dist/fi-N3BC4FYB.js +2 -0
- package/dist/fr-CA-IKSBTBHG.js +2 -0
- package/dist/fr-CA-S23ERMPM.js +1233 -0
- package/dist/fr-FR-RRTMSQWD.js +2 -0
- package/dist/fr-FR-SOIXFVK2.js +1233 -0
- package/dist/fr-ca-SUWTTOEW.js +2 -0
- package/dist/fr-ca-UUHAWMHI.js +98 -0
- package/dist/fr-fr-SGQ77PBC.js +98 -0
- package/dist/fr-fr-XE2V7MKM.js +2 -0
- package/dist/gu-RT7GQT5B.js +2 -0
- package/dist/gu-Z2QX2VCX.js +1233 -0
- package/dist/he-27MBDHSP.js +2 -0
- package/dist/he-E7RIZOIT.js +1233 -0
- package/dist/he-QGD477CH.js +98 -0
- package/dist/he-R3UJFF46.js +2 -0
- package/dist/hi-2AVAXR7K.js +1233 -0
- package/dist/hi-6ZBMVMGH.js +2 -0
- package/dist/hi-SGQH4OWG.js +98 -0
- package/dist/hi-XJHFN25N.js +2 -0
- package/dist/hls-C5FWCMHH.js +37426 -0
- package/dist/hls-ZQNRY2TQ.js +45 -0
- package/dist/hu-IOGZTF7L.js +2 -0
- package/dist/hu-KNZXJ7ZI.js +98 -0
- package/dist/hu-ORVGO3ZY.js +1233 -0
- package/dist/hu-PKL3T3JT.js +2 -0
- package/dist/id-FKFVQIN6.js +2 -0
- package/dist/id-JH2DLDBA.js +98 -0
- package/dist/id-TMOJUCBD.js +1233 -0
- package/dist/id-WLBO2VOW.js +2 -0
- package/dist/index.d.ts +2955 -0
- package/dist/index.js +67 -0
- package/dist/it-AGUEDSVA.js +2 -0
- package/dist/it-PJAB5BQB.js +98 -0
- package/dist/it-WF5BTFFJ.js +2 -0
- package/dist/it-YMZRYSIJ.js +1233 -0
- package/dist/ja-2ZVND7MB.js +2 -0
- package/dist/ja-555SY4AF.js +1233 -0
- package/dist/ja-RMBJ7E5Z.js +2 -0
- package/dist/ja-ZKBUQDUT.js +98 -0
- package/dist/kanorio-elements.js +97 -0
- package/dist/km-DF366BBP.js +1233 -0
- package/dist/km-JIUQ7MSM.js +2 -0
- package/dist/kn-KTJPREMQ.js +2 -0
- package/dist/kn-MJKASLJD.js +1233 -0
- package/dist/ko-CGY75OW4.js +2 -0
- package/dist/ko-KECCYX66.js +2 -0
- package/dist/ko-L5735TRU.js +98 -0
- package/dist/ko-S3OTZKIG.js +1233 -0
- package/dist/lo-7R55FKUB.js +1233 -0
- package/dist/lo-DNWTAFYF.js +2 -0
- package/dist/ml-B4BJPFVQ.js +2 -0
- package/dist/ml-FCTNQ4SP.js +1233 -0
- package/dist/mr-FJ4EDO7F.js +2 -0
- package/dist/mr-TZTFABWX.js +2 -0
- package/dist/mr-VZ5Y74YA.js +1233 -0
- package/dist/mr-Y464JCKX.js +98 -0
- package/dist/ms-VCX47GHB.js +2 -0
- package/dist/ms-WAJKD7ZV.js +1233 -0
- package/dist/my-S5L32WDK.js +2 -0
- package/dist/my-T7Y3Y64H.js +1233 -0
- package/dist/nb-53GCFBHF.js +2 -0
- package/dist/nb-IJDALVGX.js +99 -0
- package/dist/nb-LXBBUZUD.js +1233 -0
- package/dist/nb-PWWLEFUC.js +2 -0
- package/dist/ne-F7EEIDMA.js +2 -0
- package/dist/ne-NDLRKG6T.js +1233 -0
- package/dist/nl-262SKC6R.js +98 -0
- package/dist/nl-BE-3KOYUD6Y.js +1233 -0
- package/dist/nl-BE-VZJDK6CH.js +2 -0
- package/dist/nl-NL-3OIKN2DQ.js +2 -0
- package/dist/nl-NL-T7SQOLLA.js +1233 -0
- package/dist/nl-XKCUNU3P.js +2 -0
- package/dist/nn-AHWRAFXZ.js +1233 -0
- package/dist/nn-YH7F7UK3.js +2 -0
- package/dist/pa-HC24FOUI.js +2 -0
- package/dist/pa-J26C5J7M.js +1233 -0
- package/dist/pl-QSTOYTPG.js +1233 -0
- package/dist/pl-T7J6A26Y.js +2 -0
- package/dist/pl-TYHET6JJ.js +2 -0
- package/dist/pl-XDJJ6AUG.js +98 -0
- package/dist/prod-MRWX5W24.js +38 -0
- package/dist/prod-YHXWTKNF.js +2 -0
- package/dist/pt-BR-4QRR4PXU.js +2 -0
- package/dist/pt-BR-7JM75AGX.js +1233 -0
- package/dist/pt-PT-W3WZEROD.js +1233 -0
- package/dist/pt-PT-Z5FI4CLF.js +2 -0
- package/dist/pt-br-2W4P4ZAJ.js +2 -0
- package/dist/pt-br-JP6VI5C5.js +98 -0
- package/dist/pt-pt-22LJFZT5.js +98 -0
- package/dist/pt-pt-HOBFIPWZ.js +2 -0
- package/dist/ro-3KXIEYVK.js +98 -0
- package/dist/ro-3YUPB2TJ.js +1233 -0
- package/dist/ro-JXHNIBOA.js +2 -0
- package/dist/ro-KHPOLQC6.js +2 -0
- package/dist/ru-5ZVLKPFN.js +2 -0
- package/dist/ru-ASND25AB.js +2 -0
- package/dist/ru-ATGZC5LB.js +1233 -0
- package/dist/ru-W44AHOIC.js +98 -0
- package/dist/si-RHXLIDQI.js +1233 -0
- package/dist/si-U3O6NRHE.js +2 -0
- package/dist/srt-parser-6DEDUV5P.js +43 -0
- package/dist/srt-parser-E666S3YO.js +3 -0
- package/dist/ssa-parser-5GJ737XF.js +309 -0
- package/dist/ssa-parser-BR3CTDHR.js +5 -0
- package/dist/sv-5LOOKXJA.js +98 -0
- package/dist/sv-6GKNCPMS.js +2 -0
- package/dist/sv-LL3HMUIA.js +1233 -0
- package/dist/sv-RRJ6LYFT.js +2 -0
- package/dist/sw-HBNHIHPG.js +2 -0
- package/dist/sw-HP7MYGQ5.js +1233 -0
- package/dist/sw-NTSCFQXY.js +2 -0
- package/dist/sw-YIUB7QN3.js +98 -0
- package/dist/ta-4RG3PWN5.js +98 -0
- package/dist/ta-ARSNSDK5.js +2 -0
- package/dist/ta-Q2LBTDH6.js +2 -0
- package/dist/ta-Z5EVUBYF.js +1233 -0
- package/dist/te-FAWIFHVW.js +2 -0
- package/dist/te-FXJYUGGL.js +98 -0
- package/dist/te-GDV3DJFJ.js +1233 -0
- package/dist/te-TIMB7HBY.js +2 -0
- package/dist/th-7CEFYE5H.js +2 -0
- package/dist/th-CFAEFK3E.js +1233 -0
- package/dist/th-KGPTXFIF.js +2 -0
- package/dist/th-TC6J25FB.js +98 -0
- package/dist/tl-2JDK2CBL.js +2 -0
- package/dist/tl-SGZM4XSX.js +1233 -0
- package/dist/tr-27OEWIPE.js +1233 -0
- package/dist/tr-2MEHQO75.js +98 -0
- package/dist/tr-7P2UAX7U.js +2 -0
- package/dist/tr-NKD6C4RY.js +2 -0
- package/dist/uk-CXQISVJP.js +2 -0
- package/dist/uk-EJIGGLKY.js +1233 -0
- package/dist/uk-JCI3UE6Q.js +98 -0
- package/dist/uk-QM5BBWP7.js +2 -0
- package/dist/ur-5EWYHPME.js +1233 -0
- package/dist/ur-IIOUQYSA.js +98 -0
- package/dist/ur-M3QWGAPF.js +2 -0
- package/dist/ur-TLLPXSTM.js +2 -0
- package/dist/vi-AXQYYRD3.js +2 -0
- package/dist/vi-JALLXYS7.js +1233 -0
- package/dist/vi-SS65KZTI.js +2 -0
- package/dist/vi-YQVNQEVG.js +98 -0
- package/dist/vidstack-B9fTkxQO-LJP5ADOO.js +215 -0
- package/dist/vidstack-B9fTkxQO-OCT23G55.js +2 -0
- package/dist/vidstack-BmcqUMKx-A2W3TQB6.js +2 -0
- package/dist/vidstack-BmcqUMKx-G6TB22IC.js +286 -0
- package/dist/vidstack-C0fPJIzs-7AH6MOHO.js +2 -0
- package/dist/vidstack-C0fPJIzs-PNQOR4TK.js +11 -0
- package/dist/vidstack-CHcsWfRV-UAVLHO6N.js +40 -0
- package/dist/vidstack-CHcsWfRV-V52LFHYG.js +2 -0
- package/dist/vidstack-CvezEmSQ-JXKCQ4VQ.js +2 -0
- package/dist/vidstack-CvezEmSQ-R32NZKJ2.js +130 -0
- package/dist/vidstack-D2vrrUMs-7XAY5IBS.js +2 -0
- package/dist/vidstack-D2vrrUMs-FNQR2A5M.js +467 -0
- package/dist/vidstack-Di0HObvT-6ND3AXWZ.js +112 -0
- package/dist/vidstack-Di0HObvT-ZV7XK2OT.js +2 -0
- package/dist/vidstack-DiaLSJYx-H762DXYG.js +2 -0
- package/dist/vidstack-DiaLSJYx-S7DDW2H3.js +380 -0
- package/dist/vidstack-Dy74GavT-EYLL6MEF.js +2 -0
- package/dist/vidstack-Dy74GavT-XNIJ7PF4.js +11 -0
- package/dist/vidstack-GkTzay8D-C7EJKMV4.js +2 -0
- package/dist/vidstack-GkTzay8D-SQU5IF3P.js +482 -0
- package/dist/web-components.d.ts +12 -0
- package/dist/web-components.js +123 -0
- package/dist/worker.js +1 -0
- package/dist/zh-CN-PVVDP25S.js +2 -0
- package/dist/zh-CN-TLPNCXUN.js +1233 -0
- package/dist/zh-HK-GOKVZUJZ.js +1233 -0
- package/dist/zh-HK-Z5B2ANLW.js +2 -0
- package/dist/zh-Hant-2R7T4HJT.js +1233 -0
- package/dist/zh-Hant-MWAFLLDD.js +2 -0
- package/dist/zh-cn-D36OS2SI.js +2 -0
- package/dist/zh-cn-Z5YVUN62.js +98 -0
- package/dist/zh-tw-JWILJCBD.js +2 -0
- package/dist/zh-tw-X7JGMR4G.js +98 -0
- package/package.json +84 -3
|
@@ -0,0 +1,1350 @@
|
|
|
1
|
+
// ../../node_modules/.pnpm/media-captions@1.0.4/node_modules/media-captions/dist/prod/index.js
|
|
2
|
+
var ParseErrorCode = {
|
|
3
|
+
LoadFail: 0,
|
|
4
|
+
BadSignature: 1,
|
|
5
|
+
BadTimestamp: 2,
|
|
6
|
+
BadSettingValue: 3,
|
|
7
|
+
BadFormat: 4,
|
|
8
|
+
UnknownSetting: 5
|
|
9
|
+
};
|
|
10
|
+
var ParseError = class extends Error {
|
|
11
|
+
code;
|
|
12
|
+
line;
|
|
13
|
+
constructor(init) {
|
|
14
|
+
super(init.reason);
|
|
15
|
+
this.code = init.code;
|
|
16
|
+
this.line = init.line;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var LINE_TERMINATOR_RE = /\r?\n|\r/gm;
|
|
20
|
+
var TextLineTransformStream = class {
|
|
21
|
+
writable;
|
|
22
|
+
readable;
|
|
23
|
+
constructor(encoding) {
|
|
24
|
+
const transformer = new TextStreamLineIterator(encoding);
|
|
25
|
+
this.writable = new WritableStream({
|
|
26
|
+
write(chunk) {
|
|
27
|
+
transformer.transform(chunk);
|
|
28
|
+
},
|
|
29
|
+
close() {
|
|
30
|
+
transformer.close();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
this.readable = new ReadableStream({
|
|
34
|
+
start(controller) {
|
|
35
|
+
transformer.onLine = (line) => controller.enqueue(line);
|
|
36
|
+
transformer.onClose = () => controller.close();
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var TextStreamLineIterator = class {
|
|
42
|
+
a = "";
|
|
43
|
+
b;
|
|
44
|
+
onLine;
|
|
45
|
+
onClose;
|
|
46
|
+
constructor(encoding) {
|
|
47
|
+
this.b = new TextDecoder(encoding);
|
|
48
|
+
}
|
|
49
|
+
transform(chunk) {
|
|
50
|
+
this.a += this.b.decode(chunk, { stream: true });
|
|
51
|
+
const lines = this.a.split(LINE_TERMINATOR_RE);
|
|
52
|
+
this.a = lines.pop() || "";
|
|
53
|
+
for (let i = 0; i < lines.length; i++)
|
|
54
|
+
this.onLine(lines[i].trim());
|
|
55
|
+
}
|
|
56
|
+
close() {
|
|
57
|
+
if (this.a)
|
|
58
|
+
this.onLine(this.a.trim());
|
|
59
|
+
this.a = "";
|
|
60
|
+
this.onClose();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
async function parseText(text, options) {
|
|
64
|
+
const stream = new ReadableStream({
|
|
65
|
+
start(controller) {
|
|
66
|
+
const lines = text.split(LINE_TERMINATOR_RE);
|
|
67
|
+
for (const line of lines)
|
|
68
|
+
controller.enqueue(line);
|
|
69
|
+
controller.close();
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return parseTextStream(stream, options);
|
|
73
|
+
}
|
|
74
|
+
async function parseTextStream(stream, options) {
|
|
75
|
+
const type = options?.type ?? "vtt";
|
|
76
|
+
let factory;
|
|
77
|
+
if (typeof type === "string") {
|
|
78
|
+
switch (type) {
|
|
79
|
+
case "srt":
|
|
80
|
+
factory = (await import("./srt-parser-6DEDUV5P.js")).default;
|
|
81
|
+
break;
|
|
82
|
+
case "ssa":
|
|
83
|
+
case "ass":
|
|
84
|
+
factory = (await import("./ssa-parser-5GJ737XF.js")).default;
|
|
85
|
+
break;
|
|
86
|
+
default:
|
|
87
|
+
factory = (await Promise.resolve().then(function() {
|
|
88
|
+
return vttParser;
|
|
89
|
+
})).default;
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
factory = type;
|
|
93
|
+
}
|
|
94
|
+
let result;
|
|
95
|
+
const reader = stream.getReader(), parser = factory(), errors = !!options?.strict || !!options?.errors;
|
|
96
|
+
await parser.init({
|
|
97
|
+
strict: false,
|
|
98
|
+
...options,
|
|
99
|
+
errors,
|
|
100
|
+
type,
|
|
101
|
+
cancel() {
|
|
102
|
+
reader.cancel();
|
|
103
|
+
result = parser.done(true);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
let i = 1;
|
|
107
|
+
while (true) {
|
|
108
|
+
const { value, done } = await reader.read();
|
|
109
|
+
if (done) {
|
|
110
|
+
parser.parse("", i);
|
|
111
|
+
result = parser.done(false);
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
parser.parse(value, i);
|
|
115
|
+
i++;
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
async function parseResponse(response, options) {
|
|
120
|
+
const res = await response;
|
|
121
|
+
if (!res.ok || !res.body) {
|
|
122
|
+
let error;
|
|
123
|
+
return {
|
|
124
|
+
metadata: {},
|
|
125
|
+
cues: [],
|
|
126
|
+
regions: [],
|
|
127
|
+
errors: [error]
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const contentType = res.headers.get("content-type") || "", type = contentType.match(/text\/(.*?)(?:;|$)/)?.[1], encoding = contentType.match(/charset=(.*?)(?:;|$)/)?.[1];
|
|
131
|
+
return parseByteStream(res.body, { type, encoding, ...options });
|
|
132
|
+
}
|
|
133
|
+
async function parseByteStream(stream, { encoding = "utf-8", ...options } = {}) {
|
|
134
|
+
const textStream = stream.pipeThrough(new TextLineTransformStream(encoding));
|
|
135
|
+
return parseTextStream(textStream, options);
|
|
136
|
+
}
|
|
137
|
+
var TextCue = class extends EventTarget {
|
|
138
|
+
/**
|
|
139
|
+
* A string that identifies the cue.
|
|
140
|
+
*
|
|
141
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCue/id}
|
|
142
|
+
*/
|
|
143
|
+
id = "";
|
|
144
|
+
/**
|
|
145
|
+
* A `double` that represents the video time that the cue will start being displayed, in seconds.
|
|
146
|
+
*
|
|
147
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCue/startTime}
|
|
148
|
+
*/
|
|
149
|
+
startTime;
|
|
150
|
+
/**
|
|
151
|
+
* A `double` that represents the video time that the cue will stop being displayed, in seconds.
|
|
152
|
+
*
|
|
153
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCue/endTime}
|
|
154
|
+
*/
|
|
155
|
+
endTime;
|
|
156
|
+
/**
|
|
157
|
+
* Returns a string with the contents of the cue.
|
|
158
|
+
*
|
|
159
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/text}
|
|
160
|
+
*/
|
|
161
|
+
text;
|
|
162
|
+
/**
|
|
163
|
+
* A `boolean` for whether the video will pause when this cue stops being displayed.
|
|
164
|
+
*
|
|
165
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCue/pauseOnExit}
|
|
166
|
+
*/
|
|
167
|
+
pauseOnExit = false;
|
|
168
|
+
constructor(startTime, endTime, text) {
|
|
169
|
+
super();
|
|
170
|
+
this.startTime = startTime;
|
|
171
|
+
this.endTime = endTime;
|
|
172
|
+
this.text = text;
|
|
173
|
+
}
|
|
174
|
+
addEventListener(type, listener, options) {
|
|
175
|
+
super.addEventListener(type, listener, options);
|
|
176
|
+
}
|
|
177
|
+
removeEventListener(type, listener, options) {
|
|
178
|
+
super.removeEventListener(type, listener, options);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
var IS_SERVER = typeof document === "undefined";
|
|
182
|
+
var CueBase = IS_SERVER ? TextCue : window.VTTCue;
|
|
183
|
+
var VTTCue = class extends CueBase {
|
|
184
|
+
/**
|
|
185
|
+
* A `VTTRegion` object describing the video's sub-region that the cue will be drawn onto,
|
|
186
|
+
* or `null` if none is assigned.
|
|
187
|
+
*
|
|
188
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/region}
|
|
189
|
+
*/
|
|
190
|
+
region = null;
|
|
191
|
+
/**
|
|
192
|
+
* The cue writing direction.
|
|
193
|
+
*
|
|
194
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/vertical}
|
|
195
|
+
*/
|
|
196
|
+
vertical = "";
|
|
197
|
+
/**
|
|
198
|
+
* Returns `true` if the `VTTCue.line` attribute is an integer number of lines or a percentage
|
|
199
|
+
* of the video size.
|
|
200
|
+
*
|
|
201
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/snapToLines}
|
|
202
|
+
*/
|
|
203
|
+
snapToLines = true;
|
|
204
|
+
/**
|
|
205
|
+
* Returns the line positioning of the cue. This can be the string `'auto'` or a number whose
|
|
206
|
+
* interpretation depends on the value of `VTTCue.snapToLines`.
|
|
207
|
+
*
|
|
208
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/line}
|
|
209
|
+
*/
|
|
210
|
+
line = "auto";
|
|
211
|
+
/**
|
|
212
|
+
* Returns an enum representing the alignment of the `VTTCue.line`.
|
|
213
|
+
*
|
|
214
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/lineAlign}
|
|
215
|
+
*/
|
|
216
|
+
lineAlign = "start";
|
|
217
|
+
/**
|
|
218
|
+
* Returns the indentation of the cue within the line. This can be the string `'auto'` or a
|
|
219
|
+
* number representing the percentage of the `VTTCue.region`, or the video size if `VTTCue`.region`
|
|
220
|
+
* is `null`.
|
|
221
|
+
*
|
|
222
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/position}
|
|
223
|
+
*/
|
|
224
|
+
position = "auto";
|
|
225
|
+
/**
|
|
226
|
+
* Returns an enum representing the alignment of the cue. This is used to determine what
|
|
227
|
+
* the `VTTCue.position` is anchored to. The default is `'auto'`.
|
|
228
|
+
*
|
|
229
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/positionAlign}
|
|
230
|
+
*/
|
|
231
|
+
positionAlign = "auto";
|
|
232
|
+
/**
|
|
233
|
+
* Returns a double representing the size of the cue, as a percentage of the video size.
|
|
234
|
+
*
|
|
235
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/size}
|
|
236
|
+
*/
|
|
237
|
+
size = 100;
|
|
238
|
+
/**
|
|
239
|
+
* Returns an enum representing the alignment of all the lines of text within the cue box.
|
|
240
|
+
*
|
|
241
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/align}
|
|
242
|
+
*/
|
|
243
|
+
align = "center";
|
|
244
|
+
/**
|
|
245
|
+
* Additional styles associated with the cue.
|
|
246
|
+
*/
|
|
247
|
+
style;
|
|
248
|
+
};
|
|
249
|
+
var VTTRegion = class {
|
|
250
|
+
/**
|
|
251
|
+
* A string that identifies the region.
|
|
252
|
+
*/
|
|
253
|
+
id = "";
|
|
254
|
+
/**
|
|
255
|
+
* A `double` representing the width of the region, as a percentage of the video.
|
|
256
|
+
*/
|
|
257
|
+
width = 100;
|
|
258
|
+
/**
|
|
259
|
+
* A `double` representing the height of the region, in number of lines.
|
|
260
|
+
*/
|
|
261
|
+
lines = 3;
|
|
262
|
+
/**
|
|
263
|
+
* A `double` representing the region anchor X offset, as a percentage of the region.
|
|
264
|
+
*/
|
|
265
|
+
regionAnchorX = 0;
|
|
266
|
+
/**
|
|
267
|
+
* A `double` representing the region anchor Y offset, as a percentage of the region.
|
|
268
|
+
*/
|
|
269
|
+
regionAnchorY = 100;
|
|
270
|
+
/**
|
|
271
|
+
* A `double` representing the viewport anchor X offset, as a percentage of the video.
|
|
272
|
+
*/
|
|
273
|
+
viewportAnchorX = 0;
|
|
274
|
+
/**
|
|
275
|
+
* A `double` representing the viewport anchor Y offset, as a percentage of the video.
|
|
276
|
+
*/
|
|
277
|
+
viewportAnchorY = 100;
|
|
278
|
+
/**
|
|
279
|
+
* An enum representing how adding new cues will move existing cues.
|
|
280
|
+
*/
|
|
281
|
+
scroll = "";
|
|
282
|
+
};
|
|
283
|
+
var COMMA$1 = ",";
|
|
284
|
+
var PERCENT_SIGN$1 = "%";
|
|
285
|
+
function toNumber(text) {
|
|
286
|
+
const num = parseInt(text, 10);
|
|
287
|
+
return !Number.isNaN(num) ? num : null;
|
|
288
|
+
}
|
|
289
|
+
function toPercentage(text) {
|
|
290
|
+
const num = parseInt(text.replace(PERCENT_SIGN$1, ""), 10);
|
|
291
|
+
return !Number.isNaN(num) && num >= 0 && num <= 100 ? num : null;
|
|
292
|
+
}
|
|
293
|
+
function toCoords(text) {
|
|
294
|
+
if (!text.includes(COMMA$1))
|
|
295
|
+
return null;
|
|
296
|
+
const [x, y] = text.split(COMMA$1).map(toPercentage);
|
|
297
|
+
return x !== null && y !== null ? [x, y] : null;
|
|
298
|
+
}
|
|
299
|
+
function toFloat(text) {
|
|
300
|
+
const num = parseFloat(text);
|
|
301
|
+
return !Number.isNaN(num) ? num : null;
|
|
302
|
+
}
|
|
303
|
+
var HEADER_MAGIC = "WEBVTT";
|
|
304
|
+
var COMMA = ",";
|
|
305
|
+
var PERCENT_SIGN = "%";
|
|
306
|
+
var SETTING_SEP_RE = /[:=]/;
|
|
307
|
+
var SETTING_LINE_RE = /^[\s\t]*(region|vertical|line|position|size|align)[:=]/;
|
|
308
|
+
var NOTE_BLOCK_START = "NOTE";
|
|
309
|
+
var REGION_BLOCK_START = "REGION";
|
|
310
|
+
var REGION_BLOCK_START_RE = /^REGION:?[\s\t]+/;
|
|
311
|
+
var SPACE_RE = /[\s\t]+/;
|
|
312
|
+
var TIMESTAMP_SEP = "-->";
|
|
313
|
+
var TIMESTAMP_SEP_RE = /[\s\t]*-->[\s\t]+/;
|
|
314
|
+
var ALIGN_RE = /start|center|end|left|right/;
|
|
315
|
+
var LINE_ALIGN_RE = /start|center|end/;
|
|
316
|
+
var POS_ALIGN_RE = /line-(?:left|right)|center|auto/;
|
|
317
|
+
var TIMESTAMP_RE = /^(?:(\d{1,2}):)?(\d{2}):(\d{2})(?:\.(\d{1,3}))?$/;
|
|
318
|
+
var VTTBlock = /* @__PURE__ */ ((VTTBlock2) => {
|
|
319
|
+
VTTBlock2[VTTBlock2["None"] = 0] = "None";
|
|
320
|
+
VTTBlock2[VTTBlock2["Header"] = 1] = "Header";
|
|
321
|
+
VTTBlock2[VTTBlock2["Cue"] = 2] = "Cue";
|
|
322
|
+
VTTBlock2[VTTBlock2["Region"] = 3] = "Region";
|
|
323
|
+
VTTBlock2[VTTBlock2["Note"] = 4] = "Note";
|
|
324
|
+
return VTTBlock2;
|
|
325
|
+
})(VTTBlock || {});
|
|
326
|
+
var VTTParser = class {
|
|
327
|
+
h;
|
|
328
|
+
e = 0;
|
|
329
|
+
i = {};
|
|
330
|
+
j = {};
|
|
331
|
+
l = [];
|
|
332
|
+
c = null;
|
|
333
|
+
d = null;
|
|
334
|
+
m = [];
|
|
335
|
+
f;
|
|
336
|
+
n = "";
|
|
337
|
+
async init(init) {
|
|
338
|
+
this.h = init;
|
|
339
|
+
if (init.strict)
|
|
340
|
+
this.e = 1;
|
|
341
|
+
if (init.errors)
|
|
342
|
+
this.f = (await import("./errors-7SQHRWKX.js")).ParseErrorBuilder;
|
|
343
|
+
}
|
|
344
|
+
parse(line, lineCount) {
|
|
345
|
+
if (line === "") {
|
|
346
|
+
if (this.c) {
|
|
347
|
+
this.l.push(this.c);
|
|
348
|
+
this.h.onCue?.(this.c);
|
|
349
|
+
this.c = null;
|
|
350
|
+
} else if (this.d) {
|
|
351
|
+
this.j[this.d.id] = this.d;
|
|
352
|
+
this.h.onRegion?.(this.d);
|
|
353
|
+
this.d = null;
|
|
354
|
+
} else if (this.e === 1) {
|
|
355
|
+
this.k(line, lineCount);
|
|
356
|
+
this.h.onHeaderMetadata?.(this.i);
|
|
357
|
+
}
|
|
358
|
+
this.e = 0;
|
|
359
|
+
} else if (this.e) {
|
|
360
|
+
switch (this.e) {
|
|
361
|
+
case 1:
|
|
362
|
+
this.k(line, lineCount);
|
|
363
|
+
break;
|
|
364
|
+
case 2:
|
|
365
|
+
if (this.c) {
|
|
366
|
+
const hasText = this.c.text.length > 0;
|
|
367
|
+
if (!hasText && SETTING_LINE_RE.test(line)) {
|
|
368
|
+
this.o(line.split(SPACE_RE), lineCount);
|
|
369
|
+
} else {
|
|
370
|
+
this.c.text += (hasText ? "\n" : "") + line;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
break;
|
|
374
|
+
case 3:
|
|
375
|
+
this.p(line.split(SPACE_RE), lineCount);
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
} else if (line.startsWith(NOTE_BLOCK_START)) {
|
|
379
|
+
this.e = 4;
|
|
380
|
+
} else if (line.startsWith(REGION_BLOCK_START)) {
|
|
381
|
+
this.e = 3;
|
|
382
|
+
this.d = new VTTRegion();
|
|
383
|
+
this.p(line.replace(REGION_BLOCK_START_RE, "").split(SPACE_RE), lineCount);
|
|
384
|
+
} else if (line.includes(TIMESTAMP_SEP)) {
|
|
385
|
+
const result = this.q(line, lineCount);
|
|
386
|
+
if (result) {
|
|
387
|
+
this.c = new VTTCue(result[0], result[1], "");
|
|
388
|
+
this.c.id = this.n;
|
|
389
|
+
this.o(result[2], lineCount);
|
|
390
|
+
}
|
|
391
|
+
this.e = 2;
|
|
392
|
+
} else if (lineCount === 1) {
|
|
393
|
+
this.k(line, lineCount);
|
|
394
|
+
}
|
|
395
|
+
this.n = line;
|
|
396
|
+
}
|
|
397
|
+
done() {
|
|
398
|
+
return {
|
|
399
|
+
metadata: this.i,
|
|
400
|
+
cues: this.l,
|
|
401
|
+
regions: Object.values(this.j),
|
|
402
|
+
errors: this.m
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
k(line, lineCount) {
|
|
406
|
+
if (lineCount > 1) {
|
|
407
|
+
if (SETTING_SEP_RE.test(line)) {
|
|
408
|
+
const [key, value] = line.split(SETTING_SEP_RE);
|
|
409
|
+
if (key)
|
|
410
|
+
this.i[key] = (value || "").replace(SPACE_RE, "");
|
|
411
|
+
}
|
|
412
|
+
} else if (line.startsWith(HEADER_MAGIC)) {
|
|
413
|
+
this.e = 1;
|
|
414
|
+
} else {
|
|
415
|
+
this.g(this.f?.r());
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
q(line, lineCount) {
|
|
419
|
+
const [startTimeText, trailingText = ""] = line.split(TIMESTAMP_SEP_RE), [endTimeText, ...settingsText] = trailingText.split(SPACE_RE), startTime = parseVTTTimestamp(startTimeText), endTime = parseVTTTimestamp(endTimeText);
|
|
420
|
+
if (startTime !== null && endTime !== null && endTime > startTime) {
|
|
421
|
+
return [startTime, endTime, settingsText];
|
|
422
|
+
} else {
|
|
423
|
+
if (startTime === null) {
|
|
424
|
+
this.g(this.f?.s(startTimeText, lineCount));
|
|
425
|
+
}
|
|
426
|
+
if (endTime === null) {
|
|
427
|
+
this.g(this.f?.t(endTimeText, lineCount));
|
|
428
|
+
}
|
|
429
|
+
if (startTime != null && endTime !== null && endTime > startTime) {
|
|
430
|
+
this.g(this.f?.u(startTime, endTime, lineCount));
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* @see {@link https://www.w3.org/TR/webvtt1/#region-settings-parsing}
|
|
436
|
+
*/
|
|
437
|
+
p(settings, line) {
|
|
438
|
+
let badValue;
|
|
439
|
+
for (let i = 0; i < settings.length; i++) {
|
|
440
|
+
if (SETTING_SEP_RE.test(settings[i])) {
|
|
441
|
+
badValue = false;
|
|
442
|
+
const [name, value] = settings[i].split(SETTING_SEP_RE);
|
|
443
|
+
switch (name) {
|
|
444
|
+
case "id":
|
|
445
|
+
this.d.id = value;
|
|
446
|
+
break;
|
|
447
|
+
case "width":
|
|
448
|
+
const width = toPercentage(value);
|
|
449
|
+
if (width !== null)
|
|
450
|
+
this.d.width = width;
|
|
451
|
+
else
|
|
452
|
+
badValue = true;
|
|
453
|
+
break;
|
|
454
|
+
case "lines":
|
|
455
|
+
const lines = toNumber(value);
|
|
456
|
+
if (lines !== null)
|
|
457
|
+
this.d.lines = lines;
|
|
458
|
+
else
|
|
459
|
+
badValue = true;
|
|
460
|
+
break;
|
|
461
|
+
case "regionanchor":
|
|
462
|
+
const region = toCoords(value);
|
|
463
|
+
if (region !== null) {
|
|
464
|
+
this.d.regionAnchorX = region[0];
|
|
465
|
+
this.d.regionAnchorY = region[1];
|
|
466
|
+
} else
|
|
467
|
+
badValue = true;
|
|
468
|
+
break;
|
|
469
|
+
case "viewportanchor":
|
|
470
|
+
const viewport = toCoords(value);
|
|
471
|
+
if (viewport !== null) {
|
|
472
|
+
this.d.viewportAnchorX = viewport[0];
|
|
473
|
+
this.d.viewportAnchorY = viewport[1];
|
|
474
|
+
} else
|
|
475
|
+
badValue = true;
|
|
476
|
+
break;
|
|
477
|
+
case "scroll":
|
|
478
|
+
if (value === "up")
|
|
479
|
+
this.d.scroll = "up";
|
|
480
|
+
else
|
|
481
|
+
badValue = true;
|
|
482
|
+
break;
|
|
483
|
+
default:
|
|
484
|
+
this.g(this.f?.v(name, value, line));
|
|
485
|
+
}
|
|
486
|
+
if (badValue) {
|
|
487
|
+
this.g(this.f?.w(name, value, line));
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* @see {@link https://www.w3.org/TR/webvtt1/#cue-timings-and-settings-parsing}
|
|
494
|
+
*/
|
|
495
|
+
o(settings, line) {
|
|
496
|
+
let badValue;
|
|
497
|
+
for (let i = 0; i < settings.length; i++) {
|
|
498
|
+
badValue = false;
|
|
499
|
+
if (SETTING_SEP_RE.test(settings[i])) {
|
|
500
|
+
const [name, value] = settings[i].split(SETTING_SEP_RE);
|
|
501
|
+
switch (name) {
|
|
502
|
+
case "region":
|
|
503
|
+
const region = this.j[value];
|
|
504
|
+
if (region)
|
|
505
|
+
this.c.region = region;
|
|
506
|
+
break;
|
|
507
|
+
case "vertical":
|
|
508
|
+
if (value === "lr" || value === "rl") {
|
|
509
|
+
this.c.vertical = value;
|
|
510
|
+
this.c.region = null;
|
|
511
|
+
} else
|
|
512
|
+
badValue = true;
|
|
513
|
+
break;
|
|
514
|
+
case "line":
|
|
515
|
+
const [linePos, lineAlign] = value.split(COMMA);
|
|
516
|
+
if (linePos.includes(PERCENT_SIGN)) {
|
|
517
|
+
const percentage = toPercentage(linePos);
|
|
518
|
+
if (percentage !== null) {
|
|
519
|
+
this.c.line = percentage;
|
|
520
|
+
this.c.snapToLines = false;
|
|
521
|
+
} else
|
|
522
|
+
badValue = true;
|
|
523
|
+
} else {
|
|
524
|
+
const number = toFloat(linePos);
|
|
525
|
+
if (number !== null)
|
|
526
|
+
this.c.line = number;
|
|
527
|
+
else
|
|
528
|
+
badValue = true;
|
|
529
|
+
}
|
|
530
|
+
if (LINE_ALIGN_RE.test(lineAlign)) {
|
|
531
|
+
this.c.lineAlign = lineAlign;
|
|
532
|
+
} else if (lineAlign) {
|
|
533
|
+
badValue = true;
|
|
534
|
+
}
|
|
535
|
+
if (this.c.line !== "auto")
|
|
536
|
+
this.c.region = null;
|
|
537
|
+
break;
|
|
538
|
+
case "position":
|
|
539
|
+
const [colPos, colAlign] = value.split(COMMA), position = toPercentage(colPos);
|
|
540
|
+
if (position !== null)
|
|
541
|
+
this.c.position = position;
|
|
542
|
+
else
|
|
543
|
+
badValue = true;
|
|
544
|
+
if (colAlign && POS_ALIGN_RE.test(colAlign)) {
|
|
545
|
+
this.c.positionAlign = colAlign;
|
|
546
|
+
} else if (colAlign) {
|
|
547
|
+
badValue = true;
|
|
548
|
+
}
|
|
549
|
+
break;
|
|
550
|
+
case "size":
|
|
551
|
+
const size = toPercentage(value);
|
|
552
|
+
if (size !== null) {
|
|
553
|
+
this.c.size = size;
|
|
554
|
+
if (size < 100)
|
|
555
|
+
this.c.region = null;
|
|
556
|
+
} else {
|
|
557
|
+
badValue = true;
|
|
558
|
+
}
|
|
559
|
+
break;
|
|
560
|
+
case "align":
|
|
561
|
+
if (ALIGN_RE.test(value)) {
|
|
562
|
+
this.c.align = value;
|
|
563
|
+
} else {
|
|
564
|
+
badValue = true;
|
|
565
|
+
}
|
|
566
|
+
break;
|
|
567
|
+
default:
|
|
568
|
+
this.g(this.f?.x(name, value, line));
|
|
569
|
+
}
|
|
570
|
+
if (badValue) {
|
|
571
|
+
this.g(this.f?.y(name, value, line));
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
g(error) {
|
|
577
|
+
if (!error)
|
|
578
|
+
return;
|
|
579
|
+
this.m.push(error);
|
|
580
|
+
if (this.h.strict) {
|
|
581
|
+
this.h.cancel();
|
|
582
|
+
throw error;
|
|
583
|
+
} else {
|
|
584
|
+
this.h.onError?.(error);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
function parseVTTTimestamp(timestamp) {
|
|
589
|
+
const match = timestamp.match(TIMESTAMP_RE);
|
|
590
|
+
if (!match)
|
|
591
|
+
return null;
|
|
592
|
+
const hours = match[1] ? parseInt(match[1], 10) : 0, minutes = parseInt(match[2], 10), seconds = parseInt(match[3], 10), milliseconds = match[4] ? parseInt(match[4].padEnd(3, "0"), 10) : 0, total = hours * 3600 + minutes * 60 + seconds + milliseconds / 1e3;
|
|
593
|
+
if (hours < 0 || minutes < 0 || seconds < 0 || milliseconds < 0 || minutes > 59 || seconds > 59) {
|
|
594
|
+
return null;
|
|
595
|
+
}
|
|
596
|
+
return total;
|
|
597
|
+
}
|
|
598
|
+
function createVTTParser() {
|
|
599
|
+
return new VTTParser();
|
|
600
|
+
}
|
|
601
|
+
var vttParser = /* @__PURE__ */ Object.freeze({
|
|
602
|
+
__proto__: null,
|
|
603
|
+
VTTBlock,
|
|
604
|
+
VTTParser,
|
|
605
|
+
default: createVTTParser,
|
|
606
|
+
parseVTTTimestamp
|
|
607
|
+
});
|
|
608
|
+
var DIGIT_RE = /[0-9]/;
|
|
609
|
+
var MULTI_SPACE_RE = /[\s\t]+/;
|
|
610
|
+
var TAG_NAME = {
|
|
611
|
+
c: "span",
|
|
612
|
+
i: "i",
|
|
613
|
+
b: "b",
|
|
614
|
+
u: "u",
|
|
615
|
+
ruby: "ruby",
|
|
616
|
+
rt: "rt",
|
|
617
|
+
v: "span",
|
|
618
|
+
lang: "span",
|
|
619
|
+
timestamp: "span"
|
|
620
|
+
};
|
|
621
|
+
var HTML_ENTITIES = {
|
|
622
|
+
"&": "&",
|
|
623
|
+
"<": "<",
|
|
624
|
+
">": ">",
|
|
625
|
+
""": '"',
|
|
626
|
+
"'": "'",
|
|
627
|
+
" ": "\xA0",
|
|
628
|
+
"‎": "\u200E",
|
|
629
|
+
"‏": "\u200F"
|
|
630
|
+
};
|
|
631
|
+
var HTML_ENTITY_RE = /&(?:amp|lt|gt|quot|#(0+)?39|nbsp|lrm|rlm);/g;
|
|
632
|
+
var COLORS = /* @__PURE__ */ new Set([
|
|
633
|
+
"white",
|
|
634
|
+
"lime",
|
|
635
|
+
"cyan",
|
|
636
|
+
"red",
|
|
637
|
+
"yellow",
|
|
638
|
+
"magenta",
|
|
639
|
+
"blue",
|
|
640
|
+
"black"
|
|
641
|
+
]);
|
|
642
|
+
var BLOCK_TYPES = /* @__PURE__ */ new Set(Object.keys(TAG_NAME));
|
|
643
|
+
function tokenizeVTTCue(cue) {
|
|
644
|
+
let buffer = "", mode = 1, result = [], stack = [], node;
|
|
645
|
+
for (let i = 0; i < cue.text.length; i++) {
|
|
646
|
+
const char = cue.text[i];
|
|
647
|
+
switch (mode) {
|
|
648
|
+
case 1:
|
|
649
|
+
if (char === "<") {
|
|
650
|
+
addText();
|
|
651
|
+
mode = 2;
|
|
652
|
+
} else {
|
|
653
|
+
buffer += char;
|
|
654
|
+
}
|
|
655
|
+
break;
|
|
656
|
+
case 2:
|
|
657
|
+
switch (char) {
|
|
658
|
+
case "\n":
|
|
659
|
+
case " ":
|
|
660
|
+
case " ":
|
|
661
|
+
addNode();
|
|
662
|
+
mode = 4;
|
|
663
|
+
break;
|
|
664
|
+
case ".":
|
|
665
|
+
addNode();
|
|
666
|
+
mode = 3;
|
|
667
|
+
break;
|
|
668
|
+
case "/":
|
|
669
|
+
mode = 5;
|
|
670
|
+
break;
|
|
671
|
+
case ">":
|
|
672
|
+
addNode();
|
|
673
|
+
mode = 1;
|
|
674
|
+
break;
|
|
675
|
+
default:
|
|
676
|
+
if (!buffer && DIGIT_RE.test(char))
|
|
677
|
+
mode = 6;
|
|
678
|
+
buffer += char;
|
|
679
|
+
break;
|
|
680
|
+
}
|
|
681
|
+
break;
|
|
682
|
+
case 3:
|
|
683
|
+
switch (char) {
|
|
684
|
+
case " ":
|
|
685
|
+
case " ":
|
|
686
|
+
case "\n":
|
|
687
|
+
addClass();
|
|
688
|
+
if (node)
|
|
689
|
+
node.class?.trim();
|
|
690
|
+
mode = 4;
|
|
691
|
+
break;
|
|
692
|
+
case ".":
|
|
693
|
+
addClass();
|
|
694
|
+
break;
|
|
695
|
+
case ">":
|
|
696
|
+
addClass();
|
|
697
|
+
if (node)
|
|
698
|
+
node.class?.trim();
|
|
699
|
+
mode = 1;
|
|
700
|
+
break;
|
|
701
|
+
default:
|
|
702
|
+
buffer += char;
|
|
703
|
+
}
|
|
704
|
+
break;
|
|
705
|
+
case 4:
|
|
706
|
+
if (char === ">") {
|
|
707
|
+
buffer = buffer.replace(MULTI_SPACE_RE, " ");
|
|
708
|
+
if (node?.type === "v")
|
|
709
|
+
node.voice = replaceHTMLEntities(buffer);
|
|
710
|
+
else if (node?.type === "lang")
|
|
711
|
+
node.lang = replaceHTMLEntities(buffer);
|
|
712
|
+
buffer = "";
|
|
713
|
+
mode = 1;
|
|
714
|
+
} else {
|
|
715
|
+
buffer += char;
|
|
716
|
+
}
|
|
717
|
+
break;
|
|
718
|
+
case 5:
|
|
719
|
+
if (char === ">") {
|
|
720
|
+
buffer = "";
|
|
721
|
+
node = stack.pop();
|
|
722
|
+
mode = 1;
|
|
723
|
+
}
|
|
724
|
+
break;
|
|
725
|
+
case 6:
|
|
726
|
+
if (char === ">") {
|
|
727
|
+
const time = parseVTTTimestamp(buffer);
|
|
728
|
+
if (time !== null && time >= cue.startTime && time <= cue.endTime) {
|
|
729
|
+
buffer = "timestamp";
|
|
730
|
+
addNode();
|
|
731
|
+
node.time = time;
|
|
732
|
+
}
|
|
733
|
+
buffer = "";
|
|
734
|
+
mode = 1;
|
|
735
|
+
} else {
|
|
736
|
+
buffer += char;
|
|
737
|
+
}
|
|
738
|
+
break;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
function addNode() {
|
|
742
|
+
if (BLOCK_TYPES.has(buffer)) {
|
|
743
|
+
const parent = node;
|
|
744
|
+
node = createBlockNode(buffer);
|
|
745
|
+
if (parent) {
|
|
746
|
+
if (stack[stack.length - 1] !== parent)
|
|
747
|
+
stack.push(parent);
|
|
748
|
+
parent.children.push(node);
|
|
749
|
+
} else
|
|
750
|
+
result.push(node);
|
|
751
|
+
}
|
|
752
|
+
buffer = "";
|
|
753
|
+
mode = 1;
|
|
754
|
+
}
|
|
755
|
+
function addClass() {
|
|
756
|
+
if (node && buffer) {
|
|
757
|
+
const color = buffer.replace("bg_", "");
|
|
758
|
+
if (COLORS.has(color)) {
|
|
759
|
+
node[buffer.startsWith("bg_") ? "bgColor" : "color"] = color;
|
|
760
|
+
} else {
|
|
761
|
+
node.class = !node.class ? buffer : node.class + " " + buffer;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
buffer = "";
|
|
765
|
+
}
|
|
766
|
+
function addText() {
|
|
767
|
+
if (!buffer)
|
|
768
|
+
return;
|
|
769
|
+
const text = { type: "text", data: replaceHTMLEntities(buffer) };
|
|
770
|
+
node ? node.children.push(text) : result.push(text);
|
|
771
|
+
buffer = "";
|
|
772
|
+
}
|
|
773
|
+
if (mode === 1)
|
|
774
|
+
addText();
|
|
775
|
+
return result;
|
|
776
|
+
}
|
|
777
|
+
function createBlockNode(type) {
|
|
778
|
+
return {
|
|
779
|
+
tagName: TAG_NAME[type],
|
|
780
|
+
type,
|
|
781
|
+
children: []
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
function replaceHTMLEntities(text) {
|
|
785
|
+
return text.replace(HTML_ENTITY_RE, (entity) => HTML_ENTITIES[entity] || "'");
|
|
786
|
+
}
|
|
787
|
+
function setCSSVar(el, name, value) {
|
|
788
|
+
el.style.setProperty(`--${name}`, value + "");
|
|
789
|
+
}
|
|
790
|
+
function setDataAttr(el, name, value = true) {
|
|
791
|
+
el.setAttribute(`data-${name}`, value === true ? "" : value + "");
|
|
792
|
+
}
|
|
793
|
+
function setPartAttr(el, name) {
|
|
794
|
+
el.setAttribute("data-part", name);
|
|
795
|
+
}
|
|
796
|
+
function getLineHeight(el) {
|
|
797
|
+
return parseFloat(getComputedStyle(el).lineHeight) || 0;
|
|
798
|
+
}
|
|
799
|
+
function createVTTCueTemplate(cue) {
|
|
800
|
+
if (IS_SERVER) {
|
|
801
|
+
throw Error(
|
|
802
|
+
"[media-captions] called `createVTTCueTemplate` on the server - use `renderVTTCueString`"
|
|
803
|
+
);
|
|
804
|
+
}
|
|
805
|
+
const template = document.createElement("template");
|
|
806
|
+
template.innerHTML = renderVTTCueString(cue);
|
|
807
|
+
return { cue, content: template.content };
|
|
808
|
+
}
|
|
809
|
+
function renderVTTCueString(cue, currentTime = 0) {
|
|
810
|
+
return renderVTTTokensString(tokenizeVTTCue(cue), currentTime);
|
|
811
|
+
}
|
|
812
|
+
function renderVTTTokensString(tokens, currentTime = 0) {
|
|
813
|
+
let attrs, result = "";
|
|
814
|
+
for (const token of tokens) {
|
|
815
|
+
if (token.type === "text") {
|
|
816
|
+
result += token.data;
|
|
817
|
+
} else {
|
|
818
|
+
const isTimestamp = token.type === "timestamp";
|
|
819
|
+
attrs = {};
|
|
820
|
+
attrs.class = token.class;
|
|
821
|
+
attrs.title = token.type === "v" && token.voice;
|
|
822
|
+
attrs.lang = token.type === "lang" && token.lang;
|
|
823
|
+
attrs["data-part"] = token.type === "v" && "voice";
|
|
824
|
+
if (isTimestamp) {
|
|
825
|
+
attrs["data-part"] = "timed";
|
|
826
|
+
attrs["data-time"] = token.time;
|
|
827
|
+
attrs["data-future"] = token.time > currentTime;
|
|
828
|
+
attrs["data-past"] = token.time < currentTime;
|
|
829
|
+
}
|
|
830
|
+
attrs.style = `${token.color ? `color: ${token.color};` : ""}${token.bgColor ? `background-color: ${token.bgColor};` : ""}`;
|
|
831
|
+
const attributes = Object.entries(attrs).filter((v) => v[1]).map((v) => `${v[0]}="${v[1] === true ? "" : v[1]}"`).join(" ");
|
|
832
|
+
result += `<${token.tagName}${attributes ? " " + attributes : ""}>${renderVTTTokensString(
|
|
833
|
+
token.children
|
|
834
|
+
)}</${token.tagName}>`;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
return result;
|
|
838
|
+
}
|
|
839
|
+
function updateTimedVTTCueNodes(root, currentTime) {
|
|
840
|
+
if (IS_SERVER)
|
|
841
|
+
return;
|
|
842
|
+
for (const el of root.querySelectorAll('[data-part="timed"]')) {
|
|
843
|
+
const time = Number(el.getAttribute("data-time"));
|
|
844
|
+
if (Number.isNaN(time))
|
|
845
|
+
continue;
|
|
846
|
+
if (time > currentTime)
|
|
847
|
+
setDataAttr(el, "future");
|
|
848
|
+
else
|
|
849
|
+
el.removeAttribute("data-future");
|
|
850
|
+
if (time < currentTime)
|
|
851
|
+
setDataAttr(el, "past");
|
|
852
|
+
else
|
|
853
|
+
el.removeAttribute("data-past");
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
function debounce(fn, delay) {
|
|
857
|
+
let timeout = null, args;
|
|
858
|
+
function run() {
|
|
859
|
+
clear();
|
|
860
|
+
fn(...args);
|
|
861
|
+
args = void 0;
|
|
862
|
+
}
|
|
863
|
+
function clear() {
|
|
864
|
+
clearTimeout(timeout);
|
|
865
|
+
timeout = null;
|
|
866
|
+
}
|
|
867
|
+
function debounce2() {
|
|
868
|
+
args = [].slice.call(arguments);
|
|
869
|
+
clear();
|
|
870
|
+
timeout = setTimeout(run, delay);
|
|
871
|
+
}
|
|
872
|
+
return debounce2;
|
|
873
|
+
}
|
|
874
|
+
var STARTING_BOX = /* @__PURE__ */ Symbol(0);
|
|
875
|
+
function createBox(box) {
|
|
876
|
+
if (box instanceof HTMLElement) {
|
|
877
|
+
return {
|
|
878
|
+
top: box.offsetTop,
|
|
879
|
+
width: box.clientWidth,
|
|
880
|
+
height: box.clientHeight,
|
|
881
|
+
left: box.offsetLeft,
|
|
882
|
+
right: box.offsetLeft + box.clientWidth,
|
|
883
|
+
bottom: box.offsetTop + box.clientHeight
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
return { ...box };
|
|
887
|
+
}
|
|
888
|
+
function moveBox(box, axis, delta) {
|
|
889
|
+
switch (axis) {
|
|
890
|
+
case "+x":
|
|
891
|
+
box.left += delta;
|
|
892
|
+
box.right += delta;
|
|
893
|
+
break;
|
|
894
|
+
case "-x":
|
|
895
|
+
box.left -= delta;
|
|
896
|
+
box.right -= delta;
|
|
897
|
+
break;
|
|
898
|
+
case "+y":
|
|
899
|
+
box.top += delta;
|
|
900
|
+
box.bottom += delta;
|
|
901
|
+
break;
|
|
902
|
+
case "-y":
|
|
903
|
+
box.top -= delta;
|
|
904
|
+
box.bottom -= delta;
|
|
905
|
+
break;
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
function isBoxCollision(a, b) {
|
|
909
|
+
return a.left <= b.right && a.right >= b.left && a.top <= b.bottom && a.bottom >= b.top;
|
|
910
|
+
}
|
|
911
|
+
function isAnyBoxCollision(box, boxes) {
|
|
912
|
+
for (let i = 0; i < boxes.length; i++)
|
|
913
|
+
if (isBoxCollision(box, boxes[i]))
|
|
914
|
+
return boxes[i];
|
|
915
|
+
return null;
|
|
916
|
+
}
|
|
917
|
+
function isWithinBox(container, box) {
|
|
918
|
+
return box.top >= 0 && box.bottom <= container.height && box.left >= 0 && box.right <= container.width;
|
|
919
|
+
}
|
|
920
|
+
function isBoxOutOfBounds(container, box, axis) {
|
|
921
|
+
switch (axis) {
|
|
922
|
+
case "+x":
|
|
923
|
+
return box.left < 0;
|
|
924
|
+
case "-x":
|
|
925
|
+
return box.right > container.width;
|
|
926
|
+
case "+y":
|
|
927
|
+
return box.top < 0;
|
|
928
|
+
case "-y":
|
|
929
|
+
return box.bottom > container.height;
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
function calcBoxIntersectPercentage(container, box) {
|
|
933
|
+
const x = Math.max(0, Math.min(container.width, box.right) - Math.max(0, box.left)), y = Math.max(0, Math.min(container.height, box.bottom) - Math.max(0, box.top)), intersectArea = x * y;
|
|
934
|
+
return intersectArea / (container.height * container.width);
|
|
935
|
+
}
|
|
936
|
+
function createCSSBox(container, box) {
|
|
937
|
+
return {
|
|
938
|
+
top: box.top / container.height,
|
|
939
|
+
left: box.left / container.width,
|
|
940
|
+
right: (container.width - box.right) / container.width,
|
|
941
|
+
bottom: (container.height - box.bottom) / container.height
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
function resolveRelativeBox(container, box) {
|
|
945
|
+
box.top = box.top * container.height;
|
|
946
|
+
box.left = box.left * container.width;
|
|
947
|
+
box.right = container.width - box.right * container.width;
|
|
948
|
+
box.bottom = container.height - box.bottom * container.height;
|
|
949
|
+
return box;
|
|
950
|
+
}
|
|
951
|
+
var BOX_SIDES = ["top", "left", "right", "bottom"];
|
|
952
|
+
function setBoxCSSVars(el, container, box, prefix) {
|
|
953
|
+
const cssBox = createCSSBox(container, box);
|
|
954
|
+
for (const side of BOX_SIDES) {
|
|
955
|
+
setCSSVar(el, `${prefix}-${side}`, cssBox[side] * 100 + "%");
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
function avoidBoxCollisions(container, box, boxes, axis) {
|
|
959
|
+
let percentage = 1, positionedBox, startBox = { ...box };
|
|
960
|
+
for (let i = 0; i < axis.length; i++) {
|
|
961
|
+
while (isBoxOutOfBounds(container, box, axis[i]) || isWithinBox(container, box) && isAnyBoxCollision(box, boxes)) {
|
|
962
|
+
moveBox(box, axis[i], 1);
|
|
963
|
+
}
|
|
964
|
+
if (isWithinBox(container, box))
|
|
965
|
+
return box;
|
|
966
|
+
const intersection = calcBoxIntersectPercentage(container, box);
|
|
967
|
+
if (percentage > intersection) {
|
|
968
|
+
positionedBox = { ...box };
|
|
969
|
+
percentage = intersection;
|
|
970
|
+
}
|
|
971
|
+
box = { ...startBox };
|
|
972
|
+
}
|
|
973
|
+
return positionedBox || startBox;
|
|
974
|
+
}
|
|
975
|
+
var POSITION_OVERRIDE = /* @__PURE__ */ Symbol(0);
|
|
976
|
+
function positionCue(container, cue, displayEl, boxes) {
|
|
977
|
+
let cueEl = displayEl.firstElementChild, line = computeCueLine(cue), displayBox, axis = [];
|
|
978
|
+
if (!displayEl[STARTING_BOX]) {
|
|
979
|
+
displayEl[STARTING_BOX] = createStartingBox(container, displayEl);
|
|
980
|
+
}
|
|
981
|
+
displayBox = resolveRelativeBox(container, { ...displayEl[STARTING_BOX] });
|
|
982
|
+
if (displayEl[POSITION_OVERRIDE]) {
|
|
983
|
+
axis = [displayEl[POSITION_OVERRIDE] === "top" ? "+y" : "-y", "+x", "-x"];
|
|
984
|
+
} else if (cue.snapToLines) {
|
|
985
|
+
let size;
|
|
986
|
+
switch (cue.vertical) {
|
|
987
|
+
case "":
|
|
988
|
+
axis = ["+y", "-y"];
|
|
989
|
+
size = "height";
|
|
990
|
+
break;
|
|
991
|
+
case "rl":
|
|
992
|
+
axis = ["+x", "-x"];
|
|
993
|
+
size = "width";
|
|
994
|
+
break;
|
|
995
|
+
case "lr":
|
|
996
|
+
axis = ["-x", "+x"];
|
|
997
|
+
size = "width";
|
|
998
|
+
break;
|
|
999
|
+
}
|
|
1000
|
+
let step = getLineHeight(cueEl), position = step * Math.round(line), maxPosition = container[size] + step, initialAxis = axis[0];
|
|
1001
|
+
if (Math.abs(position) > maxPosition) {
|
|
1002
|
+
position = position < 0 ? -1 : 1;
|
|
1003
|
+
position *= Math.ceil(maxPosition / step) * step;
|
|
1004
|
+
}
|
|
1005
|
+
if (line < 0) {
|
|
1006
|
+
position += cue.vertical === "" ? container.height : container.width;
|
|
1007
|
+
axis = axis.reverse();
|
|
1008
|
+
}
|
|
1009
|
+
moveBox(displayBox, initialAxis, position);
|
|
1010
|
+
} else {
|
|
1011
|
+
const isHorizontal = cue.vertical === "", posAxis = isHorizontal ? "+y" : "+x", size = isHorizontal ? displayBox.height : displayBox.width;
|
|
1012
|
+
moveBox(
|
|
1013
|
+
displayBox,
|
|
1014
|
+
posAxis,
|
|
1015
|
+
(isHorizontal ? container.height : container.width) * line / 100
|
|
1016
|
+
);
|
|
1017
|
+
moveBox(
|
|
1018
|
+
displayBox,
|
|
1019
|
+
posAxis,
|
|
1020
|
+
cue.lineAlign === "center" ? size / 2 : cue.lineAlign === "end" ? size : 0
|
|
1021
|
+
);
|
|
1022
|
+
axis = isHorizontal ? ["-y", "+y", "-x", "+x"] : ["-x", "+x", "-y", "+y"];
|
|
1023
|
+
}
|
|
1024
|
+
displayBox = avoidBoxCollisions(container, displayBox, boxes, axis);
|
|
1025
|
+
setBoxCSSVars(displayEl, container, displayBox, "cue");
|
|
1026
|
+
return displayBox;
|
|
1027
|
+
}
|
|
1028
|
+
function createStartingBox(container, cueEl) {
|
|
1029
|
+
const box = createBox(cueEl), pos = getStyledPositions(cueEl);
|
|
1030
|
+
cueEl[POSITION_OVERRIDE] = false;
|
|
1031
|
+
if (pos.top) {
|
|
1032
|
+
box.top = pos.top;
|
|
1033
|
+
box.bottom = pos.top + box.height;
|
|
1034
|
+
cueEl[POSITION_OVERRIDE] = "top";
|
|
1035
|
+
}
|
|
1036
|
+
if (pos.bottom) {
|
|
1037
|
+
const bottom = container.height - pos.bottom;
|
|
1038
|
+
box.top = bottom - box.height;
|
|
1039
|
+
box.bottom = bottom;
|
|
1040
|
+
cueEl[POSITION_OVERRIDE] = "bottom";
|
|
1041
|
+
}
|
|
1042
|
+
if (pos.left)
|
|
1043
|
+
box.left = pos.left;
|
|
1044
|
+
if (pos.right)
|
|
1045
|
+
box.right = container.width - pos.right;
|
|
1046
|
+
return createCSSBox(container, box);
|
|
1047
|
+
}
|
|
1048
|
+
function getStyledPositions(el) {
|
|
1049
|
+
const positions = {};
|
|
1050
|
+
for (const side of BOX_SIDES) {
|
|
1051
|
+
positions[side] = parseFloat(el.style.getPropertyValue(`--cue-${side}`));
|
|
1052
|
+
}
|
|
1053
|
+
return positions;
|
|
1054
|
+
}
|
|
1055
|
+
function computeCueLine(cue) {
|
|
1056
|
+
if (cue.line === "auto") {
|
|
1057
|
+
if (!cue.snapToLines) {
|
|
1058
|
+
return 100;
|
|
1059
|
+
} else {
|
|
1060
|
+
return -1;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
return cue.line;
|
|
1064
|
+
}
|
|
1065
|
+
function computeCuePosition(cue) {
|
|
1066
|
+
if (cue.position === "auto") {
|
|
1067
|
+
switch (cue.align) {
|
|
1068
|
+
case "start":
|
|
1069
|
+
case "left":
|
|
1070
|
+
return 0;
|
|
1071
|
+
case "right":
|
|
1072
|
+
case "end":
|
|
1073
|
+
return 100;
|
|
1074
|
+
default:
|
|
1075
|
+
return 50;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
return cue.position;
|
|
1079
|
+
}
|
|
1080
|
+
function computeCuePositionAlignment(cue, dir) {
|
|
1081
|
+
if (cue.positionAlign === "auto") {
|
|
1082
|
+
switch (cue.align) {
|
|
1083
|
+
case "start":
|
|
1084
|
+
return dir === "ltr" ? "line-left" : "line-right";
|
|
1085
|
+
case "end":
|
|
1086
|
+
return dir === "ltr" ? "line-right" : "line-left";
|
|
1087
|
+
case "center":
|
|
1088
|
+
return "center";
|
|
1089
|
+
default:
|
|
1090
|
+
return `line-${cue.align}`;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
return cue.positionAlign;
|
|
1094
|
+
}
|
|
1095
|
+
var REGION_AXIS = ["-y", "+y", "-x", "+x"];
|
|
1096
|
+
function positionRegion(container, region, regionEl, boxes) {
|
|
1097
|
+
let cues = Array.from(regionEl.querySelectorAll('[data-part="cue-display"]')), height = 0, limit = Math.max(0, cues.length - region.lines);
|
|
1098
|
+
for (let i = cues.length - 1; i >= limit; i--) {
|
|
1099
|
+
height += cues[i].offsetHeight;
|
|
1100
|
+
}
|
|
1101
|
+
setCSSVar(regionEl, "region-height", height + "px");
|
|
1102
|
+
if (!regionEl[STARTING_BOX]) {
|
|
1103
|
+
regionEl[STARTING_BOX] = createCSSBox(container, createBox(regionEl));
|
|
1104
|
+
}
|
|
1105
|
+
let box = { ...regionEl[STARTING_BOX] };
|
|
1106
|
+
box = resolveRelativeBox(container, box);
|
|
1107
|
+
box.width = regionEl.clientWidth;
|
|
1108
|
+
box.height = height;
|
|
1109
|
+
box.right = box.left + box.width;
|
|
1110
|
+
box.bottom = box.top + height;
|
|
1111
|
+
box = avoidBoxCollisions(container, box, boxes, REGION_AXIS);
|
|
1112
|
+
setBoxCSSVars(regionEl, container, box, "region");
|
|
1113
|
+
return box;
|
|
1114
|
+
}
|
|
1115
|
+
var CaptionsRenderer = class {
|
|
1116
|
+
overlay;
|
|
1117
|
+
z;
|
|
1118
|
+
A = 0;
|
|
1119
|
+
C = "ltr";
|
|
1120
|
+
B = [];
|
|
1121
|
+
D = false;
|
|
1122
|
+
E;
|
|
1123
|
+
j = /* @__PURE__ */ new Map();
|
|
1124
|
+
l = /* @__PURE__ */ new Map();
|
|
1125
|
+
/* Text direction. */
|
|
1126
|
+
get dir() {
|
|
1127
|
+
return this.C;
|
|
1128
|
+
}
|
|
1129
|
+
set dir(dir) {
|
|
1130
|
+
this.C = dir;
|
|
1131
|
+
setDataAttr(this.overlay, "dir", dir);
|
|
1132
|
+
}
|
|
1133
|
+
get currentTime() {
|
|
1134
|
+
return this.A;
|
|
1135
|
+
}
|
|
1136
|
+
set currentTime(time) {
|
|
1137
|
+
this.A = time;
|
|
1138
|
+
this.update();
|
|
1139
|
+
}
|
|
1140
|
+
constructor(overlay, init) {
|
|
1141
|
+
this.overlay = overlay;
|
|
1142
|
+
this.dir = init?.dir ?? "ltr";
|
|
1143
|
+
overlay.setAttribute("translate", "yes");
|
|
1144
|
+
overlay.setAttribute("aria-live", "off");
|
|
1145
|
+
overlay.setAttribute("aria-atomic", "true");
|
|
1146
|
+
setPartAttr(overlay, "captions");
|
|
1147
|
+
this.G();
|
|
1148
|
+
this.E = new ResizeObserver(this.I.bind(this));
|
|
1149
|
+
this.E.observe(overlay);
|
|
1150
|
+
}
|
|
1151
|
+
changeTrack({ regions, cues }) {
|
|
1152
|
+
this.reset();
|
|
1153
|
+
this.J(regions);
|
|
1154
|
+
for (const cue of cues)
|
|
1155
|
+
this.l.set(cue, null);
|
|
1156
|
+
this.update();
|
|
1157
|
+
}
|
|
1158
|
+
addCue(cue) {
|
|
1159
|
+
this.l.set(cue, null);
|
|
1160
|
+
this.update();
|
|
1161
|
+
}
|
|
1162
|
+
removeCue(cue) {
|
|
1163
|
+
this.l.delete(cue);
|
|
1164
|
+
this.update();
|
|
1165
|
+
}
|
|
1166
|
+
update(forceUpdate = false) {
|
|
1167
|
+
this.H(forceUpdate);
|
|
1168
|
+
}
|
|
1169
|
+
reset() {
|
|
1170
|
+
this.l.clear();
|
|
1171
|
+
this.j.clear();
|
|
1172
|
+
this.B = [];
|
|
1173
|
+
this.overlay.textContent = "";
|
|
1174
|
+
}
|
|
1175
|
+
destroy() {
|
|
1176
|
+
this.reset();
|
|
1177
|
+
this.E.disconnect();
|
|
1178
|
+
}
|
|
1179
|
+
I() {
|
|
1180
|
+
this.D = true;
|
|
1181
|
+
this.K();
|
|
1182
|
+
}
|
|
1183
|
+
K = debounce(() => {
|
|
1184
|
+
this.D = false;
|
|
1185
|
+
this.G();
|
|
1186
|
+
for (const el of this.j.values()) {
|
|
1187
|
+
el[STARTING_BOX] = null;
|
|
1188
|
+
}
|
|
1189
|
+
for (const el of this.l.values()) {
|
|
1190
|
+
if (el)
|
|
1191
|
+
el[STARTING_BOX] = null;
|
|
1192
|
+
}
|
|
1193
|
+
this.H(true);
|
|
1194
|
+
}, 50);
|
|
1195
|
+
G() {
|
|
1196
|
+
this.z = createBox(this.overlay);
|
|
1197
|
+
setCSSVar(this.overlay, "overlay-width", this.z.width + "px");
|
|
1198
|
+
setCSSVar(this.overlay, "overlay-height", this.z.height + "px");
|
|
1199
|
+
}
|
|
1200
|
+
H(forceUpdate = false) {
|
|
1201
|
+
if (!this.l.size || this.D)
|
|
1202
|
+
return;
|
|
1203
|
+
let cue, activeCues = [...this.l.keys()].filter((cue2) => this.A >= cue2.startTime && this.A <= cue2.endTime).sort(
|
|
1204
|
+
(cueA, cueB) => cueA.startTime !== cueB.startTime ? cueA.startTime - cueB.startTime : cueA.endTime - cueB.endTime
|
|
1205
|
+
), activeRegions = activeCues.map((cue2) => cue2.region);
|
|
1206
|
+
for (let i = 0; i < this.B.length; i++) {
|
|
1207
|
+
cue = this.B[i];
|
|
1208
|
+
if (activeCues[i] === cue)
|
|
1209
|
+
continue;
|
|
1210
|
+
if (cue.region && !activeRegions.includes(cue.region)) {
|
|
1211
|
+
const regionEl = this.j.get(cue.region.id);
|
|
1212
|
+
if (regionEl) {
|
|
1213
|
+
regionEl.removeAttribute("data-active");
|
|
1214
|
+
forceUpdate = true;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
const cueEl = this.l.get(cue);
|
|
1218
|
+
if (cueEl) {
|
|
1219
|
+
cueEl.remove();
|
|
1220
|
+
forceUpdate = true;
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
for (let i = 0; i < activeCues.length; i++) {
|
|
1224
|
+
cue = activeCues[i];
|
|
1225
|
+
let cueEl = this.l.get(cue);
|
|
1226
|
+
if (!cueEl)
|
|
1227
|
+
this.l.set(cue, cueEl = this.L(cue));
|
|
1228
|
+
const regionEl = this.F(cue) && this.j.get(cue.region.id);
|
|
1229
|
+
if (regionEl && !regionEl.hasAttribute("data-active")) {
|
|
1230
|
+
requestAnimationFrame(() => setDataAttr(regionEl, "active"));
|
|
1231
|
+
forceUpdate = true;
|
|
1232
|
+
}
|
|
1233
|
+
if (!cueEl.isConnected) {
|
|
1234
|
+
(regionEl || this.overlay).append(cueEl);
|
|
1235
|
+
forceUpdate = true;
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
if (forceUpdate) {
|
|
1239
|
+
const boxes = [], seen = /* @__PURE__ */ new Set();
|
|
1240
|
+
for (let i = activeCues.length - 1; i >= 0; i--) {
|
|
1241
|
+
cue = activeCues[i];
|
|
1242
|
+
if (seen.has(cue.region || cue))
|
|
1243
|
+
continue;
|
|
1244
|
+
const isRegion = this.F(cue), el = isRegion ? this.j.get(cue.region.id) : this.l.get(cue);
|
|
1245
|
+
if (isRegion) {
|
|
1246
|
+
boxes.push(positionRegion(this.z, cue.region, el, boxes));
|
|
1247
|
+
} else {
|
|
1248
|
+
boxes.push(positionCue(this.z, cue, el, boxes));
|
|
1249
|
+
}
|
|
1250
|
+
seen.add(isRegion ? cue.region : cue);
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
updateTimedVTTCueNodes(this.overlay, this.A);
|
|
1254
|
+
this.B = activeCues;
|
|
1255
|
+
}
|
|
1256
|
+
J(regions) {
|
|
1257
|
+
if (!regions)
|
|
1258
|
+
return;
|
|
1259
|
+
for (const region of regions) {
|
|
1260
|
+
const el = this.M(region);
|
|
1261
|
+
this.j.set(region.id, el);
|
|
1262
|
+
this.overlay.append(el);
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
M(region) {
|
|
1266
|
+
const el = document.createElement("div");
|
|
1267
|
+
setPartAttr(el, "region");
|
|
1268
|
+
setDataAttr(el, "id", region.id);
|
|
1269
|
+
setDataAttr(el, "scroll", region.scroll);
|
|
1270
|
+
setCSSVar(el, "region-width", region.width + "%");
|
|
1271
|
+
setCSSVar(el, "region-anchor-x", region.regionAnchorX);
|
|
1272
|
+
setCSSVar(el, "region-anchor-y", region.regionAnchorY);
|
|
1273
|
+
setCSSVar(el, "region-viewport-anchor-x", region.viewportAnchorX);
|
|
1274
|
+
setCSSVar(el, "region-viewport-anchor-y", region.viewportAnchorY);
|
|
1275
|
+
setCSSVar(el, "region-lines", region.lines);
|
|
1276
|
+
return el;
|
|
1277
|
+
}
|
|
1278
|
+
L(cue) {
|
|
1279
|
+
const display = document.createElement("div"), position = computeCuePosition(cue), positionAlignment = computeCuePositionAlignment(cue, this.C);
|
|
1280
|
+
setPartAttr(display, "cue-display");
|
|
1281
|
+
if (cue.vertical !== "")
|
|
1282
|
+
setDataAttr(display, "vertical");
|
|
1283
|
+
setCSSVar(display, "cue-text-align", cue.align);
|
|
1284
|
+
if (cue.style) {
|
|
1285
|
+
for (const prop of Object.keys(cue.style)) {
|
|
1286
|
+
display.style.setProperty(prop, cue.style[prop]);
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
if (!this.F(cue)) {
|
|
1290
|
+
setCSSVar(
|
|
1291
|
+
display,
|
|
1292
|
+
"cue-writing-mode",
|
|
1293
|
+
cue.vertical === "" ? "horizontal-tb" : cue.vertical === "lr" ? "vertical-lr" : "vertical-rl"
|
|
1294
|
+
);
|
|
1295
|
+
if (!cue.style?.["--cue-width"]) {
|
|
1296
|
+
let maxSize = position;
|
|
1297
|
+
if (positionAlignment === "line-left") {
|
|
1298
|
+
maxSize = 100 - position;
|
|
1299
|
+
} else if (positionAlignment === "center" && position <= 50) {
|
|
1300
|
+
maxSize = position * 2;
|
|
1301
|
+
} else if (positionAlignment === "center" && position > 50) {
|
|
1302
|
+
maxSize = (100 - position) * 2;
|
|
1303
|
+
}
|
|
1304
|
+
const size = cue.size < maxSize ? cue.size : maxSize;
|
|
1305
|
+
if (cue.vertical === "")
|
|
1306
|
+
setCSSVar(display, "cue-width", size + "%");
|
|
1307
|
+
else
|
|
1308
|
+
setCSSVar(display, "cue-height", size + "%");
|
|
1309
|
+
}
|
|
1310
|
+
} else {
|
|
1311
|
+
setCSSVar(
|
|
1312
|
+
display,
|
|
1313
|
+
"cue-offset",
|
|
1314
|
+
`${position - (positionAlignment === "line-right" ? 100 : positionAlignment === "center" ? 50 : 0)}%`
|
|
1315
|
+
);
|
|
1316
|
+
}
|
|
1317
|
+
const el = document.createElement("div");
|
|
1318
|
+
setPartAttr(el, "cue");
|
|
1319
|
+
if (cue.id)
|
|
1320
|
+
setDataAttr(el, "id", cue.id);
|
|
1321
|
+
el.innerHTML = renderVTTCueString(cue);
|
|
1322
|
+
display.append(el);
|
|
1323
|
+
return display;
|
|
1324
|
+
}
|
|
1325
|
+
F(cue) {
|
|
1326
|
+
return cue.region && cue.size === 100 && cue.vertical === "" && cue.line === "auto";
|
|
1327
|
+
}
|
|
1328
|
+
};
|
|
1329
|
+
|
|
1330
|
+
export {
|
|
1331
|
+
ParseErrorCode,
|
|
1332
|
+
ParseError,
|
|
1333
|
+
parseText,
|
|
1334
|
+
parseTextStream,
|
|
1335
|
+
parseResponse,
|
|
1336
|
+
parseByteStream,
|
|
1337
|
+
TextCue,
|
|
1338
|
+
VTTCue,
|
|
1339
|
+
VTTRegion,
|
|
1340
|
+
VTTBlock,
|
|
1341
|
+
VTTParser,
|
|
1342
|
+
parseVTTTimestamp,
|
|
1343
|
+
tokenizeVTTCue,
|
|
1344
|
+
createVTTCueTemplate,
|
|
1345
|
+
renderVTTCueString,
|
|
1346
|
+
renderVTTTokensString,
|
|
1347
|
+
updateTimedVTTCueNodes,
|
|
1348
|
+
CaptionsRenderer
|
|
1349
|
+
};
|
|
1350
|
+
//# sourceMappingURL=chunk-6LJZ4HRF.js.map
|