瀏覽代碼

deleted files that are now obtained from CDNs

tags/v0.3.3^2
Shaun Kichenbrand 4 年之前
父節點
當前提交
12d204cba3
共有 11 個文件被更改,包括 0 次插入33063 次删除
  1. +0
    -174
      src/client/plugins/css.js
  2. +0
    -4
      src/client/plugins/howler.min.js
  3. +0
    -2
      src/client/plugins/jquery.min.js
  4. +0
    -31443
      src/client/plugins/pixi.js
  5. +0
    -21
      src/client/plugins/pixi.min.js
  6. +0
    -669
      src/client/plugins/pixi.picture.js
  7. +0
    -1
      src/client/plugins/require.min.js
  8. +0
    -3
      src/client/plugins/socket.js
  9. +0
    -391
      src/client/plugins/text.js
  10. +0
    -354
      src/client/plugins/wquery.js
  11. +0
    -1
      src/client/plugins/wquery.min.js

+ 0
- 174
src/client/plugins/css.js 查看文件

@@ -1,174 +0,0 @@
/*
* Require-CSS RequireJS css! loader plugin
* 0.1.8
* Guy Bedford 2014
* MIT
*/

/*
*
* Usage:
* require(['css!./mycssFile']);
*
* Tested and working in (up to latest versions as of March 2013):
* Android
* iOS 6
* IE 6 - 10
* Chome 3 - 26
* Firefox 3.5 - 19
* Opera 10 - 12
*
* browserling.com used for virtual testing environment
*
* Credit to B Cavalier & J Hann for the IE 6 - 9 method,
* refined with help from Martin Cermak
*
* Sources that helped along the way:
* - https://developer.mozilla.org/en-US/docs/Browser_detection_using_the_user_agent
* - http://www.phpied.com/when-is-a-stylesheet-really-loaded/
* - https://github.com/cujojs/curl/blob/master/src/curl/plugin/css.js
*
*/

define(function() {
//>>excludeStart('excludeRequireCss', pragmas.excludeRequireCss)
if (typeof window == 'undefined')
return {
load: function(n, r, load) {
load()
}
};

var head = document.getElementsByTagName('head')[0];

var engine = window.navigator.userAgent.match(/Trident\/([^ ;]*)|AppleWebKit\/([^ ;]*)|Opera\/([^ ;]*)|rv\:([^ ;]*)(.*?)Gecko\/([^ ;]*)|MSIE\s([^ ;]*)|AndroidWebKit\/([^ ;]*)/) || 0;

// use <style> @import load method (IE < 9, Firefox < 18)
var useImportLoad = false;

// set to false for explicit <link> load checking when onload doesn't work perfectly (webkit)
var useOnload = true;

// trident / msie
if (engine[1] || engine[7])
useImportLoad = parseInt(engine[1]) < 6 || parseInt(engine[7]) <= 9;
// webkit
else if (engine[2] || engine[8])
useOnload = false;
// gecko
else if (engine[4])
useImportLoad = parseInt(engine[4]) < 18;

//>>excludeEnd('excludeRequireCss')
//main api object
var cssAPI = {};

//>>excludeStart('excludeRequireCss', pragmas.excludeRequireCss)
cssAPI.pluginBuilder = './css-builder';

// <style> @import load method
var curStyle, curSheet;
var createStyle = function() {
curStyle = document.createElement('style');
head.appendChild(curStyle);
curSheet = curStyle.styleSheet || curStyle.sheet;
}
var ieCnt = 0;
var ieLoads = [];
var ieCurCallback;

var createIeLoad = function(url) {
curSheet.addImport(url);
curStyle.onload = function() {
processIeLoad()
};

ieCnt++;
if (ieCnt == 31) {
createStyle();
ieCnt = 0;
}
}
var processIeLoad = function() {
ieCurCallback();

var nextLoad = ieLoads.shift();

if (!nextLoad) {
ieCurCallback = null;
return;
}

ieCurCallback = nextLoad[1];
createIeLoad(nextLoad[0]);
}
var importLoad = function(url, callback) {
if (!curSheet || !curSheet.addImport)
createStyle();

if (curSheet && curSheet.addImport) {
// old IE
if (ieCurCallback) {
ieLoads.push([url, callback]);
} else {
createIeLoad(url);
ieCurCallback = callback;
}
} else {
// old Firefox
curStyle.textContent = '@import "' + url + '";';

var loadInterval = setInterval(function() {
try {
curStyle.sheet.cssRules;
clearInterval(loadInterval);
callback();
} catch (e) {}
}, 10);
}
}

// <link> load method
var linkLoad = function(url, callback) {
var link = document.createElement('link');
link.type = 'text/css';
link.rel = 'stylesheet';
if (useOnload) {
link.onload = function() {
link.onload = function() {};
// for style dimensions queries, a short delay can still be necessary
setTimeout(callback, 7);
}
} else {
var loadInterval = setInterval(function() {
for (var i = 0; i < document.styleSheets.length; i++) {
var sheet = document.styleSheets[i];
if (sheet.href == link.href) {
clearInterval(loadInterval);
return callback();
}
}
}, 10);
}
link.href = url;
head.appendChild(link);
}

//>>excludeEnd('excludeRequireCss')
cssAPI.normalize = function(name, normalize) {
if (name.substr(name.length - 4, 4) == '.css')
name = name.substr(0, name.length - 4);

return normalize(name);
}

//>>excludeStart('excludeRequireCss', pragmas.excludeRequireCss)
cssAPI.load = function(cssId, req, load, config) {

(useImportLoad ? importLoad : linkLoad)(req.toUrl(cssId + '.css'), load);

}

//>>excludeEnd('excludeRequireCss')
return cssAPI;
});

+ 0
- 4
src/client/plugins/howler.min.js
文件差異過大導致無法顯示
查看文件


+ 0
- 2
src/client/plugins/jquery.min.js
文件差異過大導致無法顯示
查看文件


+ 0
- 31443
src/client/plugins/pixi.js
文件差異過大導致無法顯示
查看文件


+ 0
- 21
src/client/plugins/pixi.min.js
文件差異過大導致無法顯示
查看文件


+ 0
- 669
src/client/plugins/pixi.picture.js 查看文件

@@ -1,669 +0,0 @@
let __extends = (this && this.__extends) || (function () {
let extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) {
d.__proto__ = b;
}) ||
function (d, b) {
for (let p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
};
return function (d, b) {
extendStatics(d, b);
function __ () {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var pixi_picture;
(function (pixi_picture) {
function filterManagerMixin (fm) {
if (fm.prepareBackdrop)
return;
fm.pushFilter = pushFilter;
fm.popFilter = popFilter;
fm.syncUniforms = syncUniforms;
fm.prepareBackdrop = prepareBackdrop;
}
pixi_picture.filterManagerMixin = filterManagerMixin;
function pushFilter (target, filters) {
let renderer = this.renderer;
let filterData = this.filterData;
if (!filterData) {
filterData = this.renderer._activeRenderTarget.filterStack;
let filterState = new FilterState();
filterState.sourceFrame = filterState.destinationFrame = this.renderer._activeRenderTarget.size;
filterState.renderTarget = renderer._activeRenderTarget;
this.renderer._activeRenderTarget.filterData = filterData = {
index: 0,
stack: [filterState]
};
this.filterData = filterData;
}
let currentState = filterData.stack[++filterData.index];
let renderTargetFrame = filterData.stack[0].destinationFrame;
if (!currentState)
currentState = filterData.stack[filterData.index] = new FilterState();
let fullScreen = target.filterArea
&& target.filterArea.x === 0
&& target.filterArea.y === 0
&& target.filterArea.width === renderer.screen.width
&& target.filterArea.height === renderer.screen.height;
let resolution = filters[0].resolution;
let padding = filters[0].padding | 0;
let targetBounds = fullScreen ? renderer.screen : (target.filterArea || target.getBounds(true));
let sourceFrame = currentState.sourceFrame;
let destinationFrame = currentState.destinationFrame;
sourceFrame.x = ((targetBounds.x * resolution) | 0) / resolution;
sourceFrame.y = ((targetBounds.y * resolution) | 0) / resolution;
sourceFrame.width = ((targetBounds.width * resolution) | 0) / resolution;
sourceFrame.height = ((targetBounds.height * resolution) | 0) / resolution;
if (!fullScreen) {
if (filterData.stack[0].renderTarget.transform) {
} else if (filters[0].autoFit)
sourceFrame.fit(renderTargetFrame);
sourceFrame.pad(padding);
}
for (let i = 0; i < filters.length; i++) {
let backdrop = null;
if (filters[i].backdropUniformName) {
if (backdrop === null)
backdrop = this.prepareBackdrop(sourceFrame);
filters[i]._backdropRenderTarget = backdrop;
}
}
destinationFrame.width = sourceFrame.width;
destinationFrame.height = sourceFrame.height;
let renderTarget = this.getPotRenderTarget(renderer.gl, sourceFrame.width, sourceFrame.height, resolution);
currentState.target = target;
currentState.filters = filters;
currentState.resolution = resolution;
currentState.renderTarget = renderTarget;
renderTarget.setFrame(destinationFrame, sourceFrame);
renderer.bindRenderTarget(renderTarget);
renderTarget.clear(filters[filters.length - 1].clearColor);
}
function popFilter () {
let filterData = this.filterData;
let lastState = filterData.stack[filterData.index - 1];
let currentState = filterData.stack[filterData.index];
this.quad.map(currentState.renderTarget.size, currentState.sourceFrame).upload();
let filters = currentState.filters;
if (filters.length === 1) {
filters[0].apply(this, currentState.renderTarget, lastState.renderTarget, false, currentState);
this.freePotRenderTarget(currentState.renderTarget);
} else {
let flip = currentState.renderTarget;
let flop = this.getPotRenderTarget(this.renderer.gl, currentState.sourceFrame.width, currentState.sourceFrame.height, currentState.resolution);
flop.setFrame(currentState.destinationFrame, currentState.sourceFrame);
flop.clear();
var i = 0;
for (i = 0; i < filters.length - 1; ++i) {
filters[i].apply(this, flip, flop, true, currentState);
let t = flip;
flip = flop;
flop = t;
}
filters[i].apply(this, flip, lastState.renderTarget, false, currentState);
this.freePotRenderTarget(flip);
this.freePotRenderTarget(flop);
}
currentState.clear();
let backdropFree = false;
for (var i = 0; i < filters.length; i++) {
if (filters[i]._backdropRenderTarget) {
if (!backdropFree) {
this.freePotRenderTarget(filters[i]._backdropRenderTarget);
backdropFree = true;
}
filters[i]._backdropRenderTarget = null;
}
}
filterData.index--;
if (filterData.index === 0)
this.filterData = null;
}
function syncUniforms (shader, filter) {
let renderer = this.renderer;
let gl = renderer.gl;
let uniformData = filter.uniformData;
let uniforms = filter.uniforms;
let textureCount = 1;
let currentState;
if (shader.uniforms.filterArea) {
currentState = this.filterData.stack[this.filterData.index];
let filterArea = shader.uniforms.filterArea;
filterArea[0] = currentState.renderTarget.size.width;
filterArea[1] = currentState.renderTarget.size.height;
filterArea[2] = currentState.sourceFrame.x;
filterArea[3] = currentState.sourceFrame.y;
shader.uniforms.filterArea = filterArea;
}
if (shader.uniforms.filterClamp) {
currentState = currentState || this.filterData.stack[this.filterData.index];
let filterClamp = shader.uniforms.filterClamp;
filterClamp[0] = 0;
filterClamp[1] = 0;
filterClamp[2] = (currentState.sourceFrame.width - 1) / currentState.renderTarget.size.width;
filterClamp[3] = (currentState.sourceFrame.height - 1) / currentState.renderTarget.size.height;
shader.uniforms.filterClamp = filterClamp;
}
for (let i in uniformData) {
if (!shader.uniforms.data[i])
continue;
if (i === filter.backdropUniformName) {
let rt = filter._backdropRenderTarget;
shader.uniforms[i] = textureCount;
renderer.boundTextures[textureCount] = renderer.emptyTextures[textureCount];
gl.activeTexture(gl.TEXTURE0 + textureCount);
gl.bindTexture(gl.TEXTURE_2D, rt.texture.texture);
textureCount++;
continue;
}
let type = uniformData[i].type;
if (type === 'sampler2d' && uniforms[i] !== 0) {
if (uniforms[i].baseTexture)
shader.uniforms[i] = this.renderer.bindTexture(uniforms[i].baseTexture, textureCount);
else {
shader.uniforms[i] = textureCount;
let gl_1 = this.renderer.gl;
renderer.boundTextures[textureCount] = renderer.emptyTextures[textureCount];
gl_1.activeTexture(gl_1.TEXTURE0 + textureCount);
uniforms[i].texture.bind();
}
textureCount++;
} else if (type === 'mat3') {
if (uniforms[i].a !== undefined)
shader.uniforms[i] = uniforms[i].toArray(true);
else
shader.uniforms[i] = uniforms[i];
} else if (type === 'vec2') {
if (uniforms[i].x !== undefined) {
let val = shader.uniforms[i] || new Float32Array(2);
val[0] = uniforms[i].x;
val[1] = uniforms[i].y;
shader.uniforms[i] = val;
} else
shader.uniforms[i] = uniforms[i];
} else if (type === 'float') {
if (shader.uniforms.data[i].value !== uniformData[i])
shader.uniforms[i] = uniforms[i];
} else
shader.uniforms[i] = uniforms[i];
}
}
function prepareBackdrop (bounds) {
let renderer = this.renderer;
let renderTarget = renderer._activeRenderTarget;
if (renderTarget.root)
return null;
let resolution = renderTarget.resolution;
let fr = renderTarget.sourceFrame || renderTarget.destinationFrame;
bounds.fit(fr);
let x = (bounds.x - fr.x) * resolution;
let y = (bounds.y - fr.y) * resolution;
let w = (bounds.width) * resolution;
let h = (bounds.height) * resolution;
let gl = renderer.gl;
let rt = this.getPotRenderTarget(gl, w, h, 1);
renderer.boundTextures[1] = renderer.emptyTextures[1];
gl.activeTexture(gl.TEXTURE0 + 1);
gl.bindTexture(gl.TEXTURE_2D, rt.texture.texture);
if (!rt.rebound) {
renderer._activeRenderTarget = null;
renderer.bindRenderTarget(renderTarget);
rt.rebound = true;
}
gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, x, y, w, h);
return rt;
}
var FilterState = (function () {
function FilterState () {
this.renderTarget = null;
this.target = null;
this.resolution = 1;
this.sourceFrame = new PIXI.Rectangle();
this.destinationFrame = new PIXI.Rectangle();
this.filters = [];
}
FilterState.prototype.clear = function () {
this.filters = null;
this.target = null;
this.renderTarget = null;
};
return FilterState;
})();
let BackdropFilter = (function (_super) {
__extends(BackdropFilter, _super);
function BackdropFilter () {
let _this = _super !== null && _super.apply(this, arguments) || this;
_this.backdropUniformName = null;
_this._backdropRenderTarget = null;
_this.clearColor = null;
return _this;
}
return BackdropFilter;
})(PIXI.Filter);
pixi_picture.BackdropFilter = BackdropFilter;
})(pixi_picture || (pixi_picture = {}));
var pixi_picture;
(function (pixi_picture) {
let shaderLib = [
{
vertUniforms: '',
vertCode: 'vTextureCoord = aTextureCoord;',
fragUniforms: 'uniform vec4 uTextureClamp;',
fragCode: 'vec2 textureCoord = clamp(vTextureCoord, uTextureClamp.xy, uTextureClamp.zw);'
},
{
vertUniforms: 'uniform mat3 uTransform;',
vertCode: 'vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;',
fragUniforms: '',
fragCode: 'vec2 textureCoord = vTextureCoord;'
},
{
vertUniforms: 'uniform mat3 uTransform;',
vertCode: 'vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;',
fragUniforms: 'uniform mat3 uMapCoord;\nuniform vec4 uClampFrame;\nuniform vec2 uClampOffset;',
fragCode: 'vec2 textureCoord = mod(vTextureCoord - uClampOffset, vec2(1.0, 1.0)) + uClampOffset;' +
'\ntextureCoord = (uMapCoord * vec3(textureCoord, 1.0)).xy;' +
'\ntextureCoord = clamp(textureCoord, uClampFrame.xy, uClampFrame.zw);'
}
];
let PictureShader = (function (_super) {
__extends(PictureShader, _super);
function PictureShader (gl, vert, frag, tilingMode) {
let _this = this;
let lib = shaderLib[tilingMode];
_this = _super.call(this, gl, vert.replace(/%SPRITE_UNIFORMS%/gi, lib.vertUniforms)
.replace(/%SPRITE_CODE%/gi, lib.vertCode), frag.replace(/%SPRITE_UNIFORMS%/gi, lib.fragUniforms)
.replace(/%SPRITE_CODE%/gi, lib.fragCode)) || this;
_this.bind();
_this.tilingMode = tilingMode;
_this.tempQuad = new PIXI.Quad(gl);
_this.tempQuad.initVao(_this);
_this.uniforms.uColor = new Float32Array([1, 1, 1, 1]);
_this.uniforms.uSampler = [0, 1];
return _this;
}
PictureShader.blendVert = '\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\n\nuniform mat3 projectionMatrix;\nuniform mat3 mapMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec2 vMapCoord;\n%SPRITE_UNIFORMS%\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n %SPRITE_CODE%\n vMapCoord = (mapMatrix * vec3(aVertexPosition, 1.0)).xy;\n}\n';
return PictureShader;
})(PIXI.Shader);
pixi_picture.PictureShader = PictureShader;
})(pixi_picture || (pixi_picture = {}));
var pixi_picture;
(function (pixi_picture) {
let overlayFrag = '\nvarying vec2 vTextureCoord;\nvarying vec2 vMapCoord;\nvarying vec4 vColor;\n\nuniform sampler2D uSampler[2];\nuniform vec4 uColor;\n%SPRITE_UNIFORMS%\n\nvoid main(void)\n{\n %SPRITE_CODE%\n vec4 source = texture2D(uSampler[0], textureCoord) * uColor;\n vec4 target = texture2D(uSampler[1], vMapCoord);\n\n //reverse hardlight\n if (source.a == 0.0) {\n gl_FragColor = vec4(0, 0, 0, 0);\n return;\n }\n //yeah, premultiplied\n vec3 Cb = source.rgb/source.a, Cs;\n if (target.a > 0.0) {\n Cs = target.rgb / target.a;\n }\n vec3 multiply = Cb * Cs * 2.0;\n vec3 Cs2 = Cs * 2.0 - 1.0;\n vec3 screen = Cb + Cs2 - Cb * Cs2;\n vec3 B;\n if (Cb.r <= 0.5) {\n B.r = multiply.r;\n } else {\n B.r = screen.r;\n }\n if (Cb.g <= 0.5) {\n B.g = multiply.g;\n } else {\n B.g = screen.g;\n }\n if (Cb.b <= 0.5) {\n B.b = multiply.b;\n } else {\n B.b = screen.b;\n }\n vec4 res;\n res.xyz = (1.0 - source.a) * Cs + source.a * B;\n res.a = source.a + target.a * (1.0-source.a);\n gl_FragColor = vec4(res.xyz * res.a, res.a);\n}\n';
let HardLightShader = (function (_super) {
__extends(HardLightShader, _super);
function HardLightShader (gl, tilingMode) {
return _super.call(this, gl, pixi_picture.PictureShader.blendVert, overlayFrag, tilingMode) || this;
}
return HardLightShader;
})(pixi_picture.PictureShader);
pixi_picture.HardLightShader = HardLightShader;
})(pixi_picture || (pixi_picture = {}));
var pixi_picture;
(function (pixi_picture) {
function mapFilterBlendModesToPixi (gl, array) {
if (array === void 0) array = [];
array[PIXI.BLEND_MODES.OVERLAY] = [new pixi_picture.OverlayShader(gl, 0), new pixi_picture.OverlayShader(gl, 1), new pixi_picture.OverlayShader(gl, 2)];
array[PIXI.BLEND_MODES.HARD_LIGHT] = [new pixi_picture.HardLightShader(gl, 0), new pixi_picture.HardLightShader(gl, 1), new pixi_picture.HardLightShader(gl, 2)];
array[PIXI.BLEND_MODES.SOFT_LIGHT] = [new pixi_picture.SoftLightShader(gl, 0), new pixi_picture.SoftLightShader(gl, 1), new pixi_picture.SoftLightShader(gl, 2)];
return array;
}
pixi_picture.mapFilterBlendModesToPixi = mapFilterBlendModesToPixi;
})(pixi_picture || (pixi_picture = {}));
var pixi_picture;
(function (pixi_picture) {
let normalFrag = '\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform sampler2D uSampler[2];\nuniform vec4 uColor;\n%SPRITE_UNIFORMS%\n\nvoid main(void)\n{\n %SPRITE_CODE%\n\n vec4 sample = texture2D(uSampler[0], textureCoord);\n gl_FragColor = sample * uColor;\n}\n';
let normalVert = '\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n%SPRITE_UNIFORMS%\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n %SPRITE_CODE%\n}\n';
let NormalShader = (function (_super) {
__extends(NormalShader, _super);
function NormalShader (gl, tilingMode) {
return _super.call(this, gl, normalVert, normalFrag, tilingMode) || this;
}
return NormalShader;
})(pixi_picture.PictureShader);
pixi_picture.NormalShader = NormalShader;
})(pixi_picture || (pixi_picture = {}));
var pixi_picture;
(function (pixi_picture) {
let overlayFrag = '\nvarying vec2 vTextureCoord;\nvarying vec2 vMapCoord;\nvarying vec4 vColor;\n\nuniform sampler2D uSampler[2];\nuniform vec4 uColor;\n%SPRITE_UNIFORMS%\n\nvoid main(void)\n{\n %SPRITE_CODE%\n vec4 source = texture2D(uSampler[0], textureCoord) * uColor;\n vec4 target = texture2D(uSampler[1], vMapCoord);\n\n //reverse hardlight\n if (source.a == 0.0) {\n gl_FragColor = vec4(0, 0, 0, 0);\n return;\n }\n //yeah, premultiplied\n vec3 Cb = source.rgb/source.a, Cs;\n if (target.a > 0.0) {\n Cs = target.rgb / target.a;\n }\n vec3 multiply = Cb * Cs * 2.0;\n vec3 Cb2 = Cb * 2.0 - 1.0;\n vec3 screen = Cb2 + Cs - Cb2 * Cs;\n vec3 B;\n if (Cs.r <= 0.5) {\n B.r = multiply.r;\n } else {\n B.r = screen.r;\n }\n if (Cs.g <= 0.5) {\n B.g = multiply.g;\n } else {\n B.g = screen.g;\n }\n if (Cs.b <= 0.5) {\n B.b = multiply.b;\n } else {\n B.b = screen.b;\n }\n vec4 res;\n res.xyz = (1.0 - source.a) * Cs + source.a * B;\n res.a = source.a + target.a * (1.0-source.a);\n gl_FragColor = vec4(res.xyz * res.a, res.a);\n}\n';
let OverlayShader = (function (_super) {
__extends(OverlayShader, _super);
function OverlayShader (gl, tilingMode) {
return _super.call(this, gl, pixi_picture.PictureShader.blendVert, overlayFrag, tilingMode) || this;
}
return OverlayShader;
})(pixi_picture.PictureShader);
pixi_picture.OverlayShader = OverlayShader;
})(pixi_picture || (pixi_picture = {}));
var pixi_picture;
(function (pixi_picture) {
let WRAP_MODES = PIXI.WRAP_MODES;
function nextPow2 (v) {
v += (v === 0) ? 1 : 0;
--v;
v |= v >>> 1;
v |= v >>> 2;
v |= v >>> 4;
v |= v >>> 8;
v |= v >>> 16;
return v + 1;
}
let PictureRenderer = (function (_super) {
__extends(PictureRenderer, _super);
function PictureRenderer (renderer) {
return _super.call(this, renderer) || this;
}
PictureRenderer.prototype.onContextChange = function () {
pixi_picture.filterManagerMixin(this.renderer.filterManager);
let gl = this.renderer.gl;
this.drawModes = pixi_picture.mapFilterBlendModesToPixi(gl);
this.normalShader = [new pixi_picture.NormalShader(gl, 0), new pixi_picture.NormalShader(gl, 1), new pixi_picture.NormalShader(gl, 2)];
this._tempClamp = new Float32Array(4);
this._tempColor = new Float32Array(4);
this._tempRect = new PIXI.Rectangle();
this._tempRect2 = new PIXI.Rectangle();
this._tempRect3 = new PIXI.Rectangle();
this._tempMatrix = new PIXI.Matrix();
this._tempMatrix2 = new PIXI.Matrix();
this._bigBuf = new Uint8Array(1 << 20);
this._renderTexture = new PIXI.BaseRenderTexture(1024, 1024);
};
PictureRenderer.prototype.start = function () {
};
PictureRenderer.prototype.flush = function () {
};
PictureRenderer.prototype._getRenderTexture = function (minWidth, minHeight) {
if (this._renderTexture.width < minWidth ||
this._renderTexture.height < minHeight) {
minWidth = nextPow2(minWidth);
minHeight = nextPow2(minHeight);
this._renderTexture.resize(minWidth, minHeight);
}
return this._renderTexture;
};
PictureRenderer.prototype._getBuf = function (size) {
let buf = this._bigBuf;
if (buf.length < size) {
size = nextPow2(size);
buf = new Uint8Array(size);
this._bigBuf = buf;
}
return buf;
};
PictureRenderer.prototype.render = function (sprite) {
if (!sprite.texture.valid)
return;
let tilingMode = 0;
if (sprite.tileTransform)
tilingMode = this._isSimpleSprite(sprite) ? 1 : 2;
if (!this.drawModes)
pixi_picture.mapFilterBlendModesToPixi(this.renderer.gl);
let blendShader = this.drawModes[sprite.blendMode];
if (blendShader)
this._renderBlend(sprite, blendShader[tilingMode]);
else
this._renderNormal(sprite, this.normalShader[tilingMode]);
};
PictureRenderer.prototype._renderNormal = function (sprite, shader) {
let renderer = this.renderer;
renderer.bindShader(shader);
renderer.state.setBlendMode(sprite.blendMode);
this._renderInner(sprite, shader);
};
PictureRenderer.prototype._renderBlend = function (sprite, shader) {
let renderer = this.renderer;
let spriteBounds = sprite.getBounds();
let renderTarget = renderer._activeRenderTarget;
let matrix = renderTarget.projectionMatrix;
let flipX = matrix.a < 0;
let flipY = matrix.d < 0;
let resolution = renderTarget.resolution;
let screen = this._tempRect;
let fr = renderTarget.sourceFrame || renderTarget.destinationFrame;
screen.x = 0;
screen.y = 0;
screen.width = fr.width;
screen.height = fr.height;
let bounds = this._tempRect2;
let fbw = fr.width * resolution, fbh = fr.height * resolution;
bounds.x = (spriteBounds.x + matrix.tx / matrix.a) * resolution + fbw / 2;
bounds.y = (spriteBounds.y + matrix.ty / matrix.d) * resolution + fbh / 2;
bounds.width = spriteBounds.width * resolution;
bounds.height = spriteBounds.height * resolution;
if (flipX)
bounds.y = fbw - bounds.width - bounds.x;
if (flipY)
bounds.y = fbh - bounds.height - bounds.y;
let screenBounds = this._tempRect3;
let x_1 = Math.floor(Math.max(screen.x, bounds.x));
let x_2 = Math.ceil(Math.min(screen.x + screen.width, bounds.x + bounds.width));
let y_1 = Math.floor(Math.max(screen.y, bounds.y));
let y_2 = Math.ceil(Math.min(screen.y + screen.height, bounds.y + bounds.height));
let pixelsWidth = x_2 - x_1;
let pixelsHeight = y_2 - y_1;
if (pixelsWidth <= 0 || pixelsHeight <= 0)
return;
let rt = this._getRenderTexture(pixelsWidth, pixelsHeight);
renderer.bindTexture(rt, 1, true);
let gl = renderer.gl;
if (renderer.renderingToScreen && renderTarget.root) {
let buf = this._getBuf(pixelsWidth * pixelsHeight * 4);
gl.readPixels(x_1, y_1, pixelsWidth, pixelsHeight, gl.RGBA, gl.UNSIGNED_BYTE, this._bigBuf);
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, pixelsWidth, pixelsHeight, gl.RGBA, gl.UNSIGNED_BYTE, this._bigBuf);
} else
gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, x_1, y_1, pixelsWidth, pixelsHeight);
renderer.bindShader(shader);
renderer.state.setBlendMode(PIXI.BLEND_MODES.NORMAL);
if (shader.uniforms.mapMatrix) {
let mapMatrix = this._tempMatrix;
mapMatrix.a = bounds.width / rt.width / spriteBounds.width;
if (flipX) {
mapMatrix.a = -mapMatrix.a;
mapMatrix.tx = (bounds.x - x_1) / rt.width - (spriteBounds.x + spriteBounds.width) * mapMatrix.a;
} else
mapMatrix.tx = (bounds.x - x_1) / rt.width - spriteBounds.x * mapMatrix.a;
mapMatrix.d = bounds.height / rt.height / spriteBounds.height;
if (flipY) {
mapMatrix.d = -mapMatrix.d;
mapMatrix.ty = (bounds.y - y_1) / rt.height - (spriteBounds.y + spriteBounds.height) * mapMatrix.d;
} else
mapMatrix.ty = (bounds.y - y_1) / rt.height - spriteBounds.y * mapMatrix.d;
shader.uniforms.mapMatrix = mapMatrix.toArray(true);
}
this._renderInner(sprite, shader);
};
PictureRenderer.prototype._renderInner = function (sprite, shader) {
let renderer = this.renderer;
if (shader.tilingMode > 0)
this._renderWithShader(sprite, shader.tilingMode === 1, shader);
else
this._renderSprite(sprite, shader);
};
PictureRenderer.prototype._renderWithShader = function (ts, isSimple, shader) {
let quad = shader.tempQuad;
let renderer = this.renderer;
renderer.bindVao(quad.vao);
let vertices = quad.vertices;
let _width = ts._width;
let _height = ts._height;
let _anchorX = ts._anchor._x;
let _anchorY = ts._anchor._y;
let w0 = _width * (1 - _anchorX);
let w1 = _width * -_anchorX;
let h0 = _height * (1 - _anchorY);
let h1 = _height * -_anchorY;
let wt = ts.transform.worldTransform;
let a = wt.a;
let b = wt.b;
let c = wt.c;
let d = wt.d;
let tx = wt.tx;
let ty = wt.ty;
vertices[0] = (a * w1) + (c * h1) + tx;
vertices[1] = (d * h1) + (b * w1) + ty;
vertices[2] = (a * w0) + (c * h1) + tx;
vertices[3] = (d * h1) + (b * w0) + ty;
vertices[4] = (a * w0) + (c * h0) + tx;
vertices[5] = (d * h0) + (b * w0) + ty;
vertices[6] = (a * w1) + (c * h0) + tx;
vertices[7] = (d * h0) + (b * w1) + ty;
vertices = quad.uvs;
vertices[0] = vertices[6] = -ts.anchor.x;
vertices[1] = vertices[3] = -ts.anchor.y;
vertices[2] = vertices[4] = 1.0 - ts.anchor.x;
vertices[5] = vertices[7] = 1.0 - ts.anchor.y;
quad.upload();
let tex = ts._texture;
let lt = ts.tileTransform.localTransform;
let uv = ts.uvTransform;
let mapCoord = uv.mapCoord;
let uClampFrame = uv.uClampFrame;
let uClampOffset = uv.uClampOffset;
let w = tex.width;
let h = tex.height;
let W = _width;
let H = _height;
let tempMat = this._tempMatrix2;
tempMat.set(lt.a * w / W, lt.b * w / H, lt.c * h / W, lt.d * h / H, lt.tx / W, lt.ty / H);
tempMat.invert();
if (isSimple)
tempMat.append(mapCoord);
else {
shader.uniforms.uMapCoord = mapCoord.toArray(true);
shader.uniforms.uClampFrame = uClampFrame;
shader.uniforms.uClampOffset = uClampOffset;
}
shader.uniforms.uTransform = tempMat.toArray(true);
let color = this._tempColor;
let alpha = ts.worldAlpha;
PIXI.utils.hex2rgb(ts.tint, color);
color[0] *= alpha;
color[1] *= alpha;
color[2] *= alpha;
color[3] = alpha;
shader.uniforms.uColor = color;
renderer.bindTexture(tex, 0, true);
quad.vao.draw(this.renderer.gl.TRIANGLES, 6, 0);
};
PictureRenderer.prototype._renderSprite = function (sprite, shader) {
let renderer = this.renderer;
let quad = shader.tempQuad;
renderer.bindVao(quad.vao);
let uvs = sprite.texture._uvs;
let vertices = quad.vertices;
let vd = sprite.vertexData;
for (let i = 0; i < 8; i++)
quad.vertices[i] = vd[i];
quad.uvs[0] = uvs.x0;
quad.uvs[1] = uvs.y0;
quad.uvs[2] = uvs.x1;
quad.uvs[3] = uvs.y1;
quad.uvs[4] = uvs.x2;
quad.uvs[5] = uvs.y2;
quad.uvs[6] = uvs.x3;
quad.uvs[7] = uvs.y3;
quad.upload();
let frame = sprite.texture.frame;
let base = sprite.texture.baseTexture;
let clamp = this._tempClamp;
let eps = 0.5 / base.resolution;
clamp[0] = (frame.x + eps) / base.width;
clamp[1] = (frame.y + eps) / base.height;
clamp[2] = (frame.x + frame.width - eps) / base.width;
clamp[3] = (frame.y + frame.height - eps) / base.height;
shader.uniforms.uTextureClamp = clamp;
let color = this._tempColor;
PIXI.utils.hex2rgb(sprite.tint, color);
let alpha = sprite.worldAlpha;
color[0] *= alpha;
color[1] *= alpha;
color[2] *= alpha;
color[3] = alpha;
shader.uniforms.uColor = color;
renderer.bindTexture(base, 0, true);
quad.vao.draw(this.renderer.gl.TRIANGLES, 6, 0);
};
PictureRenderer.prototype._isSimpleSprite = function (ts) {
let renderer = this.renderer;
let tex = ts._texture;
let baseTex = tex.baseTexture;
let isSimple = baseTex.isPowerOfTwo && tex.frame.width === baseTex.width && tex.frame.height === baseTex.height;
if (isSimple) {
if (!baseTex._glTextures[renderer.CONTEXT_UID]) {
if (baseTex.wrapMode === WRAP_MODES.CLAMP)
baseTex.wrapMode = WRAP_MODES.REPEAT;
} else
isSimple = baseTex.wrapMode !== WRAP_MODES.CLAMP;
}
return isSimple;
};
return PictureRenderer;
})(PIXI.ObjectRenderer);
pixi_picture.PictureRenderer = PictureRenderer;
PIXI.WebGLRenderer.registerPlugin('picture', PictureRenderer);
//PIXI.CanvasRenderer.registerPlugin('picture', PIXI.CanvasSpriteRenderer);
})(pixi_picture || (pixi_picture = {}));
var pixi_picture;
(function (pixi_picture) {
let softLightFrag = '\nvarying vec2 vTextureCoord;\nvarying vec2 vMapCoord;\nvarying vec4 vColor;\n \nuniform sampler2D uSampler[2];\nuniform vec4 uColor;\n%SPRITE_UNIFORMS%\n\nvoid main(void)\n{\n %SPRITE_CODE%\n vec4 source = texture2D(uSampler[0], textureCoord) * uColor;\n vec4 target = texture2D(uSampler[1], vMapCoord);\n\n if (source.a == 0.0) {\n gl_FragColor = vec4(0, 0, 0, 0);\n return;\n }\n vec3 Cb = source.rgb/source.a, Cs;\n if (target.a > 0.0) {\n Cs = target.rgb / target.a;\n }\n \n vec3 first = Cb - (1.0 - 2.0 * Cs) * Cb * (1.0 - Cb);\n\n vec3 B;\n vec3 D;\n if (Cs.r <= 0.5)\n {\n B.r = first.r;\n }\n else\n {\n if (Cb.r <= 0.25)\n {\n D.r = ((16.0 * Cb.r - 12.0) * Cb.r + 4.0) * Cb.r; \n }\n else\n {\n D.r = sqrt(Cb.r);\n }\n B.r = Cb.r + (2.0 * Cs.r - 1.0) * (D.r - Cb.r);\n }\n if (Cs.g <= 0.5)\n {\n B.g = first.g;\n }\n else\n {\n if (Cb.g <= 0.25)\n {\n D.g = ((16.0 * Cb.g - 12.0) * Cb.g + 4.0) * Cb.g; \n }\n else\n {\n D.g = sqrt(Cb.g);\n }\n B.g = Cb.g + (2.0 * Cs.g - 1.0) * (D.g - Cb.g);\n }\n if (Cs.b <= 0.5)\n {\n B.b = first.b;\n }\n else\n {\n if (Cb.b <= 0.25)\n {\n D.b = ((16.0 * Cb.b - 12.0) * Cb.b + 4.0) * Cb.b; \n }\n else\n {\n D.b = sqrt(Cb.b);\n }\n B.b = Cb.b + (2.0 * Cs.b - 1.0) * (D.b - Cb.b);\n } \n\n vec4 res;\n\n res.xyz = (1.0 - source.a) * Cs + source.a * B;\n res.a = source.a + target.a * (1.0-source.a);\n gl_FragColor = vec4(res.xyz * res.a, res.a);\n}\n';
let SoftLightShader = (function (_super) {
__extends(SoftLightShader, _super);
function SoftLightShader (gl, tilingMode) {
return _super.call(this, gl, pixi_picture.PictureShader.blendVert, softLightFrag, tilingMode) || this;
}
return SoftLightShader;
})(pixi_picture.PictureShader);
pixi_picture.SoftLightShader = SoftLightShader;
})(pixi_picture || (pixi_picture = {}));
var pixi_picture;
(function (pixi_picture) {
let Sprite = (function (_super) {
__extends(Sprite, _super);
function Sprite (texture) {
let _this = _super.call(this, texture) || this;
_this.pluginName = 'picture';
return _this;
}
return Sprite;
})(PIXI.Sprite);
pixi_picture.Sprite = Sprite;
})(pixi_picture || (pixi_picture = {}));
var pixi_picture;
(function (pixi_picture) {
let TilingSprite = (function (_super) {
__extends(TilingSprite, _super);
function TilingSprite (texture) {
let _this = _super.call(this, texture) || this;
_this.pluginName = 'picture';
return _this;
}
return TilingSprite;
})(PIXI.extras.TilingSprite);
pixi_picture.TilingSprite = TilingSprite;
})(pixi_picture || (pixi_picture = {}));
var pixi_picture;
(function (pixi_picture) {
PIXI.picture = pixi_picture;
})(pixi_picture || (pixi_picture = {}));

+ 0
- 1
src/client/plugins/require.min.js
文件差異過大導致無法顯示
查看文件


+ 0
- 3
src/client/plugins/socket.js
文件差異過大導致無法顯示
查看文件


+ 0
- 391
src/client/plugins/text.js 查看文件

@@ -1,391 +0,0 @@
/**
* @license RequireJS text 2.0.14 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/requirejs/text for details
*/
/*jslint regexp: true */
/*global require, XMLHttpRequest, ActiveXObject,
define, window, process, Packages,
java, location, Components, FileUtils */

define(['module'], function (module) {
'use strict';

var text, fs, Cc, Ci, xpcIsWindows,
progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'],
xmlRegExp = /^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,
bodyRegExp = /<body[^>]*>\s*([\s\S]+)\s*<\/body>/im,
hasLocation = typeof location !== 'undefined' && location.href,
defaultProtocol = hasLocation && location.protocol && location.protocol.replace(/\:/, ''),
defaultHostName = hasLocation && location.hostname,
defaultPort = hasLocation && (location.port || undefined),
buildMap = {},
masterConfig = (module.config && module.config()) || {};

text = {
version: '2.0.14',

strip: function (content) {
//Strips <?xml ...?> declarations so that external SVG and XML
//documents can be added to a document without worry. Also, if the string
//is an HTML document, only the part inside the body tag is returned.
if (content) {
content = content.replace(xmlRegExp, "");
var matches = content.match(bodyRegExp);
if (matches) {
content = matches[1];
}
} else {
content = "";
}
return content;
},

jsEscape: function (content) {
return content.replace(/(['\\])/g, '\\$1')
.replace(/[\f]/g, "\\f")
.replace(/[\b]/g, "\\b")
.replace(/[\n]/g, "\\n")
.replace(/[\t]/g, "\\t")
.replace(/[\r]/g, "\\r")
.replace(/[\u2028]/g, "\\u2028")
.replace(/[\u2029]/g, "\\u2029");
},

createXhr: masterConfig.createXhr || function () {
//Would love to dump the ActiveX crap in here. Need IE 6 to die first.
var xhr, i, progId;
if (typeof XMLHttpRequest !== "undefined") {
return new XMLHttpRequest();
} else if (typeof ActiveXObject !== "undefined") {
for (i = 0; i < 3; i += 1) {
progId = progIds[i];
try {
xhr = new ActiveXObject(progId);
} catch (e) {}

if (xhr) {
progIds = [progId]; // so faster next time
break;
}
}
}

return xhr;
},

/**
* Parses a resource name into its component parts. Resource names
* look like: module/name.ext!strip, where the !strip part is
* optional.
* @param {String} name the resource name
* @returns {Object} with properties "moduleName", "ext" and "strip"
* where strip is a boolean.
*/
parseName: function (name) {
var modName, ext, temp,
strip = false,
index = name.lastIndexOf("."),
isRelative = name.indexOf('./') === 0 ||
name.indexOf('../') === 0;

if (index !== -1 && (!isRelative || index > 1)) {
modName = name.substring(0, index);
ext = name.substring(index + 1);
} else {
modName = name;
}

temp = ext || modName;
index = temp.indexOf("!");
if (index !== -1) {
//Pull off the strip arg.
strip = temp.substring(index + 1) === "strip";
temp = temp.substring(0, index);
if (ext) {
ext = temp;
} else {
modName = temp;
}
}

return {
moduleName: modName,
ext: ext,
strip: strip
};
},

xdRegExp: /^((\w+)\:)?\/\/([^\/\\]+)/,

/**
* Is an URL on another domain. Only works for browser use, returns
* false in non-browser environments. Only used to know if an
* optimized .js version of a text resource should be loaded
* instead.
* @param {String} url
* @returns Boolean
*/
useXhr: function (url, protocol, hostname, port) {
var uProtocol, uHostName, uPort,
match = text.xdRegExp.exec(url);
if (!match) {
return true;
}
uProtocol = match[2];
uHostName = match[3];

uHostName = uHostName.split(':');
uPort = uHostName[1];
uHostName = uHostName[0];

return (!uProtocol || uProtocol === protocol) &&
(!uHostName || uHostName.toLowerCase() === hostname.toLowerCase()) &&
((!uPort && !uHostName) || uPort === port);
},

finishLoad: function (name, strip, content, onLoad) {
content = strip ? text.strip(content) : content;
if (masterConfig.isBuild) {
buildMap[name] = content;
}
onLoad(content);
},

load: function (name, req, onLoad, config) {
//Name has format: some.module.filext!strip
//The strip part is optional.
//if strip is present, then that means only get the string contents
//inside a body tag in an HTML string. For XML/SVG content it means
//removing the <?xml ...?> declarations so the content can be inserted
//into the current doc without problems.

// Do not bother with the work if a build and text will
// not be inlined.
if (config && config.isBuild && !config.inlineText) {
onLoad();
return;
}

masterConfig.isBuild = config && config.isBuild;

var parsed = text.parseName(name),
nonStripName = parsed.moduleName +
(parsed.ext ? '.' + parsed.ext : ''),
url = req.toUrl(nonStripName),
useXhr = (masterConfig.useXhr) ||
text.useXhr;

// Do not load if it is an empty: url
if (url.indexOf('empty:') === 0) {
onLoad();
return;
}

//Load the text. Use XHR if possible and in a browser.
if (!hasLocation || useXhr(url, defaultProtocol, defaultHostName, defaultPort)) {
text.get(url, function (content) {
text.finishLoad(name, parsed.strip, content, onLoad);
}, function (err) {
if (onLoad.error) {
onLoad.error(err);
}
});
} else {
//Need to fetch the resource across domains. Assume
//the resource has been optimized into a JS module. Fetch
//by the module name + extension, but do not include the
//!strip part to avoid file system issues.
req([nonStripName], function (content) {
text.finishLoad(parsed.moduleName + '.' + parsed.ext,
parsed.strip, content, onLoad);
});
}
},

write: function (pluginName, moduleName, write, config) {
if (buildMap.hasOwnProperty(moduleName)) {
var content = text.jsEscape(buildMap[moduleName]);
write.asModule(pluginName + "!" + moduleName,
"define(function () { return '" +
content +
"';});\n");
}
},

writeFile: function (pluginName, moduleName, req, write, config) {
var parsed = text.parseName(moduleName),
extPart = parsed.ext ? '.' + parsed.ext : '',
nonStripName = parsed.moduleName + extPart,
//Use a '.js' file name so that it indicates it is a
//script that can be loaded across domains.
fileName = req.toUrl(parsed.moduleName + extPart) + '.js';

//Leverage own load() method to load plugin value, but only
//write out values that do not have the strip argument,
//to avoid any potential issues with ! in file names.
text.load(nonStripName, req, function (value) {
//Use own write() method to construct full module value.
//But need to create shell that translates writeFile's
//write() to the right interface.
var textWrite = function (contents) {
return write(fileName, contents);
};
textWrite.asModule = function (moduleName, contents) {
return write.asModule(moduleName, fileName, contents);
};

text.write(pluginName, nonStripName, textWrite, config);
}, config);
}
};

if (masterConfig.env === 'node' || (!masterConfig.env &&
typeof process !== "undefined" &&
process.versions &&
!!process.versions.node &&
!process.versions['node-webkit'] &&
!process.versions['atom-shell'])) {
//Using special require.nodeRequire, something added by r.js.
fs = require.nodeRequire('fs');

text.get = function (url, callback, errback) {
try {
var file = fs.readFileSync(url, 'utf8');
//Remove BOM (Byte Mark Order) from utf8 files if it is there.
if (file[0] === '\uFEFF') {
file = file.substring(1);
}
callback(file);
} catch (e) {
if (errback) {
errback(e);
}
}
};
} else if (masterConfig.env === 'xhr' || (!masterConfig.env &&
text.createXhr())) {
text.get = function (url, callback, errback, headers) {
var xhr = text.createXhr(), header;
xhr.open('GET', url, true);

//Allow plugins direct access to xhr headers
if (headers) {
for (header in headers) {
if (headers.hasOwnProperty(header)) {
xhr.setRequestHeader(header.toLowerCase(), headers[header]);
}
}
}

//Allow overrides specified in config
if (masterConfig.onXhr) {
masterConfig.onXhr(xhr, url);
}

xhr.onreadystatechange = function (evt) {
var status, err;
//Do not explicitly handle errors, those should be
//visible via console output in the browser.
if (xhr.readyState === 4) {
status = xhr.status || 0;
if (status > 399 && status < 600) {
//An http 4xx or 5xx error. Signal an error.
err = new Error(url + ' HTTP status: ' + status);
err.xhr = xhr;
if (errback) {
errback(err);
}
} else {
callback(xhr.responseText);
}

if (masterConfig.onXhrComplete) {
masterConfig.onXhrComplete(xhr, url);
}
}
};
xhr.send(null);
};
} else if (masterConfig.env === 'rhino' || (!masterConfig.env &&
typeof Packages !== 'undefined' && typeof java !== 'undefined')) {
//Why Java, why is this so awkward?
text.get = function (url, callback) {
var stringBuffer, line,
encoding = "utf-8",
file = new java.io.File(url),
lineSeparator = java.lang.System.getProperty("line.separator"),
input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(file), encoding)),
content = '';
try {
stringBuffer = new java.lang.StringBuffer();
line = input.readLine();

// Byte Order Mark (BOM) - The Unicode Standard, version 3.0, page 324
// http://www.unicode.org/faq/utf_bom.html

// Note that when we use utf-8, the BOM should appear as "EF BB BF", but it doesn't due to this bug in the JDK:
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058
if (line && line.length() && line.charAt(0) === 0xfeff) {
// Eat the BOM, since we've already found the encoding on this file,
// and we plan to concatenating this buffer with others; the BOM should
// only appear at the top of a file.
line = line.substring(1);
}

if (line !== null) {
stringBuffer.append(line);
}

while ((line = input.readLine()) !== null) {
stringBuffer.append(lineSeparator);
stringBuffer.append(line);
}
//Make sure we return a JavaScript string and not a Java string.
content = String(stringBuffer.toString()); //String
} finally {
input.close();
}
callback(content);
};
} else if (masterConfig.env === 'xpconnect' || (!masterConfig.env &&
typeof Components !== 'undefined' && Components.classes &&
Components.interfaces)) {
//Avert your gaze!
Cc = Components.classes;
Ci = Components.interfaces;
Components.utils['import']('resource://gre/modules/FileUtils.jsm');
xpcIsWindows = ('@mozilla.org/windows-registry-key;1' in Cc);

text.get = function (url, callback) {
var inStream, convertStream, fileObj,
readData = {};

if (xpcIsWindows) {
url = url.replace(/\//g, '\\');
}

fileObj = new FileUtils.File(url);

//XPCOM, you so crazy
try {
inStream = Cc['@mozilla.org/network/file-input-stream;1']
.createInstance(Ci.nsIFileInputStream);
inStream.init(fileObj, 1, 0, false);

convertStream = Cc['@mozilla.org/intl/converter-input-stream;1']
.createInstance(Ci.nsIConverterInputStream);
convertStream.init(inStream, "utf-8", inStream.available(),
Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);

convertStream.readString(inStream.available(), readData);
convertStream.close();
inStream.close();
callback(readData.value);
} catch (e) {
throw new Error((fileObj && fileObj.path || '') + ': ' + e);
}
};
}
return text;
});

+ 0
- 354
src/client/plugins/wquery.js 查看文件

@@ -1,354 +0,0 @@
const sqData = new Map();

const sq = {
default: function (q) {
const type = typeof(q);
if (type === 'string') {
if (q[0] === '<')
return this.build(q);
return sq.find(q);
} else if (type === 'object')
return sq.wrap([q]);

document.addEventListener('DOMContentLoaded', q, false);
},

build: function (tpl) {
let el = document.createElement('template');
el.innerHTML = tpl.trim();
return sq.wrap([el.content.firstChild]);
},

find: function (queryString) {
if (!this[0])
return sq.wrap(document.querySelectorAll(queryString));

let els = [];
this.each(el => els.push(...el.querySelectorAll(queryString)));
return sq.wrap(els);
},

children: function (filter) {
if (!filter)
return sq.wrap(this[0].children);

return this.find(filter);
},

parent: function () {
let parents = [];
this.each(el => parents.push(el.parentElement));

return sq.wrap(parents);
},

on: function (event, fn, preventDefault) {
let fnHandler = function (fn, el, noDefault, e) {
e.target = el;
requestAnimationFrame(fn.bind(null, e));

if (noDefault) {
e.preventDefault();
return false;
}
};

this.each(el => el.addEventListener(event, fnHandler.bind(null, fn, el, preventDefault)));

return this;
},

off: function () {
let newNodes = [];

this.each(el => {
let newNode = el.cloneNode(true);
el.parentNode.replaceChild(newNode, el);
newNodes.push(newNode);
});

return this.wrap(newNodes);
},

clone: function () {
let newNode = this[0].cloneNode(true);
return this.wrap([newNode]);
},

each: function (fn) {
const len = this.length;
for (let i = 0; i < len; i++)
fn(this[i]);
},

appendTo: function (el) {
if (typeof(el) === 'string')
el = sq.find(el)[0];
else
el = el.on ? el[0] : el;

this.each(c => el.appendChild(c));
return this;
},

prependTo: function (el) {
el[0].insertBefore(this[0], el.children()[0]);
return this;
},

remove: function () {
this.each(el => el.remove());
},

addClass: function (classNames) {
if (classNames)
classNames.split(' ').forEach(c => this.each(el => el.classList.add(c)));
return this;
},

removeClass: function (classNames) {
classNames.split(' ').forEach(c => this.each(el => el.classList.remove(c)));
return this;
},

hasClass: function (className) {
return this[0].classList.contains(className);
},

toggleClass: function (className) {
this.hasClass(className) ? this.removeClass(className) : this.addClass(className);
},

show: function () {
this.each(el => {
if ($(el).css('display') !== 'none')
return;

let newDisplay = el.oldDisplay || 'block';
delete el.oldDisplay;
el.attributeStyleMap.set('display', newDisplay);
});

return this;
},

hide: function () {
this.each(el => {
let oldDisplay = $(el).css('display');
if (oldDisplay !== 'none')
el.oldDisplay = oldDisplay;
el.attributeStyleMap.set('display', 'none');
});
return this;
},

css: function (property, value) {
let config = property;
let aLen = arguments.length;

if (aLen === 1 && typeof(property) === 'string') {
let value = this[0].attributeStyleMap.get(property);
if (!value) {
let styles = this[0].computedStyleMap();
value = (styles.get(property) || {});
}
return value.value;
} else if (aLen === 2) {
config = {
[property]: value
};
}

Object.keys(config).forEach(c => {
let val = config[c];
if (['left', 'top', 'width', 'height'].includes(c) && (!val.indexOf || val.indexOf('%') === -1))
val += 'px';

this.each(el => {
if (val)
el.style[c] = val;

else
el.attributeStyleMap.delete(c);
});
});
return this;
},

empty: function () {
let node = this[0];
while (node.firstChild)
node.removeChild(node.firstChild);

return this;
},

is: function (state) {
return (this.width() && this.height());
},

html: function (val) {
if (!arguments.length)
return this[0].innerHTML;

this[0].innerHTML = val;
return this;
},

click: function () {
this[0].click();
return this;
},

next: function () {
return sq.wrap([this[0].nextSibling]);
},

scrollTop: function (value) {
if (!arguments.length)
return this[0].scrollTop;
this[0].scrollTop = value;
},

val: function (val) {
if (!arguments.length)
return this[0].value;

this[0].value = val;
return this;
},

attr: function (property, value) {
if (arguments.length === 1)
return this[0].getAttribute(property);

this[0].setAttribute(property, value);
return this;
},

insertAfter: function (el) {
el[0].parentNode.insertBefore(this[0], el[0].nextSibling);
return this;
},

insertBefore: function (el) {
el[0].parentNode.insertBefore(this[0], el[0]);
return this;
},

index: function () {
let el = this[0];
return Array.prototype.indexOf.call(el.parentElement.children, el);
},

offset: function () {
return this[0].getBoundingClientRect();
},

data: function (property, value) {
let dataSet = sqData.get(this[0]);
if (!dataSet) {
dataSet = {};
sqData.set(this[0], dataSet);
}

if (arguments.length === 1)
return dataSet[property];

dataSet[property] = value;

return this;
},

removeData: function (property) {
if (this.dataSet)
delete this.dataSet[property];

return this;
},

wrap: function (els) {
let res = {
length: els.length
};

Object.keys(sq)
.forEach(k => res[k] = sq[k].bind(res));

for (let i = 0; i < els.length; i++)
res[i] = els[i];

return res;
},

width: function (val) {
if (val) {
this.css('width', val);
return this;
}

return this[0].offsetWidth;
},

height: function (val) {
if (val) {
this.css('height', val);
return this;
}

return this[0].offsetHeight;
},

eq: function (index) {
return sq.wrap([this[index]]);
},

focus: function () {
this[0].focus();
return this;
},

blur: function () {
this[0].blur();
return this;
},

cloneRecursive: function (o, newO) {
if (typeof o !== 'object')
return o;
if (!o)
return o;
if (o instanceof Array) {
if (!newO || !newO.push)
newO = [];

for (let i = 0; i < o.length; i++)
newO[i] = sq.cloneRecursive(o[i], newO[i]);
return newO;
}

if (!newO || typeof(newO) !== 'object')
newO = {};
for (let i in o) {
if (o.hasOwnProperty(i))
newO[i] = sq.cloneRecursive(o[i], newO[i]);
}
return newO;
},

extend: function (temp, o) {
let aLen = arguments.length;
for (let i = 2; i < aLen; i++)
sq.cloneRecursive(arguments[i], o);

return o;
}
};

window.$ = sq.default.bind(sq);

Object.keys(sq).forEach(k => window.$[k] = sq[k].bind(sq));

+ 0
- 1
src/client/plugins/wquery.min.js 查看文件

@@ -1 +0,0 @@
const sq={default:function(t){const e=typeof t;return"string"===e?"<"===t[0]?this.build(t):sq.find(t):"object"===e?sq.wrap([t]):void document.addEventListener("DOMContentLoaded",t,!1)},build:function(t){let e=document.createElement("template");return e.innerHTML=t.trim(),sq.wrap([e.content.firstChild])},find:function(t){const e=(this[0]||document).querySelectorAll(t);return sq.wrap(e)},children:function(){return sq.wrap(this[0].children)},parent:function(){return sq.wrap([this[0].parentElement])},on:function(t,e){return this.each(n=>n.addEventListener(t,t=>{t.target=n,e(t)})),this},each:function(t){const e=this.length;for(let n=0;n<e;n++)t(this[n])},appendTo:function(t){return t="string"==typeof t?sq.find(t)[0]:t.on?t[0]:t,this.each(e=>t.appendChild(e)),this},prependTo:function(t){return t[0].insertBefore(this[0],t.children()[0]),this},remove:function(){this.each(t=>t.remove())},addClass:function(t){return t.split(" ").forEach(t=>this.each(e=>e.classList.add(t))),this},removeClass:function(t){return t.split(" ").forEach(t=>this.each(e=>e.classList.remove(t))),this},hasClass:function(t){return this[0].classList.contains(t)},toggleClass:function(t){this.hasClass(t)?this.removeClass(t):this.addClass(t)},show:function(){return this.each(t=>t.attributeStyleMap.set("display","block")),this},hide:function(){return this.each(t=>t.attributeStyleMap.set("display","none")),this},css:function(t,e){let n=t,i=arguments.length;return 1===i&&"string"==typeof t?(this[0].attributeStyleMap.get(t)||{}).value:(2===i&&(n={[t]:e}),Object.keys(n).forEach(t=>{let e=n[t];!["left","top","width","height"].includes(t)||e.indexOf&&-1!==e.indexOf("%")||(e+="px"),this.each(n=>e?n.attributeStyleMap.set(t,e):n.attributeStyleMap.delete(t))}),this)},empty:function(){let t=this[0];for(;t.firstChild;)t.removeChild(t.firstChild);return this},is:function(t){return this.width()&&this.height()},html:function(t){return arguments.length?(this[0].innerHTML=t,this):this[0].innerHTML},click:function(){return this[0].click(),this},next:function(){return sq.wrap([this[0].nextSibling])},scrollTop:function(t){if(!arguments.length)return this[0].scrollTop;this[0].scrollTop=t},val:function(t){return arguments.length?(this[0].value=t,this):this[0].value},attr:function(t,e){return 1===arguments.length?this[0].getAttribute(t):(this[0].setAttribute(t,e),this)},insertAfter:function(t){return t[0].parentNode.insertBefore(this[0],t[0].nextSibling),this},insertBefore:function(t){return t[0].parentNode.insertBefore(this[0],t[0]),this},index:function(){let t=this[0];return Array.prototype.indexOf.call(t.parentElement.children,t)},offset:function(){return this[0].getBoundingClientRect()},data:function(t,e){return this.dataSet||(this.dataSet={}),1===arguments.length?this.dataSet[t]:(this.dataSet[t]=e,this)},removeData:function(t){return this.dataSet&&delete this.dataSet[t],this},wrap:function(t){let e={length:t.length};Object.keys(sq).forEach(t=>e[t]=sq[t].bind(e));for(let n=0;n<t.length;n++)e[n]=t[n];return e},width:function(){return this[0].offsetWidth},height:function(){return this[0].offsetHeight},eq:function(t){return sq.wrap([this[t]])},focus:function(){return this[0].focus(),this},cloneRecursive:function(t,e){if("object"!=typeof t)return t;if(!t)return t;if(t instanceof Array){e&&e.push||(e=[]);for(let n=0;n<t.length;n++)e[n]=sq.cloneRecursive(t[n],e[n]);return e}e||(e={});for(let n in t)t.hasOwnProperty(n)&&(e[n]=sq.cloneRecursive(t[n],e[n]));return e},extend:function(t,e){let n=arguments.length;for(let t=2;t<n;t++)sq.cloneRecursive(arguments[t],e);return e}};window.$=sq.default.bind(sq),Object.keys(sq).forEach(t=>window.$[t]=sq[t].bind(sq));

Loading…
取消
儲存