Comparing version 1.1.6 to 1.1.7
@@ -7,2 +7,5 @@ ####################################################################### | ||
ver 1.1.7 | ||
* 新增:支持子模板,语法为 <%require.text('./my.tpl')%> | ||
ver 1.1.6 | ||
@@ -9,0 +12,0 @@ * Bugfix: 模板出现\\n。 |
{ | ||
"name": "tpm", | ||
"version": "1.1.6", | ||
"version": "1.1.7", | ||
"description": "Static Package Manager", | ||
@@ -5,0 +5,0 @@ "author": "Longhao Luo <lhluo@tudou.com>", |
@@ -210,5 +210,5 @@ var Path = require('path'); | ||
if (/^(module|page|lazy)\/mobile\//.test(relativePath)) { | ||
var ignore = config.mobileIgnore; | ||
var ignore = config.mobileIgnore || []; | ||
} else { | ||
var ignore = config.ignore; | ||
var ignore = config.ignore || []; | ||
} | ||
@@ -321,4 +321,8 @@ } else { | ||
var jsDirPath = config.root + '/src/js'; | ||
config.ignore = Util.grepDepList(jsDirPath + '/g.js', jsDirPath, true); | ||
config.mobileIgnore = Util.grepDepList(jsDirPath + '/m.js', jsDirPath, true); | ||
if (Fs.existsSync(jsDirPath + '/g.js')) { | ||
config.ignore = Util.grepDepList(jsDirPath + '/g.js', jsDirPath, true); | ||
} | ||
if (Fs.existsSync(jsDirPath + '/m.js')) { | ||
config.mobileIgnore = Util.grepDepList(jsDirPath + '/m.js', jsDirPath, true); | ||
} | ||
@@ -325,0 +329,0 @@ buildFiles(pathList); |
@@ -889,4 +889,4 @@ /** | ||
define('g', [ | ||
'tui/cookie', | ||
'tui/dialog' | ||
"tui/cookie", | ||
"tui/dialog" | ||
], function(Cookie, Dialog, require, exports) { | ||
@@ -893,0 +893,0 @@ |
@@ -5,3 +5,2 @@ /** | ||
*/ | ||
/* @source lazy/demo.js */; | ||
@@ -8,0 +7,0 @@ |
@@ -15,2 +15,4 @@ /** | ||
var testStr = '<div>\n<% for (var i = 0; i < 100; i++) {%>\n<li>\n<%=row.nickname%>: <img src="#"/>\n</li>\n<%}%>\n</div>'; | ||
require(['lazy/demo'], function(Demo) { | ||
@@ -17,0 +19,0 @@ Demo.init(); |
@@ -5,2 +5,2 @@ /** | ||
*/ | ||
require.config({enable_ozma:!0}),define("tui/class",[],function(){function e(){return function(){this.initialize&&this.initialize.apply(this,arguments)}}function t(t,n){var r=this,i=e();$.extend(i,r,n);var s=Object.create(r.prototype);return s.constructor=i,i.prototype=s,$.extend(i.prototype,t),i.superClass=r.prototype,i}var n=function(n){var r=e();return $.extend(r.prototype,n),r.extend=t,r};return n.extend=t,n}),define("tui/event",["tui/class"],function(e){var t=e({initialize:function(){this.__event=window.Zepto?new window.Zepto.Events:$({})}}),n=t.prototype;return["bind","one"].forEach(function(e){n[e]=function(t,n){var r=this.__event,i=function(){n.apply(r,arguments.length>0?window.Zepto?arguments:Array.prototype.slice.call(arguments,1):[])};return r[e].call(r,t,i),this}}),["unbind","trigger"].forEach(function(e){n[e]=function(){var t=this.__event;return t[e].apply(t,arguments)}}),n.fire=n.trigger,t.mix=function(e){return $.extend(e,new t)},t}),define("tui/drag",["tui/event"],function(e){function n(){return window.getSelection?window.getSelection().removeAllRanges():document.selection&&document.selection.empty(),this}var t=$(window),r=e.extend({initialize:function(e,i){function u(e){e.preventDefault()}function f(e){e.preventDefault();if(!s.bubble||e.target==a[0])s.start(e),$(document).bind("selectstart",u),a[0].setCapture&&a[0].setCapture()}function l(e){e.preventDefault();if(s.state2){s.state2=!1;var n=e.pageX-s.mx2+s.x2-s.cx2,r=e.pageY-s.my2+s.y2-s.cy2;s.fixed2&&(n-=t.scrollLeft(),r-=t.scrollTop()),s.limit&&(n=Math.max(n,0),r=Math.max(r,0),n=Math.min(n,s.cWidth-s.dWidth),r=Math.min(r,s.cHeight-s.dHeight)),s.x2=s.node2.offset().left,s.y2=s.node2.offset().top,s.trigger("drag:end",[n,r,e.pageX,e.pageY,s.node2,s.container2])}$(document).unbind("selectstart",u),a[0].releaseCapture&&a[0].releaseCapture()}function c(e){e.preventDefault();if(s.state2&&s.enable2){if(!!s.hasMove()||e.pageX!=s.fx||e.pageY!=s.fy)s.hasMove2=!0;var r=e.pageX-s.mx2+s.x2-s.cx2,i=e.pageY-s.my2+s.y2-s.cy2;s.fixed2&&(r-=t.scrollLeft(),i-=t.scrollTop()),s.limit&&(r=Math.max(r,0),i=Math.max(i,0),r=Math.min(r,s.cWidth-s.dWidth),i=Math.min(i,s.cHeight-s.dHeight)),s.node2.css({left:r,top:i}),n(),s.trigger("drag:move",[r,i,e.pageX,e.pageY,s.node2,s.container2])}}var s=this;i=i||{};var o=i.handler||e;r.superClass.initialize.call(s),s.limit=i.limit,s.bubble=i.bubble,s.enable2=!0,s.state2=!1,s.hasMove2=!1,s.fx=s.fy=-1,s.x2=s.y2=s.mx2=s.my2=s.cx2=s.cy2=0,s.node2=$.type(e)=="string"?$(e):e,s.container2=i.container||s.node2.parent(),s.fixed2=s.node2.css("position").toLowerCase()=="fixed",s.handler2=$.type(o)=="string"?$(o):o;var a=s.handler2||s.node2;a.bind("mousedown",f),$(document).bind("mouseup",l),$(document).bind("mousemove",c),s.cancel=function(){a.unbind("mousedown",f),$(document).unbind("mouseup",l),$(document).unbind("mousemove",c)}},start:function(e){var t=this;t.limit&&(t.cWidth=t.container2.outerWidth(),t.cHeight=t.container2.outerHeight(),t.dWidth=t.node2.outerWidth(),t.dHeight=t.node2.outerHeight()),t.fx=e.pageX,t.fy=e.pageY;while(t.container2[0]){if(t.container2[0].nodeName=="BODY"||["absolute","relative"].indexOf(t.container2.css("position"))>-1)break;t.container2=t.container2.parent()}return t.cx2=t.container2.offset().left,t.cy2=t.container2.offset().top,t.x2=t.node2.offset().left,t.y2=t.node2.offset().top,t.mx2=e.pageX,t.my2=e.pageY,t.state2=!0,t.trigger("drag:start",[t.x2,t.y2,e.pageX,e.pageY,t.node2,t.container2]),this},enable:function(){return this.enable2=!0,this},disable:function(){return this.enable2=!1,this},state:function(){return this.state2},hasMove:function(){return this.hasMove2}});return r}),define("tui/template",[],function(e,t){function r(e,i,s){var o,u=t.tplSettings,a=s?"#"+s:"";if(!/[\t\r\n% ]/.test(e)){o=u._cache[e+a];if(!o){var f=n.getElementById(e);f&&(o=u._cache[e+a]=r(f.innerHTML,!1,s))}}else o=new Function(s||"obj","api","var __p=[];"+(s?"":"with(obj){")+"var mix=api.mix,escapeHTML=api.escapeHTML,substr=api.substr,include=api.include,has=api._has("+(s||"obj")+");"+"__p.push('"+e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(u.interpolate,function(e,t){return"',"+t.replace(/\\'/g,"'")+",'"}).replace(u.evaluate||null,function(e,t){return"');"+t.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+"__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');"+(s?"":"}")+"return __p.join('');");return o?i?o(i,t.tplHelpers):o:""}t.ns=function(e,t,n){var r,i=n||window,s=e.split(".").reverse();while((r=s.pop())&&s.length>0){if(typeof i[r]=="undefined")i[r]={};else if(typeof i[r]!="object")return!1;i=i[r]}return typeof t!="undefined"&&(i[r]=t),i[r]},t.format=function(e,t){return e.replace(/<%\=(\w+)%>/g,function(e,n){return t[n]!=null?t[n]:""})},t.escapeHTML=function(e){e=e||"";var t={"<":"<",">":">","'":"'",'"':""","{":"{","}":"}","@":"@"};return e.replace(/[<>'"\{\}@]/g,function(e){return t[e]})},t.substr=function(e,t,n){if(!e||typeof e!="string")return"";var r=e.substr(0,t).replace(/([^\x00-\xff])/g,"$1 ").substr(0,t).replace(/([^\x00-\xff])\s/g,"$1");return n?n.call(r,r):e.length>r.length?r+"...":r},t.strsize=function(e){return e.replace(/([^\x00-\xff]|[A-Z])/g,"$1 ").length};var n=this.document;t.tplSettings={_cache:{},evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g},t.tplHelpers={mix:$.extend,escapeHTML:t.escapeHTML,substr:t.substr,include:r,_has:function(e){return function(n){return t.ns(n,undefined,e)}}},t.convertTpl=r,t.reloadTpl=function(e){delete t.tplSettings._cache[e]}}),define("tui/widget",["tui/event","tui/template"],function(e,t){function n(e,t){var n,r,i=e.split(" ");return i.length==1?(n=t,r=e):(n=i.shift(),r=i.join(" ")),[n,r]}var r=e.extend({element:null,template:"<div></div>",eventType:"click",model:{},events:{},targetNode:$(document.body),renderMethod:"append",initialize:function(e){var t=this;r.superClass.initialize.call(t),$.each(["element","targetNode"],function(){e[this]&&(t[this]=$(e[this]))}),$.each(["template","eventType","renderMethod"],function(){e[this]&&(t[this]=e[this])}),$.each(["model","events"],function(){e[this]&&$.extend(t[this],e[this])})},find:function(e){return this.element.find(e)},delegate:function(e,t){var r=this;if($.type(e)=="string"&&$.isFunction(t)){var i={};i[e]=t,e=i}return $.each(e,function(e,t){var i=function(e){return $.isFunction(t)?t.call(r,e):r[t](e)},s=n(e,r.eventType);r.element.on(s[0],s[1],i)}),r},undelegate:function(e){var t=this,r=n(e,t.eventType);return t.element.off(r[0],r[1]),t},render:function(e){var n=this;if(!n.element||!n.element[0])n.element=$(t.convertTpl(n.template,e||n.model));return n.delegate(n.events),n.targetNode[n.renderMethod](n.element),n}});return r}),define("tui/mask",[],function(){function s(){e.css({width:Math.max(n.width(),r.width()),height:Math.max(n.height(),r.height())})}var e=$('<div class="tui_mask">'),t,n=$(window),r=$(document),i=$(document.body);return{node:function(){return e},resize:function(){s()},show:function(r){return n.bind("resize",s),e.css("z-index",r||9e4),this.resize(),t?e.show():(i.append(e),t=!0),this},hide:function(r){return n.unbind("resize",s),r?(e.remove(),t=!1):e.hide(),this},update:function(){s()},state:function(){return e.is(":visible")}}}),define("tui/browser",[],function(){var e=navigator.userAgent.toLowerCase(),t={ie6:$.browser.msie&&$.browser.version==6,html5:function(){var e=document.createElement("input"),t=document.createElement("video");return{h264:!!t.canPlayType&&!!t.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"').replace(/no/,""),history:!!(window.history&&window.history.pushState&&window.history.popState),placeholder:"placeholder"in e}},lang:(navigator.language||navigator.systemLanguage).toLowerCase(),iOS:(e.match(/(ipad|iphone|ipod)/)||[])[0],iOSVersion:(e.match(/os\s+([\d_]+)\s+like\s+mac\s+os/)||[0,"0_0_0"])[1].split("_"),wphone:parseFloat((e.match(/windows\sphone\sos\s([\d.]+)/)||["","0"])[1]),android:parseFloat((e.match(/android\s([\d.]+)/)||["","0"])[1])};return t.isMobile=!!t.iOS||!!t.wphone||!!t.android||window.orientation!==undefined||!1,t.isPad=t.isMobile&&(t.iOS=="ipad"||e.indexOf("mobile")==-1)||!1,t}),define("tui/dialog",["tui/browser","tui/template","tui/mask","tui/widget","tui/drag"],function(e,t,n,r,i){var s=$(window),o=e.ie6||!$.support.boxModel,u=10001,a='<div class="tui_dialog_button"><% for (var i = 0; i < data.buttons.length; i++) { %><a data-role="button_<%=i%>" href="#"><%=data.buttons[i].name%></a><% } %></div>',f='<div class="tui_dialog <%=data.className%>"><div<% if (data.msie) { %> class="tui_dialog_wrap"<% } %>><div class="tui_dialog_holder" data-role="holder"><div class="tui_dialog_resize"></div><div class="tui_dialog_w_tp"></div><div class="tui_dialog_w_bm"></div><div class="tui_dialog_w_lf"></div><div class="tui_dialog_w_rt"></div><div class="tui_dialog_w_tl"></div><div class="tui_dialog_w_tr"></div><div class="tui_dialog_w_bl"></div><div class="tui_dialog_w_br"></div><div class="tui_dialog_header" data-role="header"><span class="tui_dialog_close" data-role="close" title="关闭">关闭</span><div class="tui_dialog_title" data-role="title"><%=data.title%></div><div class="tui_dialog_bar"><%=data.bar%></div></div><div class="tui_dialog_content" data-role="content"></div><% if (data.buttons.length > 0) { %><div class="tui_dialog_footer" data-role="footer">'+a+"</div><% } %>"+'<% if (data.info) { %><div class="tui_dialog_info"><%=data.info%></div><% } %>'+"</div></div></div>",l=r.extend({events:{"click [data-role=close]":function(e){e.preventDefault(),this.close()}},initialize:function(e){var n=this,r={template:f,buttons:[],zIndex:u,hasDrag:!0,hasMask:!0,isFixed:!0};e=$.extend(r,e||{}),u=e.zIndex;var i={msie:$.browser.msie&&parseFloat($.browser.version)<9,className:e.className||"tudou_dialog",title:e.title||"",bar:e.bar||"",info:e.info||"",buttons:e.buttons};e.element=$(t.convertTpl(e.template,i,"data")),l.superClass.initialize.call(this,e),n.dom={holder:n.element.find("[data-role=holder]"),header:n.element.find("[data-role=header]"),title:n.element.find("[data-role=title]"),content:n.element.find("[data-role=content]"),footer:n.element.find("[data-role=footer]"),close:n.element.find("[data-role=close]")},n.config=e,n.open()},title:function(e){return this.dom.title.html(e),this},content:function(e){return this.dom.content.html(e),this},open:function(){var e=this,t=e.config,r=e.element,a=e.dom;return r.css("z-index",u),u+=2,t.hasMask&&n.show(r.css("z-index")-1),r.css("position",o||!t.isFixed?"absolute":"fixed"),o&&(e.iframeMask=$("<iframe>",{src:"about:blank",frameborder:0,css:{border:"none","z-index":-1,position:"absolute",top:0,left:0,width:"100%","background-color":"#fff"}}).prependTo(a.holder)),e.content(t.content||""),$.each(t.buttons,function(t){e.events["[data-role=button_"+t+"]"]=this.callback}),e.element.parent()[0]||e.render(),e.element.show(),e.locate(),e.resizeLocate=function(t){e.locate()},s.bind("resize",e.resizeLocate),o&&t.isFixed&&(e.iefixScroll=function(t){e.locate()},s.bind("scroll",e.iefixScroll),e.iframeMask.css({height:a.holder.height()})),e.config.hasDrag&&new i(r,{handler:a.header,limit:!0}),e},close:function(e){var t=this;return t.config.hasMask&&n.hide(!0),t.trigger("close",[t]),t.element[e?"hide":"remove"](),s.unbind("resize",t.resizeLocate),t.iefixScroll&&(s.unbind("scroll",t.iefixScroll),t.iefixScroll=null),t},locate:function(){var e=this,t=Math.max(0,s.width()-e.element.width()>>1);if(!e.config.isFixed)var n=s.scrollTop()+(s.height()-e.element.height())/2;else var n=Math.max(0,s.height()-e.element.height()>>1)+(o?s.scrollTop():0);return e.element.css({left:t,top:n}),e}});return l.confirm=function(e,t){return new l({className:"tudou_dialog alert",title:"土豆提示",content:'<div class="tui_dialog_logo"></div><div class="tui_dialog_text">'+e+"</div>",hasMask:!0,buttons:[{name:"确定",callback:function(e){e.preventDefault(),t&&t.call(this),this.close()}},{name:"取消",callback:function(e){e.preventDefault(),this.close()}}]})},l.alert=function(e,t){return new l({className:"tudou_dialog alert",title:"土豆提示",content:'<div class="tui_dialog_logo"></div><div class="tui_dialog_text">'+e+"</div>",hasMask:!0,buttons:[{name:"确定",callback:function(e){e.preventDefault(),t&&t.call(this),this.close()}}]})},l}),define("tui/cookie",[],function(){return function(e,t,n,r){typeof e=="string"&&(r=n,n=t,t=e,e=window);if(n===undefined)return n=e.document.cookie.match(new RegExp("(?:\\s|^)"+t+"\\=([^;]*)")),n?decodeURIComponent(n[1]):null;r=r||{};var i,s="";r.expires&&(r.expires.constructor==Date?i=r.expires:(i=new Date,i.setTime(i.getTime()+r.expires*24*60*60*1e3)),s="; expires="+i.toGMTString());var o=r.path?"; path="+r.path:"",u=r.domain?"; domain="+r.domain:"",a=r.secure?"; secure":"";e.document.cookie=[t,"=",encodeURIComponent(n),s,o,u,a].join("")}}),define("g",["tui/cookie","tui/dialog"],function(e,t,n,r){r.init=function(){console.log("global init")}}),require(["g"],function(){}); | ||
require.config({enable_ozma:true});define("tui/class",[],function(){function e(){return function(){if(this.initialize)this.initialize.apply(this,arguments)}}function t(t,i){var n=this;var a=e();$.extend(a,n,i);var o=Object.create(n.prototype);o.constructor=a;a.prototype=o;$.extend(a.prototype,t);a.superClass=n.prototype;return a}var i=function(i){var n=e();$.extend(n.prototype,i);n.extend=t;return n};i.extend=t;return i});define("tui/event",["tui/class"],function(e){var t=e({initialize:function(){this.__event=window.Zepto?new window.Zepto.Events:$({})}});var i=t.prototype;["bind","one"].forEach(function(e){i[e]=function(t,i){var n=this.__event;var a=function(){i.apply(n,arguments.length>0?window.Zepto?arguments:Array.prototype.slice.call(arguments,1):[])};n[e].call(n,t,a);return this}});["unbind","trigger"].forEach(function(e){i[e]=function(){var t=this.__event;return t[e].apply(t,arguments)}});i.fire=i.trigger;t.mix=function(e){return $.extend(e,new t)};return t});define("tui/drag",["tui/event"],function(e){var t=$(window);function i(){if(window.getSelection)window.getSelection().removeAllRanges();else if(document.selection)document.selection.empty();return this}var n=e.extend({initialize:function(e,a){var o=this;a=a||{};var r=a.handler||e;n.superClass.initialize.call(o);o.limit=a.limit;o.bubble=a.bubble;o.enable2=true;o.state2=false;o.hasMove2=false;o.fx=o.fy=-1;o.x2=o.y2=o.mx2=o.my2=o.cx2=o.cy2=0;o.node2="string"==$.type(e)?$(e):e;o.container2=a.container||o.node2.parent();o.fixed2="fixed"==o.node2.css("position").toLowerCase();o.handler2="string"==$.type(r)?$(r):r;function s(e){e.preventDefault()}var l=o.handler2||o.node2;function d(e){e.preventDefault();if(!o.bubble||e.target==l[0]){o.start(e);$(document).bind("selectstart",s);if(l[0].setCapture)l[0].setCapture()}}l.bind("mousedown",d);function c(e){e.preventDefault();if(o.state2){o.state2=false;var i=e.pageX-o.mx2+o.x2-o.cx2,n=e.pageY-o.my2+o.y2-o.cy2;if(o.fixed2){i-=t.scrollLeft();n-=t.scrollTop()}if(o.limit){i=Math.max(i,0);n=Math.max(n,0);i=Math.min(i,o.cWidth-o.dWidth);n=Math.min(n,o.cHeight-o.dHeight)}o.x2=o.node2.offset().left;o.y2=o.node2.offset().top;o.trigger("drag:end",[i,n,e.pageX,e.pageY,o.node2,o.container2])}$(document).unbind("selectstart",s);if(l[0].releaseCapture)l[0].releaseCapture()}$(document).bind("mouseup",c);function u(e){e.preventDefault();if(o.state2&&o.enable2){if(!o.hasMove()&&e.pageX==o.fx&&e.pageY==o.fy);else o.hasMove2=true;var n=e.pageX-o.mx2+o.x2-o.cx2,a=e.pageY-o.my2+o.y2-o.cy2;if(o.fixed2){n-=t.scrollLeft();a-=t.scrollTop()}if(o.limit){n=Math.max(n,0);a=Math.max(a,0);n=Math.min(n,o.cWidth-o.dWidth);a=Math.min(a,o.cHeight-o.dHeight)}o.node2.css({left:n,top:a});i();o.trigger("drag:move",[n,a,e.pageX,e.pageY,o.node2,o.container2])}}$(document).bind("mousemove",u);o.cancel=function(){l.unbind("mousedown",d);$(document).unbind("mouseup",c);$(document).unbind("mousemove",u)}},start:function(e){var t=this;if(t.limit){t.cWidth=t.container2.outerWidth();t.cHeight=t.container2.outerHeight();t.dWidth=t.node2.outerWidth();t.dHeight=t.node2.outerHeight()}t.fx=e.pageX;t.fy=e.pageY;while(t.container2[0]){if("BODY"==t.container2[0].nodeName||["absolute","relative"].indexOf(t.container2.css("position"))>-1)break;t.container2=t.container2.parent()}t.cx2=t.container2.offset().left;t.cy2=t.container2.offset().top;t.x2=t.node2.offset().left;t.y2=t.node2.offset().top;t.mx2=e.pageX;t.my2=e.pageY;t.state2=true;t.trigger("drag:start",[t.x2,t.y2,e.pageX,e.pageY,t.node2,t.container2]);return this},enable:function(){this.enable2=true;return this},disable:function(){this.enable2=false;return this},state:function(){return this.state2},hasMove:function(){return this.hasMove2}});return n});define("tui/template",[],function(e,t){t.ns=function(e,t,i){var n,a=i||window,o=e.split(".").reverse();while((n=o.pop())&&o.length>0){if("undefined"===typeof a[n])a[n]={};else if("object"!==typeof a[n])return false;a=a[n]}if("undefined"!==typeof t)a[n]=t;return a[n]};t.format=function(e,t){return e.replace(/<%\=(\w+)%>/g,function(e,i){return null!=t[i]?t[i]:""})};t.escapeHTML=function(e){e=e||"";var t={"<":"<",">":">","'":"'",'"':""","{":"{","}":"}","@":"@"};return e.replace(/[<>'"\{\}@]/g,function(e){return t[e]})};t.substr=function(e,t,i){if(!e||"string"!==typeof e)return"";var n=e.substr(0,t).replace(/([^\x00-\xff])/g,"$1 ").substr(0,t).replace(/([^\x00-\xff])\s/g,"$1");return i?i.call(n,n):e.length>n.length?n+"...":n};t.strsize=function(e){return e.replace(/([^\x00-\xff]|[A-Z])/g,"$1 ").length};var i=this.document;t.tplSettings={_cache:{},evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g};t.tplHelpers={mix:$.extend,escapeHTML:t.escapeHTML,substr:t.substr,include:n,_has:function(e){return function(i){return t.ns(i,void 0,e)}}};function n(e,a,o){var r,s=t.tplSettings,l=o?"#"+o:"";if(!/[\t\r\n% ]/.test(e)){r=s._cache[e+l];if(!r){var d=i.getElementById(e);if(d)r=s._cache[e+l]=n(d.innerHTML,false,o)}}else r=new Function(o||"obj","api","var __p=[];"+(o?"":"with(obj){")+"var mix=api.mix,escapeHTML=api.escapeHTML,substr=api.substr,include=api.include,has=api._has("+(o||"obj")+");"+"__p.push('"+e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(s.interpolate,function(e,t){return"',"+t.replace(/\\'/g,"'")+",'"}).replace(s.evaluate||null,function(e,t){return"');"+t.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+"__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');"+(o?"":"}")+"return __p.join('');");return!r?"":a?r(a,t.tplHelpers):r}t.convertTpl=n;t.reloadTpl=function(e){delete t.tplSettings._cache[e]}});define("tui/widget",["tui/event","tui/template"],function(e,t){function i(e,t){var i;var n;var a=e.split(" ");if(1==a.length){i=t;n=e}else{i=a.shift();n=a.join(" ")}return[i,n]}var n=e.extend({element:null,template:"<div></div>",eventType:"click",model:{},events:{},targetNode:$(document.body),renderMethod:"append",initialize:function(e){var t=this;n.superClass.initialize.call(t);$.each(["element","targetNode"],function(){e[this]&&(t[this]=$(e[this]))});$.each(["template","eventType","renderMethod"],function(){e[this]&&(t[this]=e[this])});$.each(["model","events"],function(){e[this]&&$.extend(t[this],e[this])})},find:function(e){return this.element.find(e)},delegate:function(e,t){var n=this;if("string"==$.type(e)&&$.isFunction(t)){var a={};a[e]=t;e=a}$.each(e,function(e,t){var a=function(e){if($.isFunction(t))return t.call(n,e);else return n[t](e)};var o=i(e,n.eventType);n.element.on(o[0],o[1],a)});return n},undelegate:function(e){var t=this;var n=i(e,t.eventType);t.element.off(n[0],n[1]);return t},render:function(e){var i=this;if(!i.element||!i.element[0])i.element=$(t.convertTpl(i.template,e||i.model));i.delegate(i.events);i.targetNode[i.renderMethod](i.element);return i}});return n});define("tui/mask",[],function(){var e=$('<div class="tui_mask">');var t;var i=$(window);var n=$(document);var a=$(document.body);function o(){e.css({width:Math.max(i.width(),n.width()),height:Math.max(i.height(),n.height())})}return{node:function(){return e},resize:function(){o()},show:function(n){i.bind("resize",o);e.css("z-index",n||9e4);this.resize();if(!t){a.append(e);t=true}else e.show();return this},hide:function(n){i.unbind("resize",o);if(n){e.remove();t=false}else e.hide();return this},update:function(){o()},state:function(){return e.is(":visible")}}});define("tui/browser",[],function(){var e=navigator.userAgent.toLowerCase();var t={ie6:$.browser.msie&&6==$.browser.version,html5:function(){var e=document.createElement("input");var t=document.createElement("video");return{h264:!!(t.canPlayType&&t.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"').replace(/no/,"")),history:!!(window.history&&window.history.pushState&&window.history.popState),placeholder:"placeholder"in e}},lang:(navigator.language||navigator.systemLanguage).toLowerCase(),iOS:(e.match(/(ipad|iphone|ipod)/)||[])[0],iOSVersion:(e.match(/os\s+([\d_]+)\s+like\s+mac\s+os/)||[0,"0_0_0"])[1].split("_"),wphone:parseFloat((e.match(/windows\sphone\sos\s([\d.]+)/)||["","0"])[1]),android:parseFloat((e.match(/android\s([\d.]+)/)||["","0"])[1])};t.isMobile=!!t.iOS||!!t.wphone||!!t.android||void 0!==window.orientation||false;t.isPad=t.isMobile&&("ipad"==t.iOS||e.indexOf("mobile")==-1)||false;return t});define("tui/dialog",["tui/browser","tui/template","tui/mask","tui/widget","tui/drag"],function(e,t,i,n,a){var o=$(window);var r=e.ie6||!$.support.boxModel;var s=10001;var l='<div class="tui_dialog_button"><% for (var i = 0; i < data.buttons.length; i++) { %>'+'<a data-role="button_<%=i%>" href="#"><%=data.buttons[i].name%></a>'+"<% } %></div>";var d='<div class="tui_dialog <%=data.className%>"><div<% if (data.msie) { %> class="tui_dialog_wrap"<% } %>><div class="tui_dialog_holder" data-role="holder">'+'<div class="tui_dialog_resize"></div>'+'<div class="tui_dialog_w_tp"></div><div class="tui_dialog_w_bm"></div>'+'<div class="tui_dialog_w_lf"></div><div class="tui_dialog_w_rt"></div>'+'<div class="tui_dialog_w_tl"></div><div class="tui_dialog_w_tr"></div>'+'<div class="tui_dialog_w_bl"></div><div class="tui_dialog_w_br"></div>'+'<div class="tui_dialog_header" data-role="header"><span class="tui_dialog_close" data-role="close" title="关闭">关闭</span>'+'<div class="tui_dialog_title" data-role="title"><%=data.title%></div><div class="tui_dialog_bar"><%=data.bar%></div></div>'+'<div class="tui_dialog_content" data-role="content"></div>'+'<% if (data.buttons.length > 0) { %><div class="tui_dialog_footer" data-role="footer">'+l+"</div><% } %>"+'<% if (data.info) { %><div class="tui_dialog_info"><%=data.info%></div><% } %>'+"</div></div></div>";var c=n.extend({events:{"click [data-role=close]":function(e){e.preventDefault();this.close()}},initialize:function(e){var i=this;var n={template:d,buttons:[],zIndex:s,hasDrag:true,hasMask:true,isFixed:true};e=$.extend(n,e||{});s=e.zIndex;var a={msie:$.browser.msie&&parseFloat($.browser.version)<9,className:e.className||"tudou_dialog",title:e.title||"",bar:e.bar||"",info:e.info||"",buttons:e.buttons};e.element=$(t.convertTpl(e.template,a,"data"));c.superClass.initialize.call(this,e);i.dom={holder:i.element.find("[data-role=holder]"),header:i.element.find("[data-role=header]"),title:i.element.find("[data-role=title]"),content:i.element.find("[data-role=content]"),footer:i.element.find("[data-role=footer]"),close:i.element.find("[data-role=close]")};i.config=e;i.open()},title:function(e){this.dom.title.html(e);return this},content:function(e){this.dom.content.html(e);return this},open:function(){var e=this;var t=e.config;var n=e.element;var l=e.dom;n.css("z-index",s);s+=2;if(t.hasMask)i.show(n.css("z-index")-1);n.css("position",r||!t.isFixed?"absolute":"fixed");if(r)e.iframeMask=$("<iframe>",{src:"about:blank",frameborder:0,css:{border:"none","z-index":-1,position:"absolute",top:0,left:0,width:"100%","background-color":"#fff"}}).prependTo(l.holder);e.content(t.content||"");$.each(t.buttons,function(t){e.events["[data-role=button_"+t+"]"]=this.callback});if(!e.element.parent()[0])e.render();e.element.show();e.locate();e.resizeLocate=function(t){e.locate()};o.bind("resize",e.resizeLocate);if(r&&t.isFixed){e.iefixScroll=function(t){e.locate()};o.bind("scroll",e.iefixScroll);e.iframeMask.css({height:l.holder.height()})}if(e.config.hasDrag)new a(n,{handler:l.header,limit:true});return e},close:function(e){var t=this;if(t.config.hasMask)i.hide(true);t.trigger("close",[t]);t.element[e?"hide":"remove"]();o.unbind("resize",t.resizeLocate);if(t.iefixScroll){o.unbind("scroll",t.iefixScroll);t.iefixScroll=null}return t},locate:function(){var e=this;var t=Math.max(0,o.width()-e.element.width()>>1);if(!e.config.isFixed)var i=o.scrollTop()+(o.height()-e.element.height())/2;else var i=Math.max(0,o.height()-e.element.height()>>1)+(r?o.scrollTop():0);e.element.css({left:t,top:i});return e}});c.confirm=function(e,t){return new c({className:"tudou_dialog alert",title:"土豆提示",content:'<div class="tui_dialog_logo"></div><div class="tui_dialog_text">'+e+"</div>",hasMask:true,buttons:[{name:"确定",callback:function(e){e.preventDefault();t&&t.call(this);this.close()}},{name:"取消",callback:function(e){e.preventDefault();this.close()}}]})};c.alert=function(e,t){return new c({className:"tudou_dialog alert",title:"土豆提示",content:'<div class="tui_dialog_logo"></div><div class="tui_dialog_text">'+e+"</div>",hasMask:true,buttons:[{name:"确定",callback:function(e){e.preventDefault();t&&t.call(this);this.close()}}]})};return c});define("tui/cookie",[],function(){return function(e,t,i,n){if("string"==typeof e){n=i;i=t;t=e;e=window}if(void 0!==i){n=n||{};var a,o="";if(n.expires){if(n.expires.constructor==Date)a=n.expires;else{a=new Date;a.setTime(a.getTime()+1e3*60*60*24*n.expires)}o="; expires="+a.toGMTString()}var r=n.path?"; path="+n.path:"";var s=n.domain?"; domain="+n.domain:"";var l=n.secure?"; secure":"";e.document.cookie=[t,"=",encodeURIComponent(i),o,r,s,l].join("")}else{i=e.document.cookie.match(new RegExp("(?:\\s|^)"+t+"\\=([^;]*)"));return i?decodeURIComponent(i[1]):null}}});define("g",["tui/cookie","tui/dialog"],function(e,t,i,n){n.init=function(){console.log("global init")}});require(["g"],function(){});; |
@@ -5,2 +5,2 @@ /** | ||
*/ | ||
define("lazy/demo",["tui/cookie","tui/event"],function(e,t,n,r){r.init=function(){console.log("lazy/demo init")}}); | ||
define("lazy/demo",["tui/cookie","tui/event"],function(i,n,o,e){e.init=function(){console.log("lazy/demo init")}});; |
@@ -5,2 +5,2 @@ /** | ||
*/ | ||
require.config({enable_ozma:!0}),require(["g"],function(e){e.init(),require(["lazy/demo"],function(e){e.init()})}); | ||
require.config({enable_ozma:true});require(["g"],function(i){i.init();var n='<div>\n<% for (var i = 0; i < 100; i++) {%>\n<li>\n<%=row.nickname%>: <img src="#"/>\n</li>\n<%}%>\n</div>';require(["lazy/demo"],function(i){i.init()})});; |
@@ -5,2 +5,4 @@ | ||
var testStr = require.text('./test1.tpl'); | ||
require(['lazy/demo'], function(Demo) { | ||
@@ -7,0 +9,0 @@ Demo.init(); |
@@ -8,18 +8,2 @@ | ||
exports.ignore = [ | ||
"g", | ||
"tui/browser", | ||
"tui/util", | ||
"tui/class", | ||
"tui/event", | ||
"tui/cookie", | ||
"tui/storage", | ||
"tui/net", | ||
"tui/template", | ||
"tui/drag", | ||
"tui/mask", | ||
"tui/widget", | ||
"tui/dialog" | ||
]; | ||
exports.main = { | ||
@@ -26,0 +10,0 @@ "js" : [ |
54
util.js
@@ -308,2 +308,13 @@ | ||
function resolveUrl(url) { | ||
while(true) { | ||
url = url.replace(/\w+\/\.\.\//g, ''); | ||
if (!/\.\.\//.test(url)) { | ||
break; | ||
} | ||
} | ||
url = url.replace(/\.\//g, ''); | ||
return url; | ||
} | ||
// 将JS代码改成AMD模块,包含路径转换,补充模块ID,模板转换等 | ||
@@ -315,13 +326,4 @@ function fixModule(path, str) { | ||
function resolveUrl(url) { | ||
while(true) { | ||
url = url.replace(/\w+\/\.\.\//g, ''); | ||
if (!/\.\.\//.test(url)) { | ||
break; | ||
} | ||
} | ||
url = url.replace(/\.\//g, ''); | ||
return url; | ||
} | ||
function fixDep(s, format) { | ||
@@ -367,3 +369,28 @@ if (format) { | ||
// JS模板转换 | ||
return str; | ||
} | ||
// Replace require.text to string | ||
function replaceTemplate(path, str) { | ||
var root = path.replace(/^(.*?)[\\\/](src|build|dist)[\\\/].*$/, '$1'); | ||
// sub template | ||
function replaceSubTemplate(parentPath, str) { | ||
info('import: ' + Path.relative(root + '/src/js', parentPath).split(Path.sep).join('/')); | ||
return str.replace(/<%\s*require\.text\(\s*(['"])(.+?)\1\s*\);?\s*%>/g, function($0, $1, $2) { | ||
var f = $2; | ||
if(/^[a-z_/]/i.test(f)) { | ||
f = root + '/src/js/' + f; | ||
} | ||
else { | ||
f = parentPath.replace(/[\w-]+\.\w+$/, '') + f; | ||
f = resolveUrl(f); | ||
} | ||
var s = readFileSync(f, 'utf-8'); | ||
s = replaceSubTemplate(f, s); | ||
s = s.replace(/^\uFEFF/, ''); | ||
return s; | ||
}); | ||
} | ||
// replace template string | ||
str = str.replace(/(\b)require\.text\(\s*(['"])(.+?)\2\s*\)/g, function($0, $1, $2, $3) { | ||
@@ -375,6 +402,7 @@ var f = $3; | ||
else { | ||
f = path.replace(/[\w-]+\.js$/, '') + f; | ||
f = path.replace(/[\w-]+\.\w+$/, '') + f; | ||
f = resolveUrl(f); | ||
} | ||
var s = readFileSync(f, 'utf-8'); | ||
s = replaceSubTemplate(f, s); | ||
s = s.replace(/^\uFEFF/, ''); | ||
@@ -516,2 +544,3 @@ s = s.replace(/\\/g, '\\\\'); | ||
str = fixModule(filePath, str); | ||
str = replaceTemplate(filePath, str); | ||
content += '\n' + str + '\n'; | ||
@@ -528,2 +557,3 @@ }); | ||
str = fixModule(path, str); | ||
str = replaceTemplate(path, str); | ||
content += '\n' + str; | ||
@@ -530,0 +560,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
1672195
80
38721