Skip to content

Commit

Permalink
Merge 6874e37 into 684d54c
Browse files Browse the repository at this point in the history
  • Loading branch information
jabbany authored Oct 22, 2016
2 parents 684d54c + 6874e37 commit b1c9ab8
Show file tree
Hide file tree
Showing 81 changed files with 4,793 additions and 3,013 deletions.
8 changes: 4 additions & 4 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ CommentCoreLibrary在库外提供了很多可扩展的空间,你可以相对

即可按照默认模板编译。除此之外,你还可以改变编译目标:

- build : 只编译项目,不会clean掉build文件夹下的产物
- build-core : 只编译弹幕核心,不包括Acfun和Bilibili的解析器。这个更加适用各种二次开发不需要
已有的弹幕格式的
- build-scripting : 只编译代码弹幕支持
- `build` : 只编译项目,不会clean掉build文件夹下的产物
- `build:core_only` : 只编译弹幕核心,不包括CommentProvider和parsers里面的解析器。
这个更加适用不需要已有的弹幕格式的各种二次开发
- `build:scripting` : 只编译代码弹幕支持

默认模式会自动看管 `src` 源码文件夹,并且在产生变化的时候自动生成新版。

Expand Down
147 changes: 77 additions & 70 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,58 +5,67 @@ module.exports = (grunt) ->
grunt.file.readJSON('package.json')

# !! Compile configurations
License = '/*!Copyright(c) CommentCoreLibrary (//github.com/jabbany/CommentCoreLibrary) - Licensed under the MIT License */'
FilterType = "Simple" # "Comment" || "Simple"
LICENSE = '/*!Copyright(c) CommentCoreLibrary (//github.com/jabbany/CommentCoreLibrary) - Licensed under the MIT License */'
# !! End of config area

CSS = [
'src/css/base.css',
'src/css/fontalias.css'
]

SRC_CORE_CMP = [
'Comment'
'CommentSpaceAllocator'
]

SRC_CORE = [
'src/Array.js'
'src/core/CommentSpaceAllocator.js'
'src/core/Comment.js'
'src/filter/' + FilterType + 'Filter.js'
'src/CommentCoreLibrary.js'
'src/CommentManager.js'
]

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

# Typescript targets
SRC_TS_CORE = [
'Comment'
'CommentSpaceAllocator'
]

SRC_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'
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'

SRC_PARSER = [
'src/parsers/AcfunFormat.js'
'src/parsers/BilibiliFormat.js'
]
# ==== 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

# !! Below are compile settings
# Dynamically generate the core ts targets
CMP_CORE_TS = { }
CMP_CORE_NAME = [ ]
for target in SRC_CORE_CMP
CMP_CORE_NAME.push ("ts:" + target)
CMP_CORE_TS[target] =
CMP_CORE_TS = {}
CMP_CORE_NAME = []
for target in SRC_TS_CORE
CMP_CORE_NAME.push ("ts:core_" + target)
CMP_CORE_TS["core_" + target] =
src: ["src/core/" + target + ".ts"]
out: "src/core/" + target + ".js"

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

# Append Typescript Tasks
ts_config =
Expand All @@ -67,32 +76,30 @@ module.exports = (grunt) ->
for key,value of CMP_KAGEROU_TS
ts_config[key] = value

# Core concatenated with libraries
# Actual concat ordering does not/should not matter
SRC_CORELIB = SRC_CORE.concat(SRC_PARSER)
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-jasmine'

grunt.loadNpmTasks('grunt-contrib-coffee')
grunt.loadNpmTasks('grunt-contrib-jasmine')
grunt.initConfig(
clean:
scripting: ['build/scripting']
build: ['build']
scripting: ['dist/scripting']
dist: ['dist']

# Concat CSS and JS files
# core_only : builds CCL without parsers
# all : builds CCL with everything
# dist_core : builds CCL with just the comment system
# dist_all : builds CCL with everything
# scripting_host : builds just the scripting host
concat:
scripting_host:
dist_core:
files:
'build/scripting/Host.js': ['src/scripting/Host.js','src/scripting/Unpacker.js']
core_only:
'dist/css/style.css': CSS
'dist/CommentCoreLibrary.js': SRC_CORE
dist_all:
files:
'build/style.css': CSS
'build/CommentCore.js': SRC_CORE
all:
'dist/css/style.css': CSS
'dist/CommentCoreLibrary.js': CMP_ALL
scripting_host:
files:
'build/style.css': CSS
'build/CommentCoreLibrary.js': SRC_CORELIB
'dist/scripting/Host.js': ['src/scripting/Host.js','src/scripting/Unpacker.js']

# Compile TypeScript
ts: ts_config
Expand All @@ -101,43 +108,42 @@ module.exports = (grunt) ->
copy:
scripting_sandbox:
files:[
{expand: true, cwd:'src/scripting/api/', src: ['*.js'], dest:'build/scripting/api/'},
{expand: true, cwd:'src/scripting/', src: ['OOAPI.js','Worker.js'], dest:'build/scripting/'}
{expand: true, cwd:'src/scripting/api/', src: ['*.js'], dest:'dist/scripting/api/'},
{expand: true, cwd:'src/scripting/', src: ['OOAPI.js','Worker.js'], dest:'dist/scripting/'}
]

# Auto-prefix CSS properties using Can I Use?
autoprefixer:
options:
browsers: ['last 3 versions', 'bb 10', 'android 3']

no_dest:
# File to output
src: 'build/style.css'
src: 'dist/css/style.css'

# Minify CSS
cssmin:
minify:
src: ['build/style.css']
dest: 'build/style.min.css'
src: ['dist/css/style.css']
dest: 'dist/css/style.min.css'

# Minify JS
uglify:
options: banner: License
core_only:
files:
'build/CommentCore.min.js': SRC_CORE
options:
banner: LICENSE
all:
files:
'build/CommentCoreLibrary.min.js': SRC_CORELIB
'dist/CommentCoreLibrary.min.js': ['dist/CommentCoreLibrary.js']

# Watch files for changes
#
watch:
all:
files: ['src/**/*', '!node_modules']

# Run concat, autoprefixer, cssmin and uglify
scripting:
files: ['src/scripting/**/*', '!node_modules']
tasks: ['build-scripting']
core:
files: ['src/**/*', '!node_modules', '!src/scripting/**/*']
tasks: ['build']

# JSHint
jshint:
options:
curly: true,
Expand All @@ -157,7 +163,6 @@ module.exports = (grunt) ->
src: ['src/*.js']

# Jasmine test

jasmine:
coverage:
src: 'src/**/*.js'
Expand All @@ -169,13 +174,14 @@ module.exports = (grunt) ->
'node_modules/jasmine-jquery/lib/jasmine-jquery.js'
'node_modules/sinon/pkg/sinon.js'
'node_modules/jasmine-sinon/lib/jasmine-sinon.js'
'node_modules/promise-polyfill/promise.js' # TODO: remove when phantomjs supports promises
]
template: require('grunt-template-jasmine-istanbul')
templateOptions:
report: 'coverage'
coverage: 'coverage/coverage.json'
ci:
src: 'build/CommentCoreLibrary.js'
src: 'dist/CommentCoreLibrary.js'
options:
specs: 'compiled_spec/*spec.js'
helpers: 'spec/*helper.js'
Expand All @@ -184,6 +190,7 @@ module.exports = (grunt) ->
'node_modules/jasmine-jquery/lib/jasmine-jquery.js'
'node_modules/sinon/pkg/sinon.js'
'node_modules/jasmine-sinon/lib/jasmine-sinon.js'
'node_modules/promise-polyfill/promise.js' # TODO: remove when phantomjs supports promises
]
template: require('grunt-template-jasmine-istanbul')
templateOptions:
Expand All @@ -202,14 +209,14 @@ module.exports = (grunt) ->
)

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

# Register our tasks
grunt.registerTask 'test', ['coffee', 'jasmine:coverage']
grunt.registerTask 'build-scripting', ['clean:scripting','concat:scripting_host', 'compile-ts-kagerou', 'copy:scripting_sandbox']
grunt.registerTask 'build-core', ['compile-ts-core', 'concat:core_only', 'autoprefixer', 'cssmin', 'uglify:core_only']
grunt.registerTask 'build', ['compile-ts-core', 'concat:all', 'autoprefixer', 'cssmin', 'uglify:all']
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 'ci', ['build', 'coffee', 'jasmine:ci']
grunt.registerTask 'default', ['clean', 'build', 'build-scripting', 'watch']

grunt.registerTask 'default', ['clean', 'build', 'build:scripting', 'watch']
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ gem 'rails-assets-comment-core-library'

## Examples and Documentation
- [Documentation](docs/) can be found inside the `docs/` folder.
- Some sample extension modules may be found in `src/extend/`.
- Experimental modules are in `experimental/`.
- You may test using test data found in `test/`.

Expand Down Expand Up @@ -77,7 +76,6 @@ implementation of a video player with CommentCoreLibrary.

## 使用
- 有关本项目的[文档](docs/) 可以在 `docs/` 文件夹里面找到。
- 一些功能性扩展模块会出现在 `src/extend/` 中。
- 一些实验性模块在 `experimental/` 里。
- 测试数据在 `test/` 里。

Expand Down
12 changes: 8 additions & 4 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"name": "comment-core-library",
"version": "0.9.3",
"main": ["build/CommentCoreLibrary.js","build/style.css"],
"ignore": [
"name": "comment-core-library",
"description": "Javascript library for organizing and displaying danmaku comments",
"license": "MIT",
"authors": [
"Jim Chen <knh.jabbany@gmail.com>"
],
"main": ["dist/CommentCoreLibrary.js","dist/style.css"],
"ignore": [
"test/**/*",
"experimental/**/*",
"demo/**/*"
Expand Down
Loading

0 comments on commit b1c9ab8

Please sign in to comment.