Browse Source

add node-webvtt for parsing subtitles

pull/185/head
frost768 2 years ago
parent
commit
7bf1d05f16
  1. 1
      package.json
  2. 27
      src/types/node_webtt.d.ts
  3. 1
      tsconfig.json
  4. 8498
      yarn.lock

1
package.json

@ -16,6 +16,7 @@
"json5": "^2.2.0", "json5": "^2.2.0",
"lodash.throttle": "^4.1.1", "lodash.throttle": "^4.1.1",
"nanoid": "^4.0.0", "nanoid": "^4.0.0",
"node-webvtt": "^1.9.4",
"ofetch": "^1.0.0", "ofetch": "^1.0.0",
"pako": "^2.1.0", "pako": "^2.1.0",
"react": "^17.0.2", "react": "^17.0.2",

27
src/types/node_webtt.d.ts vendored

@ -0,0 +1,27 @@
declare module "node-webvtt" {
interface Cue {
identifier: string;
start: number;
end: number;
text: string;
styles: string;
}
interface Options {
meta?: boolean;
strict?: boolean;
}
type ParserError = Error;
interface ParseResult {
valid: boolean;
strict: boolean;
cues: Cue[];
errors: ParserError[];
meta?: Map<string, string>;
}
interface Segment {
duration: number;
cues: Cue[];
}
function parse(text: string, options: Options): ParseResult;
function segment(input: string, segmentLength?: number): Segment[];
}

1
tsconfig.json

@ -16,6 +16,7 @@
"noEmit": true, "noEmit": true,
"jsx": "react-jsx", "jsx": "react-jsx",
"baseUrl": "./src", "baseUrl": "./src",
"typeRoots": ["./src/types"],
"paths": { "paths": {
"@/*": ["./*"] "@/*": ["./*"]
}, },

8498
yarn.lock

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save