Skip to content

Commit

Permalink
refactor: use class private fields
Browse files Browse the repository at this point in the history
  • Loading branch information
weizhenye committed Jun 9, 2024
1 parent f3783b1 commit e017772
Show file tree
Hide file tree
Showing 36 changed files with 625 additions and 2,710 deletions.
23 changes: 19 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,33 @@
"env": {
"browser": true
},
"extends": "airbnb-base",
"parserOptions": {
"ecmaVersion": "latest"
},
"extends": [
"airbnb-base",
"plugin:unicorn/recommended"
],
"plugins": [
"unicorn"
],
"rules": {
"no-bitwise": 0,
"no-constructor-return": 0,
"no-mixed-operators": 0,
"no-plusplus": 0,
"no-underscore-dangle": 0,
"object-curly-newline": ["error", {
"ObjectExpression": { "multiline": true, "consistent": true },
"ObjectPattern": { "multiline": true, "consistent": true }
}],
"import/extensions": ["error", "ignorePackages"],
"import/no-extraneous-dependencies": 0,
"import/prefer-default-export": 0
"import/prefer-default-export": 0,
"unicorn/no-array-callback-reference": 0,
"unicorn/no-array-for-each": 0,
"unicorn/no-array-reduce": 0,
"unicorn/no-for-loop": 0,
"unicorn/no-null": 0,
"unicorn/prefer-string-replace-all": 0,
"unicorn/prevent-abbreviations": 0
}
}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '14.x'
node-version: '22.x'
- name: Install Dependencies
run: npm i
- name: Build
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
npm-debug.log*
node_modules
coverage
types
package-lock.json
47 changes: 17 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
[![File size](https://badgen.net/bundlephobia/minzip/assjs?icon=https://api.iconify.design/ant-design:file-zip-outline.svg?color=white)](https://bundlephobia.com/result?p=assjs)
[![jsDelivr](https://badgen.net/jsdelivr/hits/npm/assjs?icon=https://api.iconify.design/simple-icons:jsdelivr.svg?color=white)](https://www.jsdelivr.com/package/npm/assjs)

[![Browser compatibility](https://saucelabs.com/browser-matrix/assjs.svg)](https://saucelabs.com/u/assjs)

ASS.js uses [ass-compiler](https://github.com/weizhenye/ass-compiler) to parse ASS subtitle file format, and then renders subtitles on HTML5 video.

[Demo](https://ass.js.org/)
Expand All @@ -23,53 +21,42 @@ npm install assjs

CDN: [jsDelivr](https://www.jsdelivr.com/package/npm/assjs), [unpkg](https://unpkg.com/assjs/)

ASS.js only targets for latest modern browsers, if you need support IE 10 or 11, please use [v0.0.11](https://github.com/weizhenye/ASS/tree/v0.0.11).

## Usage

```html
<div id="container" style="position:relative;">
<video id="video" src="./example.mp4" style="position:absolute;"></video>
<div id="container" style="position: relative;">
<video
id="video"
src="./example.mp4"
style="position: absolute; width: 100%; height: 100%;"
></video>
<!-- ASS will be added here -->
</div>
<video id="video" src="example.mp4"></video>

<script src="dist/ass.min.js"></script>
<script>
fetch('/path/to/example.ass')
.then(res => res.text())
.then((text) => {
const ass = new ASS(
text,
document.getElementById('video'),
{ container: document.getElementById('container') },
);
});
</script>
```

```js
import ASS from 'assjs';

const content = await fetch('/path/to/example.ass').then((res) => res.text());
const ass = new ASS(content, document.querySelector('#video'), {
container: document.querySelector('#container'),
});
```

## API

#### Initialization

```js
const ass = new ASS(text, video, {
const ass = new ASS(content, video, {
// Subtitles will display in the container.
// The container will be created automatically if it's not provided.
container: document.getElementById('my-container'),

// see resampling API below
resampling: 'video_width',
});
```

#### Resize

If you change the size of video, you should call it.

```js
ass.resize();
```

#### Show

```js
Expand Down
41 changes: 41 additions & 0 deletions api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",

"mainEntryPointFilePath": "<projectFolder>/types/index.d.ts",
"bundledPackages": ["ass-compiler"],

"apiReport": {
"enabled": false
},

"docModel": {
"enabled": false
},

"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "<projectFolder>/dist/ass.d.ts"
},

"tsdocMetadata": {
"enabled": false
},

"messages": {
"compilerMessageReporting": {
"default": {
"logLevel": "warning"
}
},
"extractorMessageReporting": {
"default": {
"logLevel": "none"
}
},
"tsdocMessageReporting": {
"default": {
"logLevel": "none"
}
}
}
}
Loading

0 comments on commit e017772

Please sign in to comment.