├── .gitignore ├── .npmignore ├── LICENSE.md ├── README.md ├── fis-kernel.js ├── lib ├── cache.js ├── compile.js ├── config.js ├── file.js ├── log.js ├── project.js ├── release.js ├── uri.js └── util.js ├── package.json └── test └── ut ├── cache.js ├── cache └── src │ ├── c1.js │ └── c2.css ├── compile.js ├── compile ├── css │ ├── click.ogg │ ├── expect.css │ ├── expect_require.css │ ├── inline.css │ ├── main.css │ ├── require.css │ └── test.bmp ├── html │ ├── a.png │ ├── expect.html │ ├── expect_query.html │ ├── expect_require.html │ ├── inline.html │ ├── inline2.html │ ├── main.html │ ├── require.html │ └── require.tpl └── js │ ├── expect_require.js │ ├── inline.js │ ├── main.js │ ├── require.js │ └── uri.js ├── config.js ├── file.js ├── file ├── css │ ├── test.css │ └── test.js ├── embed │ ├── embed.gif │ └── embed.txt ├── ext │ ├── lint │ │ └── lint.js │ ├── modular │ │ ├── html.html │ │ ├── js.js │ │ └── js.less │ ├── optimizer │ │ └── optimizer.js │ └── parser │ │ └── js.js ├── fis-config-test │ └── index.js ├── fis-lint-lint │ └── index.js ├── fis-modular-modular │ └── index.js ├── fis-optimizer-optimizer │ └── index.js ├── fis-parser-options │ └── index.js ├── fis-parser-parser │ └── index.js └── fis-test-test │ └── index.js ├── fis-tmp └── src │ ├── c1.js │ ├── c2.css │ ├── d2.css │ ├── dep1.js │ └── dep3.js ├── img ├── w3c_home.bmp ├── w3c_home.gif ├── w3c_home.jpg └── w3c_home.png ├── release.js ├── release ├── expect1 │ ├── __p0__.js │ ├── aa.json │ ├── bb.json │ └── photo-map.json ├── standard.json ├── test1 │ ├── fis-conf.js │ ├── index.css │ ├── index.js │ ├── index.tpl │ ├── npm.png │ ├── plugin │ │ ├── FISResource.class.php │ │ ├── compiler.body.php │ │ ├── compiler.head.php │ │ ├── compiler.html.php │ │ ├── compiler.require.php │ │ ├── compiler.script.php │ │ └── compiler.widget.php │ ├── sea.js │ └── widget │ │ ├── comp │ │ └── comp.js │ │ └── list │ │ ├── list.css │ │ ├── list.js │ │ └── list.tpl ├── test2 │ ├── fis-conf.js │ ├── index.css │ ├── index.js │ ├── index.tpl │ ├── npm.png │ ├── plugin │ │ ├── FISResource.class.php │ │ ├── compiler.body.php │ │ ├── compiler.head.php │ │ ├── compiler.html.php │ │ ├── compiler.require.php │ │ ├── compiler.script.php │ │ └── compiler.widget.php │ ├── sea.js │ ├── ui │ │ ├── a │ │ │ └── a.js │ │ └── b │ │ │ └── b.js │ └── widget │ │ ├── c │ │ └── c.js │ │ ├── comp │ │ └── comp.js │ │ ├── d │ │ └── d.js │ │ ├── e │ │ └── e.js │ │ └── list │ │ ├── list.css │ │ ├── list.js │ │ └── list.tpl ├── test3 │ ├── fis-conf.js │ ├── index.css │ ├── index.js │ ├── index.tpl │ ├── npm.png │ ├── plugin │ │ ├── FISResource.class.php │ │ ├── compiler.body.php │ │ ├── compiler.head.php │ │ ├── compiler.html.php │ │ ├── compiler.require.php │ │ ├── compiler.script.php │ │ └── compiler.widget.php │ ├── sea.js │ ├── ui │ │ ├── a │ │ │ └── a.js │ │ └── b │ │ │ └── b.js │ └── widget │ │ ├── c │ │ └── c.js │ │ ├── comp │ │ └── comp.js │ │ ├── d │ │ └── d.js │ │ ├── e │ │ └── e.js │ │ └── list │ │ ├── list.css │ │ ├── list.js │ │ └── list.tpl ├── test4 │ ├── fis-conf.js │ ├── index.css │ ├── index.js │ ├── index.tpl │ ├── npm.png │ ├── plugin │ │ ├── FISResource.class.php │ │ ├── compiler.body.php │ │ ├── compiler.head.php │ │ ├── compiler.html.php │ │ ├── compiler.require.php │ │ ├── compiler.script.php │ │ └── compiler.widget.php │ ├── sea.js │ ├── ui │ │ ├── a │ │ │ └── a.js │ │ └── b │ │ │ └── b.js │ └── widget │ │ ├── c │ │ └── c.js │ │ ├── comp │ │ └── comp.js │ │ ├── d │ │ └── d.js │ │ ├── e │ │ └── e.js │ │ └── list │ │ ├── list.css │ │ ├── list.js │ │ └── list.tpl ├── test5 │ ├── fis-conf.js │ ├── index.css │ ├── index.js │ ├── index.tpl │ ├── npm.png │ ├── plugin │ │ ├── FISResource.class.php │ │ ├── compiler.body.php │ │ ├── compiler.head.php │ │ ├── compiler.html.php │ │ ├── compiler.require.php │ │ ├── compiler.script.php │ │ └── compiler.widget.php │ ├── sea.js │ ├── ui │ │ ├── a │ │ │ └── a.js │ │ └── b │ │ │ └── b.js │ └── widget │ │ ├── c │ │ └── c.js │ │ ├── comp │ │ └── comp.js │ │ ├── d │ │ └── d.js │ │ ├── e │ │ └── e.js │ │ └── list │ │ ├── list.css │ │ ├── list.js │ │ └── list.tpl ├── test6 │ ├── fis-conf.js │ ├── index.css │ ├── index.js │ ├── index.tpl │ ├── npm.png │ ├── plugin │ │ ├── FISResource.class.php │ │ ├── compiler.body.php │ │ ├── compiler.head.php │ │ ├── compiler.html.php │ │ ├── compiler.require.php │ │ ├── compiler.script.php │ │ └── compiler.widget.php │ ├── sea.js │ ├── ui │ │ ├── a │ │ │ └── a.js │ │ └── b │ │ │ └── b.js │ └── widget │ │ ├── c │ │ └── c.js │ │ ├── comp │ │ └── comp.js │ │ ├── d │ │ └── d.js │ │ ├── e │ │ └── e.js │ │ └── list │ │ ├── list.css │ │ ├── list.js │ │ └── list.tpl ├── test7 │ ├── fis-conf.js │ ├── index.css │ ├── index.js │ ├── index.tpl │ ├── js │ │ ├── a │ │ │ └── a.js │ │ └── b │ │ │ └── b.js │ ├── npm.png │ ├── plugin │ │ ├── FISResource.class.php │ │ ├── compiler.body.php │ │ ├── compiler.head.php │ │ ├── compiler.html.php │ │ ├── compiler.require.php │ │ ├── compiler.script.php │ │ └── compiler.widget.php │ ├── sea.js │ ├── ui │ │ ├── a │ │ │ └── a.js │ │ └── b │ │ │ └── b.js │ └── widget │ │ ├── c │ │ └── c.js │ │ ├── comp │ │ └── comp.js │ │ ├── d │ │ └── d.js │ │ ├── e │ │ └── e.js │ │ └── list │ │ ├── list.css │ │ ├── list.js │ │ └── list.tpl └── test8 │ ├── fis-conf.js │ ├── fis-pack.json │ ├── index.css │ ├── index.js │ ├── index.tpl │ ├── js │ ├── a │ │ └── a.js │ └── b │ │ └── b.js │ ├── npm.png │ ├── plugin │ ├── FISResource.class.php │ ├── compiler.body.php │ ├── compiler.head.php │ ├── compiler.html.php │ ├── compiler.require.php │ ├── compiler.script.php │ └── compiler.widget.php │ ├── sea.js │ ├── ui │ ├── a │ │ └── a.js │ └── b │ │ └── b.js │ └── widget │ ├── c │ └── c.js │ ├── comp │ └── comp.js │ ├── d │ └── d.js │ ├── e │ └── e.js │ └── list │ ├── list.css │ ├── list.js │ └── list.tpl ├── tar ├── test.tar └── test.tgz ├── upload └── a.js ├── uri.js ├── uri └── file │ ├── a.js │ └── b.js ├── util.js ├── util ├── base64 │ ├── logo.gif │ └── logo.txt ├── encoding │ ├── gbk.txt │ ├── utf8-bom.txt │ ├── utf8.txt │ └── utfcode.txt ├── img │ ├── data.png │ └── test.png └── json │ ├── error.json │ ├── gbk.json │ ├── json.json │ ├── utf8-bom.json │ └── utf8.json └── xunit-report └── do.js /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | node_modules/ 3 | /test/ut/install 4 | /test/ut/file/target 5 | /test/ut/download 6 | .DS_Store 7 | *.db 8 | *.bak 9 | *.tmp 10 | *.cmd 11 | ~* 12 | 13 | upload.py -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /.settings 3 | /.project 4 | /.gitignore 5 | /node_modules 6 | /test 7 | /.tmp 8 | 9 | .DS_Store 10 | 11 | *.db 12 | *.bak 13 | *.tmp 14 | *.cmd 15 | ~* 16 | 17 | upload.py -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (C) 2013 baidu.com 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 14 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 15 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 18 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FIS Kernel 2 | 3 | This is fis kernel. -------------------------------------------------------------------------------- /fis-kernel.js: -------------------------------------------------------------------------------- 1 | /* 2 | * fis 3 | * http://fis.baidu.com/ 4 | */ 5 | 6 | 'use strict'; 7 | 8 | var last = Date.now(); 9 | 10 | //oo 11 | Function.prototype.derive = function(constructor, proto){ 12 | if(typeof constructor === 'object'){ 13 | proto = constructor; 14 | constructor = proto.constructor || function(){}; 15 | delete proto.constructor; 16 | } 17 | var parent = this; 18 | var fn = function(){ 19 | parent.apply(this, arguments); 20 | constructor.apply(this, arguments); 21 | }; 22 | var tmp = function(){}; 23 | tmp.prototype = parent.prototype; 24 | var fp = new tmp(), 25 | cp = constructor.prototype, 26 | key; 27 | for(key in cp){ 28 | if(cp.hasOwnProperty(key)){ 29 | fp[key] = cp[key]; 30 | } 31 | } 32 | proto = proto || {}; 33 | for(key in proto){ 34 | if(proto.hasOwnProperty(key)){ 35 | fp[key] = proto[key]; 36 | } 37 | } 38 | fp.constructor = constructor.prototype.constructor; 39 | fn.prototype = fp; 40 | return fn; 41 | }; 42 | 43 | //factory 44 | Function.prototype.factory = function(){ 45 | var clazz = this; 46 | function F(args){ 47 | clazz.apply(this, args); 48 | } 49 | F.prototype = clazz.prototype; 50 | return function(){ 51 | return new F(arguments); 52 | }; 53 | }; 54 | 55 | var fis = module.exports = {}; 56 | 57 | //register global variable 58 | Object.defineProperty(global, 'fis', { 59 | enumerable : true, 60 | writable : false, 61 | value : fis 62 | }); 63 | 64 | fis.emitter = new (require('events').EventEmitter); 65 | 66 | //time for debug 67 | fis.time = function(title){ 68 | console.log(title + ' : ' + (Date.now() - last) + 'ms'); 69 | last = Date.now(); 70 | }; 71 | 72 | //log 73 | fis.log = require('./lib/log.js'); 74 | 75 | //require 76 | fis.require = function(){ 77 | var path; 78 | var name = Array.prototype.slice.call(arguments, 0).join('-'); 79 | if(fis.require._cache.hasOwnProperty(name)) return fis.require._cache[name]; 80 | var names = []; 81 | for(var i = 0, len = fis.require.prefixes.length; i < len; i++){ 82 | try { 83 | var pluginName = fis.require.prefixes[i] + '-' + name; 84 | names.push(pluginName); 85 | path = require.resolve(pluginName); 86 | try { 87 | return fis.require._cache[name] = require(pluginName); 88 | } catch (e){ 89 | fis.log.error('load plugin [' + pluginName + '] error : ' + e.message); 90 | } 91 | } catch (e){ 92 | if (e.code !== 'MODULE_NOT_FOUND') { 93 | throw e; 94 | } 95 | } 96 | } 97 | fis.log.error('unable to load plugin [' + names.join('] or [') + ']'); 98 | }; 99 | 100 | fis.require._cache = {}; 101 | 102 | fis.require.prefixes = ['fis']; 103 | 104 | //system config 105 | fis.config = require('./lib/config.js'); 106 | 107 | //utils 108 | fis.util = require('./lib/util.js'); 109 | 110 | //resource location 111 | fis.uri = require('./lib/uri.js'); 112 | 113 | //project 114 | fis.project = require('./lib/project.js'); 115 | 116 | //file 117 | fis.file = require('./lib/file.js'); 118 | 119 | //cache 120 | fis.cache = require('./lib/cache.js'); 121 | 122 | //compile kernel 123 | fis.compile = require('./lib/compile.js'); 124 | 125 | //release api 126 | fis.release = require('./lib/release.js'); 127 | 128 | //package info 129 | fis.info = fis.util.readJSON(__dirname + '/package.json'); 130 | 131 | //kernel version 132 | fis.version = fis.info.version; 133 | -------------------------------------------------------------------------------- /lib/cache.js: -------------------------------------------------------------------------------- 1 | /* 2 | * fis 3 | * http://fis.baidu.com/ 4 | */ 5 | 6 | 'use strict'; 7 | 8 | var Cache = Object.derive(function(path, dir){ 9 | var file = fis.util.realpath(path); 10 | if(!fis.util.isFile(file)){ 11 | fis.log.error('unable to cache file[' + path + ']: No such file.'); 12 | } 13 | this.timestamp = fis.util.mtime(file).getTime(); 14 | this.deps = {}; 15 | this.version = fis.version; 16 | 17 | var info = fis.util.pathinfo(file); 18 | var basename = fis.project.getCachePath(dir, info.basename); 19 | var hash = fis.util.md5(file, 10); 20 | this.cacheFile = basename + '-c-' + hash + '.tmp'; 21 | this.cacheInfo = basename + '-o-' + hash + '.json'; 22 | }, { 23 | save : function(content, info){ 24 | var infos = { 25 | version : this.version, 26 | timestamp : this.timestamp, 27 | deps : this.deps, 28 | info : info 29 | }; 30 | fis.util.write(this.cacheInfo, JSON.stringify(infos)); 31 | fis.util.write(this.cacheFile, content); 32 | }, 33 | revert : function(file){ 34 | fis.log.debug('revert cache'); 35 | if( 36 | exports.enable 37 | && fis.util.exists(this.cacheInfo) 38 | && fis.util.exists(this.cacheFile) 39 | ){ 40 | fis.log.debug('cache file exists'); 41 | var infos = fis.util.readJSON(this.cacheInfo); 42 | fis.log.debug('cache info read'); 43 | if(infos.version == this.version && infos.timestamp == this.timestamp){ 44 | var deps = infos['deps']; 45 | for(var f in deps){ 46 | if(deps.hasOwnProperty(f)){ 47 | var d = fis.util.mtime(f); 48 | if(d == 0 || deps[f] != d.getTime()){ 49 | fis.log.debug('cache is expired'); 50 | return false; 51 | } 52 | } 53 | } 54 | this.deps = deps; 55 | fis.log.debug('cache is valid'); 56 | if(file){ 57 | file.info = infos.info; 58 | file.content = fis.util.fs.readFileSync(this.cacheFile); 59 | } 60 | fis.log.debug('revert cache finished'); 61 | return true; 62 | } 63 | } 64 | fis.log.debug('cache is expired'); 65 | return false; 66 | }, 67 | addDeps : function(file){ 68 | var path = fis.util.realpath(file); 69 | if(path){ 70 | this.deps[path] = fis.util.mtime(path).getTime(); 71 | } else { 72 | fis.log.warning('unable to add dependency file[' + file + ']: No such file.'); 73 | } 74 | return this; 75 | }, 76 | removeDeps : function(file){ 77 | var path = fis.util.realpath(file); 78 | if(path && this.deps[path]){ 79 | delete this.deps[path]; 80 | } 81 | return this; 82 | }, 83 | mergeDeps : function(cache){ 84 | var deps = {}; 85 | if(cache instanceof Cache){ 86 | deps = cache.deps 87 | } else if(typeof cache === 'object'){ 88 | deps = cache 89 | } else { 90 | fis.log.error('unable to merge deps of data[' + cache + ']'); 91 | } 92 | fis.util.map(deps, this.deps, true); 93 | } 94 | }); 95 | 96 | exports = module.exports = Cache.factory(); 97 | exports.enable = true; 98 | exports.Cache = Cache; 99 | exports.clean = function(name){ 100 | name = name || ''; 101 | var path = fis.project.getCachePath(name); 102 | if(fis.util.exists(path)){ 103 | fis.util.del(path); 104 | } 105 | }; -------------------------------------------------------------------------------- /lib/config.js: -------------------------------------------------------------------------------- 1 | /* 2 | * fis 3 | * http://fis.baidu.com/ 4 | */ 5 | 6 | 'use strict'; 7 | 8 | var DEFALUT_SETTINGS = { 9 | system : { 10 | repos : 'http://fis.baidu.com/repos' 11 | }, 12 | project : { 13 | charset : 'utf8', 14 | md5Length : 7, 15 | md5Connector : '_' 16 | } 17 | }; 18 | 19 | //You can't use merge in util.js 20 | function merge(source, target){ 21 | if(typeof source === 'object' && typeof target === 'object'){ 22 | for(var key in target){ 23 | if(target.hasOwnProperty(key)){ 24 | source[key] = merge(source[key], target[key]); 25 | } 26 | } 27 | } else { 28 | source = target; 29 | } 30 | return source; 31 | } 32 | 33 | var Config = Object.derive({ 34 | constructor : function(){ 35 | this.init.apply(this, arguments); 36 | }, 37 | init : function(){ 38 | this.data = {}; 39 | if(arguments.length > 0){ 40 | this.merge.apply(this, arguments); 41 | } 42 | return this; 43 | }, 44 | get : function(path, def){ 45 | var result = this.data || {}; 46 | (path || '').split('.').forEach(function(key){ 47 | if(key && (typeof result !== 'undefined')){ 48 | result = result[key]; 49 | } 50 | }); 51 | if(typeof result === 'undefined'){ 52 | return def; 53 | } else { 54 | return result; 55 | } 56 | }, 57 | set : function(path, value){ 58 | if(typeof value === 'undefined'){ 59 | this.data = path; 60 | } else { 61 | path = String(path || '').trim(); 62 | if(path){ 63 | var paths = path.split('.'), 64 | last = paths.pop(), 65 | data = this.data || {}; 66 | paths.forEach(function(key){ 67 | var type = typeof data[key]; 68 | if(type === 'object'){ 69 | data = data[key]; 70 | } else if(type === 'undefined'){ 71 | data = data[key] = {}; 72 | } else { 73 | fis.log.error('forbidden to set property[' + key + '] of [' + type + '] data'); 74 | } 75 | }); 76 | data[last] = value; 77 | } 78 | } 79 | return this; 80 | }, 81 | del : function(path){ 82 | path = String(path || '').trim(); 83 | if(path){ 84 | var paths = path.split('.'), 85 | data = this.data, 86 | last = paths.pop(), key; 87 | for(var i = 0, len = paths.length; i < len; i++){ 88 | key = paths[i]; 89 | if(typeof data[key] === 'object'){ 90 | data = data[key]; 91 | } else { 92 | return this; 93 | } 94 | } 95 | if(typeof data[last] !== 'undefined'){ 96 | delete data[last]; 97 | } 98 | } 99 | return this; 100 | }, 101 | merge : function(){ 102 | var self = this; 103 | [].slice.call(arguments).forEach(function(arg){ 104 | if(typeof arg === 'object'){ 105 | merge(self.data, arg); 106 | } else { 107 | fis.log.warning('unable to merge data[' + arg + '].'); 108 | } 109 | }); 110 | return this; 111 | }, 112 | require : function(name){ 113 | fis.require('config', name); 114 | return this; 115 | } 116 | }); 117 | 118 | module.exports = (new Config).init(DEFALUT_SETTINGS); 119 | module.exports.Config = Config; -------------------------------------------------------------------------------- /lib/log.js: -------------------------------------------------------------------------------- 1 | /* 2 | * fis 3 | * http://fis.baidu.com/ 4 | */ 5 | 6 | 'use strict'; 7 | 8 | exports.L_ALL = 0x01111; 9 | exports.L_NOTIC = 0x00001; 10 | exports.L_DEBUG = 0x00010; 11 | exports.L_WARNI = 0x00100; 12 | exports.L_ERROR = 0x01000; 13 | exports.L_NORMAL = 0x01101; 14 | 15 | exports.level = exports.L_NORMAL; 16 | exports.throw = false; 17 | exports.alert = false; 18 | 19 | exports.now = function(withoutMilliseconds){ 20 | var d = new Date(), str; 21 | str = [ 22 | d.getHours(), 23 | d.getMinutes(), 24 | d.getSeconds() 25 | ].join(':').replace(/\b\d\b/g, '0$&'); 26 | if(!withoutMilliseconds){ 27 | str += '.' + ('00' + d.getMilliseconds()).substr(-4); 28 | } 29 | return str; 30 | }; 31 | 32 | function log(type, msg, code){ 33 | code = code || 0; 34 | if((exports.level & code) > 0){ 35 | var listener = exports.on[type]; 36 | if(listener){ 37 | listener(msg); 38 | } 39 | exports.on.any(type, msg); 40 | } 41 | } 42 | 43 | exports.debug = function(msg){ 44 | log('debug', exports.now() + ' ' + msg, exports.L_DEBUG); 45 | }; 46 | 47 | exports.notice = function(msg){ 48 | log('notice', msg, exports.L_NOTIC); 49 | }; 50 | 51 | exports.warning = function(msg){ 52 | log('warning', msg, exports.L_WARNI); 53 | }; 54 | 55 | exports.error = function(err){ 56 | if(!(err instanceof Error)){ 57 | err = new Error(err.message || err); 58 | } 59 | if(exports.alert){ 60 | err.message += '\u0007'; 61 | } 62 | if(exports.throw){ 63 | throw err 64 | } else { 65 | log('error', err.message, exports.L_ERROR); 66 | process.exit(1); 67 | } 68 | }; 69 | 70 | exports.on = { 71 | any : function(type, msg){}, 72 | debug : function(msg){ process.stdout.write('\n [DEBUG] ' + msg + '\n'); }, 73 | notice : function(msg){ process.stdout.write('\n [NOTIC] ' + msg + '\n'); }, 74 | warning : function(msg){ process.stdout.write('\n [WARNI] ' + msg + '\n'); }, 75 | error : function(msg){ process.stdout.write('\n [ERROR] ' + msg + '\n'); } 76 | }; -------------------------------------------------------------------------------- /lib/project.js: -------------------------------------------------------------------------------- 1 | /* 2 | * fis 3 | * http://fis.baidu.com/ 4 | */ 5 | 6 | 'use strict'; 7 | 8 | exports.DEFAULT_REMOTE_REPOS = 'http://fis.baidu.com/repos'; 9 | 10 | exports.getSource = function(){ 11 | var root = exports.getProjectPath(), 12 | source = {}, 13 | project_exclude = /^(\/output\b|\/fis-[^\/]+)$/, 14 | include = fis.config.get('project.include'), 15 | exclude = fis.config.get('project.exclude'); 16 | if (fis.util.is(exclude, 'Array')){ 17 | project_exclude = [project_exclude].concat(exclude); 18 | }else if (exclude){ 19 | project_exclude = [project_exclude, exclude]; 20 | } 21 | fis.util.find(root, include, project_exclude, root).forEach(function(file){ 22 | file = fis.file(file); 23 | if (file.release) { 24 | source[file.subpath] = file; 25 | } 26 | }); 27 | return source; 28 | }; 29 | 30 | //paths 31 | var PROJECT_ROOT; 32 | var TEMP_ROOT; 33 | 34 | function getPath(root, args){ 35 | if(args && args.length > 0){ 36 | args = root + '/' + Array.prototype.join.call(args, '/'); 37 | return fis.util(args); 38 | } else { 39 | return fis.util(root); 40 | } 41 | } 42 | 43 | function initDir(path, title){ 44 | if(fis.util.exists(path)){ 45 | if(!fis.util.isDir(path)){ 46 | fis.log.error('unable to set path[' + path + '] as ' + title + ' directory.'); 47 | } 48 | } else { 49 | fis.util.mkdir(path); 50 | } 51 | path = fis.util.realpath(path); 52 | if(path){ 53 | return path; 54 | } else { 55 | fis.log.error('unable to create dir [' + path + '] for ' + title + ' directory.'); 56 | } 57 | } 58 | 59 | exports.getProjectPath = function(){ 60 | if(PROJECT_ROOT){ 61 | return getPath(PROJECT_ROOT, arguments); 62 | } else { 63 | fis.log.error('undefined project root'); 64 | } 65 | }; 66 | 67 | exports.setProjectRoot = function(path){ 68 | if(fis.util.isDir(path)){ 69 | PROJECT_ROOT = fis.util.realpath(path); 70 | } else { 71 | fis.log.error('invalid project root path [' + path + ']'); 72 | } 73 | }; 74 | 75 | exports.setTempRoot = function(tmp){ 76 | TEMP_ROOT = initDir(tmp); 77 | }; 78 | 79 | exports.getTempPath = function(){ 80 | if(!TEMP_ROOT){ 81 | var list = ['FIS_TEMP_DIR', 'LOCALAPPDATA', 'APPDATA', 'HOME']; 82 | var name = fis.cli && fis.cli.name ? fis.cli.name : 'fis'; 83 | var tmp; 84 | for(var i = 0, len = list.length; i < len; i++){ 85 | if(tmp = process.env[list[i]]){ 86 | break; 87 | } 88 | } 89 | tmp = tmp || __dirname + '/../'; 90 | exports.setTempRoot(tmp + '/.' + name + '-tmp'); 91 | } 92 | return getPath(TEMP_ROOT, arguments); 93 | }; 94 | 95 | exports.getCachePath = function(){ 96 | return getPath(exports.getTempPath('cache'), arguments); 97 | }; 98 | -------------------------------------------------------------------------------- /lib/release.js: -------------------------------------------------------------------------------- 1 | /* 2 | * fis 3 | * http://fis.baidu.com/ 4 | */ 5 | 6 | 'use strict'; 7 | 8 | /** 9 | * @type {Function} 10 | * @param {Object} [opt] 11 | * @param {Function} callback 12 | * opt = { 13 | * include : {RegExp} find include filter, 14 | * exclude : {RegExp} find exclude filter, 15 | * debug : {Boolean} debug model, 16 | * optimize : {Boolean} if optimize, 17 | * pack : {Boolean|String} if package, 18 | * lint : {Boolean} if lint, 19 | * test : {Boolean} if test, 20 | * hash : {Boolean} if with hash, 21 | * domain : {Boolean} if with domain, 22 | * beforeEach : {Function} before compile each file callback, 23 | * afterEach : {Function} after compile each file callback, 24 | * beforePack : {Function} before pack file callback, 25 | * afterPack : {Function} after pack file callback 26 | * } 27 | */ 28 | 29 | var exports = module.exports = function(opt, callback){ 30 | if(typeof opt === 'function'){ 31 | callback = opt; 32 | opt = {}; 33 | } else { 34 | opt = opt || {}; 35 | } 36 | 37 | var src = {}; 38 | if (Array.isArray(opt.srcCache) && opt.srcCache.length) { 39 | opt.srcCache.forEach(function (path) { 40 | if (!fis.util.isFile(path)) return; 41 | var file = fis.file(path); 42 | if (file.release) { 43 | src[file.subpath] = file; 44 | } 45 | }); 46 | } else { 47 | src = fis.project.getSource(); 48 | } 49 | 50 | var ret = { 51 | src : src, 52 | ids : {}, 53 | pkg : {}, 54 | map : { 55 | res : {}, 56 | pkg : {} 57 | } 58 | }; 59 | opt.hash = opt.md5 > 0; 60 | fis.compile.setup(opt); 61 | fis.util.map(ret.src, function(subpath, file){ 62 | if(opt.beforeEach) { 63 | opt.beforeEach(file, ret); 64 | } 65 | 66 | file = fis.compile(file); 67 | 68 | if(opt.afterEach) { 69 | opt.afterEach(file, ret); 70 | } 71 | 72 | if(file.release && file.useMap) { 73 | //add resource map 74 | var id = file.getId(); 75 | ret.ids[id] = file; 76 | if(file.isJsLike){ 77 | file.addSameNameRequire('.css'); 78 | } else if(file.isHtmlLike){ 79 | file.addSameNameRequire('.js'); 80 | file.addSameNameRequire('.css'); 81 | } 82 | var res = ret.map.res[id] = { 83 | uri : file.getUrl(opt.hash, opt.domain), 84 | type : file.rExt.replace(/^\./, '') 85 | }; 86 | for(var key in file.extras){ 87 | if(file.extras.hasOwnProperty(key)){ 88 | res.extras = file.extras; 89 | break; 90 | } 91 | } 92 | if(file.requires && file.requires.length){ 93 | res.deps = file.requires; 94 | } 95 | } 96 | }); 97 | 98 | //project root 99 | var root = fis.project.getProjectPath(); 100 | 101 | var ns = fis.config.get('namespace'); 102 | 103 | //get pack config 104 | var conf = fis.config.get('pack'); 105 | if(typeof conf === 'undefined'){ 106 | //from fis-pack.json 107 | var file = root + '/fis-pack.json'; 108 | if(fis.util.isFile(file)){ 109 | fis.config.set('pack', conf = fis.util.readJSON(file)); 110 | } 111 | } 112 | 113 | //package callback 114 | var cb = function(packager, settings, key){ 115 | fis.log.debug('[' + key + '] start'); 116 | packager(ret, conf, settings, opt); 117 | fis.log.debug('[' + key + '] end'); 118 | }; 119 | 120 | //prepackage 121 | fis.util.pipe('prepackager', cb, opt.prepackager); 122 | 123 | //package 124 | if(opt.pack){ 125 | //package 126 | fis.util.pipe('packager', cb, opt.packager); 127 | //css sprites 128 | fis.util.pipe('spriter', cb, opt.spriter); 129 | } 130 | 131 | //postpackage 132 | fis.util.pipe('postpackager', cb, opt.postpackager); 133 | 134 | //create map.json 135 | var map = fis.file(root, (ns ? ns + '-' : '') + 'map.json'); 136 | if(map.release){ 137 | map.setContent(JSON.stringify(ret.map, null, opt.optimize ? null : 4)); 138 | ret.pkg[map.subpath] = map; 139 | } 140 | 141 | //done 142 | if(callback){ 143 | callback(ret); 144 | } 145 | }; -------------------------------------------------------------------------------- /lib/uri.js: -------------------------------------------------------------------------------- 1 | /* 2 | * fis 3 | * http://fis.baidu.com/ 4 | */ 5 | 6 | 'use strict'; 7 | 8 | function replaceDefine(value, escape){ 9 | return value.replace(/\$\{([^\}]+)\}/g, function(all, $1){ 10 | var val = fis.config.get($1); 11 | if(typeof val === 'undefined'){ 12 | fis.log.error('undefined property [' + $1 + '].'); 13 | } else { 14 | return escape ? fis.util.escapeReg(val) : val; 15 | } 16 | return all; 17 | }); 18 | } 19 | 20 | function replaceMatches(value, matches){ 21 | return value.replace(/\$(\d+|&)/g, function(all, $1){ 22 | var key = $1 === '&' ? '0' : $1; 23 | return matches.hasOwnProperty(key) ? (matches[key] || '') : all; 24 | }); 25 | } 26 | 27 | function replaceProperties(source, matches, target){ 28 | var type = typeof source; 29 | if(type === 'object'){ 30 | if(fis.util.is(source, 'Array')){ 31 | target = target || []; 32 | } else { 33 | target = target || {}; 34 | } 35 | fis.util.map(source, function(key, value){ 36 | target[key] = replaceProperties(value, matches); 37 | }); 38 | return target; 39 | } else if(type === 'string'){ 40 | return replaceDefine(replaceMatches(source, matches)); 41 | // TODO support function type 42 | // } else if(type === 'function'){ 43 | // return source(subpath || target.subpath, matches); 44 | } else { 45 | return source; 46 | } 47 | } 48 | 49 | function roadmap(subpath, path, obj){ 50 | var map = fis.config.get('roadmap.' + path, []); 51 | for(var i = 0, len = map.length; i < len; i++){ 52 | var opt = map[i], reg = opt.reg; 53 | if(reg){ 54 | if(typeof reg === 'string'){ 55 | reg = fis.util.glob(replaceDefine(reg, true)); 56 | } else if(!fis.util.is(reg, 'RegExp')){ 57 | fis.log.error('invalid regexp [' + reg + '] of [roadmap.' + path + '.' + i + ']'); 58 | } 59 | var matches = subpath.match(reg); 60 | if(matches){ 61 | obj = obj || {}; 62 | replaceProperties(opt, matches, obj); 63 | delete obj.reg; 64 | return obj; 65 | } 66 | } else { 67 | fis.log.error('[roadmap.' + path + '.' + i + '] missing property [reg].'); 68 | } 69 | } 70 | return false; 71 | } 72 | 73 | var uri = module.exports = function(path, dirname){ 74 | var info = fis.util.stringQuote(path), 75 | qInfo = fis.util.query(info.rest); 76 | info.query = qInfo.query; 77 | info.hash = qInfo.hash; 78 | info.rest = qInfo.rest; 79 | if(info.rest){ 80 | path = info.rest; 81 | if(path.indexOf(':') === -1){ 82 | var file; 83 | if(path[0] === '/'){ 84 | file = fis.project.getProjectPath(path); 85 | } else if(dirname) { 86 | file = fis.util(dirname, path); 87 | } else { 88 | fis.log.error('invalid dirname.'); 89 | } 90 | 91 | var root = fis.project.getProjectPath(); 92 | if(file && fis.util.isFile(file) && file.indexOf(root) === 0){ 93 | info.file = fis.file(file); 94 | } 95 | } 96 | } 97 | return info; 98 | }; 99 | 100 | uri.getId = function(path, dirname){ 101 | var info = uri(path, dirname); 102 | if(info.file){ 103 | info.id = info.file.getId(); 104 | } else { 105 | info.id = info.rest; 106 | } 107 | return info; 108 | }; 109 | 110 | uri.replaceDefine = replaceDefine; 111 | uri.replaceMatches = replaceMatches; 112 | uri.replaceProperties = replaceProperties; 113 | uri.roadmap = roadmap; 114 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fis-kernel", 3 | "description": "fis kernel.", 4 | "version": "2.0.19", 5 | "author": "FIS Team ", 6 | "homepage": "http://fis.baidu.com/", 7 | "license": "MIT", 8 | "keywords": [ 9 | "fis" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/fis-dev/fis-kernel.git" 14 | }, 15 | "engines": { 16 | "node": ">= 0.8.0" 17 | }, 18 | "main": "fis-kernel.js", 19 | "scripts": { 20 | "test": "mocha test/ut" 21 | }, 22 | "dependencies": { 23 | "tar": "2.2.1", 24 | "iconv-lite": "0.2.10" 25 | }, 26 | "devDependencies": { 27 | "chai": "1.9.1", 28 | "fis-optimizer-clean-css": "0.0.12", 29 | "fis-optimizer-uglify-js": "0.1.2", 30 | "fis-packager-map": "0.0.9", 31 | "mocha": "2.0.1" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /test/ut/cache/src/c1.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/cache/src/c1.js -------------------------------------------------------------------------------- /test/ut/cache/src/c2.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/cache/src/c2.css -------------------------------------------------------------------------------- /test/ut/compile/css/click.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/compile/css/click.ogg -------------------------------------------------------------------------------- /test/ut/compile/css/expect.css: -------------------------------------------------------------------------------- 1 | @import url(/css/inline_d6fe2c4.css); 2 | .test{ 3 | background: red; 4 | } 5 | 6 | .test{ 7 | background-image: url(/css/test_bbcd6a7.bmp); 8 | background-image: url(/css/test_bbcd6a7.bmp); 9 | background-image: url(/css/test_bbcd6a7.bmp); 10 | background-image: url('/css/test_bbcd6a7.bmp'); 11 | background-image: url('/css/test_bbcd6a7.bmp'); 12 | background-image: url('/css/test_bbcd6a7.bmp'); 13 | background-image: url("/css/test_bbcd6a7.bmp"); 14 | background-image: url("/css/test_bbcd6a7.bmp"); 15 | background-image: url("/css/test_bbcd6a7.bmp"); 16 | _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/css/test_bbcd6a7.bmp'); 17 | _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader( src='/css/test_bbcd6a7.bmp'); 18 | _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/css/test_bbcd6a7.bmp' ); 19 | _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/css/test_bbcd6a7.bmp?__inline'); 20 | _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader( src='/css/test_bbcd6a7.bmp?__inline'); 21 | _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/css/test_bbcd6a7.bmp?__inline' ); 22 | } -------------------------------------------------------------------------------- /test/ut/compile/css/expect_require.css: -------------------------------------------------------------------------------- 1 | /*@require 'css/main.css';*/ 2 | /*@require css/main.css;*/ 3 | /*@require 'css/main.css';*/ 4 | /*@require "css/main.css";*/ 5 | /*@require 'css/main.css';*/ 6 | /*@require 'css/main.css';@require css/main.css;@require 'css/main.css';@require "css/main.css";@require 'css/main.css';*/ 7 | .test{ 8 | background: red; 9 | /*@require 'css/main.css'; */ 10 | /*@require css/main.css;@require 'css/main.css';@require "css/main.css";@require 'css/main.css';*/ 11 | } -------------------------------------------------------------------------------- /test/ut/compile/css/inline.css: -------------------------------------------------------------------------------- 1 | .test{ 2 | background: red; 3 | } -------------------------------------------------------------------------------- /test/ut/compile/css/main.css: -------------------------------------------------------------------------------- 1 | @import url(./inline.css); 2 | @import url(./inline.css?__inline); 3 | 4 | .test{ 5 | background-image: url(./test.bmp); 6 | background-image: url( ./test.bmp); 7 | background-image: url(./test.bmp ); 8 | background-image: url('./test.bmp'); 9 | background-image: url( './test.bmp'); 10 | background-image: url('./test.bmp' ); 11 | background-image: url("./test.bmp"); 12 | background-image: url( "./test.bmp"); 13 | background-image: url("./test.bmp" ); 14 | _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='./test.bmp'); 15 | _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader( src='./test.bmp'); 16 | _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='./test.bmp' ); 17 | _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='./test.bmp?__inline'); 18 | _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader( src='./test.bmp?__inline'); 19 | _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='./test.bmp?__inline' ); 20 | } -------------------------------------------------------------------------------- /test/ut/compile/css/require.css: -------------------------------------------------------------------------------- 1 | /*@require '../css/main.css';*/ 2 | /*@require main.css;*/ 3 | /*@require 'main.css';*/ 4 | /*@require "main.css";*/ 5 | /*@require './main.css';*/ 6 | /*@require '../css/main.css';@require main.css;@require 'main.css';@require "main.css";@require './main.css';*/ 7 | .test{ 8 | background: red; 9 | /*@require '../css/main.css'; */ 10 | /*@require main.css;@require 'main.css';@require "main.css";@require './main.css';*/ 11 | } -------------------------------------------------------------------------------- /test/ut/compile/css/test.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/compile/css/test.bmp -------------------------------------------------------------------------------- /test/ut/compile/html/a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/compile/html/a.png -------------------------------------------------------------------------------- /test/ut/compile/html/expect_require.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 24 | 25 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /test/ut/compile/html/inline.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /test/ut/compile/html/inline2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /test/ut/compile/html/main.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 61 | 62 | 70 | 78 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /test/ut/compile/html/require.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 24 | 25 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /test/ut/compile/html/require.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 24 | 25 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /test/ut/compile/js/expect_require.js: -------------------------------------------------------------------------------- 1 | //@require js/main.js 2 | //@require 'js/main.js' 3 | //@require "js/main.js" 4 | /* 5 | *@require js/main.js 6 | @require 'js/main.js' 7 | @require "js/main.js" 8 | * */ 9 | 10 | //require 'main.js' 11 | /* 12 | *@require js/main.js;@require 'js/main.js';@require "js/main.js" 13 | * */ 14 | var s = "require('main.js');"; 15 | require('js/main.js'); 16 | require("js/main.js"); 17 | require("js/main.js"); 18 | require('js/main.js'); 19 | require('js/main.js'); 20 | require('js/main.js'); -------------------------------------------------------------------------------- /test/ut/compile/js/inline.js: -------------------------------------------------------------------------------- 1 | var a = 'inline'; -------------------------------------------------------------------------------- /test/ut/compile/js/main.js: -------------------------------------------------------------------------------- 1 | __inline('inline.js');__inline("inline.js"); -------------------------------------------------------------------------------- /test/ut/compile/js/require.js: -------------------------------------------------------------------------------- 1 | //@require main.js 2 | //@require 'main.js' 3 | //@require "main.js" 4 | /* 5 | *@require main.js 6 | @require 'main.js' 7 | @require "main.js" 8 | * */ 9 | 10 | //require 'main.js' 11 | /* 12 | *@require main.js;@require 'main.js';@require "main.js" 13 | * */ 14 | var s = "require('main.js');"; 15 | require('main.js'); 16 | require("main.js"); 17 | require("./main.js"); 18 | require('./main.js'); 19 | require( './main.js' ); 20 | require( 21 | './main.js' 22 | 23 | ); -------------------------------------------------------------------------------- /test/ut/compile/js/uri.js: -------------------------------------------------------------------------------- 1 | __uri('./inline.js');__uri("./inline.js"); 2 | __uri( "./inline.js" );__uri( './inline.js'); 3 | //__uri("./inline.js"); 4 | /* 5 | * __uri("./inline.js"); 6 | * */__uri("./inline.js"); 7 | var a = '__uri("./inline.js")'; 8 | __uri( 9 | './inline.js' 10 | ); -------------------------------------------------------------------------------- /test/ut/config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created with JetBrains WebStorm. 3 | * User: tanwenmin 4 | * Date: 13-0-18 5 | * Time: 13:25 6 | * To change this template use File | Settings | File Templates. 7 | */ 8 | var fs = require('fs'), 9 | path = require('path'); 10 | var fis = require('../../fis-kernel.js'); 11 | var _ = fis.file, 12 | config = fis.config; 13 | var expect = require('chai').expect; 14 | var u = fis.util; 15 | 16 | describe('config',function(){ 17 | beforeEach(function(){ 18 | fis.project.setProjectRoot(__dirname); 19 | config.init(); 20 | }); 21 | 22 | it('set',function(){ 23 | config.set('roadmap', { 24 | path : [{ 25 | "reg" : /^\/(.*)/, 26 | "release" : "static/$1" 27 | }] 28 | }); 29 | fis.config.set('roadmap.domain','www.baidu.com'); 30 | path = __dirname+'/file/ext/modular/js.js?__inline'; 31 | var f = _.wrap(path); 32 | var url = f.getUrl(false,true); 33 | expect(url).to.equal('www.baidu.com/static/file/ext/modular/js.js?__inline'); 34 | //without domain 35 | fis.config.del('roadmap.domain'); 36 | path = __dirname+'/file/ext/modular/js.js?__inline'; 37 | var f = _.wrap(path); 38 | var url = f.getUrl(false,true); 39 | expect(url).to.equal('/static/file/ext/modular/js.js?__inline'); 40 | //without path 41 | fis.config.del('roadmap.path'); 42 | path = __dirname+'/file/ext/modular/js.js?__inline'; 43 | var f = _.wrap(path); 44 | var url = f.getUrl(false,true); 45 | expect(url).to.equal('/file/ext/modular/js.js?__inline'); 46 | //no change 47 | fis.config.del(); 48 | path = __dirname+'/file/ext/modular/js.js?__inline'; 49 | var f = _.wrap(path); 50 | var url = f.getUrl(false,true); 51 | expect(url).to.equal('/file/ext/modular/js.js?__inline'); 52 | }); 53 | 54 | it('del',function(){ 55 | //without domain 56 | fis.config.del('roadmap.domain'); 57 | path = __dirname+'/file/ext/modular/js.js?__inline'; 58 | var f = _.wrap(path); 59 | var url = f.getUrl(false,true); 60 | expect(url).to.equal('/file/ext/modular/js.js?__inline'); 61 | 62 | //without path 63 | fis.config.del('roadmap.path'); 64 | path = __dirname+'/file/ext/modular/js.js?__inline'; 65 | var f = _.wrap(path); 66 | var url = f.getUrl(false,true); 67 | expect(url).to.equal('/file/ext/modular/js.js?__inline'); 68 | }); 69 | 70 | it('del null', function(){ 71 | fis.config.del(); 72 | path = __dirname+'/file/ext/modular/js.js?__inline'; 73 | var f = _.wrap(path); 74 | var url = f.getUrl(false,true); 75 | expect(url).to.equal('/file/ext/modular/js.js?__inline'); 76 | 77 | fis.config.del('roadmap'); 78 | fis.config.del('system'); 79 | fis.config.del('project'); 80 | fis.config.set(); 81 | expect(fis.config.get()).to.deep.equal({}); 82 | }); 83 | }); 84 | -------------------------------------------------------------------------------- /test/ut/file/css/test.css: -------------------------------------------------------------------------------- 1 | hello world -------------------------------------------------------------------------------- /test/ut/file/css/test.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/file/css/test.js -------------------------------------------------------------------------------- /test/ut/file/embed/embed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/file/embed/embed.gif -------------------------------------------------------------------------------- /test/ut/file/embed/embed.txt: -------------------------------------------------------------------------------- 1 | R0lGODlhDgGBALMAAGBn6eYxLvvy9PnKyfOene1qZ8/R+Ker84WK7ubn+/vh4DQ840VM5Sky4eEGAv///yH5BAAAAAAALAAAAAAOAYEAAAT/8MlJq7046827/2AojmRpnmiqrmzrvnAsz3Rt33iu73zv/8CgcEgsGo/IpHLJbDqf0Kh0Sq1ar9isdsvter/gsHhMLpvP6LR6zW673/C4fE6v2+/4vH7P7/v/gIGCg4SFhoeIiYqLjI2Oj5CRkpOUlYsJCAwLAAaWkQYLDaKiCJ6OCaGjowcYBgChDKymfQCqqgsJFge2DQACs3oGvKqyE7vDAMB5CMOjDBTCzQ3FynS10g2/EtfNz9V1qdK5DwnYop3fc+YN6MfY1Olv4c3jzObw8W0M5tr22OP53vgb5u3BQIIB1WiDhq2UBHfNHCYkIwBBKk4UuNnCNSFaM44T/8ck2GerGKhh8EiiDElGI7GO8xpI7BiR5RiIGwFigoXvYcyZNr+4tAW0g4ADCBAcAHhUJcagVgSYK3hCwFCZUKt4lKbiKqmsU3AOW1hi6zCAYJ0cPItiLdG0UMTyQkvhAIB9DJ5e8OoM7hOzwy4YUKkKAF0JMQP7dZK4sC5sDNBRWNdgsdp3FeTmrEC5hwAHoB0E6PM5tOnTogMEKDDgRYHTEwQQLkwWcLNkFBrf8mx6NJ/SqIOfJtDitWloiRnQnd2QAnNb3gIIn059AvXrwVvHAY4ddQCyJ4yHrpCAGwME4N1ilqB+lEPp3btbj99dOxzu9EMXWCEedKvDD2iGzf8C6NimCjrw5TfdfApOZ98b+DX4oAn9OQCCgeswoA1fuD2QYIOoMegAAQOUaOKJKKZYInht4LdfBgR86MCLKAxAwI03fnASMQb0uA5uVhEEkAIqnvghiUXaZ5qSoU04QYIsQngajRgIIKMPOx44AWUdGoDAXXkdECUGA/TmwZIiOikBlHW4yAEBp41Jg2aSUdZLCv0R18GSIJqmgBxubgCnaQvJGNxqTlbIgYB12tnhBn2ithCfkTrw53ZTcqDok/QFcKkEm2bAFztb2tmLnCJWOmmTlVoKaKYaDBqab2sqaF+oFgRZ2AE99riQKAAES9gmwgILIAWthrYqaEwyiwH/m3Tgt1oB1FZbraF61prfd6DCdoFst/S05QITlDNKh+Y2oJwGvanm7rvwuktomvReAO0cEW5bQZImxjhct8ftdYtkGDRArgTp3onwwBmYlm0HZSpb7wMOqyirA6iukS99am5gpZkP4GpMSdAcYPKvB5Pj2MK3HOswCBGDtqwDzcaXsUKRdvymtyI/IMA8VA1UZ8oJo8vLo8iG9jAHMWM8sb5tVrq0BxdbGLK3db31kC1Dl7uyynNd8PIHTc9c83UFfIqvd/G+i9rU/tIH8HgVuFSMS12zDKzXvBRFcbJOS4BmIoFm0DRoalco39UB50ayBLPlDfbeeqtCVaqRmn24/4Jrm0YlmbAyzrno/nGm9QN4j8s35ZPvZgHggf/N7Ob5da5fBx/6RvviPR9Nk5YSGLy6wq2rIjbgmkdK632ha7Bp7h1XPXfpzoUtgSujSB5gsABIlPAoKScNGpL8nnix2Q/EDVoAS6s//s1nFK6BjALgp7P0pFtNwVpIX3DOBt9jnfhGBLN5Ca5JEhBA1QLQGvfNCH5okB/o4qQArF0Afz2Ti98mo65jVc49xxtfASV2QGdNQAEVklHa7iDBCiigaqLx2WnuxzMLJvA5sTiWM8SEgQCS6nVKG6HMJjaBARhKNDpjXqtedBoGYgCDNtyaqaaIDAyMjWoGlB3NLrA5T9TpYWP50Ybi4jM9/dWNimjMnhWRR8T0HRE0K2Rhq+zzsQaVsUqjSuNK1pisARqROm9EIKb65EQKKCCQC8qfBg7wHGd0TykmS8orpkIwIC7Rj29kn8/GaEIlbqsAU0ugA69zxw0YIJKQ5FXGvHSXWwCAh+yq1GrI8q4/TmlCAxhjEi3Dy1768pfADKYwh0nMYhrzmMhMpjKXycxmOvOZ0IymNKdJzWpa85rYzKY2t8nNbnrzm+AMpzjHSc5ymvOc6EynOtfJzna6853wjKc850nPeoYgAgA7 -------------------------------------------------------------------------------- /test/ut/file/ext/lint/lint.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function(content){ 4 | // <[{require("../optmizer/js.js")}] 5 | return content + '--lint--'; 6 | }; -------------------------------------------------------------------------------- /test/ut/file/ext/modular/html.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/file/ext/modular/html.html -------------------------------------------------------------------------------- /test/ut/file/ext/modular/js.js: -------------------------------------------------------------------------------- 1 | /* 2 | * fis 3 | * http://fis.baidu.com/ 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = function(content){ 9 | return content + '--module--'; 10 | }; -------------------------------------------------------------------------------- /test/ut/file/ext/modular/js.less: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/file/ext/modular/js.less -------------------------------------------------------------------------------- /test/ut/file/ext/optimizer/optimizer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created with JetBrains WebStorm. 3 | * User: shenlixia01 4 | * Date: 13-5-16 5 | * Time: 下午5:51 6 | * To change this template use File | Settings | File Templates. 7 | */ 8 | 'use strict'; 9 | 10 | module.exports = function(content){ 11 | return content + '--opt--'; 12 | }; -------------------------------------------------------------------------------- /test/ut/file/ext/parser/js.js: -------------------------------------------------------------------------------- 1 | /* 2 | * fis 3 | * http://fis.baidu.com/ 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = function(content){ 9 | return content + '--parser--'; 10 | }; -------------------------------------------------------------------------------- /test/ut/file/fis-config-test/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * fis 3 | * http://fis.baidu.com/ 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = function(content){ 9 | console.log(content) 10 | return content + '--configTEST--'; 11 | }; -------------------------------------------------------------------------------- /test/ut/file/fis-lint-lint/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function(content){ 4 | // <[{require("../optmizer/js.js")}] 5 | return content + '--lint--'; 6 | }; -------------------------------------------------------------------------------- /test/ut/file/fis-modular-modular/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * fis 3 | * http://fis.baidu.com/ 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = function(content){ 9 | return content + '--module--'; 10 | }; -------------------------------------------------------------------------------- /test/ut/file/fis-optimizer-optimizer/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created with JetBrains WebStorm. 3 | * User: shenlixia01 4 | * Date: 13-5-16 5 | * Time: 下午5:51 6 | * To change this template use File | Settings | File Templates. 7 | */ 8 | 'use strict'; 9 | 10 | module.exports = function(content){ 11 | return content + '--opt--'; 12 | }; -------------------------------------------------------------------------------- /test/ut/file/fis-parser-options/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * fis 3 | * http://fis.baidu.com/ 4 | */ 5 | 6 | 'use strict'; 7 | module.exports = function(content, file, conf) { 8 | return content + conf.PARAtest; 9 | }; 10 | 11 | module.exports.defaultOptions = { 12 | PARAtest: '--compile--' 13 | }; 14 | 15 | -------------------------------------------------------------------------------- /test/ut/file/fis-parser-parser/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * fis 3 | * http://fis.baidu.com/ 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = function(content){ 9 | return content + '--parser--'; 10 | }; -------------------------------------------------------------------------------- /test/ut/file/fis-test-test/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * fis 3 | * http://fis.baidu.com/ 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = function(content){ 9 | return content + '--test--'; 10 | }; -------------------------------------------------------------------------------- /test/ut/fis-tmp/src/c1.js: -------------------------------------------------------------------------------- 1 | F.use('c2'); -------------------------------------------------------------------------------- /test/ut/fis-tmp/src/c2.css: -------------------------------------------------------------------------------- 1 | hahaha -------------------------------------------------------------------------------- /test/ut/fis-tmp/src/d2.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/fis-tmp/src/d2.css -------------------------------------------------------------------------------- /test/ut/fis-tmp/src/dep1.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created with JetBrains WebStorm. 3 | * User: shenlixia01 4 | * Date: 13-5-15 5 | * Time: 下午7:47 6 | * To change this template use File | Settings | File Templates. 7 | */ 8 | -------------------------------------------------------------------------------- /test/ut/fis-tmp/src/dep3.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created with JetBrains WebStorm. 3 | * User: shenlixia01 4 | * Date: 13-5-15 5 | * Time: 下午7:47 6 | * To change this template use File | Settings | File Templates. 7 | */ 8 | -------------------------------------------------------------------------------- /test/ut/img/w3c_home.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/img/w3c_home.bmp -------------------------------------------------------------------------------- /test/ut/img/w3c_home.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/img/w3c_home.gif -------------------------------------------------------------------------------- /test/ut/img/w3c_home.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/img/w3c_home.jpg -------------------------------------------------------------------------------- /test/ut/img/w3c_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/img/w3c_home.png -------------------------------------------------------------------------------- /test/ut/release/expect1/__p0__.js: -------------------------------------------------------------------------------- 1 | define(\'photo:widget/comp/comp.js\', [], function(require, exports, module){\n\nexports.name = \'comp\';\nconsole.log(\'comp loaded\');\n\n});define(\'photo:widget/list/list.js\', [\'photo:widget/comp/comp.js\'], function(require, exports, module){\n\nvar comp = require(\'photo:widget/comp/comp.js\');\nconsole.log(comp);\nexports.name = \'list\';\nconsole.log(\'list loaded\');\n\n}); -------------------------------------------------------------------------------- /test/ut/release/expect1/aa.json: -------------------------------------------------------------------------------- 1 | {"res":{ 2 | "photo:index.css":{ 3 | "uri":"/static/photo/index.css","type":"css" 4 | }, 5 | "photo:index.js":{ 6 | "uri":"/static/photo/index.js","type":"js","deps":["photo:index.css"] 7 | }, 8 | "photo:sea.js":{ 9 | "uri":"/static/photo/sea.js","type":"js" 10 | }, 11 | "photo:widget/comp/comp.js":{ 12 | "uri":"/static/photo/widget/comp/comp.js","type":"js","pkg":"p0" 13 | }, 14 | "photo:widget/list/list.css":{ 15 | "uri":"/static/photo/widget/list/list.css","type":"css" 16 | }, 17 | "photo:widget/list/list.js":{ 18 | "uri":"/static/photo/widget/list/list.js","type":"js","deps":["photo:widget/comp/comp.js","photo:widget/list/list.css"],"pkg":"p0" 19 | }, 20 | "photo:widget/list/list.tpl":{ 21 | "uri":"widget/photo/list/list.tpl","type":"tpl","deps":["photo:widget/list/list.js","photo:widget/list/list.css"] 22 | }}, 23 | "pkg":{ 24 | "p0":{"uri":"/static/aio.js","type":"js","has":["photo:widget/comp/comp.js","photo:widget/list/list.js"],"deps":["photo:widget/list/list.css"]}}} -------------------------------------------------------------------------------- /test/ut/release/expect1/bb.json: -------------------------------------------------------------------------------- 1 | {"res":{ 2 | "photo:index.css":{ 3 | "uri":"http://css.baidu.com/static/photo/index.css", 4 | "type":"css"}, 5 | "photo:index.js":{ 6 | "uri":"http://img.baidu.com/static/photo/index.js", 7 | "type":"js", 8 | "deps":["photo:index.css"]}, 9 | "photo:sea.js":{ 10 | "uri":"http://img.baidu.com/static/photo/sea.js", 11 | "type":"js"}, 12 | "photo:widget/comp/comp.js":{ 13 | "uri":"/static/photo/widget/comp/comp.js", 14 | "type":"js", 15 | "pkg":"photo:p0"}, 16 | "photo:widget/list/list.css":{ 17 | "uri":"/static/photo/widget/list/list.css", 18 | "type":"css"}, 19 | "photo:widget/list/list.js":{ 20 | "uri":"/static/photo/widget/list/list.js", 21 | "type":"js", 22 | "deps":["photo:widget/comp/comp.js","photo:widget/list/list.css"], 23 | "pkg":"photo:p0"}, 24 | "photo:widget/list/list.tpl":{ 25 | "uri":"widget/photo/list/list.tpl", 26 | "type":"tpl", 27 | "deps":["photo:widget/list/list.js","photo:widget/list/list.css"]}}, 28 | "pkg":{"photo:p0":{"uri":"/static/aio.js","type":"js","has":["photo:widget/comp/comp.js","photo:widget/list/list.js"],"deps":["photo:widget/list/list.css"]}}} -------------------------------------------------------------------------------- /test/ut/release/expect1/photo-map.json: -------------------------------------------------------------------------------- 1 | {"res":{"photo:index.css":{"uri":"http://css.baidu.com/static/photo/index.css","type":"css"},"photo:index.js":{"uri":"http://img.baidu.com/static/photo/index.js","type":"js","deps":["photo:index.css"]},"photo:sea.js":{"uri":"http://img.baidu.com/static/photo/sea.js","type":"js"},"photo:widget/comp/comp.js":{"uri":"http://img.baidu.com/static/photo/widget/comp/comp.js","type":"js","extras":{"say":"123","hi":"wenmin"},"pkg":"photo:p0"},"photo:widget/list/list.css":{"uri":"http://css.baidu.com/static/photo/widget/list/list.css","type":"css","extras":{"say":"123","hi":"wenmin"}},"photo:widget/list/list.js":{"uri":"http://img.baidu.com/static/photo/widget/list/list.js","type":"js","extras":{"say":"123","hi":"wenmin"},"deps":["photo:widget/comp/comp.js","photo:widget/list/list.css"],"pkg":"photo:p0"},"photo:widget/list/list.tpl":{"uri":"widget/photo/list/list.tpl","type":"tpl","deps":["photo:widget/list/list.js","photo:widget/list/list.css"]}},"pkg":{"photo:p0":{"uri":"http://img.baidu.com/static/photo/aio.js","type":"js","has":["photo:widget/comp/comp.js","photo:widget/list/list.js"],"deps":["photo:widget/list/list.css"]}}} -------------------------------------------------------------------------------- /test/ut/release/standard.json: -------------------------------------------------------------------------------- 1 | { 2 | "modules" : { 3 | "optimizer" : { 4 | "js" : "uglify-js", 5 | "css" : "clean-css" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /test/ut/release/test1/fis-conf.js: -------------------------------------------------------------------------------- 1 | fis.config.merge({ 2 | namespace : 'photo', 3 | modules : { 4 | //打包调用fis-packager-your_packager插件进行处理 5 | packager : 'map' 6 | }, 7 | roadmap : { 8 | domain : { 9 | '**.js' : 'http://img.baidu.com', 10 | '**.css' : 'http://css.baidu.com' 11 | }, 12 | path : [ 13 | { 14 | reg : /^\/test\//i, 15 | release : false 16 | }, 17 | { 18 | reg : /\.tmpl$/i, 19 | release : false 20 | }, 21 | { 22 | reg : /^\/widget\/.*\.(js|css)$/i, 23 | isMod : true, 24 | release : '/static/${namespace}$&', 25 | extras : { 26 | say : '123', 27 | hi : 'wenmin' 28 | } 29 | }, 30 | { 31 | reg : /^\/widget\/(.*\.tpl)$/i, 32 | isMod : true, 33 | url : 'widget/${namespace}/$1', 34 | release : '/template/widget/${namespace}/$1' 35 | }, 36 | { 37 | reg : /^\/plugin\//i 38 | }, 39 | { 40 | reg : /^\/.+\.tpl$/i, 41 | release : '/template/${namespace}$&' 42 | }, 43 | { 44 | reg : /^\/photo-map\.json$/i, 45 | release : '/config$&' 46 | }, 47 | { 48 | reg : /^.*$/, 49 | release : '/static/${namespace}$&' 50 | } 51 | ] 52 | }, 53 | settings : { 54 | postprocessor : { 55 | jswrapper : { 56 | type : 'amd' 57 | } 58 | } 59 | }, 60 | deploy : { 61 | 'rd-test' : { 62 | receiver : 'http://zhangyunlong.fe.baidu.com/receiver.php', 63 | to : '/home/zhangyunlong/public_html' 64 | } 65 | }, 66 | pack : { 67 | 'aio.js' : [ 68 | 'widget/comp/comp.js', 69 | 'widget/list/list.js' 70 | ] 71 | } 72 | }); 73 | -------------------------------------------------------------------------------- /test/ut/release/test1/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 20px; 3 | } -------------------------------------------------------------------------------- /test/ut/release/test1/index.js: -------------------------------------------------------------------------------- 1 | console.log('index.js'); -------------------------------------------------------------------------------- /test/ut/release/test1/index.tpl: -------------------------------------------------------------------------------- 1 | {%html%} 2 | {%head%} 3 | 4 | name----- 5 | {%/head%} 6 | {%body%} 7 | 8 | {%require name="photo:sea.js"%} 9 | {%require name="photo:index.js"%} 10 | 11 | 12 | 13 |

hello world fis.

14 |

I'm a boy.

15 |

test1

16 | 17 | {%widget name="photo:widget/list/list.tpl"%} 18 | 19 | {%require name="photo:index.css"%} 20 | {%/body%} 21 | {%/html%} -------------------------------------------------------------------------------- /test/ut/release/test1/npm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/release/test1/npm.png -------------------------------------------------------------------------------- /test/ut/release/test1/plugin/FISResource.class.php: -------------------------------------------------------------------------------- 1 | '; 5 | 6 | private static $arrMap = array(); 7 | private static $arrLoaded = array(); 8 | private static $arrStaticCollection = array(); 9 | private static $arrScriptPool = array(); 10 | 11 | public static function reset(){ 12 | self::$arrMap = array(); 13 | self::$arrLoaded = array(); 14 | self::$arrStaticCollection = array(); 15 | self::$arrScriptPool = array(); 16 | } 17 | 18 | public static function cssHook(){ 19 | return self::CSS_LINKS_HOOK; 20 | } 21 | 22 | public static function renderResponse($strContent){ 23 | $intPos = strpos($strContent, self::CSS_LINKS_HOOK); 24 | if($intPos !== false){ 25 | $strContent = substr_replace($strContent, self::render('css'), $intPos, strlen(self::CSS_LINKS_HOOK)); 26 | } 27 | self::reset(); 28 | return $strContent; 29 | } 30 | 31 | public static function render($type){ 32 | $html = ''; 33 | if(!empty(self::$arrStaticCollection[$type])){ 34 | $arrURIs = &self::$arrStaticCollection[$type]; 35 | if($type === 'js'){ 36 | $html = ''; 37 | } else if($type === 'css'){ 38 | $html = ''; 39 | } 40 | } 41 | return $html; 42 | } 43 | 44 | public static function addScriptPool($str){ 45 | self::$arrScriptPool[] = $str; 46 | } 47 | 48 | public static function renderScriptPool(){ 49 | $html = ''; 50 | if(!empty(self::$arrScriptPool)){ 51 | $html = ''; 52 | } 53 | return $html; 54 | } 55 | 56 | public static function register($strNamespace, $smarty){ 57 | if($strNamespace === '__global__'){ 58 | $strMapName = 'map.json'; 59 | } else { 60 | $strMapName = $strNamespace . '-map.json'; 61 | } 62 | $arrConfigDir = $smarty->getConfigDir(); 63 | foreach ($arrConfigDir as $strDir) { 64 | $strPath = preg_replace('/[\\/\\\\]+/', '/', $strDir . '/' . $strMapName); 65 | if(is_file($strPath)){ 66 | self::$arrMap[$strNamespace] = json_decode(file_get_contents($strPath), true); 67 | return true; 68 | } 69 | } 70 | return false; 71 | } 72 | 73 | public static function load($strName, $smarty){ 74 | $strLoadedURI = self::$arrLoaded[$strName]; 75 | if(isset($strLoadedURI)){ 76 | return $strLoadedURI; 77 | } else { 78 | $intPos = strpos($strName, ':'); 79 | if($intPos === false){ 80 | $strNamespace = '__global__'; 81 | } else { 82 | $strNamespace = substr($strName, 0, $intPos); 83 | } 84 | if(isset(self::$arrMap[$strNamespace]) || self::register($strNamespace, $smarty)){ 85 | $arrMap = &self::$arrMap[$strNamespace]; 86 | $arrRes = &$arrMap['res'][$strName]; 87 | if(isset($arrRes)){ 88 | if(isset($arrRes['pkg'])){ 89 | $arrPkg = &$arrMap['pkg'][$arrRes['pkg']]; 90 | $strURI = $arrPkg['uri']; 91 | foreach ($arrPkg['has'] as $strResId) { 92 | //todo 93 | self::$arrLoaded[$strName] = $strURI; 94 | } 95 | } else { 96 | if(isset($arrRes['deps'])){ 97 | foreach ($arrRes['deps'] as $strDep) { 98 | self::load($strDep, $smarty); 99 | } 100 | } 101 | $strURI = $arrRes['uri']; 102 | self::$arrLoaded[$strName] = $strURI; 103 | } 104 | self::$arrStaticCollection[$arrRes['type']][] = $strURI; 105 | return $strURI; 106 | } else { 107 | trigger_error('undefined resource "' . $strName . '"', E_USER_ERROR); 108 | } 109 | } else { 110 | trigger_error('missing map file of "' . $strNamespace . '"', E_USER_ERROR); 111 | } 112 | } 113 | trigger_error('unknown resource load error', E_USER_ERROR); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /test/ut/release/test1/plugin/compiler.body.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return ''; 9 | } 10 | 11 | function smarty_compiler_bodyclose($arrParams, $smarty){ 12 | $strCode = ''; 13 | $strCode .= ''; 19 | return $strCode; 20 | } -------------------------------------------------------------------------------- /test/ut/release/test1/plugin/compiler.head.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return ''; 9 | } 10 | 11 | function smarty_compiler_headclose($arrParams, $smarty){ 12 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 13 | $strCode = ''; 17 | $strCode .= ''; 18 | return $strCode; 19 | } -------------------------------------------------------------------------------- /test/ut/release/test1/plugin/compiler.html.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return "\n"; 9 | } 10 | 11 | function smarty_compiler_htmlclose($arrParams, $smarty){ 12 | $strCode = 'registerFilter(\'output\', array(\'FISResource\', \'renderResponse\'));'; 14 | $strCode .= '?>'; 15 | $strCode .= ''; 16 | return $strCode; 17 | } -------------------------------------------------------------------------------- /test/ut/release/test1/plugin/compiler.require.php: -------------------------------------------------------------------------------- 1 | smarty);'; 10 | $strCode .= '?>'; 11 | } 12 | return $strCode; 13 | } -------------------------------------------------------------------------------- /test/ut/release/test1/plugin/compiler.script.php: -------------------------------------------------------------------------------- 1 | '; 5 | } 6 | 7 | function smarty_compiler_scriptclose($params, $smarty){ 8 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 9 | $strCode = ''; 15 | return $strCode; 16 | } -------------------------------------------------------------------------------- /test/ut/release/test1/plugin/compiler.widget.php: -------------------------------------------------------------------------------- 1 | getConfigDir(); 13 | foreach ($arrConfigDir as $strDir) { 14 | $strPath = preg_replace('/[\\/\\\\]+/', '/', $strDir . '/' . $strFilename); 15 | if(is_file($strPath)){ 16 | self::$arrCached[$strFilename] = $strPath; 17 | return $strPath; 18 | } 19 | } 20 | } 21 | trigger_error('missing map file "' . $strFilename . '"', E_USER_ERROR); 22 | } 23 | } 24 | 25 | function smarty_compiler_widget($arrParams, $smarty){ 26 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 27 | $strCode = ' $_value) { 36 | if (is_int($_key)) { 37 | $arrFuncParams[] = "$_key=>$_value"; 38 | } else { 39 | $arrFuncParams[] = "'$_key'=>$_value"; 40 | } 41 | } 42 | $strFuncParams = 'array(' . implode(',', $arrFuncParams) . ')'; 43 | $strTplFuncName = '\'smarty_template_function_\'.' . $strCall; 44 | $strCallTplFunc = 'call_user_func('. $strTplFuncName . ',$_smarty_tpl,' . $strFuncParams . ');'; 45 | 46 | $strCode .= 'if(is_callable('. $strTplFuncName . ')){'; 47 | $strCode .= $strCallTplFunc; 48 | $strCode .= '}else{'; 49 | } 50 | if($strName){ 51 | $strCode .= '$_tpl_path=FISResource::load(' . $strName . ',$_smarty_tpl->smarty);'; 52 | $strCode .= 'if(isset($_tpl_path)){'; 53 | if($bHasCall){ 54 | $strCode .= '$_smarty_tpl->smarty->fetch($_tpl_path);'; 55 | $strCode .= 'if(is_callable('. $strTplFuncName . ')){'; 56 | $strCode .= $strCallTplFunc; 57 | $strCode .= '}else{'; 58 | $strCode .= 'trigger_error(\'missing function define "\'.' . $strTplFuncName . '.\'" in tpl "\'.$_tpl_path.\'"\', E_USER_ERROR);'; 59 | $strCode .= '}'; 60 | } else { 61 | $strCode .= 'echo $_smarty_tpl->smarty->fetch($_tpl_path);'; 62 | } 63 | $strCode .= '}else{'; 64 | $strCode .= 'trigger_error(\'unable to locale resource "\'.' . $strName . '.\'"\', E_USER_ERROR);'; 65 | $strCode .= '}'; 66 | } else { 67 | trigger_error('undefined widget name in file "' . $smarty->_current_file . '"', E_USER_ERROR); 68 | } 69 | if($bHasCall){ 70 | $strCode .= '}'; 71 | } 72 | $strCode .= '?>'; 73 | return $strCode; 74 | } -------------------------------------------------------------------------------- /test/ut/release/test1/sea.js: -------------------------------------------------------------------------------- 1 | /*! SeaJS 2.0.0 | seajs.org/LICENSE.md */ 2 | (function(u,r){function x(a){return function(c){return Object.prototype.toString.call(c)==="[object "+a+"]"}}function R(a){a=a.replace(ka,"/");for(a=a.replace(la,"$1/");a.match(S);)a=a.replace(S,"/");return a}function T(a){a=R(a);ma.test(a)?a=a.slice(0,-1):na.test(a)||(a+=".js");return a.replace(":80/","/")}function U(a,c){return oa.test(a)?a:pa.test(a)?(c||v).match(H)[0]+a:qa.test(a)?(v.match(ra)||["/"])[0]+a.substring(1):j.base+a}function I(a,c){if(!a)return"";var b=a,d=j.alias,b=a=d&&J(d[b])?d[b]: 3 | b,d=j.paths,f;if(d&&(f=b.match(sa))&&J(d[f[1]]))b=d[f[1]]+f[2];f=b;var K=j.vars;K&&-1 ")),p.length=0,c(!0)):(ba[a]=f,X(f,c))}function d(a){!a&&e.status=ga)return a.exports;a.status=ga;b.resolve=c;b.async=function(a,d){D(c(a),d);return b};var d=a.factory,d=y(d)?d(b,a.exports={},a):d;a.exports=d===r?a.exports:d;a.status=Ba;return a.exports}function Z(a){for(var c=[],b=0;b1*navigator.userAgent.replace(/.*AppleWebKit\/(\d+)\..*/,"$1"),za=/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\/\*[\S\s]*?\*\/|\/(?:\\\/|[^/\r\n])+\/(?=[^\/])|\/\/.*|\.\s*require|(?:^|[^$])\brequire\s*\(\s*(["'])(.+?)\1\s*\)/g, 13 | ya=/\\\\/g,l=e.cache={},F,M={},N={},G={},ba={},va=1,E=2,L=3,ga=4,Ba=5;B.prototype.destroy=function(){delete l[this.uri];delete N[this.uri]};var p=[];e.use=function(a,c){ha(function(){D(s(a),c)});return e};B.load=D;e.resolve=I;u.define=xa;e.require=function(a){return(l[I(a)]||{}).exports};var P=ia,ja=P.match(/^(.+?\/)(?:seajs\/)+(?:\d[^/]+\/)?$/);ja&&(P=ja[1]);var j=O.data={base:P,charset:"utf-8",preload:[]};e.config=O;var Q,h=h.search.replace(/(seajs-\w+)(&|$)/g,"$1=1$2"),h=h+(" "+q.cookie);h.replace(/seajs-(\w+)=1/g, 14 | function(a,c){(Q||(Q=[])).push(c)});O({plugins:Q});h=g.getAttribute("data-config");g=g.getAttribute("data-main");h&&j.preload.push(h);g&&e.use(g);if(m&&m.args){g=["define","config","use"];m=m.args;for(h=0;hwidget run! 2 | {%script%} 3 | seajs.use('photo:widget/list/list.js', function(list){ 4 | console.log(list); 5 | }); 6 | {%/script%} -------------------------------------------------------------------------------- /test/ut/release/test2/fis-conf.js: -------------------------------------------------------------------------------- 1 | fis.config.merge({ 2 | namespace : 'photo', 3 | modules : { 4 | //打包调用fis-packager-your_packager插件进行处理 5 | packager : 'map' 6 | }, 7 | 8 | roadmap : { 9 | domain : { 10 | '**.js' : 'http://img.baidu.com', 11 | '**.css' : 'http://css.baidu.com' 12 | }, 13 | path : [ 14 | { 15 | reg : /^\/test\//i, 16 | release : false 17 | }, 18 | { 19 | reg : /\.tmpl$/i, 20 | release : false 21 | }, 22 | { 23 | reg : /^\/widget\/.*\.(js|css)$/i, 24 | isMod : true, 25 | release : '/static/${namespace}$&' 26 | }, 27 | { 28 | reg : /^\/ui\/.*\.(js|css)$/i, 29 | isMod : true, 30 | release : '/static/${namespace}$&' 31 | }, 32 | { 33 | reg : /^\/widget\/(.*\.tpl)$/i, 34 | isMod : true, 35 | url : 'widget/${namespace}/$1', 36 | release : '/template/widget/${namespace}/$1' 37 | }, 38 | { 39 | reg : /^\/plugin\//i 40 | }, 41 | { 42 | reg : /^\/.+\.tpl$/i, 43 | release : '/template/${namespace}$&' 44 | }, 45 | { 46 | reg : /^\/photo-map\.json$/i, 47 | release : '/config$&' 48 | }, 49 | { 50 | reg : /^.*$/, 51 | release : '/static/${namespace}$&' 52 | } 53 | ] 54 | }, 55 | settings : { 56 | modular : { 57 | reqlang : { 58 | wrap : 'amd' 59 | } 60 | } 61 | }, 62 | deploy : { 63 | 'rd-test' : { 64 | receiver : 'http://zhangyunlong.fe.baidu.com/receiver.php', 65 | to : '/home/zhangyunlong/public_html' 66 | } 67 | }, 68 | merge : { 69 | 'static/aio.js' : [ 70 | 'widget/comp/comp.js', 71 | 'widget/list/list.js' 72 | ] 73 | } 74 | }); 75 | -------------------------------------------------------------------------------- /test/ut/release/test2/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 20px; 3 | } -------------------------------------------------------------------------------- /test/ut/release/test2/index.js: -------------------------------------------------------------------------------- 1 | console.log('index.js'); -------------------------------------------------------------------------------- /test/ut/release/test2/index.tpl: -------------------------------------------------------------------------------- 1 | {%html%} 2 | {%head%} 3 | 4 | name----- 5 | {%/head%} 6 | {%body%} 7 | 8 | {%require name="photo:sea.js"%} 9 | {%require name="photo:index.js"%} 10 | {%require name="photo:ui/a/a.js"%} 11 | {%script%} 12 | seajs.use('photo:ui/a/a.js', function(a){ 13 | 14 | }); 15 | {%/script%} 16 | 17 | 18 |

hello world fis.

19 |

I'm a boy.

20 |

test1

21 |

test2

22 |

test3

23 |

test4

24 | 25 | {%widget name="photo:widget/list/list.tpl"%} 26 | 27 | {%require name="photo:index.css"%} 28 | {%/body%} 29 | {%/html%} -------------------------------------------------------------------------------- /test/ut/release/test2/npm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/release/test2/npm.png -------------------------------------------------------------------------------- /test/ut/release/test2/plugin/FISResource.class.php: -------------------------------------------------------------------------------- 1 | '; 5 | 6 | private static $arrMap = array(); 7 | private static $arrLoaded = array(); 8 | private static $arrStaticCollection = array(); 9 | private static $arrScriptPool = array(); 10 | 11 | public static function reset(){ 12 | self::$arrMap = array(); 13 | self::$arrLoaded = array(); 14 | self::$arrStaticCollection = array(); 15 | self::$arrScriptPool = array(); 16 | } 17 | 18 | public static function cssHook(){ 19 | return self::CSS_LINKS_HOOK; 20 | } 21 | 22 | public static function renderResponse($strContent){ 23 | $intPos = strpos($strContent, self::CSS_LINKS_HOOK); 24 | if($intPos !== false){ 25 | $strContent = substr_replace($strContent, self::render('css'), $intPos, strlen(self::CSS_LINKS_HOOK)); 26 | } 27 | self::reset(); 28 | return $strContent; 29 | } 30 | 31 | public static function render($type){ 32 | $html = ''; 33 | if(!empty(self::$arrStaticCollection[$type])){ 34 | $arrURIs = &self::$arrStaticCollection[$type]; 35 | if($type === 'js'){ 36 | $html = ''; 37 | } else if($type === 'css'){ 38 | $html = ''; 39 | } 40 | } 41 | return $html; 42 | } 43 | 44 | public static function addScriptPool($str){ 45 | self::$arrScriptPool[] = $str; 46 | } 47 | 48 | public static function renderScriptPool(){ 49 | $html = ''; 50 | if(!empty(self::$arrScriptPool)){ 51 | $html = ''; 52 | } 53 | return $html; 54 | } 55 | 56 | public static function register($strNamespace, $smarty){ 57 | if($strNamespace === '__global__'){ 58 | $strMapName = 'map.json'; 59 | } else { 60 | $strMapName = $strNamespace . '-map.json'; 61 | } 62 | $arrConfigDir = $smarty->getConfigDir(); 63 | foreach ($arrConfigDir as $strDir) { 64 | $strPath = preg_replace('/[\\/\\\\]+/', '/', $strDir . '/' . $strMapName); 65 | if(is_file($strPath)){ 66 | self::$arrMap[$strNamespace] = json_decode(file_get_contents($strPath), true); 67 | return true; 68 | } 69 | } 70 | return false; 71 | } 72 | 73 | public static function load($strName, $smarty){ 74 | $strLoadedURI = self::$arrLoaded[$strName]; 75 | if(isset($strLoadedURI)){ 76 | return $strLoadedURI; 77 | } else { 78 | $intPos = strpos($strName, ':'); 79 | if($intPos === false){ 80 | $strNamespace = '__global__'; 81 | } else { 82 | $strNamespace = substr($strName, 0, $intPos); 83 | } 84 | if(isset(self::$arrMap[$strNamespace]) || self::register($strNamespace, $smarty)){ 85 | $arrMap = &self::$arrMap[$strNamespace]; 86 | $arrRes = &$arrMap['res'][$strName]; 87 | if(isset($arrRes)){ 88 | if(isset($arrRes['pkg'])){ 89 | $arrPkg = &$arrMap['pkg'][$arrRes['pkg']]; 90 | $strURI = $arrPkg['uri']; 91 | foreach ($arrPkg['has'] as $strResId) { 92 | //todo 93 | self::$arrLoaded[$strName] = $strURI; 94 | } 95 | } else { 96 | if(isset($arrRes['deps'])){ 97 | foreach ($arrRes['deps'] as $strDep) { 98 | self::load($strDep, $smarty); 99 | } 100 | } 101 | $strURI = $arrRes['uri']; 102 | self::$arrLoaded[$strName] = $strURI; 103 | } 104 | self::$arrStaticCollection[$arrRes['type']][] = $strURI; 105 | return $strURI; 106 | } else { 107 | trigger_error('undefined resource "' . $strName . '"', E_USER_ERROR); 108 | } 109 | } else { 110 | trigger_error('missing map file of "' . $strNamespace . '"', E_USER_ERROR); 111 | } 112 | } 113 | trigger_error('unknown resource load error', E_USER_ERROR); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /test/ut/release/test2/plugin/compiler.body.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return ''; 9 | } 10 | 11 | function smarty_compiler_bodyclose($arrParams, $smarty){ 12 | $strCode = ''; 13 | $strCode .= ''; 19 | return $strCode; 20 | } -------------------------------------------------------------------------------- /test/ut/release/test2/plugin/compiler.head.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return ''; 9 | } 10 | 11 | function smarty_compiler_headclose($arrParams, $smarty){ 12 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 13 | $strCode = ''; 17 | $strCode .= ''; 18 | return $strCode; 19 | } -------------------------------------------------------------------------------- /test/ut/release/test2/plugin/compiler.html.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return "\n"; 9 | } 10 | 11 | function smarty_compiler_htmlclose($arrParams, $smarty){ 12 | $strCode = 'registerFilter(\'output\', array(\'FISResource\', \'renderResponse\'));'; 14 | $strCode .= '?>'; 15 | $strCode .= ''; 16 | return $strCode; 17 | } -------------------------------------------------------------------------------- /test/ut/release/test2/plugin/compiler.require.php: -------------------------------------------------------------------------------- 1 | smarty);'; 10 | $strCode .= '?>'; 11 | } 12 | return $strCode; 13 | } -------------------------------------------------------------------------------- /test/ut/release/test2/plugin/compiler.script.php: -------------------------------------------------------------------------------- 1 | '; 5 | } 6 | 7 | function smarty_compiler_scriptclose($params, $smarty){ 8 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 9 | $strCode = ''; 15 | return $strCode; 16 | } -------------------------------------------------------------------------------- /test/ut/release/test2/plugin/compiler.widget.php: -------------------------------------------------------------------------------- 1 | getConfigDir(); 13 | foreach ($arrConfigDir as $strDir) { 14 | $strPath = preg_replace('/[\\/\\\\]+/', '/', $strDir . '/' . $strFilename); 15 | if(is_file($strPath)){ 16 | self::$arrCached[$strFilename] = $strPath; 17 | return $strPath; 18 | } 19 | } 20 | } 21 | trigger_error('missing map file "' . $strFilename . '"', E_USER_ERROR); 22 | } 23 | } 24 | 25 | function smarty_compiler_widget($arrParams, $smarty){ 26 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 27 | $strCode = ' $_value) { 36 | if (is_int($_key)) { 37 | $arrFuncParams[] = "$_key=>$_value"; 38 | } else { 39 | $arrFuncParams[] = "'$_key'=>$_value"; 40 | } 41 | } 42 | $strFuncParams = 'array(' . implode(',', $arrFuncParams) . ')'; 43 | $strTplFuncName = '\'smarty_template_function_\'.' . $strCall; 44 | $strCallTplFunc = 'call_user_func('. $strTplFuncName . ',$_smarty_tpl,' . $strFuncParams . ');'; 45 | 46 | $strCode .= 'if(is_callable('. $strTplFuncName . ')){'; 47 | $strCode .= $strCallTplFunc; 48 | $strCode .= '}else{'; 49 | } 50 | if($strName){ 51 | $strCode .= '$_tpl_path=FISResource::load(' . $strName . ',$_smarty_tpl->smarty);'; 52 | $strCode .= 'if(isset($_tpl_path)){'; 53 | if($bHasCall){ 54 | $strCode .= '$_smarty_tpl->smarty->fetch($_tpl_path);'; 55 | $strCode .= 'if(is_callable('. $strTplFuncName . ')){'; 56 | $strCode .= $strCallTplFunc; 57 | $strCode .= '}else{'; 58 | $strCode .= 'trigger_error(\'missing function define "\'.' . $strTplFuncName . '.\'" in tpl "\'.$_tpl_path.\'"\', E_USER_ERROR);'; 59 | $strCode .= '}'; 60 | } else { 61 | $strCode .= 'echo $_smarty_tpl->smarty->fetch($_tpl_path);'; 62 | } 63 | $strCode .= '}else{'; 64 | $strCode .= 'trigger_error(\'unable to locale resource "\'.' . $strName . '.\'"\', E_USER_ERROR);'; 65 | $strCode .= '}'; 66 | } else { 67 | trigger_error('undefined widget name in file "' . $smarty->_current_file . '"', E_USER_ERROR); 68 | } 69 | if($bHasCall){ 70 | $strCode .= '}'; 71 | } 72 | $strCode .= '?>'; 73 | return $strCode; 74 | } -------------------------------------------------------------------------------- /test/ut/release/test2/sea.js: -------------------------------------------------------------------------------- 1 | /*! SeaJS 2.0.0 | seajs.org/LICENSE.md */ 2 | (function(u,r){function x(a){return function(c){return Object.prototype.toString.call(c)==="[object "+a+"]"}}function R(a){a=a.replace(ka,"/");for(a=a.replace(la,"$1/");a.match(S);)a=a.replace(S,"/");return a}function T(a){a=R(a);ma.test(a)?a=a.slice(0,-1):na.test(a)||(a+=".js");return a.replace(":80/","/")}function U(a,c){return oa.test(a)?a:pa.test(a)?(c||v).match(H)[0]+a:qa.test(a)?(v.match(ra)||["/"])[0]+a.substring(1):j.base+a}function I(a,c){if(!a)return"";var b=a,d=j.alias,b=a=d&&J(d[b])?d[b]: 3 | b,d=j.paths,f;if(d&&(f=b.match(sa))&&J(d[f[1]]))b=d[f[1]]+f[2];f=b;var K=j.vars;K&&-1 ")),p.length=0,c(!0)):(ba[a]=f,X(f,c))}function d(a){!a&&e.status=ga)return a.exports;a.status=ga;b.resolve=c;b.async=function(a,d){D(c(a),d);return b};var d=a.factory,d=y(d)?d(b,a.exports={},a):d;a.exports=d===r?a.exports:d;a.status=Ba;return a.exports}function Z(a){for(var c=[],b=0;b1*navigator.userAgent.replace(/.*AppleWebKit\/(\d+)\..*/,"$1"),za=/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\/\*[\S\s]*?\*\/|\/(?:\\\/|[^/\r\n])+\/(?=[^\/])|\/\/.*|\.\s*require|(?:^|[^$])\brequire\s*\(\s*(["'])(.+?)\1\s*\)/g, 13 | ya=/\\\\/g,l=e.cache={},F,M={},N={},G={},ba={},va=1,E=2,L=3,ga=4,Ba=5;B.prototype.destroy=function(){delete l[this.uri];delete N[this.uri]};var p=[];e.use=function(a,c){ha(function(){D(s(a),c)});return e};B.load=D;e.resolve=I;u.define=xa;e.require=function(a){return(l[I(a)]||{}).exports};var P=ia,ja=P.match(/^(.+?\/)(?:seajs\/)+(?:\d[^/]+\/)?$/);ja&&(P=ja[1]);var j=O.data={base:P,charset:"utf-8",preload:[]};e.config=O;var Q,h=h.search.replace(/(seajs-\w+)(&|$)/g,"$1=1$2"),h=h+(" "+q.cookie);h.replace(/seajs-(\w+)=1/g, 14 | function(a,c){(Q||(Q=[])).push(c)});O({plugins:Q});h=g.getAttribute("data-config");g=g.getAttribute("data-main");h&&j.preload.push(h);g&&e.use(g);if(m&&m.args){g=["define","config","use"];m=m.args;for(h=0;hwidget run! 2 | {%script%} 3 | seajs.use('photo:widget/list/list.js', function(list){ 4 | console.log(list); 5 | }); 6 | {%/script%} -------------------------------------------------------------------------------- /test/ut/release/test3/fis-conf.js: -------------------------------------------------------------------------------- 1 | fis.config.merge({ 2 | namespace : 'photo', 3 | modules : { 4 | //打包调用fis-packager-your_packager插件进行处理 5 | packager : 'map' 6 | }, 7 | roadmap : { 8 | domain : { 9 | '*.js' : 'http://img.baidu.com', 10 | '*.css' : 'http://css.baidu.com' 11 | }, 12 | path : [ 13 | { 14 | reg : /^\/test\//i, 15 | release : false 16 | }, 17 | { 18 | reg : /\.tmpl$/i, 19 | release : false 20 | }, 21 | { 22 | reg : /^\/widget\/.*\.(js|css)$/i, 23 | isMod : true, 24 | release : '/static/${namespace}$&' 25 | }, 26 | { 27 | reg : /^\/ui\/.*\.(js|css)$/i, 28 | isMod : true, 29 | release : '/static/${namespace}$&' 30 | }, 31 | { 32 | reg : /^\/widget\/(.*\.tpl)$/i, 33 | isMod : true, 34 | url : 'widget/${namespace}/$1', 35 | release : '/template/widget/${namespace}/$1' 36 | }, 37 | { 38 | reg : /^\/plugin\//i 39 | }, 40 | { 41 | reg : /^\/.+\.tpl$/i, 42 | release : '/template/${namespace}$&' 43 | }, 44 | { 45 | reg : /^\/photo-map\.json$/i, 46 | release : '/config$&' 47 | }, 48 | { 49 | reg : /^.*$/, 50 | release : '/static/${namespace}$&' 51 | } 52 | 53 | ] 54 | }, 55 | settings : { 56 | modular : { 57 | reqlang : { 58 | wrap : 'amd' 59 | } 60 | } 61 | }, 62 | deploy : { 63 | 'rd-test' : { 64 | receiver : 'http://zhangyunlong.fe.baidu.com/receiver.php', 65 | to : '/home/zhangyunlong/public_html' 66 | } 67 | }, 68 | pack : { 69 | 'static/aio.js' : [ 70 | 'widget/comp/comp.js', 71 | 'widget/list/list.js' 72 | ], 73 | 'static/aio1.js':[ 74 | 'ui/a/a.js', 75 | 'ui/b/b.js' 76 | ] 77 | } 78 | }); 79 | -------------------------------------------------------------------------------- /test/ut/release/test3/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 20px; 3 | } -------------------------------------------------------------------------------- /test/ut/release/test3/index.js: -------------------------------------------------------------------------------- 1 | console.log('index.js'); -------------------------------------------------------------------------------- /test/ut/release/test3/index.tpl: -------------------------------------------------------------------------------- 1 | {%html%} 2 | {%head%} 3 | 4 | name----- 5 | {%/head%} 6 | {%body%} 7 | 8 | {%require name="photo:sea.js"%} 9 | {%require name="photo:index.js"%} 10 | {%require name="photo:ui/a/a.js"%} 11 | {%script%} 12 | seajs.use('photo:ui/a/a.js', function(a){ 13 | 14 | }); 15 | {%/script%} 16 | 17 | 18 |

hello world fis.

19 |

I'm a boy.

20 |

test1

21 |

test2

22 |

test3

23 |

test4

24 | 25 | {%widget name="photo:widget/list/list.tpl"%} 26 | 27 | {%require name="photo:index.css"%} 28 | {%/body%} 29 | {%/html%} -------------------------------------------------------------------------------- /test/ut/release/test3/npm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/release/test3/npm.png -------------------------------------------------------------------------------- /test/ut/release/test3/plugin/FISResource.class.php: -------------------------------------------------------------------------------- 1 | '; 5 | 6 | private static $arrMap = array(); 7 | private static $arrLoaded = array(); 8 | private static $arrStaticCollection = array(); 9 | private static $arrScriptPool = array(); 10 | 11 | public static function reset(){ 12 | self::$arrMap = array(); 13 | self::$arrLoaded = array(); 14 | self::$arrStaticCollection = array(); 15 | self::$arrScriptPool = array(); 16 | } 17 | 18 | public static function cssHook(){ 19 | return self::CSS_LINKS_HOOK; 20 | } 21 | 22 | public static function renderResponse($strContent){ 23 | $intPos = strpos($strContent, self::CSS_LINKS_HOOK); 24 | if($intPos !== false){ 25 | $strContent = substr_replace($strContent, self::render('css'), $intPos, strlen(self::CSS_LINKS_HOOK)); 26 | } 27 | self::reset(); 28 | return $strContent; 29 | } 30 | 31 | public static function render($type){ 32 | $html = ''; 33 | if(!empty(self::$arrStaticCollection[$type])){ 34 | $arrURIs = &self::$arrStaticCollection[$type]; 35 | if($type === 'js'){ 36 | $html = ''; 37 | } else if($type === 'css'){ 38 | $html = ''; 39 | } 40 | } 41 | return $html; 42 | } 43 | 44 | public static function addScriptPool($str){ 45 | self::$arrScriptPool[] = $str; 46 | } 47 | 48 | public static function renderScriptPool(){ 49 | $html = ''; 50 | if(!empty(self::$arrScriptPool)){ 51 | $html = ''; 52 | } 53 | return $html; 54 | } 55 | 56 | public static function register($strNamespace, $smarty){ 57 | if($strNamespace === '__global__'){ 58 | $strMapName = 'map.json'; 59 | } else { 60 | $strMapName = $strNamespace . '-map.json'; 61 | } 62 | $arrConfigDir = $smarty->getConfigDir(); 63 | foreach ($arrConfigDir as $strDir) { 64 | $strPath = preg_replace('/[\\/\\\\]+/', '/', $strDir . '/' . $strMapName); 65 | if(is_file($strPath)){ 66 | self::$arrMap[$strNamespace] = json_decode(file_get_contents($strPath), true); 67 | return true; 68 | } 69 | } 70 | return false; 71 | } 72 | 73 | public static function load($strName, $smarty){ 74 | $strLoadedURI = self::$arrLoaded[$strName]; 75 | if(isset($strLoadedURI)){ 76 | return $strLoadedURI; 77 | } else { 78 | $intPos = strpos($strName, ':'); 79 | if($intPos === false){ 80 | $strNamespace = '__global__'; 81 | } else { 82 | $strNamespace = substr($strName, 0, $intPos); 83 | } 84 | if(isset(self::$arrMap[$strNamespace]) || self::register($strNamespace, $smarty)){ 85 | $arrMap = &self::$arrMap[$strNamespace]; 86 | $arrRes = &$arrMap['res'][$strName]; 87 | if(isset($arrRes)){ 88 | if(isset($arrRes['pkg'])){ 89 | $arrPkg = &$arrMap['pkg'][$arrRes['pkg']]; 90 | $strURI = $arrPkg['uri']; 91 | foreach ($arrPkg['has'] as $strResId) { 92 | //todo 93 | self::$arrLoaded[$strName] = $strURI; 94 | } 95 | } else { 96 | if(isset($arrRes['deps'])){ 97 | foreach ($arrRes['deps'] as $strDep) { 98 | self::load($strDep, $smarty); 99 | } 100 | } 101 | $strURI = $arrRes['uri']; 102 | self::$arrLoaded[$strName] = $strURI; 103 | } 104 | self::$arrStaticCollection[$arrRes['type']][] = $strURI; 105 | return $strURI; 106 | } else { 107 | trigger_error('undefined resource "' . $strName . '"', E_USER_ERROR); 108 | } 109 | } else { 110 | trigger_error('missing map file of "' . $strNamespace . '"', E_USER_ERROR); 111 | } 112 | } 113 | trigger_error('unknown resource load error', E_USER_ERROR); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /test/ut/release/test3/plugin/compiler.body.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return ''; 9 | } 10 | 11 | function smarty_compiler_bodyclose($arrParams, $smarty){ 12 | $strCode = ''; 13 | $strCode .= ''; 19 | return $strCode; 20 | } -------------------------------------------------------------------------------- /test/ut/release/test3/plugin/compiler.head.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return ''; 9 | } 10 | 11 | function smarty_compiler_headclose($arrParams, $smarty){ 12 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 13 | $strCode = ''; 17 | $strCode .= ''; 18 | return $strCode; 19 | } -------------------------------------------------------------------------------- /test/ut/release/test3/plugin/compiler.html.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return "\n"; 9 | } 10 | 11 | function smarty_compiler_htmlclose($arrParams, $smarty){ 12 | $strCode = 'registerFilter(\'output\', array(\'FISResource\', \'renderResponse\'));'; 14 | $strCode .= '?>'; 15 | $strCode .= ''; 16 | return $strCode; 17 | } -------------------------------------------------------------------------------- /test/ut/release/test3/plugin/compiler.require.php: -------------------------------------------------------------------------------- 1 | smarty);'; 10 | $strCode .= '?>'; 11 | } 12 | return $strCode; 13 | } -------------------------------------------------------------------------------- /test/ut/release/test3/plugin/compiler.script.php: -------------------------------------------------------------------------------- 1 | '; 5 | } 6 | 7 | function smarty_compiler_scriptclose($params, $smarty){ 8 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 9 | $strCode = ''; 15 | return $strCode; 16 | } -------------------------------------------------------------------------------- /test/ut/release/test3/plugin/compiler.widget.php: -------------------------------------------------------------------------------- 1 | getConfigDir(); 13 | foreach ($arrConfigDir as $strDir) { 14 | $strPath = preg_replace('/[\\/\\\\]+/', '/', $strDir . '/' . $strFilename); 15 | if(is_file($strPath)){ 16 | self::$arrCached[$strFilename] = $strPath; 17 | return $strPath; 18 | } 19 | } 20 | } 21 | trigger_error('missing map file "' . $strFilename . '"', E_USER_ERROR); 22 | } 23 | } 24 | 25 | function smarty_compiler_widget($arrParams, $smarty){ 26 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 27 | $strCode = ' $_value) { 36 | if (is_int($_key)) { 37 | $arrFuncParams[] = "$_key=>$_value"; 38 | } else { 39 | $arrFuncParams[] = "'$_key'=>$_value"; 40 | } 41 | } 42 | $strFuncParams = 'array(' . implode(',', $arrFuncParams) . ')'; 43 | $strTplFuncName = '\'smarty_template_function_\'.' . $strCall; 44 | $strCallTplFunc = 'call_user_func('. $strTplFuncName . ',$_smarty_tpl,' . $strFuncParams . ');'; 45 | 46 | $strCode .= 'if(is_callable('. $strTplFuncName . ')){'; 47 | $strCode .= $strCallTplFunc; 48 | $strCode .= '}else{'; 49 | } 50 | if($strName){ 51 | $strCode .= '$_tpl_path=FISResource::load(' . $strName . ',$_smarty_tpl->smarty);'; 52 | $strCode .= 'if(isset($_tpl_path)){'; 53 | if($bHasCall){ 54 | $strCode .= '$_smarty_tpl->smarty->fetch($_tpl_path);'; 55 | $strCode .= 'if(is_callable('. $strTplFuncName . ')){'; 56 | $strCode .= $strCallTplFunc; 57 | $strCode .= '}else{'; 58 | $strCode .= 'trigger_error(\'missing function define "\'.' . $strTplFuncName . '.\'" in tpl "\'.$_tpl_path.\'"\', E_USER_ERROR);'; 59 | $strCode .= '}'; 60 | } else { 61 | $strCode .= 'echo $_smarty_tpl->smarty->fetch($_tpl_path);'; 62 | } 63 | $strCode .= '}else{'; 64 | $strCode .= 'trigger_error(\'unable to locale resource "\'.' . $strName . '.\'"\', E_USER_ERROR);'; 65 | $strCode .= '}'; 66 | } else { 67 | trigger_error('undefined widget name in file "' . $smarty->_current_file . '"', E_USER_ERROR); 68 | } 69 | if($bHasCall){ 70 | $strCode .= '}'; 71 | } 72 | $strCode .= '?>'; 73 | return $strCode; 74 | } -------------------------------------------------------------------------------- /test/ut/release/test3/ui/a/a.js: -------------------------------------------------------------------------------- 1 | require('../b/b.js'); 2 | console.log("a"); -------------------------------------------------------------------------------- /test/ut/release/test3/ui/b/b.js: -------------------------------------------------------------------------------- 1 | console.log("b"); -------------------------------------------------------------------------------- /test/ut/release/test3/widget/c/c.js: -------------------------------------------------------------------------------- 1 | console.log("c"); 2 | require('../d/d.js'); -------------------------------------------------------------------------------- /test/ut/release/test3/widget/comp/comp.js: -------------------------------------------------------------------------------- 1 | exports.name = 'comp'; 2 | console.log('comp loaded'); -------------------------------------------------------------------------------- /test/ut/release/test3/widget/d/d.js: -------------------------------------------------------------------------------- 1 | console.log("d"); -------------------------------------------------------------------------------- /test/ut/release/test3/widget/e/e.js: -------------------------------------------------------------------------------- 1 | console.log("e"); -------------------------------------------------------------------------------- /test/ut/release/test3/widget/list/list.css: -------------------------------------------------------------------------------- 1 | h2 { 2 | color: red; 3 | } -------------------------------------------------------------------------------- /test/ut/release/test3/widget/list/list.js: -------------------------------------------------------------------------------- 1 | var comp = require('../comp/comp.js'); 2 | require('../c/c.js'); 3 | require('../e/e.js'); 4 | console.log(comp); 5 | exports.name = 'list'; 6 | console.log('list loaded'); -------------------------------------------------------------------------------- /test/ut/release/test3/widget/list/list.tpl: -------------------------------------------------------------------------------- 1 |

widget run!

2 | {%script%} 3 | seajs.use('photo:widget/list/list.js', function(list){ 4 | console.log(list); 5 | }); 6 | {%/script%} -------------------------------------------------------------------------------- /test/ut/release/test4/fis-conf.js: -------------------------------------------------------------------------------- 1 | fis.config.merge({ 2 | namespace : 'photo', 3 | modules : { 4 | //打包调用fis-packager-your_packager插件进行处理 5 | packager : 'map' 6 | }, 7 | roadmap : { 8 | domain : { 9 | '**.js' : 'http://img.baidu.com', 10 | '**.css' : 'http://css.baidu.com' 11 | }, 12 | path : [ 13 | { 14 | reg : /^\/test\//i, 15 | release : false 16 | }, 17 | { 18 | reg : /\.tmpl$/i, 19 | release : false 20 | }, 21 | { 22 | reg : /^\/widget\/.*\.(js|css)$/i, 23 | isMod : true, 24 | release : '/static/${namespace}$&' 25 | }, 26 | { 27 | reg : /^\/ui\/.*\.(js|css)$/i, 28 | isMod : true, 29 | release : '/static/${namespace}$&' 30 | }, 31 | { 32 | reg : /^\/widget\/(.*\.tpl)$/i, 33 | isMod : true, 34 | url : 'widget/${namespace}/$1', 35 | release : '/template/widget/${namespace}/$1' 36 | }, 37 | { 38 | reg : /^\/plugin\//i 39 | }, 40 | { 41 | reg : /^\/.+\.tpl$/i, 42 | release : '/template/${namespace}$&' 43 | }, 44 | { 45 | reg : /^\/photo-map\.json$/i, 46 | release : '/config$&' 47 | }, 48 | { 49 | reg : /^.*$/, 50 | release : '/static/${namespace}$&' 51 | } 52 | ] 53 | }, 54 | settings : { 55 | modular : { 56 | reqlang : { 57 | wrap : 'amd' 58 | } 59 | } 60 | }, 61 | deploy : { 62 | 'rd-test' : { 63 | receiver : 'http://zhangyunlong.fe.baidu.com/receiver.php', 64 | to : '/home/zhangyunlong/public_html' 65 | } 66 | }, 67 | merge : { 68 | 'static/aio.js' : [ 69 | 'widget/comp/comp.js', 70 | 'widget/list/list.js' 71 | ] 72 | } 73 | }); 74 | -------------------------------------------------------------------------------- /test/ut/release/test4/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 20px; 3 | } -------------------------------------------------------------------------------- /test/ut/release/test4/index.js: -------------------------------------------------------------------------------- 1 | console.log('index.js'); -------------------------------------------------------------------------------- /test/ut/release/test4/index.tpl: -------------------------------------------------------------------------------- 1 | {%html%} 2 | {%head%} 3 | 4 | name----- 5 | {%/head%} 6 | {%body%} 7 | 8 | {%require name="photo:sea.js"%} 9 | {%require name="photo:index.js"%} 10 | {%require name="photo:ui/a/a.js"%} 11 | {%script%} 12 | seajs.use('photo:ui/a/a.js', function(a){ 13 | 14 | }); 15 | {%/script%} 16 | 17 | 18 |

hello world fis.

19 |

I'm a boy.

20 |

test1

21 |

test2

22 |

test3

23 |

test4

24 | 25 | {%widget name="photo:widget/list/list.tpl"%} 26 | 27 | {%require name="photo:index.css"%} 28 | {%/body%} 29 | {%/html%} -------------------------------------------------------------------------------- /test/ut/release/test4/npm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/release/test4/npm.png -------------------------------------------------------------------------------- /test/ut/release/test4/plugin/FISResource.class.php: -------------------------------------------------------------------------------- 1 | '; 5 | 6 | private static $arrMap = array(); 7 | private static $arrLoaded = array(); 8 | private static $arrStaticCollection = array(); 9 | private static $arrScriptPool = array(); 10 | 11 | public static function reset(){ 12 | self::$arrMap = array(); 13 | self::$arrLoaded = array(); 14 | self::$arrStaticCollection = array(); 15 | self::$arrScriptPool = array(); 16 | } 17 | 18 | public static function cssHook(){ 19 | return self::CSS_LINKS_HOOK; 20 | } 21 | 22 | public static function renderResponse($strContent){ 23 | $intPos = strpos($strContent, self::CSS_LINKS_HOOK); 24 | if($intPos !== false){ 25 | $strContent = substr_replace($strContent, self::render('css'), $intPos, strlen(self::CSS_LINKS_HOOK)); 26 | } 27 | self::reset(); 28 | return $strContent; 29 | } 30 | 31 | public static function render($type){ 32 | $html = ''; 33 | if(!empty(self::$arrStaticCollection[$type])){ 34 | $arrURIs = &self::$arrStaticCollection[$type]; 35 | if($type === 'js'){ 36 | $html = ''; 37 | } else if($type === 'css'){ 38 | $html = ''; 39 | } 40 | } 41 | return $html; 42 | } 43 | 44 | public static function addScriptPool($str){ 45 | self::$arrScriptPool[] = $str; 46 | } 47 | 48 | public static function renderScriptPool(){ 49 | $html = ''; 50 | if(!empty(self::$arrScriptPool)){ 51 | $html = ''; 52 | } 53 | return $html; 54 | } 55 | 56 | public static function register($strNamespace, $smarty){ 57 | if($strNamespace === '__global__'){ 58 | $strMapName = 'map.json'; 59 | } else { 60 | $strMapName = $strNamespace . '-map.json'; 61 | } 62 | $arrConfigDir = $smarty->getConfigDir(); 63 | foreach ($arrConfigDir as $strDir) { 64 | $strPath = preg_replace('/[\\/\\\\]+/', '/', $strDir . '/' . $strMapName); 65 | if(is_file($strPath)){ 66 | self::$arrMap[$strNamespace] = json_decode(file_get_contents($strPath), true); 67 | return true; 68 | } 69 | } 70 | return false; 71 | } 72 | 73 | public static function load($strName, $smarty){ 74 | $strLoadedURI = self::$arrLoaded[$strName]; 75 | if(isset($strLoadedURI)){ 76 | return $strLoadedURI; 77 | } else { 78 | $intPos = strpos($strName, ':'); 79 | if($intPos === false){ 80 | $strNamespace = '__global__'; 81 | } else { 82 | $strNamespace = substr($strName, 0, $intPos); 83 | } 84 | if(isset(self::$arrMap[$strNamespace]) || self::register($strNamespace, $smarty)){ 85 | $arrMap = &self::$arrMap[$strNamespace]; 86 | $arrRes = &$arrMap['res'][$strName]; 87 | if(isset($arrRes)){ 88 | if(isset($arrRes['pkg'])){ 89 | $arrPkg = &$arrMap['pkg'][$arrRes['pkg']]; 90 | $strURI = $arrPkg['uri']; 91 | foreach ($arrPkg['has'] as $strResId) { 92 | //todo 93 | self::$arrLoaded[$strName] = $strURI; 94 | } 95 | } else { 96 | if(isset($arrRes['deps'])){ 97 | foreach ($arrRes['deps'] as $strDep) { 98 | self::load($strDep, $smarty); 99 | } 100 | } 101 | $strURI = $arrRes['uri']; 102 | self::$arrLoaded[$strName] = $strURI; 103 | } 104 | self::$arrStaticCollection[$arrRes['type']][] = $strURI; 105 | return $strURI; 106 | } else { 107 | trigger_error('undefined resource "' . $strName . '"', E_USER_ERROR); 108 | } 109 | } else { 110 | trigger_error('missing map file of "' . $strNamespace . '"', E_USER_ERROR); 111 | } 112 | } 113 | trigger_error('unknown resource load error', E_USER_ERROR); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /test/ut/release/test4/plugin/compiler.body.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return ''; 9 | } 10 | 11 | function smarty_compiler_bodyclose($arrParams, $smarty){ 12 | $strCode = ''; 13 | $strCode .= ''; 19 | return $strCode; 20 | } -------------------------------------------------------------------------------- /test/ut/release/test4/plugin/compiler.head.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return ''; 9 | } 10 | 11 | function smarty_compiler_headclose($arrParams, $smarty){ 12 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 13 | $strCode = ''; 17 | $strCode .= ''; 18 | return $strCode; 19 | } -------------------------------------------------------------------------------- /test/ut/release/test4/plugin/compiler.html.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return "\n"; 9 | } 10 | 11 | function smarty_compiler_htmlclose($arrParams, $smarty){ 12 | $strCode = 'registerFilter(\'output\', array(\'FISResource\', \'renderResponse\'));'; 14 | $strCode .= '?>'; 15 | $strCode .= ''; 16 | return $strCode; 17 | } -------------------------------------------------------------------------------- /test/ut/release/test4/plugin/compiler.require.php: -------------------------------------------------------------------------------- 1 | smarty);'; 10 | $strCode .= '?>'; 11 | } 12 | return $strCode; 13 | } -------------------------------------------------------------------------------- /test/ut/release/test4/plugin/compiler.script.php: -------------------------------------------------------------------------------- 1 | '; 5 | } 6 | 7 | function smarty_compiler_scriptclose($params, $smarty){ 8 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 9 | $strCode = ''; 15 | return $strCode; 16 | } -------------------------------------------------------------------------------- /test/ut/release/test4/plugin/compiler.widget.php: -------------------------------------------------------------------------------- 1 | getConfigDir(); 13 | foreach ($arrConfigDir as $strDir) { 14 | $strPath = preg_replace('/[\\/\\\\]+/', '/', $strDir . '/' . $strFilename); 15 | if(is_file($strPath)){ 16 | self::$arrCached[$strFilename] = $strPath; 17 | return $strPath; 18 | } 19 | } 20 | } 21 | trigger_error('missing map file "' . $strFilename . '"', E_USER_ERROR); 22 | } 23 | } 24 | 25 | function smarty_compiler_widget($arrParams, $smarty){ 26 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 27 | $strCode = ' $_value) { 36 | if (is_int($_key)) { 37 | $arrFuncParams[] = "$_key=>$_value"; 38 | } else { 39 | $arrFuncParams[] = "'$_key'=>$_value"; 40 | } 41 | } 42 | $strFuncParams = 'array(' . implode(',', $arrFuncParams) . ')'; 43 | $strTplFuncName = '\'smarty_template_function_\'.' . $strCall; 44 | $strCallTplFunc = 'call_user_func('. $strTplFuncName . ',$_smarty_tpl,' . $strFuncParams . ');'; 45 | 46 | $strCode .= 'if(is_callable('. $strTplFuncName . ')){'; 47 | $strCode .= $strCallTplFunc; 48 | $strCode .= '}else{'; 49 | } 50 | if($strName){ 51 | $strCode .= '$_tpl_path=FISResource::load(' . $strName . ',$_smarty_tpl->smarty);'; 52 | $strCode .= 'if(isset($_tpl_path)){'; 53 | if($bHasCall){ 54 | $strCode .= '$_smarty_tpl->smarty->fetch($_tpl_path);'; 55 | $strCode .= 'if(is_callable('. $strTplFuncName . ')){'; 56 | $strCode .= $strCallTplFunc; 57 | $strCode .= '}else{'; 58 | $strCode .= 'trigger_error(\'missing function define "\'.' . $strTplFuncName . '.\'" in tpl "\'.$_tpl_path.\'"\', E_USER_ERROR);'; 59 | $strCode .= '}'; 60 | } else { 61 | $strCode .= 'echo $_smarty_tpl->smarty->fetch($_tpl_path);'; 62 | } 63 | $strCode .= '}else{'; 64 | $strCode .= 'trigger_error(\'unable to locale resource "\'.' . $strName . '.\'"\', E_USER_ERROR);'; 65 | $strCode .= '}'; 66 | } else { 67 | trigger_error('undefined widget name in file "' . $smarty->_current_file . '"', E_USER_ERROR); 68 | } 69 | if($bHasCall){ 70 | $strCode .= '}'; 71 | } 72 | $strCode .= '?>'; 73 | return $strCode; 74 | } -------------------------------------------------------------------------------- /test/ut/release/test4/ui/a/a.js: -------------------------------------------------------------------------------- 1 | require('../b/b.js'); 2 | console.log("a"); -------------------------------------------------------------------------------- /test/ut/release/test4/ui/b/b.js: -------------------------------------------------------------------------------- 1 | console.log("b"); -------------------------------------------------------------------------------- /test/ut/release/test4/widget/c/c.js: -------------------------------------------------------------------------------- 1 | console.log("c"); 2 | require('../d/d.js'); -------------------------------------------------------------------------------- /test/ut/release/test4/widget/comp/comp.js: -------------------------------------------------------------------------------- 1 | exports.name = 'comp'; 2 | console.log('comp loaded'); -------------------------------------------------------------------------------- /test/ut/release/test4/widget/d/d.js: -------------------------------------------------------------------------------- 1 | console.log("d"); -------------------------------------------------------------------------------- /test/ut/release/test4/widget/e/e.js: -------------------------------------------------------------------------------- 1 | console.log("e"); -------------------------------------------------------------------------------- /test/ut/release/test4/widget/list/list.css: -------------------------------------------------------------------------------- 1 | h2 { 2 | color: red; 3 | } -------------------------------------------------------------------------------- /test/ut/release/test4/widget/list/list.js: -------------------------------------------------------------------------------- 1 | var comp = require('../comp/comp.js'); 2 | //@require '../c/c.js' 3 | /*@require '../e/e.js'*/ 4 | console.log(comp); 5 | exports.name = 'list'; 6 | console.log('list loaded'); -------------------------------------------------------------------------------- /test/ut/release/test4/widget/list/list.tpl: -------------------------------------------------------------------------------- 1 |

widget run!

2 | {%script%} 3 | seajs.use('photo:widget/list/list.js', function(list){ 4 | console.log(list); 5 | }); 6 | {%/script%} -------------------------------------------------------------------------------- /test/ut/release/test5/fis-conf.js: -------------------------------------------------------------------------------- 1 | fis.config.merge({ 2 | namespace : 'photo', 3 | modules : { 4 | //打包调用fis-packager-your_packager插件进行处理 5 | packager : 'map' 6 | }, 7 | roadmap : { 8 | domain : { 9 | '**.js' : 'http://img.baidu.com', 10 | '**.css' : 'http://css.baidu.com' 11 | }, 12 | path : [ 13 | { 14 | reg : /^\/test\//i, 15 | release : false 16 | }, 17 | { 18 | reg : /\.tmpl$/i, 19 | release : false 20 | }, 21 | { 22 | reg : /^\/widget\/.*\.(js|css)$/i, 23 | isMod : true, 24 | release : '/static/${namespace}$&' 25 | }, 26 | { 27 | reg : /^\/ui\/.*\.(js|css)$/i, 28 | isMod : true, 29 | release : '/static/${namespace}$&' 30 | }, 31 | { 32 | reg : /^\/widget\/(.*\.tpl)$/i, 33 | isMod : true, 34 | url : 'widget/${namespace}/$1', 35 | release : '/template/widget/${namespace}/$1' 36 | }, 37 | { 38 | reg : /^\/plugin\//i 39 | }, 40 | { 41 | reg : /^\/.+\.tpl$/i, 42 | release : '/template/${namespace}$&' 43 | }, 44 | { 45 | reg : /^\/photo-map\.json$/i, 46 | release : '/config$&' 47 | }, 48 | { 49 | reg : /^.*$/, 50 | release : '/static/${namespace}$&' 51 | } 52 | ] 53 | }, 54 | settings : { 55 | modular : { 56 | reqlang : { 57 | wrap : 'amd' 58 | } 59 | } 60 | }, 61 | deploy : { 62 | 'rd-test' : { 63 | receiver : 'http://zhangyunlong.fe.baidu.com/receiver.php', 64 | to : '/home/zhangyunlong/public_html' 65 | } 66 | }, 67 | merge : { 68 | 'static/aio.js' : [ 69 | 'widget/comp/comp.js', 70 | 'widget/list/list.js' 71 | ] 72 | } 73 | }); 74 | -------------------------------------------------------------------------------- /test/ut/release/test5/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 20px; 3 | } -------------------------------------------------------------------------------- /test/ut/release/test5/index.js: -------------------------------------------------------------------------------- 1 | console.log('index.js'); -------------------------------------------------------------------------------- /test/ut/release/test5/index.tpl: -------------------------------------------------------------------------------- 1 | {%html%} 2 | {%head%} 3 | 4 | name----- 5 | {%/head%} 6 | {%body%} 7 | 8 | {%require name="photo:sea.js"%} 9 | {%require name="photo:index.js"%} 10 | {%require name="photo:ui/a/a.js"%} 11 | {%script%} 12 | seajs.use('photo:ui/a/a.js', function(a){ 13 | 14 | }); 15 | {%/script%} 16 | 17 | 18 |

hello world fis.

19 |

I'm a boy.

20 |

test1

21 |

test2

22 |

test3

23 |

test4

24 | 25 | {%widget name="photo:widget/list/list.tpl"%} 26 | 27 | {%require name="photo:index.css"%} 28 | {%/body%} 29 | {%/html%} -------------------------------------------------------------------------------- /test/ut/release/test5/npm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/release/test5/npm.png -------------------------------------------------------------------------------- /test/ut/release/test5/plugin/FISResource.class.php: -------------------------------------------------------------------------------- 1 | '; 5 | 6 | private static $arrMap = array(); 7 | private static $arrLoaded = array(); 8 | private static $arrStaticCollection = array(); 9 | private static $arrScriptPool = array(); 10 | 11 | public static function reset(){ 12 | self::$arrMap = array(); 13 | self::$arrLoaded = array(); 14 | self::$arrStaticCollection = array(); 15 | self::$arrScriptPool = array(); 16 | } 17 | 18 | public static function cssHook(){ 19 | return self::CSS_LINKS_HOOK; 20 | } 21 | 22 | public static function renderResponse($strContent){ 23 | $intPos = strpos($strContent, self::CSS_LINKS_HOOK); 24 | if($intPos !== false){ 25 | $strContent = substr_replace($strContent, self::render('css'), $intPos, strlen(self::CSS_LINKS_HOOK)); 26 | } 27 | self::reset(); 28 | return $strContent; 29 | } 30 | 31 | public static function render($type){ 32 | $html = ''; 33 | if(!empty(self::$arrStaticCollection[$type])){ 34 | $arrURIs = &self::$arrStaticCollection[$type]; 35 | if($type === 'js'){ 36 | $html = ''; 37 | } else if($type === 'css'){ 38 | $html = ''; 39 | } 40 | } 41 | return $html; 42 | } 43 | 44 | public static function addScriptPool($str){ 45 | self::$arrScriptPool[] = $str; 46 | } 47 | 48 | public static function renderScriptPool(){ 49 | $html = ''; 50 | if(!empty(self::$arrScriptPool)){ 51 | $html = ''; 52 | } 53 | return $html; 54 | } 55 | 56 | public static function register($strNamespace, $smarty){ 57 | if($strNamespace === '__global__'){ 58 | $strMapName = 'map.json'; 59 | } else { 60 | $strMapName = $strNamespace . '-map.json'; 61 | } 62 | $arrConfigDir = $smarty->getConfigDir(); 63 | foreach ($arrConfigDir as $strDir) { 64 | $strPath = preg_replace('/[\\/\\\\]+/', '/', $strDir . '/' . $strMapName); 65 | if(is_file($strPath)){ 66 | self::$arrMap[$strNamespace] = json_decode(file_get_contents($strPath), true); 67 | return true; 68 | } 69 | } 70 | return false; 71 | } 72 | 73 | public static function load($strName, $smarty){ 74 | $strLoadedURI = self::$arrLoaded[$strName]; 75 | if(isset($strLoadedURI)){ 76 | return $strLoadedURI; 77 | } else { 78 | $intPos = strpos($strName, ':'); 79 | if($intPos === false){ 80 | $strNamespace = '__global__'; 81 | } else { 82 | $strNamespace = substr($strName, 0, $intPos); 83 | } 84 | if(isset(self::$arrMap[$strNamespace]) || self::register($strNamespace, $smarty)){ 85 | $arrMap = &self::$arrMap[$strNamespace]; 86 | $arrRes = &$arrMap['res'][$strName]; 87 | if(isset($arrRes)){ 88 | if(isset($arrRes['pkg'])){ 89 | $arrPkg = &$arrMap['pkg'][$arrRes['pkg']]; 90 | $strURI = $arrPkg['uri']; 91 | foreach ($arrPkg['has'] as $strResId) { 92 | //todo 93 | self::$arrLoaded[$strName] = $strURI; 94 | } 95 | } else { 96 | if(isset($arrRes['deps'])){ 97 | foreach ($arrRes['deps'] as $strDep) { 98 | self::load($strDep, $smarty); 99 | } 100 | } 101 | $strURI = $arrRes['uri']; 102 | self::$arrLoaded[$strName] = $strURI; 103 | } 104 | self::$arrStaticCollection[$arrRes['type']][] = $strURI; 105 | return $strURI; 106 | } else { 107 | trigger_error('undefined resource "' . $strName . '"', E_USER_ERROR); 108 | } 109 | } else { 110 | trigger_error('missing map file of "' . $strNamespace . '"', E_USER_ERROR); 111 | } 112 | } 113 | trigger_error('unknown resource load error', E_USER_ERROR); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /test/ut/release/test5/plugin/compiler.body.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return ''; 9 | } 10 | 11 | function smarty_compiler_bodyclose($arrParams, $smarty){ 12 | $strCode = ''; 13 | $strCode .= ''; 19 | return $strCode; 20 | } -------------------------------------------------------------------------------- /test/ut/release/test5/plugin/compiler.head.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return ''; 9 | } 10 | 11 | function smarty_compiler_headclose($arrParams, $smarty){ 12 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 13 | $strCode = ''; 17 | $strCode .= ''; 18 | return $strCode; 19 | } -------------------------------------------------------------------------------- /test/ut/release/test5/plugin/compiler.html.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return "\n"; 9 | } 10 | 11 | function smarty_compiler_htmlclose($arrParams, $smarty){ 12 | $strCode = 'registerFilter(\'output\', array(\'FISResource\', \'renderResponse\'));'; 14 | $strCode .= '?>'; 15 | $strCode .= ''; 16 | return $strCode; 17 | } -------------------------------------------------------------------------------- /test/ut/release/test5/plugin/compiler.require.php: -------------------------------------------------------------------------------- 1 | smarty);'; 10 | $strCode .= '?>'; 11 | } 12 | return $strCode; 13 | } -------------------------------------------------------------------------------- /test/ut/release/test5/plugin/compiler.script.php: -------------------------------------------------------------------------------- 1 | '; 5 | } 6 | 7 | function smarty_compiler_scriptclose($params, $smarty){ 8 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 9 | $strCode = ''; 15 | return $strCode; 16 | } -------------------------------------------------------------------------------- /test/ut/release/test5/plugin/compiler.widget.php: -------------------------------------------------------------------------------- 1 | getConfigDir(); 13 | foreach ($arrConfigDir as $strDir) { 14 | $strPath = preg_replace('/[\\/\\\\]+/', '/', $strDir . '/' . $strFilename); 15 | if(is_file($strPath)){ 16 | self::$arrCached[$strFilename] = $strPath; 17 | return $strPath; 18 | } 19 | } 20 | } 21 | trigger_error('missing map file "' . $strFilename . '"', E_USER_ERROR); 22 | } 23 | } 24 | 25 | function smarty_compiler_widget($arrParams, $smarty){ 26 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 27 | $strCode = ' $_value) { 36 | if (is_int($_key)) { 37 | $arrFuncParams[] = "$_key=>$_value"; 38 | } else { 39 | $arrFuncParams[] = "'$_key'=>$_value"; 40 | } 41 | } 42 | $strFuncParams = 'array(' . implode(',', $arrFuncParams) . ')'; 43 | $strTplFuncName = '\'smarty_template_function_\'.' . $strCall; 44 | $strCallTplFunc = 'call_user_func('. $strTplFuncName . ',$_smarty_tpl,' . $strFuncParams . ');'; 45 | 46 | $strCode .= 'if(is_callable('. $strTplFuncName . ')){'; 47 | $strCode .= $strCallTplFunc; 48 | $strCode .= '}else{'; 49 | } 50 | if($strName){ 51 | $strCode .= '$_tpl_path=FISResource::load(' . $strName . ',$_smarty_tpl->smarty);'; 52 | $strCode .= 'if(isset($_tpl_path)){'; 53 | if($bHasCall){ 54 | $strCode .= '$_smarty_tpl->smarty->fetch($_tpl_path);'; 55 | $strCode .= 'if(is_callable('. $strTplFuncName . ')){'; 56 | $strCode .= $strCallTplFunc; 57 | $strCode .= '}else{'; 58 | $strCode .= 'trigger_error(\'missing function define "\'.' . $strTplFuncName . '.\'" in tpl "\'.$_tpl_path.\'"\', E_USER_ERROR);'; 59 | $strCode .= '}'; 60 | } else { 61 | $strCode .= 'echo $_smarty_tpl->smarty->fetch($_tpl_path);'; 62 | } 63 | $strCode .= '}else{'; 64 | $strCode .= 'trigger_error(\'unable to locale resource "\'.' . $strName . '.\'"\', E_USER_ERROR);'; 65 | $strCode .= '}'; 66 | } else { 67 | trigger_error('undefined widget name in file "' . $smarty->_current_file . '"', E_USER_ERROR); 68 | } 69 | if($bHasCall){ 70 | $strCode .= '}'; 71 | } 72 | $strCode .= '?>'; 73 | return $strCode; 74 | } -------------------------------------------------------------------------------- /test/ut/release/test5/ui/a/a.js: -------------------------------------------------------------------------------- 1 | require('../b/b.js'); 2 | console.log("a"); -------------------------------------------------------------------------------- /test/ut/release/test5/ui/b/b.js: -------------------------------------------------------------------------------- 1 | console.log("b"); -------------------------------------------------------------------------------- /test/ut/release/test5/widget/c/c.js: -------------------------------------------------------------------------------- 1 | console.log("c"); 2 | require('../d/d.js'); -------------------------------------------------------------------------------- /test/ut/release/test5/widget/comp/comp.js: -------------------------------------------------------------------------------- 1 | exports.name = 'comp'; 2 | console.log('comp loaded'); -------------------------------------------------------------------------------- /test/ut/release/test5/widget/d/d.js: -------------------------------------------------------------------------------- 1 | console.log("d"); -------------------------------------------------------------------------------- /test/ut/release/test5/widget/e/e.js: -------------------------------------------------------------------------------- 1 | console.log("e"); -------------------------------------------------------------------------------- /test/ut/release/test5/widget/list/list.css: -------------------------------------------------------------------------------- 1 | h2 { 2 | color: red; 3 | } -------------------------------------------------------------------------------- /test/ut/release/test5/widget/list/list.js: -------------------------------------------------------------------------------- 1 | var comp = require('../comp/comp.js'); 2 | require('../c/c.js'); 3 | require('../e/e.js'); 4 | console.log(comp); 5 | exports.name = 'list'; 6 | console.log('list loaded'); -------------------------------------------------------------------------------- /test/ut/release/test5/widget/list/list.tpl: -------------------------------------------------------------------------------- 1 |

widget run!

2 | {%script%} 3 | seajs.use('photo:widget/list/list.js', function(list){ 4 | console.log(list); 5 | }); 6 | {%/script%} -------------------------------------------------------------------------------- /test/ut/release/test6/fis-conf.js: -------------------------------------------------------------------------------- 1 | fis.config.merge({ 2 | namespace : 'photo', 3 | modules : { 4 | //打包调用fis-packager-your_packager插件进行处理 5 | packager : 'map' 6 | }, 7 | roadmap : { 8 | domain : { 9 | '**.js' : 'http://img.baidu.com', 10 | '**.css' : 'http://css.baidu.com' 11 | }, 12 | path : [ 13 | { 14 | reg : /^\/test\//i, 15 | release : false 16 | }, 17 | { 18 | reg : /\.tmpl$/i, 19 | release : false 20 | }, 21 | { 22 | reg : /^\/widget\/.*\.(js|css)$/i, 23 | isMod : true, 24 | release : '/static/${namespace}$&' 25 | }, 26 | { 27 | reg : /^\/ui\/.*\.(js|css)$/i, 28 | isMod : true, 29 | release : '/static/${namespace}$&' 30 | }, 31 | { 32 | reg : /^\/widget\/(.*\.tpl)$/i, 33 | isMod : true, 34 | url : 'widget/${namespace}/$1', 35 | release : '/template/widget/${namespace}/$1' 36 | }, 37 | { 38 | reg : /^\/plugin\//i 39 | }, 40 | { 41 | reg : /^\/.+\.tpl$/i, 42 | release : '/template/${namespace}$&' 43 | }, 44 | { 45 | reg : /^\/photo-map\.json$/i, 46 | release : '/config$&' 47 | }, 48 | { 49 | reg : /^.*$/, 50 | release : '/static/${namespace}$&' 51 | } 52 | ] 53 | }, 54 | settings : { 55 | modular : { 56 | reqlang : { 57 | wrap : 'amd' 58 | } 59 | } 60 | }, 61 | deploy : { 62 | 'rd-test' : { 63 | receiver : 'http://zhangyunlong.fe.baidu.com/receiver.php', 64 | to : '/home/zhangyunlong/public_html' 65 | } 66 | }, 67 | merge : { 68 | 'static/aio.js' : [ 69 | 'widget/comp/comp.js', 70 | 'widget/list/list.js' 71 | ] 72 | } 73 | }); 74 | -------------------------------------------------------------------------------- /test/ut/release/test6/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 20px; 3 | } -------------------------------------------------------------------------------- /test/ut/release/test6/index.js: -------------------------------------------------------------------------------- 1 | console.log('index.js'); -------------------------------------------------------------------------------- /test/ut/release/test6/index.tpl: -------------------------------------------------------------------------------- 1 | {%html%} 2 | {%head%} 3 | 4 | name----- 5 | {%/head%} 6 | {%body%} 7 | 8 | {%require name="photo:sea.js"%} 9 | {%require name="photo:index.js"%} 10 | {%require name="photo:ui/a/a.js"%} 11 | {%script%} 12 | seajs.use('photo:ui/a/a.js', function(a){ 13 | 14 | }); 15 | {%/script%} 16 | 17 | 18 |

hello world fis.

19 |

I'm a boy.

20 |

test1

21 |

test2

22 |

test3

23 |

test4

24 | 25 | {%widget name="photo:widget/list/list.tpl"%} 26 | 27 | {%require name="photo:index.css"%} 28 | {%/body%} 29 | {%/html%} -------------------------------------------------------------------------------- /test/ut/release/test6/npm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/release/test6/npm.png -------------------------------------------------------------------------------- /test/ut/release/test6/plugin/FISResource.class.php: -------------------------------------------------------------------------------- 1 | '; 5 | 6 | private static $arrMap = array(); 7 | private static $arrLoaded = array(); 8 | private static $arrStaticCollection = array(); 9 | private static $arrScriptPool = array(); 10 | 11 | public static function reset(){ 12 | self::$arrMap = array(); 13 | self::$arrLoaded = array(); 14 | self::$arrStaticCollection = array(); 15 | self::$arrScriptPool = array(); 16 | } 17 | 18 | public static function cssHook(){ 19 | return self::CSS_LINKS_HOOK; 20 | } 21 | 22 | public static function renderResponse($strContent){ 23 | $intPos = strpos($strContent, self::CSS_LINKS_HOOK); 24 | if($intPos !== false){ 25 | $strContent = substr_replace($strContent, self::render('css'), $intPos, strlen(self::CSS_LINKS_HOOK)); 26 | } 27 | self::reset(); 28 | return $strContent; 29 | } 30 | 31 | public static function render($type){ 32 | $html = ''; 33 | if(!empty(self::$arrStaticCollection[$type])){ 34 | $arrURIs = &self::$arrStaticCollection[$type]; 35 | if($type === 'js'){ 36 | $html = ''; 37 | } else if($type === 'css'){ 38 | $html = ''; 39 | } 40 | } 41 | return $html; 42 | } 43 | 44 | public static function addScriptPool($str){ 45 | self::$arrScriptPool[] = $str; 46 | } 47 | 48 | public static function renderScriptPool(){ 49 | $html = ''; 50 | if(!empty(self::$arrScriptPool)){ 51 | $html = ''; 52 | } 53 | return $html; 54 | } 55 | 56 | public static function register($strNamespace, $smarty){ 57 | if($strNamespace === '__global__'){ 58 | $strMapName = 'map.json'; 59 | } else { 60 | $strMapName = $strNamespace . '-map.json'; 61 | } 62 | $arrConfigDir = $smarty->getConfigDir(); 63 | foreach ($arrConfigDir as $strDir) { 64 | $strPath = preg_replace('/[\\/\\\\]+/', '/', $strDir . '/' . $strMapName); 65 | if(is_file($strPath)){ 66 | self::$arrMap[$strNamespace] = json_decode(file_get_contents($strPath), true); 67 | return true; 68 | } 69 | } 70 | return false; 71 | } 72 | 73 | public static function load($strName, $smarty){ 74 | $strLoadedURI = self::$arrLoaded[$strName]; 75 | if(isset($strLoadedURI)){ 76 | return $strLoadedURI; 77 | } else { 78 | $intPos = strpos($strName, ':'); 79 | if($intPos === false){ 80 | $strNamespace = '__global__'; 81 | } else { 82 | $strNamespace = substr($strName, 0, $intPos); 83 | } 84 | if(isset(self::$arrMap[$strNamespace]) || self::register($strNamespace, $smarty)){ 85 | $arrMap = &self::$arrMap[$strNamespace]; 86 | $arrRes = &$arrMap['res'][$strName]; 87 | if(isset($arrRes)){ 88 | if(isset($arrRes['pkg'])){ 89 | $arrPkg = &$arrMap['pkg'][$arrRes['pkg']]; 90 | $strURI = $arrPkg['uri']; 91 | foreach ($arrPkg['has'] as $strResId) { 92 | //todo 93 | self::$arrLoaded[$strName] = $strURI; 94 | } 95 | } else { 96 | if(isset($arrRes['deps'])){ 97 | foreach ($arrRes['deps'] as $strDep) { 98 | self::load($strDep, $smarty); 99 | } 100 | } 101 | $strURI = $arrRes['uri']; 102 | self::$arrLoaded[$strName] = $strURI; 103 | } 104 | self::$arrStaticCollection[$arrRes['type']][] = $strURI; 105 | return $strURI; 106 | } else { 107 | trigger_error('undefined resource "' . $strName . '"', E_USER_ERROR); 108 | } 109 | } else { 110 | trigger_error('missing map file of "' . $strNamespace . '"', E_USER_ERROR); 111 | } 112 | } 113 | trigger_error('unknown resource load error', E_USER_ERROR); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /test/ut/release/test6/plugin/compiler.body.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return ''; 9 | } 10 | 11 | function smarty_compiler_bodyclose($arrParams, $smarty){ 12 | $strCode = ''; 13 | $strCode .= ''; 19 | return $strCode; 20 | } -------------------------------------------------------------------------------- /test/ut/release/test6/plugin/compiler.head.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return ''; 9 | } 10 | 11 | function smarty_compiler_headclose($arrParams, $smarty){ 12 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 13 | $strCode = ''; 17 | $strCode .= ''; 18 | return $strCode; 19 | } -------------------------------------------------------------------------------- /test/ut/release/test6/plugin/compiler.html.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return "\n"; 9 | } 10 | 11 | function smarty_compiler_htmlclose($arrParams, $smarty){ 12 | $strCode = 'registerFilter(\'output\', array(\'FISResource\', \'renderResponse\'));'; 14 | $strCode .= '?>'; 15 | $strCode .= ''; 16 | return $strCode; 17 | } -------------------------------------------------------------------------------- /test/ut/release/test6/plugin/compiler.require.php: -------------------------------------------------------------------------------- 1 | smarty);'; 10 | $strCode .= '?>'; 11 | } 12 | return $strCode; 13 | } -------------------------------------------------------------------------------- /test/ut/release/test6/plugin/compiler.script.php: -------------------------------------------------------------------------------- 1 | '; 5 | } 6 | 7 | function smarty_compiler_scriptclose($params, $smarty){ 8 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 9 | $strCode = ''; 15 | return $strCode; 16 | } -------------------------------------------------------------------------------- /test/ut/release/test6/plugin/compiler.widget.php: -------------------------------------------------------------------------------- 1 | getConfigDir(); 13 | foreach ($arrConfigDir as $strDir) { 14 | $strPath = preg_replace('/[\\/\\\\]+/', '/', $strDir . '/' . $strFilename); 15 | if(is_file($strPath)){ 16 | self::$arrCached[$strFilename] = $strPath; 17 | return $strPath; 18 | } 19 | } 20 | } 21 | trigger_error('missing map file "' . $strFilename . '"', E_USER_ERROR); 22 | } 23 | } 24 | 25 | function smarty_compiler_widget($arrParams, $smarty){ 26 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 27 | $strCode = ' $_value) { 36 | if (is_int($_key)) { 37 | $arrFuncParams[] = "$_key=>$_value"; 38 | } else { 39 | $arrFuncParams[] = "'$_key'=>$_value"; 40 | } 41 | } 42 | $strFuncParams = 'array(' . implode(',', $arrFuncParams) . ')'; 43 | $strTplFuncName = '\'smarty_template_function_\'.' . $strCall; 44 | $strCallTplFunc = 'call_user_func('. $strTplFuncName . ',$_smarty_tpl,' . $strFuncParams . ');'; 45 | 46 | $strCode .= 'if(is_callable('. $strTplFuncName . ')){'; 47 | $strCode .= $strCallTplFunc; 48 | $strCode .= '}else{'; 49 | } 50 | if($strName){ 51 | $strCode .= '$_tpl_path=FISResource::load(' . $strName . ',$_smarty_tpl->smarty);'; 52 | $strCode .= 'if(isset($_tpl_path)){'; 53 | if($bHasCall){ 54 | $strCode .= '$_smarty_tpl->smarty->fetch($_tpl_path);'; 55 | $strCode .= 'if(is_callable('. $strTplFuncName . ')){'; 56 | $strCode .= $strCallTplFunc; 57 | $strCode .= '}else{'; 58 | $strCode .= 'trigger_error(\'missing function define "\'.' . $strTplFuncName . '.\'" in tpl "\'.$_tpl_path.\'"\', E_USER_ERROR);'; 59 | $strCode .= '}'; 60 | } else { 61 | $strCode .= 'echo $_smarty_tpl->smarty->fetch($_tpl_path);'; 62 | } 63 | $strCode .= '}else{'; 64 | $strCode .= 'trigger_error(\'unable to locale resource "\'.' . $strName . '.\'"\', E_USER_ERROR);'; 65 | $strCode .= '}'; 66 | } else { 67 | trigger_error('undefined widget name in file "' . $smarty->_current_file . '"', E_USER_ERROR); 68 | } 69 | if($bHasCall){ 70 | $strCode .= '}'; 71 | } 72 | $strCode .= '?>'; 73 | return $strCode; 74 | } -------------------------------------------------------------------------------- /test/ut/release/test6/ui/a/a.js: -------------------------------------------------------------------------------- 1 | require('../b/b.js'); 2 | console.log("a"); -------------------------------------------------------------------------------- /test/ut/release/test6/ui/b/b.js: -------------------------------------------------------------------------------- 1 | console.log("b"); -------------------------------------------------------------------------------- /test/ut/release/test6/widget/c/c.js: -------------------------------------------------------------------------------- 1 | console.log("c"); 2 | require('../d/d.js'); -------------------------------------------------------------------------------- /test/ut/release/test6/widget/comp/comp.js: -------------------------------------------------------------------------------- 1 | exports.name = 'comp'; 2 | console.log('comp loaded'); -------------------------------------------------------------------------------- /test/ut/release/test6/widget/d/d.js: -------------------------------------------------------------------------------- 1 | console.log("d"); -------------------------------------------------------------------------------- /test/ut/release/test6/widget/e/e.js: -------------------------------------------------------------------------------- 1 | console.log("e"); -------------------------------------------------------------------------------- /test/ut/release/test6/widget/list/list.css: -------------------------------------------------------------------------------- 1 | h2 { 2 | color: red; 3 | } -------------------------------------------------------------------------------- /test/ut/release/test6/widget/list/list.js: -------------------------------------------------------------------------------- 1 | var comp = require('../comp/comp.js'); 2 | require('../c/c.js'); 3 | require('../e/e.js'); 4 | console.log(comp); 5 | exports.name = 'list'; 6 | console.log('list loaded'); -------------------------------------------------------------------------------- /test/ut/release/test6/widget/list/list.tpl: -------------------------------------------------------------------------------- 1 |

widget run!

2 | {%script%} 3 | seajs.use('photo:widget/list/list.js', function(list){ 4 | console.log(list); 5 | }); 6 | {%/script%} -------------------------------------------------------------------------------- /test/ut/release/test7/fis-conf.js: -------------------------------------------------------------------------------- 1 | fis.config.merge({ 2 | namespace : 'photo', 3 | modules : { 4 | //打包调用fis-packager-your_packager插件进行处理 5 | packager : 'map' 6 | }, 7 | roadmap : { 8 | domain : { 9 | '*.js' : 'http://img.baidu.com', 10 | '*.css' : 'http://css.baidu.com' 11 | }, 12 | path : [ 13 | { 14 | reg : /^\/test\//i, 15 | release : false 16 | }, 17 | { 18 | reg : /\.tmpl$/i, 19 | release : false 20 | }, 21 | { 22 | reg : /^\/widget\/.*\.(js|css)$/i, 23 | isMod : true, 24 | release : '/static/${namespace}$&' 25 | }, 26 | { 27 | reg : /^\/ui\/.*\.(js|css)$/i, 28 | isMod : true, 29 | release : '/static/${namespace}$&' 30 | }, 31 | { 32 | reg : /^\/widget\/(.*\.tpl)$/i, 33 | isMod : true, 34 | url : 'widget/${namespace}/$1', 35 | release : '/template/widget/${namespace}/$1' 36 | }, 37 | { 38 | reg : /^\/plugin\//i 39 | }, 40 | { 41 | reg : /^\/.+\.tpl$/i, 42 | release : '/template/${namespace}$&' 43 | }, 44 | { 45 | reg : /^\/photo-map\.json$/i, 46 | release : '/config$&' 47 | }, 48 | { 49 | reg : /^.*$/, 50 | release : '/static/${namespace}$&' 51 | } 52 | 53 | ] 54 | }, 55 | settings : { 56 | modular : { 57 | reqlang : { 58 | wrap : 'amd' 59 | } 60 | } 61 | }, 62 | deploy : { 63 | 'rd-test' : { 64 | receiver : 'http://zhangyunlong.fe.baidu.com/receiver.php', 65 | to : '/home/zhangyunlong/public_html' 66 | } 67 | }, 68 | pack : { 69 | 'static/aio.js' : [ 70 | 'widget/comp/comp.js', 71 | 'widget/list/list.js' 72 | ], 73 | 'static/aio1.js':[ 74 | 'ui/**' 75 | ], 76 | 'static/aio2.js':/js\// 77 | } 78 | }); 79 | -------------------------------------------------------------------------------- /test/ut/release/test7/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 20px; 3 | } -------------------------------------------------------------------------------- /test/ut/release/test7/index.js: -------------------------------------------------------------------------------- 1 | console.log('index.js'); -------------------------------------------------------------------------------- /test/ut/release/test7/index.tpl: -------------------------------------------------------------------------------- 1 | {%html%} 2 | {%head%} 3 | 4 | name----- 5 | {%/head%} 6 | {%body%} 7 | 8 | {%require name="photo:sea.js"%} 9 | {%require name="photo:index.js"%} 10 | {%require name="photo:ui/a/a.js"%} 11 | {%script%} 12 | seajs.use('photo:ui/a/a.js', function(a){ 13 | 14 | }); 15 | {%/script%} 16 | 17 | 18 |

hello world fis.

19 |

I'm a boy.

20 |

test1

21 |

test2

22 |

test3

23 |

test4

24 | 25 | {%widget name="photo:widget/list/list.tpl"%} 26 | 27 | {%require name="photo:index.css"%} 28 | {%/body%} 29 | {%/html%} -------------------------------------------------------------------------------- /test/ut/release/test7/js/a/a.js: -------------------------------------------------------------------------------- 1 | console.log("a"); -------------------------------------------------------------------------------- /test/ut/release/test7/js/b/b.js: -------------------------------------------------------------------------------- 1 | console.log("b"); -------------------------------------------------------------------------------- /test/ut/release/test7/npm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/release/test7/npm.png -------------------------------------------------------------------------------- /test/ut/release/test7/plugin/FISResource.class.php: -------------------------------------------------------------------------------- 1 | '; 5 | 6 | private static $arrMap = array(); 7 | private static $arrLoaded = array(); 8 | private static $arrStaticCollection = array(); 9 | private static $arrScriptPool = array(); 10 | 11 | public static function reset(){ 12 | self::$arrMap = array(); 13 | self::$arrLoaded = array(); 14 | self::$arrStaticCollection = array(); 15 | self::$arrScriptPool = array(); 16 | } 17 | 18 | public static function cssHook(){ 19 | return self::CSS_LINKS_HOOK; 20 | } 21 | 22 | public static function renderResponse($strContent){ 23 | $intPos = strpos($strContent, self::CSS_LINKS_HOOK); 24 | if($intPos !== false){ 25 | $strContent = substr_replace($strContent, self::render('css'), $intPos, strlen(self::CSS_LINKS_HOOK)); 26 | } 27 | self::reset(); 28 | return $strContent; 29 | } 30 | 31 | public static function render($type){ 32 | $html = ''; 33 | if(!empty(self::$arrStaticCollection[$type])){ 34 | $arrURIs = &self::$arrStaticCollection[$type]; 35 | if($type === 'js'){ 36 | $html = ''; 37 | } else if($type === 'css'){ 38 | $html = ''; 39 | } 40 | } 41 | return $html; 42 | } 43 | 44 | public static function addScriptPool($str){ 45 | self::$arrScriptPool[] = $str; 46 | } 47 | 48 | public static function renderScriptPool(){ 49 | $html = ''; 50 | if(!empty(self::$arrScriptPool)){ 51 | $html = ''; 52 | } 53 | return $html; 54 | } 55 | 56 | public static function register($strNamespace, $smarty){ 57 | if($strNamespace === '__global__'){ 58 | $strMapName = 'map.json'; 59 | } else { 60 | $strMapName = $strNamespace . '-map.json'; 61 | } 62 | $arrConfigDir = $smarty->getConfigDir(); 63 | foreach ($arrConfigDir as $strDir) { 64 | $strPath = preg_replace('/[\\/\\\\]+/', '/', $strDir . '/' . $strMapName); 65 | if(is_file($strPath)){ 66 | self::$arrMap[$strNamespace] = json_decode(file_get_contents($strPath), true); 67 | return true; 68 | } 69 | } 70 | return false; 71 | } 72 | 73 | public static function load($strName, $smarty){ 74 | $strLoadedURI = self::$arrLoaded[$strName]; 75 | if(isset($strLoadedURI)){ 76 | return $strLoadedURI; 77 | } else { 78 | $intPos = strpos($strName, ':'); 79 | if($intPos === false){ 80 | $strNamespace = '__global__'; 81 | } else { 82 | $strNamespace = substr($strName, 0, $intPos); 83 | } 84 | if(isset(self::$arrMap[$strNamespace]) || self::register($strNamespace, $smarty)){ 85 | $arrMap = &self::$arrMap[$strNamespace]; 86 | $arrRes = &$arrMap['res'][$strName]; 87 | if(isset($arrRes)){ 88 | if(isset($arrRes['pkg'])){ 89 | $arrPkg = &$arrMap['pkg'][$arrRes['pkg']]; 90 | $strURI = $arrPkg['uri']; 91 | foreach ($arrPkg['has'] as $strResId) { 92 | //todo 93 | self::$arrLoaded[$strName] = $strURI; 94 | } 95 | } else { 96 | if(isset($arrRes['deps'])){ 97 | foreach ($arrRes['deps'] as $strDep) { 98 | self::load($strDep, $smarty); 99 | } 100 | } 101 | $strURI = $arrRes['uri']; 102 | self::$arrLoaded[$strName] = $strURI; 103 | } 104 | self::$arrStaticCollection[$arrRes['type']][] = $strURI; 105 | return $strURI; 106 | } else { 107 | trigger_error('undefined resource "' . $strName . '"', E_USER_ERROR); 108 | } 109 | } else { 110 | trigger_error('missing map file of "' . $strNamespace . '"', E_USER_ERROR); 111 | } 112 | } 113 | trigger_error('unknown resource load error', E_USER_ERROR); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /test/ut/release/test7/plugin/compiler.body.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return ''; 9 | } 10 | 11 | function smarty_compiler_bodyclose($arrParams, $smarty){ 12 | $strCode = ''; 13 | $strCode .= ''; 19 | return $strCode; 20 | } -------------------------------------------------------------------------------- /test/ut/release/test7/plugin/compiler.head.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return ''; 9 | } 10 | 11 | function smarty_compiler_headclose($arrParams, $smarty){ 12 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 13 | $strCode = ''; 17 | $strCode .= ''; 18 | return $strCode; 19 | } -------------------------------------------------------------------------------- /test/ut/release/test7/plugin/compiler.html.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return "\n"; 9 | } 10 | 11 | function smarty_compiler_htmlclose($arrParams, $smarty){ 12 | $strCode = 'registerFilter(\'output\', array(\'FISResource\', \'renderResponse\'));'; 14 | $strCode .= '?>'; 15 | $strCode .= ''; 16 | return $strCode; 17 | } -------------------------------------------------------------------------------- /test/ut/release/test7/plugin/compiler.require.php: -------------------------------------------------------------------------------- 1 | smarty);'; 10 | $strCode .= '?>'; 11 | } 12 | return $strCode; 13 | } -------------------------------------------------------------------------------- /test/ut/release/test7/plugin/compiler.script.php: -------------------------------------------------------------------------------- 1 | '; 5 | } 6 | 7 | function smarty_compiler_scriptclose($params, $smarty){ 8 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 9 | $strCode = ''; 15 | return $strCode; 16 | } -------------------------------------------------------------------------------- /test/ut/release/test7/plugin/compiler.widget.php: -------------------------------------------------------------------------------- 1 | getConfigDir(); 13 | foreach ($arrConfigDir as $strDir) { 14 | $strPath = preg_replace('/[\\/\\\\]+/', '/', $strDir . '/' . $strFilename); 15 | if(is_file($strPath)){ 16 | self::$arrCached[$strFilename] = $strPath; 17 | return $strPath; 18 | } 19 | } 20 | } 21 | trigger_error('missing map file "' . $strFilename . '"', E_USER_ERROR); 22 | } 23 | } 24 | 25 | function smarty_compiler_widget($arrParams, $smarty){ 26 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 27 | $strCode = ' $_value) { 36 | if (is_int($_key)) { 37 | $arrFuncParams[] = "$_key=>$_value"; 38 | } else { 39 | $arrFuncParams[] = "'$_key'=>$_value"; 40 | } 41 | } 42 | $strFuncParams = 'array(' . implode(',', $arrFuncParams) . ')'; 43 | $strTplFuncName = '\'smarty_template_function_\'.' . $strCall; 44 | $strCallTplFunc = 'call_user_func('. $strTplFuncName . ',$_smarty_tpl,' . $strFuncParams . ');'; 45 | 46 | $strCode .= 'if(is_callable('. $strTplFuncName . ')){'; 47 | $strCode .= $strCallTplFunc; 48 | $strCode .= '}else{'; 49 | } 50 | if($strName){ 51 | $strCode .= '$_tpl_path=FISResource::load(' . $strName . ',$_smarty_tpl->smarty);'; 52 | $strCode .= 'if(isset($_tpl_path)){'; 53 | if($bHasCall){ 54 | $strCode .= '$_smarty_tpl->smarty->fetch($_tpl_path);'; 55 | $strCode .= 'if(is_callable('. $strTplFuncName . ')){'; 56 | $strCode .= $strCallTplFunc; 57 | $strCode .= '}else{'; 58 | $strCode .= 'trigger_error(\'missing function define "\'.' . $strTplFuncName . '.\'" in tpl "\'.$_tpl_path.\'"\', E_USER_ERROR);'; 59 | $strCode .= '}'; 60 | } else { 61 | $strCode .= 'echo $_smarty_tpl->smarty->fetch($_tpl_path);'; 62 | } 63 | $strCode .= '}else{'; 64 | $strCode .= 'trigger_error(\'unable to locale resource "\'.' . $strName . '.\'"\', E_USER_ERROR);'; 65 | $strCode .= '}'; 66 | } else { 67 | trigger_error('undefined widget name in file "' . $smarty->_current_file . '"', E_USER_ERROR); 68 | } 69 | if($bHasCall){ 70 | $strCode .= '}'; 71 | } 72 | $strCode .= '?>'; 73 | return $strCode; 74 | } -------------------------------------------------------------------------------- /test/ut/release/test7/ui/a/a.js: -------------------------------------------------------------------------------- 1 | require('../b/b.js'); 2 | console.log("a"); -------------------------------------------------------------------------------- /test/ut/release/test7/ui/b/b.js: -------------------------------------------------------------------------------- 1 | console.log("b"); -------------------------------------------------------------------------------- /test/ut/release/test7/widget/c/c.js: -------------------------------------------------------------------------------- 1 | console.log("c"); 2 | require('../d/d.js'); -------------------------------------------------------------------------------- /test/ut/release/test7/widget/comp/comp.js: -------------------------------------------------------------------------------- 1 | exports.name = 'comp'; 2 | console.log('comp loaded'); -------------------------------------------------------------------------------- /test/ut/release/test7/widget/d/d.js: -------------------------------------------------------------------------------- 1 | console.log("d"); -------------------------------------------------------------------------------- /test/ut/release/test7/widget/e/e.js: -------------------------------------------------------------------------------- 1 | console.log("e"); -------------------------------------------------------------------------------- /test/ut/release/test7/widget/list/list.css: -------------------------------------------------------------------------------- 1 | h2 { 2 | color: red; 3 | } -------------------------------------------------------------------------------- /test/ut/release/test7/widget/list/list.js: -------------------------------------------------------------------------------- 1 | var comp = require('../comp/comp.js'); 2 | require('../c/c.js'); 3 | require('../e/e.js'); 4 | console.log(comp); 5 | exports.name = 'list'; 6 | console.log('list loaded'); -------------------------------------------------------------------------------- /test/ut/release/test7/widget/list/list.tpl: -------------------------------------------------------------------------------- 1 |

widget run!

2 | {%script%} 3 | seajs.use('photo:widget/list/list.js', function(list){ 4 | console.log(list); 5 | }); 6 | {%/script%} -------------------------------------------------------------------------------- /test/ut/release/test8/fis-conf.js: -------------------------------------------------------------------------------- 1 | fis.config.merge({ 2 | namespace : 'photo', 3 | "modules" : { 4 | "packager" : "map" 5 | }, 6 | roadmap : { 7 | domain : { 8 | '*.js' : 'http://img.baidu.com', 9 | '*.css' : 'http://css.baidu.com' 10 | }, 11 | path : [ 12 | { 13 | reg : /^\/test\//i, 14 | release : false 15 | }, 16 | { 17 | reg : /\.tmpl$/i, 18 | release : false 19 | }, 20 | { 21 | reg : /^\/widget\/.*\.(js|css)$/i, 22 | isMod : true, 23 | release : '/static/${namespace}$&' 24 | }, 25 | { 26 | reg : /^\/ui\/.*\.(js|css)$/i, 27 | isMod : true, 28 | release : '/static/${namespace}$&' 29 | }, 30 | { 31 | reg : /^\/widget\/(.*\.tpl)$/i, 32 | isMod : true, 33 | url : 'widget/${namespace}/$1', 34 | release : '/template/widget/${namespace}/$1' 35 | }, 36 | { 37 | reg : /^\/plugin\//i 38 | }, 39 | { 40 | reg : /^\/.+\.tpl$/i, 41 | release : '/template/${namespace}$&' 42 | }, 43 | { 44 | reg : /^\/photo-map\.json$/i, 45 | release : '/config$&' 46 | }, 47 | { 48 | reg : /^.*$/, 49 | release : '/static/${namespace}$&' 50 | } 51 | 52 | ] 53 | }, 54 | settings : { 55 | modular : { 56 | reqlang : { 57 | wrap : 'amd' 58 | } 59 | } 60 | }, 61 | deploy : { 62 | 'rd-test' : { 63 | receiver : 'http://zhangyunlong.fe.baidu.com/receiver.php', 64 | to : '/home/zhangyunlong/public_html' 65 | } 66 | } 67 | }); 68 | -------------------------------------------------------------------------------- /test/ut/release/test8/fis-pack.json: -------------------------------------------------------------------------------- 1 | { 2 | "static/aio.js" : [ 3 | "widget/comp/comp.js", 4 | "widget/list/list.js" 5 | ], 6 | "static/aio1.js":[ 7 | "ui/**" 8 | ], 9 | "static/aio2.js": "/js\//" 10 | } -------------------------------------------------------------------------------- /test/ut/release/test8/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 20px; 3 | } -------------------------------------------------------------------------------- /test/ut/release/test8/index.js: -------------------------------------------------------------------------------- 1 | console.log('index.js'); -------------------------------------------------------------------------------- /test/ut/release/test8/index.tpl: -------------------------------------------------------------------------------- 1 | {%html%} 2 | {%head%} 3 | 4 | name----- 5 | {%/head%} 6 | {%body%} 7 | 8 | {%require name="photo:sea.js"%} 9 | {%require name="photo:index.js"%} 10 | {%require name="photo:ui/a/a.js"%} 11 | {%script%} 12 | seajs.use('photo:ui/a/a.js', function(a){ 13 | 14 | }); 15 | {%/script%} 16 | 17 | 18 |

hello world fis.

19 |

I'm a boy.

20 |

test1

21 |

test2

22 |

test3

23 |

test4

24 | 25 | {%widget name="photo:widget/list/list.tpl"%} 26 | 27 | {%require name="photo:index.css"%} 28 | {%/body%} 29 | {%/html%} -------------------------------------------------------------------------------- /test/ut/release/test8/js/a/a.js: -------------------------------------------------------------------------------- 1 | console.log("a"); -------------------------------------------------------------------------------- /test/ut/release/test8/js/b/b.js: -------------------------------------------------------------------------------- 1 | console.log("b"); -------------------------------------------------------------------------------- /test/ut/release/test8/npm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/release/test8/npm.png -------------------------------------------------------------------------------- /test/ut/release/test8/plugin/FISResource.class.php: -------------------------------------------------------------------------------- 1 | '; 5 | 6 | private static $arrMap = array(); 7 | private static $arrLoaded = array(); 8 | private static $arrStaticCollection = array(); 9 | private static $arrScriptPool = array(); 10 | 11 | public static function reset(){ 12 | self::$arrMap = array(); 13 | self::$arrLoaded = array(); 14 | self::$arrStaticCollection = array(); 15 | self::$arrScriptPool = array(); 16 | } 17 | 18 | public static function cssHook(){ 19 | return self::CSS_LINKS_HOOK; 20 | } 21 | 22 | public static function renderResponse($strContent){ 23 | $intPos = strpos($strContent, self::CSS_LINKS_HOOK); 24 | if($intPos !== false){ 25 | $strContent = substr_replace($strContent, self::render('css'), $intPos, strlen(self::CSS_LINKS_HOOK)); 26 | } 27 | self::reset(); 28 | return $strContent; 29 | } 30 | 31 | public static function render($type){ 32 | $html = ''; 33 | if(!empty(self::$arrStaticCollection[$type])){ 34 | $arrURIs = &self::$arrStaticCollection[$type]; 35 | if($type === 'js'){ 36 | $html = ''; 37 | } else if($type === 'css'){ 38 | $html = ''; 39 | } 40 | } 41 | return $html; 42 | } 43 | 44 | public static function addScriptPool($str){ 45 | self::$arrScriptPool[] = $str; 46 | } 47 | 48 | public static function renderScriptPool(){ 49 | $html = ''; 50 | if(!empty(self::$arrScriptPool)){ 51 | $html = ''; 52 | } 53 | return $html; 54 | } 55 | 56 | public static function register($strNamespace, $smarty){ 57 | if($strNamespace === '__global__'){ 58 | $strMapName = 'map.json'; 59 | } else { 60 | $strMapName = $strNamespace . '-map.json'; 61 | } 62 | $arrConfigDir = $smarty->getConfigDir(); 63 | foreach ($arrConfigDir as $strDir) { 64 | $strPath = preg_replace('/[\\/\\\\]+/', '/', $strDir . '/' . $strMapName); 65 | if(is_file($strPath)){ 66 | self::$arrMap[$strNamespace] = json_decode(file_get_contents($strPath), true); 67 | return true; 68 | } 69 | } 70 | return false; 71 | } 72 | 73 | public static function load($strName, $smarty){ 74 | $strLoadedURI = self::$arrLoaded[$strName]; 75 | if(isset($strLoadedURI)){ 76 | return $strLoadedURI; 77 | } else { 78 | $intPos = strpos($strName, ':'); 79 | if($intPos === false){ 80 | $strNamespace = '__global__'; 81 | } else { 82 | $strNamespace = substr($strName, 0, $intPos); 83 | } 84 | if(isset(self::$arrMap[$strNamespace]) || self::register($strNamespace, $smarty)){ 85 | $arrMap = &self::$arrMap[$strNamespace]; 86 | $arrRes = &$arrMap['res'][$strName]; 87 | if(isset($arrRes)){ 88 | if(isset($arrRes['pkg'])){ 89 | $arrPkg = &$arrMap['pkg'][$arrRes['pkg']]; 90 | $strURI = $arrPkg['uri']; 91 | foreach ($arrPkg['has'] as $strResId) { 92 | //todo 93 | self::$arrLoaded[$strName] = $strURI; 94 | } 95 | } else { 96 | if(isset($arrRes['deps'])){ 97 | foreach ($arrRes['deps'] as $strDep) { 98 | self::load($strDep, $smarty); 99 | } 100 | } 101 | $strURI = $arrRes['uri']; 102 | self::$arrLoaded[$strName] = $strURI; 103 | } 104 | self::$arrStaticCollection[$arrRes['type']][] = $strURI; 105 | return $strURI; 106 | } else { 107 | trigger_error('undefined resource "' . $strName . '"', E_USER_ERROR); 108 | } 109 | } else { 110 | trigger_error('missing map file of "' . $strNamespace . '"', E_USER_ERROR); 111 | } 112 | } 113 | trigger_error('unknown resource load error', E_USER_ERROR); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /test/ut/release/test8/plugin/compiler.body.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return ''; 9 | } 10 | 11 | function smarty_compiler_bodyclose($arrParams, $smarty){ 12 | $strCode = ''; 13 | $strCode .= ''; 19 | return $strCode; 20 | } -------------------------------------------------------------------------------- /test/ut/release/test8/plugin/compiler.head.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return ''; 9 | } 10 | 11 | function smarty_compiler_headclose($arrParams, $smarty){ 12 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 13 | $strCode = ''; 17 | $strCode .= ''; 18 | return $strCode; 19 | } -------------------------------------------------------------------------------- /test/ut/release/test8/plugin/compiler.html.php: -------------------------------------------------------------------------------- 1 | $_value) { 6 | $strAttr .= ' ' . $_key . '=""'; 7 | } 8 | return "\n"; 9 | } 10 | 11 | function smarty_compiler_htmlclose($arrParams, $smarty){ 12 | $strCode = 'registerFilter(\'output\', array(\'FISResource\', \'renderResponse\'));'; 14 | $strCode .= '?>'; 15 | $strCode .= ''; 16 | return $strCode; 17 | } -------------------------------------------------------------------------------- /test/ut/release/test8/plugin/compiler.require.php: -------------------------------------------------------------------------------- 1 | smarty);'; 10 | $strCode .= '?>'; 11 | } 12 | return $strCode; 13 | } -------------------------------------------------------------------------------- /test/ut/release/test8/plugin/compiler.script.php: -------------------------------------------------------------------------------- 1 | '; 5 | } 6 | 7 | function smarty_compiler_scriptclose($params, $smarty){ 8 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 9 | $strCode = ''; 15 | return $strCode; 16 | } -------------------------------------------------------------------------------- /test/ut/release/test8/plugin/compiler.widget.php: -------------------------------------------------------------------------------- 1 | getConfigDir(); 13 | foreach ($arrConfigDir as $strDir) { 14 | $strPath = preg_replace('/[\\/\\\\]+/', '/', $strDir . '/' . $strFilename); 15 | if(is_file($strPath)){ 16 | self::$arrCached[$strFilename] = $strPath; 17 | return $strPath; 18 | } 19 | } 20 | } 21 | trigger_error('missing map file "' . $strFilename . '"', E_USER_ERROR); 22 | } 23 | } 24 | 25 | function smarty_compiler_widget($arrParams, $smarty){ 26 | $strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php'); 27 | $strCode = ' $_value) { 36 | if (is_int($_key)) { 37 | $arrFuncParams[] = "$_key=>$_value"; 38 | } else { 39 | $arrFuncParams[] = "'$_key'=>$_value"; 40 | } 41 | } 42 | $strFuncParams = 'array(' . implode(',', $arrFuncParams) . ')'; 43 | $strTplFuncName = '\'smarty_template_function_\'.' . $strCall; 44 | $strCallTplFunc = 'call_user_func('. $strTplFuncName . ',$_smarty_tpl,' . $strFuncParams . ');'; 45 | 46 | $strCode .= 'if(is_callable('. $strTplFuncName . ')){'; 47 | $strCode .= $strCallTplFunc; 48 | $strCode .= '}else{'; 49 | } 50 | if($strName){ 51 | $strCode .= '$_tpl_path=FISResource::load(' . $strName . ',$_smarty_tpl->smarty);'; 52 | $strCode .= 'if(isset($_tpl_path)){'; 53 | if($bHasCall){ 54 | $strCode .= '$_smarty_tpl->smarty->fetch($_tpl_path);'; 55 | $strCode .= 'if(is_callable('. $strTplFuncName . ')){'; 56 | $strCode .= $strCallTplFunc; 57 | $strCode .= '}else{'; 58 | $strCode .= 'trigger_error(\'missing function define "\'.' . $strTplFuncName . '.\'" in tpl "\'.$_tpl_path.\'"\', E_USER_ERROR);'; 59 | $strCode .= '}'; 60 | } else { 61 | $strCode .= 'echo $_smarty_tpl->smarty->fetch($_tpl_path);'; 62 | } 63 | $strCode .= '}else{'; 64 | $strCode .= 'trigger_error(\'unable to locale resource "\'.' . $strName . '.\'"\', E_USER_ERROR);'; 65 | $strCode .= '}'; 66 | } else { 67 | trigger_error('undefined widget name in file "' . $smarty->_current_file . '"', E_USER_ERROR); 68 | } 69 | if($bHasCall){ 70 | $strCode .= '}'; 71 | } 72 | $strCode .= '?>'; 73 | return $strCode; 74 | } -------------------------------------------------------------------------------- /test/ut/release/test8/ui/a/a.js: -------------------------------------------------------------------------------- 1 | require('../b/b.js'); 2 | console.log("a"); -------------------------------------------------------------------------------- /test/ut/release/test8/ui/b/b.js: -------------------------------------------------------------------------------- 1 | console.log("b"); -------------------------------------------------------------------------------- /test/ut/release/test8/widget/c/c.js: -------------------------------------------------------------------------------- 1 | console.log("c"); 2 | require('../d/d.js'); -------------------------------------------------------------------------------- /test/ut/release/test8/widget/comp/comp.js: -------------------------------------------------------------------------------- 1 | exports.name = 'comp'; 2 | console.log('comp loaded'); -------------------------------------------------------------------------------- /test/ut/release/test8/widget/d/d.js: -------------------------------------------------------------------------------- 1 | console.log("d"); -------------------------------------------------------------------------------- /test/ut/release/test8/widget/e/e.js: -------------------------------------------------------------------------------- 1 | console.log("e"); -------------------------------------------------------------------------------- /test/ut/release/test8/widget/list/list.css: -------------------------------------------------------------------------------- 1 | h2 { 2 | color: red; 3 | } -------------------------------------------------------------------------------- /test/ut/release/test8/widget/list/list.js: -------------------------------------------------------------------------------- 1 | var comp = require('../comp/comp.js'); 2 | require('../c/c.js'); 3 | require('../e/e.js'); 4 | console.log(comp); 5 | exports.name = 'list'; 6 | console.log('list loaded'); -------------------------------------------------------------------------------- /test/ut/release/test8/widget/list/list.tpl: -------------------------------------------------------------------------------- 1 |

widget run!

2 | {%script%} 3 | seajs.use('photo:widget/list/list.js', function(list){ 4 | console.log(list); 5 | }); 6 | {%/script%} -------------------------------------------------------------------------------- /test/ut/tar/test.tar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/tar/test.tar -------------------------------------------------------------------------------- /test/ut/tar/test.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/tar/test.tgz -------------------------------------------------------------------------------- /test/ut/upload/a.js: -------------------------------------------------------------------------------- 1 | var s = "this is s.js" -------------------------------------------------------------------------------- /test/ut/uri/file/a.js: -------------------------------------------------------------------------------- 1 | require("./b.js"); -------------------------------------------------------------------------------- /test/ut/uri/file/b.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/uri/file/b.js -------------------------------------------------------------------------------- /test/ut/util/base64/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/util/base64/logo.gif -------------------------------------------------------------------------------- /test/ut/util/base64/logo.txt: -------------------------------------------------------------------------------- 1 | R0lGODlhDgGBALMAAGBn6eYxLvvy9PnKyfOene1qZ8/R+Ker84WK7ubn+/vh4DQ840VM5Sky4eEGAv///yH5BAAAAAAALAAAAAAOAYEAAAT/8MlJq7046827/2AojmRpnmiqrmzrvnAsz3Rt33iu73zv/8CgcEgsGo/IpHLJbDqf0Kh0Sq1ar9isdsvter/gsHhMLpvP6LR6zW673/C4fE6v2+/4vH7P7/v/gIGCg4SFhoeIiYqLjI2Oj5CRkpOUlYsJCAwLAAaWkQYLDaKiCJ6OCaGjowcYBgChDKymfQCqqgsJFge2DQACs3oGvKqyE7vDAMB5CMOjDBTCzQ3FynS10g2/EtfNz9V1qdK5DwnYop3fc+YN6MfY1Olv4c3jzObw8W0M5tr22OP53vgb5u3BQIIB1WiDhq2UBHfNHCYkIwBBKk4UuNnCNSFaM44T/8ck2GerGKhh8EiiDElGI7GO8xpI7BiR5RiIGwFigoXvYcyZNr+4tAW0g4ADCBAcAHhUJcagVgSYK3hCwFCZUKt4lKbiKqmsU3AOW1hi6zCAYJ0cPItiLdG0UMTyQkvhAIB9DJ5e8OoM7hOzwy4YUKkKAF0JMQP7dZK4sC5sDNBRWNdgsdp3FeTmrEC5hwAHoB0E6PM5tOnTogMEKDDgRYHTEwQQLkwWcLNkFBrf8mx6NJ/SqIOfJtDitWloiRnQnd2QAnNb3gIIn059AvXrwVvHAY4ddQCyJ4yHrpCAGwME4N1ilqB+lEPp3btbj99dOxzu9EMXWCEedKvDD2iGzf8C6NimCjrw5TfdfApOZ98b+DX4oAn9OQCCgeswoA1fuD2QYIOoMegAAQOUaOKJKKZYInht4LdfBgR86MCLKAxAwI03fnASMQb0uA5uVhEEkAIqnvghiUXaZ5qSoU04QYIsQngajRgIIKMPOx44AWUdGoDAXXkdECUGA/TmwZIiOikBlHW4yAEBp41Jg2aSUdZLCv0R18GSIJqmgBxubgCnaQvJGNxqTlbIgYB12tnhBn2ithCfkTrw53ZTcqDok/QFcKkEm2bAFztb2tmLnCJWOmmTlVoKaKYaDBqab2sqaF+oFgRZ2AE99riQKAAES9gmwgILIAWthrYqaEwyiwH/m3Tgt1oB1FZbraF61prfd6DCdoFst/S05QITlDNKh+Y2oJwGvanm7rvwuktomvReAO0cEW5bQZImxjhct8ftdYtkGDRArgTp3onwwBmYlm0HZSpb7wMOqyirA6iukS99am5gpZkP4GpMSdAcYPKvB5Pj2MK3HOswCBGDtqwDzcaXsUKRdvymtyI/IMA8VA1UZ8oJo8vLo8iG9jAHMWM8sb5tVrq0BxdbGLK3db31kC1Dl7uyynNd8PIHTc9c83UFfIqvd/G+i9rU/tIH8HgVuFSMS12zDKzXvBRFcbJOS4BmIoFm0DRoalco39UB50ayBLPlDfbeeqtCVaqRmn24/4Jrm0YlmbAyzrno/nGm9QN4j8s35ZPvZgHggf/N7Ob5da5fBx/6RvviPR9Nk5YSGLy6wq2rIjbgmkdK632ha7Bp7h1XPXfpzoUtgSujSB5gsABIlPAoKScNGpL8nnix2Q/EDVoAS6s//s1nFK6BjALgp7P0pFtNwVpIX3DOBt9jnfhGBLN5Ca5JEhBA1QLQGvfNCH5okB/o4qQArF0Afz2Ti98mo65jVc49xxtfASV2QGdNQAEVklHa7iDBCiigaqLx2WnuxzMLJvA5sTiWM8SEgQCS6nVKG6HMJjaBARhKNDpjXqtedBoGYgCDNtyaqaaIDAyMjWoGlB3NLrA5T9TpYWP50Ybi4jM9/dWNimjMnhWRR8T0HRE0K2Rhq+zzsQaVsUqjSuNK1pisARqROm9EIKb65EQKKCCQC8qfBg7wHGd0TykmS8orpkIwIC7Rj29kn8/GaEIlbqsAU0ugA69zxw0YIJKQ5FXGvHSXWwCAh+yq1GrI8q4/TmlCAxhjEi3Dy1768pfADKYwh0nMYhrzmMhMpjKXycxmOvOZ0IymNKdJzWpa85rYzKY2t8nNbnrzm+AMpzjHSc5ymvOc6EynOtfJzna6853wjKc850nPeoYgAgA7 -------------------------------------------------------------------------------- /test/ut/util/encoding/gbk.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/util/encoding/gbk.txt -------------------------------------------------------------------------------- /test/ut/util/encoding/utf8-bom.txt: -------------------------------------------------------------------------------- 1 | 你好,©我是€utf8-bom文件 -------------------------------------------------------------------------------- /test/ut/util/encoding/utf8.txt: -------------------------------------------------------------------------------- 1 | 你好,©我是€无bom文件 -------------------------------------------------------------------------------- /test/ut/util/encoding/utfcode.txt: -------------------------------------------------------------------------------- 1 | 𐀀񐀀􀀀ࠀ퀀 -------------------------------------------------------------------------------- /test/ut/util/img/data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/util/img/data.png -------------------------------------------------------------------------------- /test/ut/util/img/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/util/img/test.png -------------------------------------------------------------------------------- /test/ut/util/json/error.json: -------------------------------------------------------------------------------- 1 | hello world -------------------------------------------------------------------------------- /test/ut/util/json/gbk.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fex-team/fis-kernel/f02a3318977be692088e02ceda33a9ca45115441/test/ut/util/json/gbk.json -------------------------------------------------------------------------------- /test/ut/util/json/json.json: -------------------------------------------------------------------------------- 1 | { 2 | "a":"test1", 3 | "b":"test2", 4 | "arr":{ 5 | "arr1":"1" 6 | } 7 | } -------------------------------------------------------------------------------- /test/ut/util/json/utf8-bom.json: -------------------------------------------------------------------------------- 1 | { 2 | "你好" : "中文", 3 | "string" : "hello world", 4 | "boolean" : true, 5 | "number" : 123, 6 | "null" : null, 7 | "©" : "€", 8 | "array" : ["中文", "hello world", true, 123, null, "©", "€"], 9 | "object" : { 10 | "你好" : "中文", 11 | "string" : "hello world", 12 | "boolean" : true, 13 | "number" : 123, 14 | "null" : null, 15 | "©" : "€", 16 | "array" : ["中文", "hello world", true, 123, null, "©", "€"], 17 | "object" : { 18 | "你好" : "中文", 19 | "string" : "hello world", 20 | "boolean" : true, 21 | "number" : 123, 22 | "null" : null, 23 | "©" : "€", 24 | "array" : ["中文", "hello world", true, 123, null, "©", "€"] 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /test/ut/util/json/utf8.json: -------------------------------------------------------------------------------- 1 | { 2 | "你好" : "中文", 3 | "string" : "hello world", 4 | "boolean" : true, 5 | "number" : 123, 6 | "null" : null, 7 | "©" : "€", 8 | "array" : ["中文", "hello world", true, 123, null, "©", "€"], 9 | "object" : { 10 | "你好" : "中文", 11 | "string" : "hello world", 12 | "boolean" : true, 13 | "number" : 123, 14 | "null" : null, 15 | "©" : "€", 16 | "array" : ["中文", "hello world", true, 123, null, "©", "€"], 17 | "object" : { 18 | "你好" : "中文", 19 | "string" : "hello world", 20 | "boolean" : true, 21 | "number" : 123, 22 | "null" : null, 23 | "©" : "€", 24 | "array" : ["中文", "hello world", true, 123, null, "©", "€"] 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /test/ut/xunit-report/do.js: -------------------------------------------------------------------------------- 1 | /* 用来删除写到xunit report里的install信息 */ 2 | 3 | var fs = require('fs'); 4 | var file = "report.xml"; 5 | var content = fs.readFileSync(file,'utf-8'); 6 | content = content.replace(/\binstall.*\n/gi,''); 7 | fs.writeFileSync(file, content,"utf-8"); --------------------------------------------------------------------------------