@aim-packages/subtitle 0.0.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/dist/index.cjs.js +25 -0
- package/dist/index.d.ts +112 -0
- package/dist/index.es.js +185 -0
- package/package.json +24 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(e,t=2){return e.toString().padStart(t,"0")}function m(e){const t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%3600%60,o=Math.floor(r%1*1e3),l=g(t),a=g(n),p=g(Math.floor(r)),u=g(o,3);return`${l}:${a}:${p}.${u}`}function S(e){if(!e)return 0;const t=e.split(":");try{let n=t[2].split(",");return n.length===1&&(n=t[2].split(".")),parseFloat(t[0])*3600+parseFloat(t[1])*60+parseFloat(n[0])+parseFloat("0."+n[1])}catch{return 0}}const N=Object.freeze(Object.defineProperty({__proto__:null,convertToSeconds:S,formatTime:m,padNumber:g},Symbol.toStringTag,{value:"Module"}));/**
|
|
2
|
+
* @name ass2vtt
|
|
3
|
+
* @desc Converts ASS subtitle data into VTT format.
|
|
4
|
+
* @author YuQian2015 (https://github.com/YuQian2015)
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/function b(e){const t=new RegExp("Dialogue:\\s\\d,(\\d+:\\d\\d:\\d\\d.\\d\\d),(\\d+:\\d\\d:\\d\\d.\\d\\d),([^,]*),([^,]*),(?:[^,]*,){4}([\\s\\S]*)$","i");function n(r=""){return r.split(/[:.]/).map((o,l,a)=>{if(l===a.length-1){if(o.length===1)return"."+o+"00";if(o.length===2)return"."+o+"0"}else if(o.length===1)return(l===0?"0":":0")+o;return l===0?o:l===a.length-1?"."+o:":"+o}).join("")}return`WEBVTT
|
|
7
|
+
|
|
8
|
+
`+e.split(/\r?\n/).map(r=>{const o=r.match(t);return o?{start:n(o[1].trim()),end:n(o[2].trim()),text:o[5].replace(/{[\s\S]*?}/g,"").replace(/(\\N)/g,"<br />").trim().split(/\r?\n/).map(l=>l.trim()).join(`
|
|
9
|
+
`)}:null}).filter(r=>r).map((r,o)=>r?r.start+" --> "+r.end+`
|
|
10
|
+
`+r.text:"").filter(r=>r.trim()).join(`
|
|
11
|
+
|
|
12
|
+
`)}/**
|
|
13
|
+
* @name parseSRT
|
|
14
|
+
* @desc Parses and converts SRT subtitle data into JSON format. Adapted from the popcorn.js SRT parser plugin.
|
|
15
|
+
* @see http://github.com/NewtopiaDEV
|
|
16
|
+
* @see https://github.com/NewtopiaDev/parseSRT/blob/master/src/parse-srt.js
|
|
17
|
+
* @author Newtopia Dev (http://www.newtopia.com)
|
|
18
|
+
* @version 1.0.1
|
|
19
|
+
* @license MIT
|
|
20
|
+
*/function j(e,t){let n=t;for(;!e[n];)n++;return n}function _(e){let t=e.length-1;for(;t>=0&&!e[t];)t--;return t}function O(e="",t={propName:{}}){const n=[],r=e.split(/(?:\r\n|\r|\n)/gm).filter(s=>s.length>0),o=r.map((s,c)=>r[c+2]&&/\d{2}:\d{2}:\d{2}[,\.]\d{2,3}\s*-->\s*\d{2}:\d{2}:\d{2}[,\.]\d{2,3}/.test(r[c+2])?s+`\r
|
|
21
|
+
`:s).join(`
|
|
22
|
+
`).split(/(?:\r\n|\r|\n)/gm),l=_(o)+1;let a=0,p,u,i;for(let s=0;s<l;s++){for(i={},u=[],s=j(o,s),i.id=parseInt(o[s++],10),p=o[s++].split(/[\t ]*-->[\t ]*/),i[t.propName.start||"start"]=t.timeInText?p[0]:S(p[0]),a=p[1].indexOf(" "),a!==-1&&(p[1]=p[1].substr(0,a)),i[t.propName.end||"end"]=t.timeInText?p[1]:S(p[1]);s<l&&o[s];)u.push(o[s++]);const c=t.propName.text||"text";i[c]=u.join(t.keepMultiLine?`
|
|
23
|
+
`:" ").replace(/\{(\\[\w]+\(?([\w\d]+,?)+\)?)+\}/gi,""),i[c]=i[c].replace(/</g,"<").replace(/>/g,">"),i[c]=i[c].replace(/<(\/?(font|b|u|i|s))((\s+(\w|\w[\w\-]*\w)(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)(\/?)>/gi,"<$1$3$7>"),t.ignoreLineBreaks?i[c]=i[c].replace(/\\N/gi,""):i[c]=i[c].replace(/\\N/gi,"<br />"),n.push(i)}return n}function v(e,t){const n=/<\/?[^>]+(>|$)/g;return new Promise((r,o)=>{let l={};const a=[];let p=!1;const u=e.split(`
|
|
24
|
+
`);u.forEach((s,c)=>{s.replace(n,"")===" "||s.replace(n,"")===""||(s.indexOf("-->")!==-1?(p=!0,typeof l.start=="number"&&l.start>=0&&a.push(T(l)),l={start:y(s.split("-->")[0].trimRight().split(" ").pop()),end:y(s.split("-->")[1].trimLeft().split(" ").shift()),part:""}):p&&(a.length!==0?(a[a.length-1].part.replace(n,""),s.replace(n,""),l.part.length===0?l.part=s:l.part=`${l.part}
|
|
25
|
+
${s}`,c===u.length-1&&a.push(T(l))):(l.part=s,a.push(T(l)),l.part="")))}),l=[];const i=/(<([0-9:.>]+)>)/ig;a.forEach(s=>{const M=s.part.split().map(function(f){return f.replace(i,function(d){return d.split("").reduce(function(x,F){return`==${d.replace("<","").replace(">","")}`},0)})})[0].replace(n,"").split(" "),h=[];M.forEach(function(f){if(f.indexOf("==")>-1){const d=f.split("=="),x=d[0];if(d[1],x==""||x=="##")return;h.push({word:w(f.split("==")[0]),time:y(f.split("==")[1])})}else h.push({word:w(f),time:void 0})}),s.words=h,s.part=s.part.replace(n,"")}),r(a)})}function y(e){const t=e.split(":"),n=t[t.length-3]?+t[t.length-3]:0,r=t[t.length-2]?+t[t.length-2]:0,o=+t[t.length-1];return n*3600+r*60+o}function w(e){return e.replace(/[^0-9a-z'-]/gi,"").toLowerCase()}function T(e){if(e==null||typeof e!="object")return e;const t=e.constructor();for(const n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}async function L(e){return O(e,{keepMultiLine:!0,propName:{}}).filter(r=>r.text).map(r=>({st:m(r.start),et:m(r.end),text:r.text}))}async function $(e){return(await v(e)).filter(r=>r.part).map(r=>({st:m(r.start),et:m(r.end),text:r.part}))}async function E(e){return $(b(e))}const P=Object.freeze(Object.defineProperty({__proto__:null,assToAimSegments:E,srtToAimSegments:L,vttToAimSegments:$},Symbol.toStringTag,{value:"Module"}));exports.parser=P;exports.utils=N;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
// 通用字段
|
|
4
|
+
st: string; // 开始时间戳 (Start timestamp)
|
|
5
|
+
et: string; // 结束时间戳 (End timestamp)
|
|
6
|
+
text: string; // 文本内容 (Text content)
|
|
7
|
+
index?: number; // 字幕索引 (Subtitle index)
|
|
8
|
+
children?: Array<AimSegments>; // 子片段 (Child segments)
|
|
9
|
+
|
|
10
|
+
// 视频剪辑字段
|
|
11
|
+
delete?: boolean; // 是否被删除 (Whether it is deleted)
|
|
12
|
+
cut?: boolean; // 是否被裁剪 (Whether it is cut)
|
|
13
|
+
|
|
14
|
+
// tts字段
|
|
15
|
+
md5?: string; // tts使用的md5 (MD5 used by TTS)
|
|
16
|
+
|
|
17
|
+
// 翻译字段
|
|
18
|
+
tr?: 0 | 1 | 2; // 当前字幕的翻译状态 0 未翻译的原文 1 翻译中 2 翻译完成 (Translation status: 0 - untranslated, 1 - translating, 2 - translated)
|
|
19
|
+
|
|
20
|
+
// 说话人字段
|
|
21
|
+
spk?: string; // 说话人 (Speaker)
|
|
22
|
+
|
|
23
|
+
// 烧录字段
|
|
24
|
+
duration?: number; // 时长 (Duration)
|
|
25
|
+
range?: number; // 本句 st 到下一个片段的可用时长 (Available duration from this segment's start to the next segment)
|
|
26
|
+
|
|
27
|
+
// 重复检测字段
|
|
28
|
+
hit?: number; // 重复的次数,表示转写重复的片段 (Number of repetitions, indicating repeated transcription segments)
|
|
29
|
+
// 重复检测
|
|
30
|
+
rs?: Array<AimSegments>; // repeated segments 重复片段 (Repeated segments)
|
|
31
|
+
|
|
32
|
+
// 分句字段
|
|
33
|
+
em?: 0 | 1; // end mark 是否结束句 (End mark: whether it is the end of a sentence)
|
|
34
|
+
punc?: 0 | 1; // 是否存在标点分割符号 (Whether there are punctuation separators)
|
|
35
|
+
lng?: string; // 语言 (Language)
|
|
36
|
+
|
|
37
|
+
zf?: 0 | 1; // zero frame 0帧字幕 (Zero frame subtitle)
|
|
38
|
+
emt?: 0 | 1; // empty text 空白字幕 (Empty text subtitle)
|
|
39
|
+
ep?: 0 | 1; // end punctuation 结尾标点 (End punctuation)
|
|
40
|
+
space?: 0 | 1; // 存在多余空格 (Whether there are extra spaces)
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
declare interface AimSegments {
|
|
44
|
+
st: string;
|
|
45
|
+
et: string;
|
|
46
|
+
text: string;
|
|
47
|
+
index?: number;
|
|
48
|
+
children?: Array<AimSegments>;
|
|
49
|
+
delete?: boolean;
|
|
50
|
+
cut?: boolean;
|
|
51
|
+
md5?: string;
|
|
52
|
+
tr?: 0 | 1 | 2;
|
|
53
|
+
spk?: string;
|
|
54
|
+
duration?: number;
|
|
55
|
+
range?: number;
|
|
56
|
+
hit?: number;
|
|
57
|
+
rs?: Array<AimSegments>;
|
|
58
|
+
em?: 0 | 1;
|
|
59
|
+
punc?: 0 | 1;
|
|
60
|
+
lng?: string;
|
|
61
|
+
zf?: 0 | 1;
|
|
62
|
+
emt?: 0 | 1;
|
|
63
|
+
ep?: 0 | 1;
|
|
64
|
+
space?: 0 | 1;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
declare function assToAimSegments(text: string): Promise<AimSegments[]>;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Convert a HH:MM:SS,MMM or HH:MM:SS.MMM time format into seconds.
|
|
71
|
+
*
|
|
72
|
+
* @export
|
|
73
|
+
* @param {string} time - The time to be converted.
|
|
74
|
+
* @return {*} {number} - The time converted to seconds.
|
|
75
|
+
*/
|
|
76
|
+
declare function convertToSeconds(time?: string): number;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 将秒数转换为 xx:xx:xx.xxx 格式
|
|
80
|
+
*
|
|
81
|
+
* @export
|
|
82
|
+
* @param {number} seconds
|
|
83
|
+
* @return {*} {string}
|
|
84
|
+
*/
|
|
85
|
+
declare function formatTime(seconds: number): string;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 为数字前方自动补0到特定的位数,默认两位
|
|
89
|
+
*/
|
|
90
|
+
declare function padNumber(num: number, length?: number): string;
|
|
91
|
+
|
|
92
|
+
export declare namespace parser {
|
|
93
|
+
export {
|
|
94
|
+
srtToAimSegments,
|
|
95
|
+
vttToAimSegments,
|
|
96
|
+
assToAimSegments
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
declare function srtToAimSegments(text: string): Promise<AimSegments[]>;
|
|
101
|
+
|
|
102
|
+
export declare namespace utils {
|
|
103
|
+
export {
|
|
104
|
+
padNumber,
|
|
105
|
+
formatTime,
|
|
106
|
+
convertToSeconds
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
declare function vttToAimSegments(text: string): Promise<AimSegments[]>;
|
|
111
|
+
|
|
112
|
+
export { }
|
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
function g(e, t = 2) {
|
|
2
|
+
return e.toString().padStart(t, "0");
|
|
3
|
+
}
|
|
4
|
+
function m(e) {
|
|
5
|
+
const t = Math.floor(e / 3600), n = Math.floor(e % 3600 / 60), r = e % 3600 % 60, o = Math.floor(r % 1 * 1e3), l = g(t), a = g(n), p = g(Math.floor(r)), u = g(o, 3);
|
|
6
|
+
return `${l}:${a}:${p}.${u}`;
|
|
7
|
+
}
|
|
8
|
+
function y(e) {
|
|
9
|
+
if (!e)
|
|
10
|
+
return 0;
|
|
11
|
+
const t = e.split(":");
|
|
12
|
+
try {
|
|
13
|
+
let n = t[2].split(",");
|
|
14
|
+
return n.length === 1 && (n = t[2].split(".")), parseFloat(t[0]) * 3600 + parseFloat(t[1]) * 60 + parseFloat(n[0]) + parseFloat("0." + n[1]);
|
|
15
|
+
} catch {
|
|
16
|
+
return 0;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
20
|
+
__proto__: null,
|
|
21
|
+
convertToSeconds: y,
|
|
22
|
+
formatTime: m,
|
|
23
|
+
padNumber: g
|
|
24
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
25
|
+
/**
|
|
26
|
+
* @name ass2vtt
|
|
27
|
+
* @desc Converts ASS subtitle data into VTT format.
|
|
28
|
+
* @author YuQian2015 (https://github.com/YuQian2015)
|
|
29
|
+
* @license MIT
|
|
30
|
+
*/
|
|
31
|
+
function M(e) {
|
|
32
|
+
const t = new RegExp(
|
|
33
|
+
"Dialogue:\\s\\d,(\\d+:\\d\\d:\\d\\d.\\d\\d),(\\d+:\\d\\d:\\d\\d.\\d\\d),([^,]*),([^,]*),(?:[^,]*,){4}([\\s\\S]*)$",
|
|
34
|
+
"i"
|
|
35
|
+
);
|
|
36
|
+
function n(r = "") {
|
|
37
|
+
return r.split(/[:.]/).map((o, l, a) => {
|
|
38
|
+
if (l === a.length - 1) {
|
|
39
|
+
if (o.length === 1)
|
|
40
|
+
return "." + o + "00";
|
|
41
|
+
if (o.length === 2)
|
|
42
|
+
return "." + o + "0";
|
|
43
|
+
} else if (o.length === 1)
|
|
44
|
+
return (l === 0 ? "0" : ":0") + o;
|
|
45
|
+
return l === 0 ? o : l === a.length - 1 ? "." + o : ":" + o;
|
|
46
|
+
}).join("");
|
|
47
|
+
}
|
|
48
|
+
return `WEBVTT
|
|
49
|
+
|
|
50
|
+
` + e.split(/\r?\n/).map((r) => {
|
|
51
|
+
const o = r.match(t);
|
|
52
|
+
return o ? {
|
|
53
|
+
start: n(o[1].trim()),
|
|
54
|
+
end: n(o[2].trim()),
|
|
55
|
+
text: o[5].replace(/{[\s\S]*?}/g, "").replace(/(\\N)/g, "<br />").trim().split(/\r?\n/).map((l) => l.trim()).join(`
|
|
56
|
+
`)
|
|
57
|
+
} : null;
|
|
58
|
+
}).filter((r) => r).map((r, o) => r ? r.start + " --> " + r.end + `
|
|
59
|
+
` + r.text : "").filter((r) => r.trim()).join(`
|
|
60
|
+
|
|
61
|
+
`);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @name parseSRT
|
|
65
|
+
* @desc Parses and converts SRT subtitle data into JSON format. Adapted from the popcorn.js SRT parser plugin.
|
|
66
|
+
* @see http://github.com/NewtopiaDEV
|
|
67
|
+
* @see https://github.com/NewtopiaDev/parseSRT/blob/master/src/parse-srt.js
|
|
68
|
+
* @author Newtopia Dev (http://www.newtopia.com)
|
|
69
|
+
* @version 1.0.1
|
|
70
|
+
* @license MIT
|
|
71
|
+
*/
|
|
72
|
+
function j(e, t) {
|
|
73
|
+
let n = t;
|
|
74
|
+
for (; !e[n]; )
|
|
75
|
+
n++;
|
|
76
|
+
return n;
|
|
77
|
+
}
|
|
78
|
+
function _(e) {
|
|
79
|
+
let t = e.length - 1;
|
|
80
|
+
for (; t >= 0 && !e[t]; )
|
|
81
|
+
t--;
|
|
82
|
+
return t;
|
|
83
|
+
}
|
|
84
|
+
function b(e = "", t = { propName: {} }) {
|
|
85
|
+
const n = [], r = e.split(/(?:\r\n|\r|\n)/gm).filter((s) => s.length > 0), o = r.map((s, c) => r[c + 2] && /\d{2}:\d{2}:\d{2}[,\.]\d{2,3}\s*-->\s*\d{2}:\d{2}:\d{2}[,\.]\d{2,3}/.test(r[c + 2]) ? s + `\r
|
|
86
|
+
` : s).join(`
|
|
87
|
+
`).split(/(?:\r\n|\r|\n)/gm), l = _(o) + 1;
|
|
88
|
+
let a = 0, p, u, i;
|
|
89
|
+
for (let s = 0; s < l; s++) {
|
|
90
|
+
for (i = {}, u = [], s = j(o, s), i.id = parseInt(o[s++], 10), p = o[s++].split(/[\t ]*-->[\t ]*/), i[t.propName.start || "start"] = t.timeInText ? p[0] : y(p[0]), a = p[1].indexOf(" "), a !== -1 && (p[1] = p[1].substr(0, a)), i[t.propName.end || "end"] = t.timeInText ? p[1] : y(p[1]); s < l && o[s]; )
|
|
91
|
+
u.push(o[s++]);
|
|
92
|
+
const c = t.propName.text || "text";
|
|
93
|
+
i[c] = u.join(t.keepMultiLine ? `
|
|
94
|
+
` : " ").replace(/\{(\\[\w]+\(?([\w\d]+,?)+\)?)+\}/gi, ""), i[c] = i[c].replace(/</g, "<").replace(/>/g, ">"), i[c] = i[c].replace(/<(\/?(font|b|u|i|s))((\s+(\w|\w[\w\-]*\w)(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)(\/?)>/gi, "<$1$3$7>"), t.ignoreLineBreaks ? i[c] = i[c].replace(/\\N/gi, "") : i[c] = i[c].replace(/\\N/gi, "<br />"), n.push(i);
|
|
95
|
+
}
|
|
96
|
+
return n;
|
|
97
|
+
}
|
|
98
|
+
function L(e, t) {
|
|
99
|
+
const n = /<\/?[^>]+(>|$)/g;
|
|
100
|
+
return new Promise((r, o) => {
|
|
101
|
+
let l = {};
|
|
102
|
+
const a = [];
|
|
103
|
+
let p = !1;
|
|
104
|
+
const u = e.split(`
|
|
105
|
+
`);
|
|
106
|
+
u.forEach((s, c) => {
|
|
107
|
+
s.replace(n, "") === " " || s.replace(n, "") === "" || (s.indexOf("-->") !== -1 ? (p = !0, typeof l.start == "number" && l.start >= 0 && a.push(w(l)), l = {
|
|
108
|
+
start: T(s.split("-->")[0].trimRight().split(" ").pop()),
|
|
109
|
+
end: T(s.split("-->")[1].trimLeft().split(" ").shift()),
|
|
110
|
+
part: ""
|
|
111
|
+
}) : p && (a.length !== 0 ? (a[a.length - 1].part.replace(n, ""), s.replace(n, ""), l.part.length === 0 ? l.part = s : l.part = `${l.part}
|
|
112
|
+
${s}`, c === u.length - 1 && a.push(w(l))) : (l.part = s, a.push(w(l)), l.part = "")));
|
|
113
|
+
}), l = [];
|
|
114
|
+
const i = /(<([0-9:.>]+)>)/ig;
|
|
115
|
+
a.forEach((s) => {
|
|
116
|
+
const N = s.part.split().map(function(f) {
|
|
117
|
+
return f.replace(i, function(d) {
|
|
118
|
+
return d.split("").reduce(function(x, P) {
|
|
119
|
+
return `==${d.replace("<", "").replace(">", "")}`;
|
|
120
|
+
}, 0);
|
|
121
|
+
});
|
|
122
|
+
})[0].replace(n, "").split(" "), h = [];
|
|
123
|
+
N.forEach(function(f) {
|
|
124
|
+
if (f.indexOf("==") > -1) {
|
|
125
|
+
const d = f.split("=="), x = d[0];
|
|
126
|
+
if (d[1], x == "" || x == "##")
|
|
127
|
+
return;
|
|
128
|
+
h.push({
|
|
129
|
+
word: S(f.split("==")[0]),
|
|
130
|
+
time: T(f.split("==")[1])
|
|
131
|
+
});
|
|
132
|
+
} else
|
|
133
|
+
h.push({
|
|
134
|
+
word: S(f),
|
|
135
|
+
time: void 0
|
|
136
|
+
});
|
|
137
|
+
}), s.words = h, s.part = s.part.replace(n, "");
|
|
138
|
+
}), r(a);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function T(e) {
|
|
142
|
+
const t = e.split(":"), n = t[t.length - 3] ? +t[t.length - 3] : 0, r = t[t.length - 2] ? +t[t.length - 2] : 0, o = +t[t.length - 1];
|
|
143
|
+
return n * 3600 + r * 60 + o;
|
|
144
|
+
}
|
|
145
|
+
function S(e) {
|
|
146
|
+
return e.replace(/[^0-9a-z'-]/gi, "").toLowerCase();
|
|
147
|
+
}
|
|
148
|
+
function w(e) {
|
|
149
|
+
if (e == null || typeof e != "object")
|
|
150
|
+
return e;
|
|
151
|
+
const t = e.constructor();
|
|
152
|
+
for (const n in e)
|
|
153
|
+
e.hasOwnProperty(n) && (t[n] = e[n]);
|
|
154
|
+
return t;
|
|
155
|
+
}
|
|
156
|
+
async function O(e) {
|
|
157
|
+
return b(e, {
|
|
158
|
+
keepMultiLine: !0,
|
|
159
|
+
propName: {}
|
|
160
|
+
}).filter((r) => r.text).map((r) => ({
|
|
161
|
+
st: m(r.start),
|
|
162
|
+
et: m(r.end),
|
|
163
|
+
text: r.text
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
async function $(e) {
|
|
167
|
+
return (await L(e)).filter((r) => r.part).map((r) => ({
|
|
168
|
+
st: m(r.start),
|
|
169
|
+
et: m(r.end),
|
|
170
|
+
text: r.part
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
async function v(e) {
|
|
174
|
+
return $(M(e));
|
|
175
|
+
}
|
|
176
|
+
const F = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
177
|
+
__proto__: null,
|
|
178
|
+
assToAimSegments: v,
|
|
179
|
+
srtToAimSegments: O,
|
|
180
|
+
vttToAimSegments: $
|
|
181
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
182
|
+
export {
|
|
183
|
+
F as parser,
|
|
184
|
+
k as utils
|
|
185
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aim-packages/subtitle",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "dist/index.cjs.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "tsc && vite build",
|
|
9
|
+
"preview": "vite preview"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@types/lodash-es": "^4.17.12",
|
|
13
|
+
"@types/node": "^22.13.1",
|
|
14
|
+
"typescript": "~5.6.2",
|
|
15
|
+
"vite": "^6.0.5",
|
|
16
|
+
"vite-plugin-dts": "^4.5.0"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"lodash-es": "^4.17.21"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
}
|
|
24
|
+
}
|