diff --git a/examples/pxScene2d/src/node_modules/htmlparser/index.js b/examples/pxScene2d/src/node_modules/htmlparser/index.js new file mode 100644 index 0000000000..b69535eb93 --- /dev/null +++ b/examples/pxScene2d/src/node_modules/htmlparser/index.js @@ -0,0 +1,7 @@ +var htmlparser = require("./lib/htmlparser"); + +exports.Parser = htmlparser.Parser; +exports.DefaultHandler = htmlparser.DefaultHandler; +exports.RssHandler = htmlparser.RssHandler; +exports.ElementType = htmlparser.ElementType; +exports.DomUtils = htmlparser.DomUtils; diff --git a/examples/pxScene2d/src/v8_modules/emit.js b/examples/pxScene2d/src/v8_modules/emit.js new file mode 100644 index 0000000000..373ec1c6cf --- /dev/null +++ b/examples/pxScene2d/src/v8_modules/emit.js @@ -0,0 +1,28 @@ +/** + * emit class + */ +function WBEmit() {} +WBEmit.prototype.$emit = function(name) { + var args = Array.prototype.slice.call(arguments, 1); + if (this._events && this._events[name]) + this._events[name].forEach(function(cb) { + cb.apply(this, args) + }.bind(this)); + return this; +}; +WBEmit.prototype.$off = function(name, cb) { + if (!this._events) return this; + if (!cb) delete this._events[name]; + if (this._events[name]) this._events[name] = this._events[name].filter(function(i) { + return i != cb + }); + return this; +}; +WBEmit.prototype.$on = function(name, cb) { + if (!this._events) this._events = {}; + if (!this._events[name]) this._events[name] = []; + this._events[name].push(cb); + return cb; +}; + +module.exports = WBEmit; \ No newline at end of file diff --git a/examples/pxScene2d/src/v8_modules/querystring.js b/examples/pxScene2d/src/v8_modules/querystring.js index b74bb4668c..3bcf007e29 100644 --- a/examples/pxScene2d/src/v8_modules/querystring.js +++ b/examples/pxScene2d/src/v8_modules/querystring.js @@ -107,6 +107,15 @@ function qsUnescape(s, decodeSpaces) { } QueryString.unescape = qsUnescape; +/** + * unescape from Buffer, code from here + * https://github.com/nodejs/node/issues/10824 + * @param {*} buf the js Buffer + */ +function unescapeBuffer (buf) { + return buf.toString('hex').replace(/../g, e => `%${e}`); +} +QueryString.unescapeBuffer = unescapeBuffer; var hexTable = new Array(256); for (var i = 0; i < 256; ++i) diff --git a/examples/pxScene2d/src/v8_modules/ws.js b/examples/pxScene2d/src/v8_modules/ws.js index aa72573fef..a862bee827 100644 --- a/examples/pxScene2d/src/v8_modules/ws.js +++ b/examples/pxScene2d/src/v8_modules/ws.js @@ -24,33 +24,7 @@ const OPEN = 1; const CLOSING = 2; const CLOSED = 3; - -/** - * websocket emit class - */ -function WBEmit() {} -WBEmit.prototype.$emit = function(name) { - var args = Array.prototype.slice.call(arguments, 1); - if (this._events && this._events[name]) - this._events[name].forEach(function(cb) { - cb.apply(this, args) - }.bind(this)); - return this; -}; -WBEmit.prototype.$off = function(name, cb) { - if (!this._events) return this; - if (!cb) delete this._events[name]; - if (this._events[name]) this._events[name] = this._events[name].filter(function(i) { - return i != cb - }); - return this; -}; -WBEmit.prototype.$on = function(name, cb) { - if (!this._events) this._events = {}; - if (!this._events[name]) this._events[name] = []; - this._events[name].push(cb); - return cb; -}; +const WBEmit = require('emit'); /** * Create a new websocket instance