Skip to content

TypeScript Migration Project #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
language: node_js
sudo: required
dist: trusty
addons:
chrome: stable
apt:
packages:
- libnss3
node_js:
- "12.2.0"
before_install:
Expand Down
149 changes: 16 additions & 133 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,102 +15,26 @@ module.exports = (grunt) ->
'src/css/fontalias.css'
]

SRC_CORE = [
'src/Array.js'
'src/CommentManager.js'
'compiled_src/core/Comment.js'
'compiled_src/core/CommentFactory.js'
'compiled_src/core/CommentSpaceAllocator.js'
'compiled_src/core/CommentUtils.js'
'compiled_src/core/css-renderer/CssComment.js'
]

SRC_MODULES =
'filter': ['src/filter/CommentFilter.js']
'provider': ['src/CommentProvider.js', 'src/Promises.js']
'format-bilibili': ['src/parsers/BilibiliFormat.js']
'format-acfun': ['src/parsers/AcfunFormat.js']
'format-common': ['src/parsers/CommonDanmakuFormat.js']

# Typescript targets
SRC_TS_CORE = [
'src/core/Comment.ts'
'src/core/CommentFactory.ts'
'src/core/CommentSpaceAllocator.ts'
'src/core/CommentUtils.ts'
'src/core/css-renderer/CssComment.ts'
]

SRC_TS_SCRIPTING_KAGEROU =
'Display': ['src/scripting/api/Display/Display.ts']
'Runtime': ['src/scripting/api/Runtime/Runtime.ts']
'Player': ['src/scripting/api/Player/Player.ts']
'Utils': ['src/scripting/api/Utils/Utils.ts']
'Tween': ['src/scripting/api/Tween/Tween.ts']

# ==== Below this point is logic to generate compile configurations ====
# You probably do not need to edit anything below here

# Dynamically generate the target for all
CMP_ALL = []
CMP_ALL = CMP_ALL.concat SRC_CORE
for name, source of SRC_MODULES
CMP_ALL = CMP_ALL.concat source

# Generate the core ts targets
CMP_CORE_TS =
'core':
src: SRC_TS_CORE
outDir: 'compiled_src/'
CMP_CORE_NAME = ['ts:core']

# Dynamically generate the kagerou ts targets
CMP_KAGEROU_TS = {}
CMP_KAGEROU_NAME = []
for target, src of SRC_TS_SCRIPTING_KAGEROU
CMP_KAGEROU_NAME.push ('ts:kagerou_engine_' + target.toLowerCase())
CMP_KAGEROU_TS['kagerou_engine_' + target.toLowerCase()] =
src: src
out: 'dist/scripting/api/' + target + '.js'

# Append Typescript Tasks
ts_config =
options:
target: 'es5'
sourceMap: false
rootDir: 'src/'
for key,value of CMP_CORE_TS
ts_config[key] = value
for key,value of CMP_KAGEROU_TS
ts_config[key] = value

grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-jasmine'

grunt.initConfig(
clean:
scripting: ['dist/scripting']
dist: ['dist']

# Concat CSS and JS files
# dist_core : builds CCL with just the comment system
# dist_all : builds CCL with everything
# scripting_host : builds just the scripting host
concat:
dist_core:
files:
'dist/css/style.css': CSS
'dist/CommentCoreLibrary.js': SRC_CORE
dist_all:
files:
'dist/css/style.css': CSS
'dist/CommentCoreLibrary.js': CMP_ALL
scripting_host:
files:
'dist/scripting/Host.js': ['src/scripting/Host.js','src/scripting/Unpacker.js']
temp: [
'compiled_spec/',
'compiled_src/'
]
dist: [
'dist'
]

# Compile TypeScript
ts: ts_config
ts: {
default: {
tsconfig: './tsconfig.json'
}
}

# Copy
copy:
Expand Down Expand Up @@ -170,42 +94,6 @@ module.exports = (grunt) ->
all:
src: ['src/*.js']

# Jasmine test
jasmine:
coverage:
src: ['src/**/*.js', 'compiled_src/**/*.js']
options:
specs: ['compiled_spec/*_spec.js']
helpers: ['compiled_spec/*_helper.js']
vendor: [
'node_modules/jquery/dist/jquery.js'
'node_modules/sinon/pkg/sinon.js'
'node_modules/jasmine-sinon/lib/jasmine-sinon.js'
]
# Don't use this, it doesnt work anymore
#template: require('grunt-template-jasmine-istanbul')
#templateOptions:
# report: 'coverage'
# coverage: 'coverage/coverage.json'
ci:
src: ['dist/CommentCoreLibrary.js']
options:
specs: ['compiled_spec/*_spec.js']
helpers: ['compiled_spec/*_helper.js']
vendor: [
'node_modules/jquery/dist/jquery.js'
'node_modules/sinon/pkg/sinon.js'
'node_modules/jasmine-sinon/lib/jasmine-sinon.js'
]
# Don't use this, it doesnt work anymore
#template: require('grunt-template-jasmine-istanbul')
#templateOptions:
# report:
# type: 'lcovonly'
# options:
# dir: 'coverage'
# coverage: 'coverage/coverage.json'

coffee:
glob_to_multiple:
expand: true,
Expand All @@ -215,16 +103,11 @@ module.exports = (grunt) ->
ext: '.js'
)

# Register special compiles
grunt.registerTask 'compile:ts-core', CMP_CORE_NAME
grunt.registerTask 'compile:ts-kagerou', CMP_KAGEROU_NAME

# Register our tasks
grunt.registerTask 'build', ['compile:ts-core', 'concat:dist_all', 'autoprefixer', 'cssmin', 'uglify:all']
grunt.registerTask 'build:core', ['compile:ts-core', 'concat:dist_core', 'autoprefixer', 'cssmin', 'uglify:core']
grunt.registerTask 'build:scripting', ['clean:scripting','concat:scripting_host', 'compile:ts-kagerou', 'copy:scripting_sandbox']
grunt.registerTask 'build', ['clean', 'ts']

grunt.registerTask 'ci', ['build', 'coffee', 'jasmine:ci']
grunt.registerTask 'test', ['coffee', 'jasmine:coverage']
grunt.registerTask 'test', ['build'] # And do tests
grunt.registerTask 'ci', ['build'] # Do CI stuff

grunt.registerTask 'default', ['clean', 'build', 'build:scripting']
grunt.registerTask 'default', ['build', 'watch']
20 changes: 10 additions & 10 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Copyright (c) 2017 Jim Chen
Copyright (c) 2019 Jim Chen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,22 @@ Developers willing to incorporate similar comment streaming functionalities
inside their own projects (whether web based or not) are encouraged to learn
from and extend from the CommentCoreLibrary.

## Testing
## Demo
We have a live demo [here](http://jabbany.github.io/CommentCoreLibrary/demo).
Feel free to [open tickets](CONTRIBUTING.md) if this demo test has bugs.

## License
The CommentCoreLibrary is licensed under the permissive MIT License. If you wish
to use this in any project, you can simply include the following line:

CommentCoreLibrary (//github.com/jabbany/CommentCoreLibrary) - Licensed under the MIT license
CommentCoreLibrary is licensed under the permissive [MIT License](LICENSE).

## Installing
With [bower](http://bower.io/):
`bower install comment-core-library`
With [yarn](https://yarnpkg.com/):
`yarn add comment-core-library`

With [npm](https://www.npmjs.org/):
`npm install comment-core-library`

For Rails, installing with [rails-assets](https://rails-assets.org/) is recommended
For Rails, installing with [rails-assets](https://rails-assets.org/) is
recommended

In Gemfile:
```ruby
Expand All @@ -43,6 +41,13 @@ source 'https://rails-assets.org'
gem 'rails-assets-comment-core-library'
```

### Front-end Framework Integration
To use this library with [React](https://reactjs.org/), please use the
`react-ccl` package instead.

To use this library with [Vue](https://vuejs.org/), please use the `vue-ccl`
package instead.

## Examples and Documentation
- [Documentation](docs/) can be found inside the `docs/` folder.
- Experimental modules are in `experimental/`.
Expand Down
11 changes: 4 additions & 7 deletions README.zh_CN.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# 弹幕核心通用构件 CommentCoreLibrary
[![NPM version](https://badge.fury.io/js/comment-core-library.svg)](http://badge.fury.io/js/comment-core-library)
[![Bower version](https://badge.fury.io/bo/comment-core-library.svg)](http://badge.fury.io/bo/comment-core-library)
[![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/)
[![License](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
[![Build Status: Linux](https://travis-ci.org/jabbany/CommentCoreLibrary.svg?branch=master)](https://travis-ci.org/jabbany/CommentCoreLibrary)
[![Coverage Status](https://img.shields.io/coveralls/jabbany/CommentCoreLibrary.svg)](https://coveralls.io/r/jabbany/CommentCoreLibrary?branch=master)
Expand All @@ -17,14 +16,11 @@
高级弹幕效果 (5) 基础格式解析 (6) 代码弹幕支持。

## 测试
你可以在[这里](http://jabbany.github.io/CommentCoreLibrary/demo) 访问到测试页面
你可以在[这里](http://jabbany.github.io/CommentCoreLibrary/demo) 访问到在线测试页面
我们欢迎各种[BUG报告](CONTRIBUTING.md)。

## 许可
本项目采取非常宽松的MIT许可。该许可允许你把本项目运用在任何开源或是闭源的,非营利或商业性的项目中。
您只需在使用到的地方添加下面一行注释:

CommentCoreLibrary (//github.com/jabbany/CommentCoreLibrary) - Licensed under the MIT license
本项目采取非常宽松的[MIT许可](LICENSE)。

## 使用
- 有关本项目的[文档](docs/) 可以在 `docs/` 文件夹里面找到。
Expand All @@ -33,7 +29,8 @@

## 做出贡献
非常欢迎提交问题报告和意见建议,同时你也可以在GitHub上Fork本工程,并发送Pull请求来提交
你对项目的贡献。我们非常欢迎二次开发哟!有关具体介绍请参考 [CONTRIBUTING](CONTRIBUTING.md)。
你对项目的贡献。我们非常欢迎二次开发哟!有关具体介绍请参考
[CONTRIBUTING](CONTRIBUTING.md)。

我们欢迎对项目任何细节处的针对性研发,尤其比如:解析功能、高级弹幕/代码弹幕和CSS优化等。
如果希望研发播放器的构造和功能,请参考姊妹项目 ABPlayerHTML5。
16 changes: 0 additions & 16 deletions bower.json

This file was deleted.

Loading