parse : function(svgstring, config) { this.tolerance_squared = Math.pow(this.tolerance, 2); // parse xml var svgRootElement; if (typeof window !== 'undefined') { if (window.DOMParser) { var parser = new DOMParser(); svgRootElement = parser.parseFromString(svgstring, 'text/xml').documentElement; } else { xml = xml.replace(/<!DOCTYPE svg[^>]*>/, ''); var xmlDoc = new ActiveXObject('Microsoft.XMLDOM'); xmlDoc.async = 'false'; xmlDoc.loadXML(svgstring); svgRootElement = xmlDoc.documentElement; } } else { var dom = require('domino'); var window = dom.createWindow(svgstring); svgRootElement = window.document.documentElement; } // let the fun begin var node = {} this.boundarys.allcolors = [] // TODO: sort by color node.stroke = [255,0,0]; node.xformToWorld = [1,0,0,1,0,0] this.parseChildren(svgRootElement, node) return this.boundarys },
export function parseDocument(html, url = '/') { /** @type {?} */ let window = domino.createWindow(html, url); /** @type {?} */ let doc = window.document; return doc; }
exports.createTests = function(setup) { var window = domino.createWindow(html); var $ = Zepto(window); var tests = setup(window); window.document.close(); return tests; }
DynamicHeadlessBrowserEmulator.prototype.getDependencies = function () { try { var senchaCoreFile = this.getSenchaCoreFile(); // use domino to mock out our DOM api's global.window = domino.createWindow('<html><head><script src="' + senchaCoreFile + '"></script></head><body></body></html>'); global.document = window.document; defineGlobals(this.pageRoot); fixMissingDomApis(); var Ext = safelyEvalFile(senchaCoreFile); this.defineExtGlobals(Ext); this.addPatchesToExtToRun(Ext); window.document.close(); safelyEvalFile(this.pageRoot + '/' + this.appJsFilePath); if (!this.isTouch) { Ext.EventManager.deferReadyEvent = null; Ext.EventManager.fireReadyEvent(); } var files = this.reOrderFiles(); return files; } catch (e) { grunt.log.error("An error occured which could cause problems " + e); if (e.stack) { grunt.log.error("Stack for debugging: \n" + e.stack); } throw e; } };
exports.user = function(body, fn){ if (!/[<>]/.test(body)){ fn(new Error('Not HTML content')); } else { try { var window = domino.createWindow(body); window._run(jquery); var $ = window.$; var cells = $('form tr td:odd'); var id = cells.eq(0).text(); var created = cells.eq(1).text(); var karma = parseInt(cells.eq(2).text(), 10); var avg = parseFloat(cells.eq(3).text()); var about = cleanContent(cells.eq(4).html()); var user = { id: id, created: created, karma: karma, avg: avg, about: about }; fn(null, user); } catch (e){ fn(e); } } };
var requireReact = function () { var window = domino.createWindow('<div id="root"></div>'); global.window = window; global.document = window.document; global.navigator = global.window.navigator; return require('react/addons'); };
request.get(hnURL).end(function(err, r){ if (err || !r.ok){ errorRespond(res, err, callback); return; } var window = domino.createWindow(r.text); window._run(jquery); var $ = window.$; var cells = $('form tr td:odd'); var id = cells.eq(0).text(), created = cells.eq(1).text(), karma = parseInt(cells.eq(2).text(), 10), avg = parseFloat(cells.eq(3).text()), about = cleanContent(cells.eq(4).html()); var user = { id: id, created: created, karma: karma, avg: avg, about: about }; var userJSON = JSON.stringify(user); redisClient.set('user' + userID, userJSON, function(){ redisClient.expire('user' + userID, CACHE_EXP); }); if (callback) userJSON = callback + '(' + userJSON + ')'; res.sendBody(userJSON); });
var zeptoEnv = (function loadDomEnv(){ var domino = require('domino'); var Zepto = require('zepto-node'); var window = domino.createWindow(); return Zepto(window); })();
r.on('end', function(){ var window = domino.createWindow(body); window._run(jquery); var $ = window.$; var cells = $('form tr td:odd'); var id = cells.eq(0).text(), created = cells.eq(1).text(), karma = parseInt(cells.eq(2).text(), 10), avg = parseFloat(cells.eq(3).text()), about = cleanContent(cells.eq(4).html()); var user = { id: id, created: created, karma: karma, avg: avg, about: about }; var userJSON = JSON.stringify(user); cache.set('user' + userID, userJSON, CACHE_EXP); if (callback) userJSON = callback + '(' + userJSON + ')'; res.sendBody(userJSON); }).on('error', function(e){
).done(function(err, html) { if (err) { console.error('Error downloading %s', targetURL); exports.cache.delete(targetURL).done(function() { throw(err); }); return; } setImmediate(cb, null, domino.createWindow(html).document); });
request.get(hnURL).end(function(err, r){ if (err || !r.ok){ errorRespond(res, err, callback); return; } var window = domino.createWindow(r.text); window._run(jquery); var $ = window.$; var posts = [], rows = $('td table:has(td.title) tr'); rows = rows.has('td'); for (var i=0, l=rows.length; i<l; i+=2){ var row1 = $(rows[i]), row2 = $(rows[i+1]); if (!row2.length) break; var voteLink = row1.find('td a[id^=up]'), id = (voteLink.length ? (voteLink.attr('id').match(/\d+/) || [])[0] : null), cell1 = row1.find('td.title:has(a)'), link = cell1.find('a:first'), title = link.text().trim(), url = link.attr('href'), domain = (cell1.find('.comhead').text().match(/\(\s?([^()]+)\s?\)/i) || [,null])[1], cell2 = row2.find('td.subtext'), points = parseInt(cell2.find('span[id^=score]').text(), 10), userLink = cell2.find('a[href^=user]'), user = userLink.text() || null, timeAgo = userLink[0] ? userLink[0].nextSibling.textContent.replace('|', '').trim() : '', commentsCount = parseInt(cell2.find('a[href^=item]').text(), 10) || 0, type = 'link'; if (url.match(/^item/i)) type = 'ask'; if (!user){ // No users post this = job ads type = 'job'; id = (url.match(/\d+/) || [])[0]; timeAgo = cell2.text().trim(); } posts.push({ id: id, title: title, url: url, domain: domain, points: points, user: user, time_ago: timeAgo, comments_count: commentsCount, type: type }); } var postsJSON = JSON.stringify(posts); redisClient.set(path, postsJSON, function(){ redisClient.expire(path, CACHE_EXP); }); if (callback) postsJSON = callback + '(' + postsJSON + ')'; res.sendBody(postsJSON); });
var highlightFile = function(html) { var i, len, codeBlocks, codeBlock, lang, result, finalHtml; var docType = getDocType(html); // Parse HTML into DOM. If doctype present, load as entire html document instead of setting an elem innerHTML. if (docType) { container = domino.createWindow(html).document; } else { window = window || domino.createWindow(''); document = window.document; container = document.createElement('div'); container.innerHTML = html; } codeBlocks = container.querySelectorAll('code'); for(i = 0, len = codeBlocks.length; i < len; i++) { codeBlock = codeBlocks[i]; lang = getLanguage(codeBlock); if (lang) { result = highlight.highlight(lang, codeBlock.textContent, true); } else { result = highlight.highlightAuto(codeBlock.textContent); if (result.language) { codeBlock.classList.add('lang-' + result.language); } } codeBlock.innerHTML = result.value; } if (docType) { finalHtml = docType + '\n' + container.getElementsByTagName('html')[0].outerHTML; } else { finalHtml = container.innerHTML; } return finalHtml; };
exports.musicJSON = function(source, callback) { // Ugly way of creating an XML document from string var win = domino.createWindow(source); // Fetch the "root" document from the html -> body -> firstChild var root = win.document.documentElement.childNodes[1].firstChild; // Parse and convert the document var music = musicJSON(root); callback(null, music); };
r.on('end', function(){ var window = domino.createWindow(body); window._run(jquery); var $ = window.$; var comments = [], commentRows = $('tr:nth-child(3) tr:has(span.comment)'); comments = processComments(commentRows, $); var commentsJSON = JSON.stringify(comments); cache.set(path, commentsJSON, CACHE_EXP); if (callback) commentsJSON = callback + '(' + commentsJSON + ')'; res.sendBody(commentsJSON); });
function getAllPages(err, rawHTML) { if(err) { base.error(exports.buildMultiversePrintingsURL(multiverseid, 0)); base.error(err); return setImmediate(function() { cb(err); }); } var urls = []; var numPages = exports.getPagingNumPages(domino.createWindow(rawHTML).document, "printings"); for(var i = 0; i < numPages; i++) { urls.push(exports.buildMultiversePrintingsURL(multiverseid, i)); } return setImmediate(cb, undefined, urls); }
request.get(hnURL).end(function(err, r){ if (err || !r.ok){ errorRespond(res, err, callback); return; } var body = r.text; // Link has expired. Classic HN error message. if (!/[<>]/.test(body) && /expired/i.test(body)){ var result = JSON.stringify({ error: true, message: body }); if (callback) result = callback + '(' + result + ')'; res.sendBody(result); return; } var window = domino.createWindow(body); window._run(jquery); var $ = window.$; var post = { comments: [], more_comments_id: null }; var commentRows = $('table:not(:has(table)):has(.comment)'); post.comments = processComments(commentRows, $); // Check for 'More' comments (Rare case) var more = $('td.title a[href^="/x?"]'); if (more.length){ // Whatever 'fnid' means var fnid = more.attr('href').match(/fnid=(\w+)/); if (fnid){ fnid = fnid[1]; post.more_comments_id = fnid; } } var postJSON = JSON.stringify(post); redisClient.set('comments' + commentID, postJSON, function(){ redisClient.expire('comments' + commentID, CACHE_EXP); }); if (callback) postJSON = callback + '(' + postJSON + ')'; res.sendBody(postJSON); });
DynamicAnalyserMockingExtSystem.prototype.getDependencies = function () { var senchaCoreFile, contents, src; senchaCoreFile = this.mapClassToFile("Ext"); this.filesLoadedSoFar.push(senchaCoreFile); contents = grunt.file.read(senchaCoreFile); // use domino to mock out our DOM api"s global.window = domino.createWindow("<head><script src='" + senchaCoreFile + "'></script></head><body></body>"); global.document = window.document; defineGlobals(this.pageRoot); fixMissingDomApis(); var Ext = safelyEvalFile(senchaCoreFile); this.defineExtGlobals(); safelyEvalFile(this.pageRoot + "/" + this.appJsFilePath); this.filesLoadedSoFar.push(this.pageRoot + "/" + this.appJsFilePath); return this.filesLoadedSoFar; };
function compareVersions(setsHTML) { var mciSets = unique(Array.from(domino.createWindow(setsHTML).document.querySelector("a[name='en']").nextElementSibling.nextElementSibling.querySelectorAll("li a")).map(function(o) { return path.dirname(url.parse(o.getAttribute("href")).pathname).substring(1).toLowerCase(); }).filter(Boolean)); if(mciSets.length<1) { winston.error("No MCI sets found! Probably a temporary error..."); process.exit(1); } var oldMCISets = unique(C.SETS.filter(function(SET) { return SET.hasOwnProperty("magicCardsInfoCode"); }).map(function(SET) { return SET.magicCardsInfoCode.toLowerCase(); }).concat(MCI_SETS_TO_IGNORE)); var newMCISets = mciSets.filter(function(s) { return !oldMCISets.includes(s); }); if(newMCISets.length>0) winston.info(newMCISets); this(); },
exports.newComments = function(body, fn){ if (!/[<>]/.test(body)){ fn(new Error('Not HTML content')); } else { try { var window = domino.createWindow(body); window._run(jquery); var $ = window.$; var commentRows = $('tr:nth-child(3) tr:has(span.comment)'); var comments = processComments(commentRows, $); fn(null, comments); } catch (e){ fn(e); } } };
request({url:url}, function(err, response, body){ if (err || response.statusCode !==200){ return console.warn('Failed to find page'); } var myWindow = domino.createWindow(body); var $ = Zepto(myWindow); var appInfo = { title: $('.pic-container img').attr('alt'), body: $('#thepost').html(), image: $('.pic-container img').attr('src'), author: $('.innerauthor').text().trim(), category: $('.article-category').text().trim(), PublishedDate: $('.dateline').text().trim(), }; console.log('Info: ', appInfo); })
function compareVersions(cardsHTML, previousCardsJSON) { var cards = Array.from(domino.createWindow(cardsHTML[0]).document.querySelectorAll("ul.list-links li a")).map(function(o) { return o.textContent.trim(); }).filter(Boolean); if(cards.length<1) { winston.error("No cards found! Probably a temporary error..."); process.exit(1); } var previousCards = JSON.parse(previousCardsJSON); var removedCards = previousCards.filter(function(c) { return !cards.include(c); }); if(removedCards.length) winston.info("Cards Removed: %s", removedCards.join(", ")); var addedCards = cards.filter(function(c) { return !previousCards.include(c); }); if(addedCards.length) winston.info("Cards Added: %s", addedCards.join(", ")); fs.writeFile(path.join(__dirname, "previous_banned_commander_cards.json"), JSON.stringify(cards, null, ' '), {encoding : "utf8"}, this); },
files.forEach(function (file, index) { // load file contents var contents = String(grunt.file.read(file, 'utf-8')); var window = domino.createWindow(contents); var document = window.document; // get the doctype back var getDoctype = function (document) { var html = ''; var node = document.doctype; if (node) { html = "<!DOCTYPE " + node.name + (node.publicId ? ' PUBLIC "' + node.publicId + '"' : '') + (!node.publicId && node.systemId ? ' SYSTEM' : '') + (node.systemId ? ' "' + node.systemId + '"' : '') + '>\n'; } return html; }; // iterate over content nodes to find the correct script tags var scriptTags = document.getElementsByTagName('script'); util._.each(scriptTags, function (elm, idx) { // check for require js like script tags if (elm.tagName.toLowerCase() === 'script' && elm.getAttribute('data-main') !== null) { // replace the attributes of requires script tag // with the 'almonded' version of the module var insertScript = util._.isUndefined(entry.modulePath) !== true ? entry.modulePath : elm.getAttribute('data-main'); if (config.almond === true) { elm.setAttribute('src', insertScript + '.js'); elm.removeAttribute('data-main'); } else { elm.setAttribute('data-main', insertScript); } } }); // write out newly created file contents grunt.file.write(file, getDoctype(document) + document.documentElement.outerHTML); deferred.resolve(config); });
(function(parsed){ try { if(options.jsdom){ var jsdom = M.jsdom(); jsdom.env({ html:str, features:{QuerySelector:true}, done:function(err,win){ if(err){ parsed(err); return; } win.document.onload = function() { parsed(err,win); }; }}); } else if(options.phantom){ var phantom = M.phantom(); } else { parsed( null, domino.createWindow(str) ); } } catch (e) { parsed(e); } })(function(err,window){
exports.moreComments = function(body, fn){ if (!/[<>]/.test(body)){ if (/expired/i.test(body)){ fn(new Error('Content expired')); } else { fn(new Error('Not HTML content')); } } else { try { var window = domino.createWindow(body); window._run(jquery); var $ = window.$; var post = { comments: [], more_comments_id: null }; var commentRows = $('table:not(:has(table)):has(.comment)'); post.comments = processComments(commentRows, $); // Check for 'More' comments (Rare case) var more = $('td.title a[href^="/x?"]'); if (more.length){ // Whatever 'fnid' means var fnid = more.attr('href').match(/fnid=(\w+)/); if (fnid){ fnid = fnid[1]; post.more_comments_id = fnid; } } fn(null, post); } catch (e){ fn(e); } } };
describe('ditherjs.client', function() { var DitherJS = require('../client.js'); var domino = require('domino'); global.window = domino.createWindow(); global.document = window.document; it('should augment the base class', function () { [ '_replaceElementWithCtx', '_fromImgElement', '_fromSelector' ].forEach(function (method) { expect(DitherJS.prototype.hasOwnProperty(method), 'to be', true); }); }); describe('dither', function () { var ditherjs = new DitherJS(); it('should call _fromImgElement if the argument is a Node', function () { var node = document.createElement('img'); document.body.appendChild(node); var called = false; var mockInstance = { _fromImgElement: function () { called = true; } }; ditherjs.dither.call(mockInstance, node); expect(called, 'to be', true); }); it('should call _fromSelector if the argument is a string', function () { var called = false; var mockInstance = { _fromSelector: function () { called = true; } }; ditherjs.dither.call(mockInstance, '.foo'); expect(called, 'to be', true); }); }); describe('_replaceElementWithCtx', function () { var ditherjs = new DitherJS(); var element = document.createElement('img'); element.className = 'boo dither bar'; document.body.appendChild(element); it('should get the canvas context out of the element', function () { // TODO getContext() not implemented in Domino try { ditherjs._replaceElementWithCtx(element) ; } catch (err) { expect(err, 'to be defined'); } }); }); describe('_fromImgElement', function () { var ditherjs = new DitherJS(); var element = document.createElement('img'); document.body.appendChild(element); it('should get the image, process it and put that in the context', function () { var MOCK_DATA = ['panda']; ditherjs.ditherImageData = function (data) { expect(data, 'to be', MOCK_DATA); data.push('mango'); }; ditherjs._replaceElementWithCtx = function () { return { drawImage: noop, getImageData: function () { return MOCK_DATA; }, putImageData: function (data) { return expect(data, 'to satisfy', ['panda','mango']); } }; }; ditherjs._fromImgElement(element); }); }); describe('_fromSelector', function () { var ditherjs = new DitherJS(); var element = document.createElement('img'); element.className = 'mommo'; document.body.appendChild(element); it('should call _fromImgElement on the element', function () { var mockDitherCalled = false; var mockDither = { _fromImgElement: function () { mockDitherCalled = true; } }; ditherjs._fromSelector.call(mockDither,'.mommo'); element.onload(); expect(mockDitherCalled, 'to be', true); }); }); });
var g=require("domino");function v(t){return new Error("This method is not implemented in DominoAdapter: "+t)}function b(t,e){return void 0===e&&(e="/"),g.createWindow(t,e).document}var E=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return h(e,t),e.makeCurrent=function(){!function t(){Object.assign(global,g.impl),global.KeyboardEvent=g.impl.Event}(),n.ɵsetRootDomAdapter(new e)},e.prototype.logError=function(t){console.error(t)},e.prototype.log=function(t){console.log(t)},e.prototype.logGroup=function(t){console.error(t)},e.prototype.logGroupEnd=function(){},e.prototype.supportsDOMEvents=function(){return!1},e.prototype.supportsNativeShadowDOM=function(){return!1},e.prototype.contains=function(t,e){for(var r=e;r;){if(r===t)return!0;r=r.parent}return!1},e.prototype.createHtmlDocument=function(){return b("<html><head><title>fakeTitle</title></head><body></body></html>")},e.prototype.getDefaultDocument=function(){return e.defaultDoc||(e.defaultDoc=g.createDocument()),e.defaultDoc},e.prototype.createShadowRoot=function(t,e){return void 0===e&&(e=document),t.shadowRoot=e.createDocumentFragment(),t.shadowRoot.parent=t,t.shadowRoot},e.prototype.getShadowRoot=function(t){return t.shadowRoot},e.prototype.isTextNode=function(t){return t.nodeType===e.defaultDoc.TEXT_NODE},e.prototype.isCommentNode=function(t){return t.nodeType===e.defaultDoc.COMMENT_NODE},e.prototype.isElementNode=function(t){return!!t&&t.nodeType===e.defaultDoc.ELEMENT_NODE},e.prototype.hasShadowRoot=function(t){return null!=t.shadowRoot},e.prototype.isShadowRoot=function(t){return this.getShadowRoot(t)==t},e.prototype.getProperty=function(t,e){return"href"===e?this.getAttribute(t,"href"):"innerText"===e?t.textContent:t[e]},e.prototype.setProperty=function(t,e,r){"href"===e?this.setAttribute(t,"href",r):"innerText"===e&&(t.textContent=r),t[e]=r},e.prototype.getGlobalEventTarget=function(t,e){return"window"===e?t.defaultView:"document"===e?t:"body"===e?t.body:null},e.prototype.getBaseHref=function(t){var e=this.querySelector(t.documentElement,"base"),r="";return e&&(r=this.getHref(e)),r},e.prototype._readStyleAttribute=function(t){var e={},r=t.getAttribute("style");if(r)for(var n=r.split(/;+/g),o=0;o<n.length;o++){var i=n[o].trim();if(i.length>0){var a=i.indexOf(":");if(-1===a)throw new Error("Invalid CSS style: "+i);e[i.substr(0,a).trim()]=i.substr(a+1).trim()}}return e},e.prototype._writeStyleAttribute=function(t,e){var r="";for(var n in e)e[n]&&(r+=n+":"+e[n]+";");t.setAttribute("style",r)},e.prototype.setStyle=function(t,e,r){e=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();var n=this._readStyleAttribute(t);n[e]=r||"",this._writeStyleAttribute(t,n)},e.prototype.removeStyle=function(t,e){this.setStyle(t,e,"")},e.prototype.getStyle=function(t,e){return this._readStyleAttribute(t)[e]||""},e.prototype.hasStyle=function(t,e,r){var n=this.getStyle(t,e);return r?n==r:n.length>0},e.prototype.dispatchEvent=function(t,e){t.dispatchEvent(e);var r=(t.ownerDocument||t).defaultView;r&&r.dispatchEvent(e)},e.prototype.getHistory=function(){throw v("getHistory")},e.prototype.getLocation=function(){throw v("getLocation")},e.prototype.getUserAgent=function(){return"Fake user agent"},e.prototype.supportsWebAnimation=function(){return!1},e.prototype.performanceNow=function(){return Date.now()},e.prototype.getAnimationPrefix=function(){return""},e.prototype.getTransitionEnd=function(){return"transitionend"},e.prototype.supportsAnimation=function(){return!0},e.prototype.getDistributedNodes=function(t){throw v("getDistributedNodes")},e.prototype.supportsCookies=function(){return!1},e.prototype.getCookie=function(t){throw v("getCookie")},e.prototype.setCookie=function(t,e){throw v("setCookie")},e}(n.ɵBrowserDomAdapter),_=function(){function t(t){this._doc=t}return t.prototype.renderToString=function(){return function t(e){return e.serialize()}(this._doc)},t.prototype.getDocument=function(){return this._doc},d([r.Injectable(),y(0,r.Inject(e.DOCUMENT)),m("design:paramtypes",[Object])],t)}(),w=require("xhr2"),S=function(){function t(){}return t.prototype.build=function(){return new w.XMLHttpRequest},d([r.Injectable()],t)}(),D=function(t){function e(e){var r=t.call(this)||this;return r.backend=e,r}return h(e,t),e.prototype.handle=function(t){return this.wrap(t)},e.prototype.delegate=function(t){return this.backend.handle(t)},e}(function(){function t(){}return t.prototype.wrap=function(t){var e=this;return new s.Observable(function(r){var n=null,o=!1,i=null,a=null,u=null;return function(r){n=r,o=!0;var s=e.delegate(t);i=s.subscribe(function(t){return a=t},function(t){if(!o)throw new Error("An http observable was completed twice. This shouldn't happen, please file a bug.");u=t,o=!1,n.invoke()},function(){if(!o)throw new Error("An http observable was completed twice. This shouldn't happen, please file a bug.");o=!1,n.invoke()})}(Zone.current.scheduleMacroTask("ZoneMacroTaskWrapper.subscribe",function(){null!==u?r.error(u):(r.next(a),r.complete())},{},function(){return null},function(t){o&&(o=!1,i&&(i.unsubscribe(),i=null))})),function(){o&&n&&(n.zone.cancelTask(n),o=!1),i&&(i.unsubscribe(),i=null)}})},t}());
var Client = require('../lib/Client.class'); var domino = require('domino'), Zepto = require('zepto-node'), $ = Zepto(domino.createWindow()); var fs = require('fs'); testMain(); function testMain() { var client = new Client('jwc.wyu.cn', '/xks', 'gbk'); // 进入登录页面 client.get('/', {}, {}, function(err, res, body) { // 提交登录信息 client.cookie['LogonNumber'] = ''; client.post('/ec_logon.asp', { 'sid': process.argv[2], 'pwd': process.argv[3] }, {}, function(err, res, body) { //var success = /welcome/.test(body); //console.log(success ? '登录成功' : '登录失败'); console.log(res.headers) console.log(body) }); }); }
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@angular/core"),require("@angular/platform-browser"),require("@angular/animations/browser"),require("@angular/common"),require("@angular/common/http"),require("@angular/http"),require("@angular/platform-browser-dynamic"),require("@angular/platform-browser/animations"),require("rxjs/Observable"),require("rxjs/Subject"),require("url"),require("@angular/compiler"),require("rxjs/operator/filter"),require("rxjs/operator/first"),require("rxjs/operator/toPromise")):"function"==typeof define&&define.amd?define("@angular/platform-server",["exports","@angular/core","@angular/platform-browser","@angular/animations/browser","@angular/common","@angular/common/http","@angular/http","@angular/platform-browser-dynamic","@angular/platform-browser/animations","rxjs/Observable","rxjs/Subject","url","@angular/compiler","rxjs/operator/filter","rxjs/operator/first","rxjs/operator/toPromise"],factory):factory((global.ng=global.ng||{},global.ng.platformServer={}),global.ng.core,global.ng.platformBrowser,global.ng.animations.browser,global.ng.common,global.ng.common.http,global.ng.http,global.ng.platformBrowserDynamic,global.ng.platformBrowser.animations,global.Rx,global.Rx,global.url,global.ng.compiler,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.Rx.Observable.prototype)}(this,function(exports,_angular_core,_angular_platformBrowser,_angular_animations_browser,_angular_common,_angular_common_http,_angular_http,_angular_platformBrowserDynamic,_angular_platformBrowser_animations,rxjs_Observable,rxjs_Subject,url,_angular_compiler,rxjs_operator_filter,rxjs_operator_first,rxjs_operator_toPromise){"use strict";function __extends(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}function _notImplemented(methodName){return new Error("This method is not implemented in DominoAdapter: "+methodName)}function parseDocument(html,url$$1){return void 0===url$$1&&(url$$1="/"),domino.createWindow(html,url$$1).document}function serializeDocument(doc){return doc.serialize()}function validateRequestUrl(url$$1){if(!isAbsoluteUrl.test(url$$1))throw new Error("URLs requested via Http on the server must be absolute. URL: "+url$$1)}function httpFactory(xhrBackend,options){var macroBackend=new ZoneMacroTaskBackend(xhrBackend);return new _angular_http.Http(macroBackend,options)}function zoneWrappedInterceptingHandler(backend,interceptors){var realBackend=_angular_common_http.ɵinterceptingHandler(backend,interceptors);return new ZoneClientBackend(realBackend)}/**
var domino = require('domino'), Zepto = require('zepto-node'), wxValid = require('./lib/weixin-valid'), wxHandler = require('./weixin-handler/'), TOKEN = 'etips', window = domino.createWindow(), $ = Zepto(window); exports.onValid = function(req, res, next){ req.query['echostr'] ? wxValid(req, res, TOKEN) : next(); } exports.onMessage = function(req, res, next){ wxHandler(parseReqObj(req.rawBody), function(resObj) { res.end(parseResXML(resObj)); }); } function parseResXML(resObj){ return ['<xml>', '<ToUserName><![CDATA[', resObj.toUserName ,']]></ToUserName>', '<FromUserName><![CDATA[', resObj.fromUserName ,']]></FromUserName>', '<CreateTime>', resObj.createTime || new Date().getTime() ,'</CreateTime>', '<MsgType><![CDATA[', resObj.msgType || 'text' ,']]></MsgType>', '<Content><![CDATA[', resObj.content ,']]></Content>', '<FuncFlag>', resObj.funcFlag || 0 ,'</FuncFlag>', '</xml>'].join(''); } function parseReqObj(reqXML){ var $req = $('<div>').html(reqXML); return {
/** * Parses a document string to a Document object. * @param {?} html * @param {?=} url * @return {?} */ function parseDocument(html, url$$1 = '/') { let /** @type {?} */ window = domino.createWindow(html, url$$1); let /** @type {?} */ doc = window.document; return doc; }