rsnext/packages/next/compiled/amphtml-validator/index.js

17 lines
47 KiB
JavaScript
Raw Normal View History

(()=>{var e={873:(e,t,n)=>{"use strict";var r=n(742);var i=[];e.exports=asap;function asap(e){var t;if(i.length){t=i.pop()}else{t=new RawTask}t.task=e;t.domain=process.domain;r(t)}function RawTask(){this.task=null;this.domain=null}RawTask.prototype.call=function(){if(this.domain){this.domain.enter()}var e=true;try{this.task.call();e=false;if(this.domain){this.domain.exit()}}finally{if(e){r.requestFlush()}this.task=null;this.domain=null;i.push(this)}}},742:(e,t,n)=>{"use strict";var r;var i=typeof setImmediate==="function";e.exports=rawAsap;function rawAsap(e){if(!s.length){requestFlush();o=true}s[s.length]=e}var s=[];var o=false;var a=0;var l=1024;function flush(){while(a<s.length){var e=a;a=a+1;s[e].call();if(a>l){for(var t=0,n=s.length-a;t<n;t++){s[t]=s[t+a]}s.length-=a;a=0}}s.length=0;a=0;o=false}rawAsap.requestFlush=requestFlush;function requestFlush(){var e=process.domain;if(e){if(!r){r=n(639)}r.active=process.domain=null}if(o&&i){setImmediate(flush)}else{process.nextTick(flush)}if(e){r.active=process.domain=e}}},758:(e,t,n)=>{var r={};e["exports"]=r;r.themes={};var i=n(837);var s=r.styles=n(77);var o=Object.defineProperties;var a=new RegExp(/[\r\n]+/g);r.supportsColor=n(725).supportsColor;if(typeof r.enabled==="undefined"){r.enabled=r.supportsColor()!==false}r.enable=function(){r.enabled=true};r.disable=function(){r.enabled=false};r.stripColors=r.strip=function(e){return(""+e).replace(/\x1B\[\d+m/g,"")};var l=r.stylize=function stylize(e,t){if(!r.enabled){return e+""}var n=s[t];if(!n&&t in r){return r[t](e)}return n.open+e+n.close};var u=/[|\\{}()[\]^$+*?.]/g;var escapeStringRegexp=function(e){if(typeof e!=="string"){throw new TypeError("Expected a string")}return e.replace(u,"\\$&")};function build(e){var t=function builder(){return applyStyle.apply(builder,arguments)};t._styles=e;t.__proto__=h;return t}var c=function(){var e={};s.grey=s.gray;Object.keys(s).forEach((function(t){s[t].closeRe=new RegExp(escapeStringRegexp(s[t].close),"g");e[t]={get:function(){return build(this._styles.concat(t))}}}));return e}();var h=o((function colors(){}),c);function applyStyle(){var e=Array.prototype.slice.call(arguments);var t=e.map((function(e){if(e!=null&&e.constructor===String){return e}else{return i.inspect(e)}})).join(" ");if(!r.enabled||!t){return t}var n=t.indexOf("\n")!=-1;var o=this._styles;var l=o.length;while(l--){var u=s[o[l]];t=u.open+t.replace(u.closeRe,u.open)+u.close;if(n){t=t.replace(a,(function(e){return u.close+e+u.open}))}}return t}r.setTheme=function(e){if(typeof e==="string"){console.log("colors.setTheme now only accepts an object, not a string. "+"If you are trying to set a theme from a file, it is now your (the "+"caller's) responsibility to require the file. The old syntax "+"looked like colors.setTheme(__dirname + "+"'/../themes/generic-logging.js'); The new syntax looks like "+"colors.setTheme(require(__dirname + "+"'/../themes/generic-logging.js'));");return}for(var t in e){(function(t){r[t]=function(n){if(typeof e[t]==="object"){var i=n;for(var s in e[t]){i=r[e[t][s]](i)}return i}return r[e[t]](n)}})(t)}};function init(){var e={};Object.keys(c).forEach((function(t){e[t]={get:function(){return build([t])}}}));return e}var p=function sequencer(e,t){var n=t.split("");n=n.map(e);return n.join("")};r.trap=n(822);r.zalgo=n(576);r.maps={};r.maps.america=n(967)(r);r.maps.zebra=n(917)(r);r.maps.rainbow=n(410)(r);r.maps.random=n(409)(r);for(var f in r.maps){(function(e){r[e]=function(t){return p(r.maps[e],t)}})(f)}o(r,init())},822:e=>{e["exports"]=function runTheTrap(e,t){var n="";e=e||"Run the trap, drop the bass";e=e.split("");var r={a:["@","Ą","Ⱥ","Ʌ","Δ","Λ","Д"],b:["ß","Ɓ","Ƀ","ɮ","β","฿"],c:["©","Ȼ","Ͼ"],d:["Ð","Ɗ","Ԁ","ԁ","Ԃ","ԃ"],e:["Ë","ĕ","Ǝ","ɘ","Σ","ξ","Ҽ","੬"],f:["Ӻ"],g:["ɢ"],h:["Ħ","ƕ","Ң","Һ","Ӈ","Ԋ"],i:["༏"],j:["Ĵ"],k:["ĸ","Ҡ","Ӄ","Ԟ"],l:["Ĺ"],m:["ʍ","Ӎ","ӎ","Ԡ","ԡ","൩"],n:["Ñ","ŋ","Ɲ","Ͷ","Π","Ҋ"],o:["Ø","õ","ø","Ǿ","ʘ","Ѻ","ם","۝","๏"],p:["Ƿ","Ҏ"],q:["্"],r:["®","Ʀ","Ȑ","Ɍ","ʀ","Я"],s:["§","Ϟ","ϟ","Ϩ"],t:[
/**
* @license
* Copyright 2016 The AMP HTML Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the license.
*/const t=__nccwpck_require__(915);const r=__nccwpck_require__(147);const i=__nccwpck_require__(685);const s=__nccwpck_require__(687);const o=__nccwpck_require__(17);const a=__nccwpck_require__(642);const l=__nccwpck_require__(263);const u=__nccwpck_require__(477);const c=__nccwpck_require__(310);const h=__nccwpck_require__(837);const p=__nccwpck_require__(144);const f="amphtml-validator";function hasPrefix(e,t){return e.indexOf(t)==0}function isHttpOrHttpsUrl(e){return hasPrefix(e,"http://")||hasPrefix(e,"https://")}function readFromFile(e){return new l((function(t,n){r.readFile(e,"utf8",(function(e,r){if(e){n(e)}else{t(r.trim())}}))}))}function readFromReadable(e,t){return new l((function(n,r){const i=[];t.setEncoding("utf8");t.on("data",(function(e){i.push(e)}));t.on("end",(function(){n(i.join(""))}));t.on("error",(function(t){r(new Error("Could not read from "+e+" - "+t.message))}))}))}function readFromStdin(){return readFromReadable("stdin",process.stdin).then((function(e){process.stdin.resume();return e}))}function readFromUrl(e,t){return new l((function(n,r){const o=hasPrefix(e,"http://")?i:s;const a=o.request(e,(function(t){if(t.statusCode!==200){t.resume();r(new Error("Unable to fetch "+e+" - HTTP Status "+t.statusCode))}else{n(t)}}));a.setHeader("User-Agent",t);a.on("error",(function(t){r(new Error("Unable to fetch "+e+" - "+t.message))}));a.end()})).then(readFromReadable.bind(null,e))}function ValidationResult(){this.status="UNKNOWN";this.errors=[]}function ValidationError(){this.severity="UNKNOWN_SEVERITY";this.line=1;this.col=0;this.message="";this.specUrl=null;this.code="UNKNOWN_CODE";this.params=[]}function Validator(e){this.sandbox=p.createContext();try{new p.Script(e).runInContext(this.sandbox)}catch(e){throw new Error("Could not instantiate validator_wasm.js - "+e.message)}}Validator.prototype.init=function(){if(this.sandbox.amp.validator.init){return this.sandbox.amp.validator.init()}else{return l.resolve(undefined)}};Validator.prototype.validateString=function(e,t){const n=this.sandbox.amp.validator.validateString(e,t);const r=new ValidationResult;r.status=n.status;for(let e=0;e<n.errors.length;e++){const t=n.errors[e];const i=new ValidationError;i.severity=t.severity;i.line=t.line;i.col=t.col;i.message=this.sandbox.amp.validator.renderErrorMessage(t);i.specUrl=t.specUrl;i.code=t.code;i.params=t.params;r.errors.push(i)}return r};const m={};function getInstance(e,t){const n=e||"https://cdn.ampproject.org/v0/validator_wasm.js";const r=t||f;if(m.hasOwnProperty(n)){return l.resolve(m[n])}const i=isHttpOrHttpsUrl(n)?readFromUrl(n,r):readFromFile(n);return i.then((function(e){let t;try{t=new Validator(e)}catch(e){throw e}m[n]=t;return t})).then((function(e){return e.init().then((()=>e))}))}e.getInstance=getInstance;function newInstance(e){return new Validator(e)}e.newInstance=newInstance;function logValidationResult(e,n,r){if(n.status==="PASS"){process.stdout.write(e+": "+(r?t.green("PASS"):"PASS")+"\n")}for(let i=0;i<n.errors.length;i++){const s=n.errors[i];let o=e+":"+s.line+":"+s.col+" ";if(r){o+=(s.severity==="ERROR"?t.red:t.magenta)(s.message)}else{o+=s.message}if(s.specUrl){o+=" (see "+s.specUrl+")"}process.stderr.write(o+"\n")}}function main(){a.usage("[options] <fileOrUrlOrMinus...>\n\n"+' Validates the files or urls provided as arguments. If "-" is\n'+" specified, reads from stdin instead.").option("--validator_js <fileOrUrl>","The Validator Javascript.\n"+" Latest published version by default, or\n"+" dist/validator_minified.js (built with build.py)\n"+" for development.","https://cdn.ampproject.org/v0/validator_wasm.js").option("--user-agent <userAgent>","User agent string to use in requests.",f).option("--html_format <AMP|AMP4ADS|AMP4EMAIL>","The input format to be validated.\n"+" AMP by default.","AMP").option("--format <color|text|json>","How to format the output.\n"+' "color" displays errors/warnings/success in\n'+" red/orange/green.\n"+' "text" avoids color (e.g., useful in terminals not\n'+" supporting color).\n"+' "json" emits json corresponding to the Valida