// ==UserScript== // @name AST SDK Bundle // @namespace local-jsvmp-learning // @version 0.1.0 // @description Inject Babel AST SDK into page window for local JSVMP AST learning. // @match *://*/* // @run-at document-start // @grant unsafeWindow // @license WTF // ==/UserScript== var AstSdkBundle = (() => { var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __commonJS = (cb, mod) => function __require() { try { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; } catch (e) { throw mod = 0, e; } }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); // node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js var require_resolve_uri_umd = __commonJS({ "node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js"(exports, module) { (function(global, factory) { typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, global.resolveURI = factory()); })(exports, (function() { "use strict"; const schemeRegex = /^[\w+.-]+:\/\//; const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/; const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i; function isAbsoluteUrl(input) { return schemeRegex.test(input); } function isSchemeRelativeUrl(input) { return input.startsWith("//"); } function isAbsolutePath(input) { return input.startsWith("/"); } function isFileUrl(input) { return input.startsWith("file:"); } function isRelative(input) { return /^[.?#]/.test(input); } function parseAbsoluteUrl(input) { const match = urlRegex.exec(input); return makeUrl(match[1], match[2] || "", match[3], match[4] || "", match[5] || "/", match[6] || "", match[7] || ""); } function parseFileUrl(input) { const match = fileRegex.exec(input); const path = match[2]; return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path) ? path : "/" + path, match[3] || "", match[4] || ""); } function makeUrl(scheme, user, host, port, path, query, hash) { return { scheme, user, host, port, path, query, hash, type: 7 }; } function parseUrl(input) { if (isSchemeRelativeUrl(input)) { const url2 = parseAbsoluteUrl("http:" + input); url2.scheme = ""; url2.type = 6; return url2; } if (isAbsolutePath(input)) { const url2 = parseAbsoluteUrl("http://foo.com" + input); url2.scheme = ""; url2.host = ""; url2.type = 5; return url2; } if (isFileUrl(input)) return parseFileUrl(input); if (isAbsoluteUrl(input)) return parseAbsoluteUrl(input); const url = parseAbsoluteUrl("http://foo.com/" + input); url.scheme = ""; url.host = ""; url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1; return url; } function stripPathFilename(path) { if (path.endsWith("/..")) return path; const index2 = path.lastIndexOf("/"); return path.slice(0, index2 + 1); } function mergePaths(url, base) { normalizePath(base, base.type); if (url.path === "/") { url.path = base.path; } else { url.path = stripPathFilename(base.path) + url.path; } } function normalizePath(url, type) { const rel = type <= 4; const pieces = url.path.split("/"); let pointer = 1; let positive = 0; let addTrailingSlash = false; for (let i = 1; i < pieces.length; i++) { const piece = pieces[i]; if (!piece) { addTrailingSlash = true; continue; } addTrailingSlash = false; if (piece === ".") continue; if (piece === "..") { if (positive) { addTrailingSlash = true; positive--; pointer--; } else if (rel) { pieces[pointer++] = piece; } continue; } pieces[pointer++] = piece; positive++; } let path = ""; for (let i = 1; i < pointer; i++) { path += "/" + pieces[i]; } if (!path || addTrailingSlash && !path.endsWith("/..")) { path += "/"; } url.path = path; } function resolve(input, base) { if (!input && !base) return ""; const url = parseUrl(input); let inputType = url.type; if (base && inputType !== 7) { const baseUrl = parseUrl(base); const baseType = baseUrl.type; switch (inputType) { case 1: url.hash = baseUrl.hash; // fall through case 2: url.query = baseUrl.query; // fall through case 3: case 4: mergePaths(url, baseUrl); // fall through case 5: url.user = baseUrl.user; url.host = baseUrl.host; url.port = baseUrl.port; // fall through case 6: url.scheme = baseUrl.scheme; } if (baseType > inputType) inputType = baseType; } normalizePath(url, inputType); const queryHash = url.query + url.hash; switch (inputType) { // This is impossible, because of the empty checks at the start of the function. // case UrlType.Empty: case 2: case 3: return queryHash; case 4: { const path = url.path.slice(1); if (!path) return queryHash || "."; if (isRelative(base || input) && !isRelative(path)) { return "./" + path + queryHash; } return path + queryHash; } case 5: return url.path + queryHash; default: return url.scheme + "//" + url.user + url.host + url.port + url.path + queryHash; } } return resolve; })); } }); // node_modules/jsesc/jsesc.js var require_jsesc = __commonJS({ "node_modules/jsesc/jsesc.js"(exports, module) { "use strict"; var object = {}; var hasOwnProperty = object.hasOwnProperty; var forOwn = (object2, callback) => { for (const key in object2) { if (hasOwnProperty.call(object2, key)) { callback(key, object2[key]); } } }; var extend = (destination, source) => { if (!source) { return destination; } forOwn(source, (key, value) => { destination[key] = value; }); return destination; }; var forEach = (array, callback) => { const length = array.length; let index2 = -1; while (++index2 < length) { callback(array[index2]); } }; var fourHexEscape = (hex) => { return "\\u" + ("0000" + hex).slice(-4); }; var hexadecimal = (code, lowercase) => { let hexadecimal2 = code.toString(16); if (lowercase) return hexadecimal2; return hexadecimal2.toUpperCase(); }; var toString = object.toString; var isArray = Array.isArray; var isBuffer = (value) => { return typeof Buffer === "function" && Buffer.isBuffer(value); }; var isObject = (value) => { return toString.call(value) == "[object Object]"; }; var isString = (value) => { return typeof value == "string" || toString.call(value) == "[object String]"; }; var isNumber = (value) => { return typeof value == "number" || toString.call(value) == "[object Number]"; }; var isBigInt = (value) => { return typeof value == "bigint"; }; var isFunction3 = (value) => { return typeof value == "function"; }; var isMap = (value) => { return toString.call(value) == "[object Map]"; }; var isSet = (value) => { return toString.call(value) == "[object Set]"; }; var singleEscapes = { "\\": "\\\\", "\b": "\\b", "\f": "\\f", "\n": "\\n", "\r": "\\r", " ": "\\t" // `\v` is omitted intentionally, because in IE < 9, '\v' == 'v'. // '\v': '\\x0B' }; var regexSingleEscape = /[\\\b\f\n\r\t]/; var regexDigit = /[0-9]/; var regexWhitespace = /[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/; var escapeEverythingRegex = /([\uD800-\uDBFF][\uDC00-\uDFFF])|([\uD800-\uDFFF])|(['"`])|[^]/g; var escapeNonAsciiRegex = /([\uD800-\uDBFF][\uDC00-\uDFFF])|([\uD800-\uDFFF])|(['"`])|[^ !#-&\(-\[\]-_a-~]/g; var jsesc2 = (argument, options) => { const increaseIndentation = () => { oldIndent = indent; ++options.indentLevel; indent = options.indent.repeat(options.indentLevel); }; const defaults = { "escapeEverything": false, "minimal": false, "isScriptContext": false, "quotes": "single", "wrap": false, "es6": false, "json": false, "compact": true, "lowercaseHex": false, "numbers": "decimal", "indent": " ", "indentLevel": 0, "__inline1__": false, "__inline2__": false }; const json = options && options.json; if (json) { defaults.quotes = "double"; defaults.wrap = true; } options = extend(defaults, options); if (options.quotes != "single" && options.quotes != "double" && options.quotes != "backtick") { options.quotes = "single"; } const quote = options.quotes == "double" ? '"' : options.quotes == "backtick" ? "`" : "'"; const compact = options.compact; const lowercaseHex = options.lowercaseHex; let indent = options.indent.repeat(options.indentLevel); let oldIndent = ""; const inline1 = options.__inline1__; const inline2 = options.__inline2__; const newLine = compact ? "" : "\n"; let result; let isEmpty = true; const useBinNumbers = options.numbers == "binary"; const useOctNumbers = options.numbers == "octal"; const useDecNumbers = options.numbers == "decimal"; const useHexNumbers = options.numbers == "hexadecimal"; if (json && argument && isFunction3(argument.toJSON)) { argument = argument.toJSON(); } if (!isString(argument)) { if (isMap(argument)) { if (argument.size == 0) { return "new Map()"; } if (!compact) { options.__inline1__ = true; options.__inline2__ = false; } return "new Map(" + jsesc2(Array.from(argument), options) + ")"; } if (isSet(argument)) { if (argument.size == 0) { return "new Set()"; } return "new Set(" + jsesc2(Array.from(argument), options) + ")"; } if (isBuffer(argument)) { if (argument.length == 0) { return "Buffer.from([])"; } return "Buffer.from(" + jsesc2(Array.from(argument), options) + ")"; } if (isArray(argument)) { result = []; options.wrap = true; if (inline1) { options.__inline1__ = false; options.__inline2__ = true; } if (!inline2) { increaseIndentation(); } forEach(argument, (value) => { isEmpty = false; if (inline2) { options.__inline2__ = false; } result.push( (compact || inline2 ? "" : indent) + jsesc2(value, options) ); }); if (isEmpty) { return "[]"; } if (inline2) { return "[" + result.join(", ") + "]"; } return "[" + newLine + result.join("," + newLine) + newLine + (compact ? "" : oldIndent) + "]"; } else if (isNumber(argument) || isBigInt(argument)) { if (json) { return JSON.stringify(Number(argument)); } let result2; if (useDecNumbers) { result2 = String(argument); } else if (useHexNumbers) { let hexadecimal2 = argument.toString(16); if (!lowercaseHex) { hexadecimal2 = hexadecimal2.toUpperCase(); } result2 = "0x" + hexadecimal2; } else if (useBinNumbers) { result2 = "0b" + argument.toString(2); } else if (useOctNumbers) { result2 = "0o" + argument.toString(8); } if (isBigInt(argument)) { return result2 + "n"; } return result2; } else if (isBigInt(argument)) { if (json) { return JSON.stringify(Number(argument)); } return argument + "n"; } else if (!isObject(argument)) { if (json) { return JSON.stringify(argument) || "null"; } return String(argument); } else { result = []; options.wrap = true; increaseIndentation(); forOwn(argument, (key, value) => { isEmpty = false; result.push( (compact ? "" : indent) + jsesc2(key, options) + ":" + (compact ? "" : " ") + jsesc2(value, options) ); }); if (isEmpty) { return "{}"; } return "{" + newLine + result.join("," + newLine) + newLine + (compact ? "" : oldIndent) + "}"; } } const regex = options.escapeEverything ? escapeEverythingRegex : escapeNonAsciiRegex; result = argument.replace(regex, (char, pair, lone, quoteChar, index2, string) => { if (pair) { if (options.minimal) return pair; const first = pair.charCodeAt(0); const second = pair.charCodeAt(1); if (options.es6) { const codePoint = (first - 55296) * 1024 + second - 56320 + 65536; const hex2 = hexadecimal(codePoint, lowercaseHex); return "\\u{" + hex2 + "}"; } return fourHexEscape(hexadecimal(first, lowercaseHex)) + fourHexEscape(hexadecimal(second, lowercaseHex)); } if (lone) { return fourHexEscape(hexadecimal(lone.charCodeAt(0), lowercaseHex)); } if (char == "\0" && !json && !regexDigit.test(string.charAt(index2 + 1))) { return "\\0"; } if (quoteChar) { if (quoteChar == quote || options.escapeEverything) { return "\\" + quoteChar; } return quoteChar; } if (regexSingleEscape.test(char)) { return singleEscapes[char]; } if (options.minimal && !regexWhitespace.test(char)) { return char; } const hex = hexadecimal(char.charCodeAt(0), lowercaseHex); if (json || hex.length > 2) { return fourHexEscape(hex); } return "\\x" + ("00" + hex).slice(-2); }); if (quote == "`") { result = result.replace(/\$\{/g, "\\${"); } if (options.isScriptContext) { result = result.replace(/<\/(script|style)/gi, "<\\/$1").replace(/