├── .editorconfig ├── .gitignore ├── .prettierrc ├── README.md ├── _worker.js ├── images ├── FortiGuard Intrusion Prevention - Access Blocked.png ├── 转换示意.png └── 错误1102.png ├── package-lock.json ├── package.json ├── src └── worker.js └── wrangler.toml /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = tab 6 | tab_width = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.yml] 13 | indent_style = space 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | 3 | logs 4 | _.log 5 | npm-debug.log_ 6 | yarn-debug.log* 7 | yarn-error.log* 8 | lerna-debug.log* 9 | .pnpm-debug.log* 10 | 11 | # Diagnostic reports (https://nodejs.org/api/report.html) 12 | 13 | report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json 14 | 15 | # Runtime data 16 | 17 | pids 18 | _.pid 19 | _.seed 20 | \*.pid.lock 21 | 22 | # Directory for instrumented libs generated by jscoverage/JSCover 23 | 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | 28 | coverage 29 | \*.lcov 30 | 31 | # nyc test coverage 32 | 33 | .nyc_output 34 | 35 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 36 | 37 | .grunt 38 | 39 | # Bower dependency directory (https://bower.io/) 40 | 41 | bower_components 42 | 43 | # node-waf configuration 44 | 45 | .lock-wscript 46 | 47 | # Compiled binary addons (https://nodejs.org/api/addons.html) 48 | 49 | build/Release 50 | 51 | # Dependency directories 52 | 53 | node_modules/ 54 | jspm_packages/ 55 | 56 | # Snowpack dependency directory (https://snowpack.dev/) 57 | 58 | web_modules/ 59 | 60 | # TypeScript cache 61 | 62 | \*.tsbuildinfo 63 | 64 | # Optional npm cache directory 65 | 66 | .npm 67 | 68 | # Optional eslint cache 69 | 70 | .eslintcache 71 | 72 | # Optional stylelint cache 73 | 74 | .stylelintcache 75 | 76 | # Microbundle cache 77 | 78 | .rpt2_cache/ 79 | .rts2_cache_cjs/ 80 | .rts2_cache_es/ 81 | .rts2_cache_umd/ 82 | 83 | # Optional REPL history 84 | 85 | .node_repl_history 86 | 87 | # Output of 'npm pack' 88 | 89 | \*.tgz 90 | 91 | # Yarn Integrity file 92 | 93 | .yarn-integrity 94 | 95 | # dotenv environment variable files 96 | 97 | .env 98 | .env.development.local 99 | .env.test.local 100 | .env.production.local 101 | .env.local 102 | 103 | # parcel-bundler cache (https://parceljs.org/) 104 | 105 | .cache 106 | .parcel-cache 107 | 108 | # Next.js build output 109 | 110 | .next 111 | out 112 | 113 | # Nuxt.js build / generate output 114 | 115 | .nuxt 116 | dist 117 | 118 | # Gatsby files 119 | 120 | .cache/ 121 | 122 | # Comment in the public line in if your project uses Gatsby and not Next.js 123 | 124 | # https://nextjs.org/blog/next-9-1#public-directory-support 125 | 126 | # public 127 | 128 | # vuepress build output 129 | 130 | .vuepress/dist 131 | 132 | # vuepress v2.x temp and cache directory 133 | 134 | .temp 135 | .cache 136 | 137 | # Docusaurus cache and generated files 138 | 139 | .docusaurus 140 | 141 | # Serverless directories 142 | 143 | .serverless/ 144 | 145 | # FuseBox cache 146 | 147 | .fusebox/ 148 | 149 | # DynamoDB Local files 150 | 151 | .dynamodb/ 152 | 153 | # TernJS port file 154 | 155 | .tern-port 156 | 157 | # Stores VSCode versions used for testing VSCode extensions 158 | 159 | .vscode-test 160 | 161 | # yarn v2 162 | 163 | .yarn/cache 164 | .yarn/unplugged 165 | .yarn/build-state.yml 166 | .yarn/install-state.gz 167 | .pnp.\* 168 | 169 | # wrangler project 170 | 171 | .dev.vars 172 | .wrangler/ 173 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 140, 3 | "singleQuote": true, 4 | "semi": true, 5 | "useTabs": true 6 | } 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # config_to_sub 2 | 3 | 免费在 Cloudflare Workers / Papes 中,搭建一个节点订阅网站,提取 [ChromeGo/EdgeGo](ChromeGo/EdgeGo) 订阅链接的代理节点,转换为 **vless、vmess、trojan、ss、hysteria、hy2、tuic、naiveproxy**分享链接,提供给 NekoBox、v2rayN 等代理软件使用。 4 | 5 | 支持:xray(json)、singbox(json)、clash(yaml)、明文的v2ray订阅/base64编码的v2ray订阅 ==> base64编码的v2ray订阅(nekoray_v3.26)。 6 | 7 | 8 | 9 | ### 一、搭建教程 10 | 11 | - Cloudflare Workers 12 | 13 | 将 `_worker.js` 的代码复制到您的 `cloudflare worker` 应用程序中,替换掉原来的 `worker.js` 代码,部署。 14 | 15 | - Cloudflare Pages 16 | 17 | 将`_worker.js`的代码下载到本地电脑,文件名称要一样,不能修改,然后在文件外面套一层文件夹,也就是将 `_worker.js` 下载到一个空文件夹中,然后使用 git 工具,在这个文件夹的目录中执行 `git init` 命令(貌似不用做这步),最后将这个文件夹以zip格式压缩,或者直接以文件夹的形式上传到 `Cloudflare Pages` 中,完成部署。 18 | 19 | ### 二、遇到问题 20 | 21 | #### 1、出现 1102 页面错误 22 | 23 | 遇到1102错误,可以稍等一下(大概等几分钟到十多分钟,最长也就是几十分钟),再次访问应该能解决。 24 | 25 | 26 | 27 | #### 2、出现 FortiGuard Intrusion Prevention - Access Blocked 页面错误 28 | 29 | 如果绑定了自己的域名,而且使用代理访问,代理的IP地址又不干净的情况下,可能遇到下图的页面错误。 30 | 31 | 解决方法:更换其它干净的代理或不使用代理访问。 32 | 33 | 34 | 35 | #### 3、出现 Error: Too many subrequests 错误 36 | 37 | 原因是 `_worker.js` 中第 3220 行 `targetUrls` 的链接太多了,尽可能减少链接的数量(cloudflare免费用户:控制50条以内),重点剔除内容相同的链接。 38 | 39 | #### 4、获取到的节点太少 40 | 41 | 在剔除重复节点的情况下,获取到的节点数 **少于** 配置文件中的**实际节点数**,原因: 42 | - 1、出现没有检查到的代码 bug ,导致配置文件转换为分享的链接失败,亦或者不支持这个节点转换为分享链接。 43 | - 2、 因为`_worker.js` 第 3220 行 `targetUrls` 的链接太多了,出现 `Error: Too many subrequests` 错误,只处理到没有报 `Error: Too many subrequests` 错误之前的代理节点,导致获取到节点太少。 -------------------------------------------------------------------------------- /_worker.js: -------------------------------------------------------------------------------- 1 | // node_modules/js-yaml/dist/js-yaml.mjs 2 | function isNothing(subject) { 3 | return typeof subject === "undefined" || subject === null; 4 | } 5 | function isObject(subject) { 6 | return typeof subject === "object" && subject !== null; 7 | } 8 | function toArray(sequence) { 9 | if (Array.isArray(sequence)) 10 | return sequence; 11 | else if (isNothing(sequence)) 12 | return []; 13 | return [sequence]; 14 | } 15 | function extend(target, source) { 16 | var index, length, key, sourceKeys; 17 | if (source) { 18 | sourceKeys = Object.keys(source); 19 | for (index = 0, length = sourceKeys.length; index < length; index += 1) { 20 | key = sourceKeys[index]; 21 | target[key] = source[key]; 22 | } 23 | } 24 | return target; 25 | } 26 | function repeat(string, count) { 27 | var result = "", cycle; 28 | for (cycle = 0; cycle < count; cycle += 1) { 29 | result += string; 30 | } 31 | return result; 32 | } 33 | function isNegativeZero(number) { 34 | return number === 0 && Number.NEGATIVE_INFINITY === 1 / number; 35 | } 36 | var isNothing_1 = isNothing; 37 | var isObject_1 = isObject; 38 | var toArray_1 = toArray; 39 | var repeat_1 = repeat; 40 | var isNegativeZero_1 = isNegativeZero; 41 | var extend_1 = extend; 42 | var common = { 43 | isNothing: isNothing_1, 44 | isObject: isObject_1, 45 | toArray: toArray_1, 46 | repeat: repeat_1, 47 | isNegativeZero: isNegativeZero_1, 48 | extend: extend_1 49 | }; 50 | function formatError(exception2, compact) { 51 | var where = "", message = exception2.reason || "(unknown reason)"; 52 | if (!exception2.mark) 53 | return message; 54 | if (exception2.mark.name) { 55 | where += 'in "' + exception2.mark.name + '" '; 56 | } 57 | where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")"; 58 | if (!compact && exception2.mark.snippet) { 59 | where += "\n\n" + exception2.mark.snippet; 60 | } 61 | return message + " " + where; 62 | } 63 | function YAMLException$1(reason, mark) { 64 | Error.call(this); 65 | this.name = "YAMLException"; 66 | this.reason = reason; 67 | this.mark = mark; 68 | this.message = formatError(this, false); 69 | if (Error.captureStackTrace) { 70 | Error.captureStackTrace(this, this.constructor); 71 | } else { 72 | this.stack = new Error().stack || ""; 73 | } 74 | } 75 | YAMLException$1.prototype = Object.create(Error.prototype); 76 | YAMLException$1.prototype.constructor = YAMLException$1; 77 | YAMLException$1.prototype.toString = function toString(compact) { 78 | return this.name + ": " + formatError(this, compact); 79 | }; 80 | var exception = YAMLException$1; 81 | function getLine(buffer, lineStart, lineEnd, position, maxLineLength) { 82 | var head = ""; 83 | var tail = ""; 84 | var maxHalfLength = Math.floor(maxLineLength / 2) - 1; 85 | if (position - lineStart > maxHalfLength) { 86 | head = " ... "; 87 | lineStart = position - maxHalfLength + head.length; 88 | } 89 | if (lineEnd - position > maxHalfLength) { 90 | tail = " ..."; 91 | lineEnd = position + maxHalfLength - tail.length; 92 | } 93 | return { 94 | str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail, 95 | pos: position - lineStart + head.length 96 | // relative position 97 | }; 98 | } 99 | function padStart(string, max) { 100 | return common.repeat(" ", max - string.length) + string; 101 | } 102 | function makeSnippet(mark, options) { 103 | options = Object.create(options || null); 104 | if (!mark.buffer) 105 | return null; 106 | if (!options.maxLength) 107 | options.maxLength = 79; 108 | if (typeof options.indent !== "number") 109 | options.indent = 1; 110 | if (typeof options.linesBefore !== "number") 111 | options.linesBefore = 3; 112 | if (typeof options.linesAfter !== "number") 113 | options.linesAfter = 2; 114 | var re = /\r?\n|\r|\0/g; 115 | var lineStarts = [0]; 116 | var lineEnds = []; 117 | var match; 118 | var foundLineNo = -1; 119 | while (match = re.exec(mark.buffer)) { 120 | lineEnds.push(match.index); 121 | lineStarts.push(match.index + match[0].length); 122 | if (mark.position <= match.index && foundLineNo < 0) { 123 | foundLineNo = lineStarts.length - 2; 124 | } 125 | } 126 | if (foundLineNo < 0) 127 | foundLineNo = lineStarts.length - 1; 128 | var result = "", i, line; 129 | var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length; 130 | var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3); 131 | for (i = 1; i <= options.linesBefore; i++) { 132 | if (foundLineNo - i < 0) 133 | break; 134 | line = getLine( 135 | mark.buffer, 136 | lineStarts[foundLineNo - i], 137 | lineEnds[foundLineNo - i], 138 | mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), 139 | maxLineLength 140 | ); 141 | result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result; 142 | } 143 | line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength); 144 | result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n"; 145 | result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n"; 146 | for (i = 1; i <= options.linesAfter; i++) { 147 | if (foundLineNo + i >= lineEnds.length) 148 | break; 149 | line = getLine( 150 | mark.buffer, 151 | lineStarts[foundLineNo + i], 152 | lineEnds[foundLineNo + i], 153 | mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), 154 | maxLineLength 155 | ); 156 | result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n"; 157 | } 158 | return result.replace(/\n$/, ""); 159 | } 160 | var snippet = makeSnippet; 161 | var TYPE_CONSTRUCTOR_OPTIONS = [ 162 | "kind", 163 | "multi", 164 | "resolve", 165 | "construct", 166 | "instanceOf", 167 | "predicate", 168 | "represent", 169 | "representName", 170 | "defaultStyle", 171 | "styleAliases" 172 | ]; 173 | var YAML_NODE_KINDS = [ 174 | "scalar", 175 | "sequence", 176 | "mapping" 177 | ]; 178 | function compileStyleAliases(map2) { 179 | var result = {}; 180 | if (map2 !== null) { 181 | Object.keys(map2).forEach(function(style) { 182 | map2[style].forEach(function(alias) { 183 | result[String(alias)] = style; 184 | }); 185 | }); 186 | } 187 | return result; 188 | } 189 | function Type$1(tag, options) { 190 | options = options || {}; 191 | Object.keys(options).forEach(function(name) { 192 | if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { 193 | throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); 194 | } 195 | }); 196 | this.options = options; 197 | this.tag = tag; 198 | this.kind = options["kind"] || null; 199 | this.resolve = options["resolve"] || function() { 200 | return true; 201 | }; 202 | this.construct = options["construct"] || function(data) { 203 | return data; 204 | }; 205 | this.instanceOf = options["instanceOf"] || null; 206 | this.predicate = options["predicate"] || null; 207 | this.represent = options["represent"] || null; 208 | this.representName = options["representName"] || null; 209 | this.defaultStyle = options["defaultStyle"] || null; 210 | this.multi = options["multi"] || false; 211 | this.styleAliases = compileStyleAliases(options["styleAliases"] || null); 212 | if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { 213 | throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); 214 | } 215 | } 216 | var type = Type$1; 217 | function compileList(schema2, name) { 218 | var result = []; 219 | schema2[name].forEach(function(currentType) { 220 | var newIndex = result.length; 221 | result.forEach(function(previousType, previousIndex) { 222 | if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) { 223 | newIndex = previousIndex; 224 | } 225 | }); 226 | result[newIndex] = currentType; 227 | }); 228 | return result; 229 | } 230 | function compileMap() { 231 | var result = { 232 | scalar: {}, 233 | sequence: {}, 234 | mapping: {}, 235 | fallback: {}, 236 | multi: { 237 | scalar: [], 238 | sequence: [], 239 | mapping: [], 240 | fallback: [] 241 | } 242 | }, index, length; 243 | function collectType(type2) { 244 | if (type2.multi) { 245 | result.multi[type2.kind].push(type2); 246 | result.multi["fallback"].push(type2); 247 | } else { 248 | result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2; 249 | } 250 | } 251 | for (index = 0, length = arguments.length; index < length; index += 1) { 252 | arguments[index].forEach(collectType); 253 | } 254 | return result; 255 | } 256 | function Schema$1(definition) { 257 | return this.extend(definition); 258 | } 259 | Schema$1.prototype.extend = function extend2(definition) { 260 | var implicit = []; 261 | var explicit = []; 262 | if (definition instanceof type) { 263 | explicit.push(definition); 264 | } else if (Array.isArray(definition)) { 265 | explicit = explicit.concat(definition); 266 | } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) { 267 | if (definition.implicit) 268 | implicit = implicit.concat(definition.implicit); 269 | if (definition.explicit) 270 | explicit = explicit.concat(definition.explicit); 271 | } else { 272 | throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })"); 273 | } 274 | implicit.forEach(function(type$1) { 275 | if (!(type$1 instanceof type)) { 276 | throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object."); 277 | } 278 | if (type$1.loadKind && type$1.loadKind !== "scalar") { 279 | throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported."); 280 | } 281 | if (type$1.multi) { 282 | throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit."); 283 | } 284 | }); 285 | explicit.forEach(function(type$1) { 286 | if (!(type$1 instanceof type)) { 287 | throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object."); 288 | } 289 | }); 290 | var result = Object.create(Schema$1.prototype); 291 | result.implicit = (this.implicit || []).concat(implicit); 292 | result.explicit = (this.explicit || []).concat(explicit); 293 | result.compiledImplicit = compileList(result, "implicit"); 294 | result.compiledExplicit = compileList(result, "explicit"); 295 | result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit); 296 | return result; 297 | }; 298 | var schema = Schema$1; 299 | var str = new type("tag:yaml.org,2002:str", { 300 | kind: "scalar", 301 | construct: function(data) { 302 | return data !== null ? data : ""; 303 | } 304 | }); 305 | var seq = new type("tag:yaml.org,2002:seq", { 306 | kind: "sequence", 307 | construct: function(data) { 308 | return data !== null ? data : []; 309 | } 310 | }); 311 | var map = new type("tag:yaml.org,2002:map", { 312 | kind: "mapping", 313 | construct: function(data) { 314 | return data !== null ? data : {}; 315 | } 316 | }); 317 | var failsafe = new schema({ 318 | explicit: [ 319 | str, 320 | seq, 321 | map 322 | ] 323 | }); 324 | function resolveYamlNull(data) { 325 | if (data === null) 326 | return true; 327 | var max = data.length; 328 | return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL"); 329 | } 330 | function constructYamlNull() { 331 | return null; 332 | } 333 | function isNull(object) { 334 | return object === null; 335 | } 336 | var _null = new type("tag:yaml.org,2002:null", { 337 | kind: "scalar", 338 | resolve: resolveYamlNull, 339 | construct: constructYamlNull, 340 | predicate: isNull, 341 | represent: { 342 | canonical: function() { 343 | return "~"; 344 | }, 345 | lowercase: function() { 346 | return "null"; 347 | }, 348 | uppercase: function() { 349 | return "NULL"; 350 | }, 351 | camelcase: function() { 352 | return "Null"; 353 | }, 354 | empty: function() { 355 | return ""; 356 | } 357 | }, 358 | defaultStyle: "lowercase" 359 | }); 360 | function resolveYamlBoolean(data) { 361 | if (data === null) 362 | return false; 363 | var max = data.length; 364 | return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE"); 365 | } 366 | function constructYamlBoolean(data) { 367 | return data === "true" || data === "True" || data === "TRUE"; 368 | } 369 | function isBoolean(object) { 370 | return Object.prototype.toString.call(object) === "[object Boolean]"; 371 | } 372 | var bool = new type("tag:yaml.org,2002:bool", { 373 | kind: "scalar", 374 | resolve: resolveYamlBoolean, 375 | construct: constructYamlBoolean, 376 | predicate: isBoolean, 377 | represent: { 378 | lowercase: function(object) { 379 | return object ? "true" : "false"; 380 | }, 381 | uppercase: function(object) { 382 | return object ? "TRUE" : "FALSE"; 383 | }, 384 | camelcase: function(object) { 385 | return object ? "True" : "False"; 386 | } 387 | }, 388 | defaultStyle: "lowercase" 389 | }); 390 | function isHexCode(c) { 391 | return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102; 392 | } 393 | function isOctCode(c) { 394 | return 48 <= c && c <= 55; 395 | } 396 | function isDecCode(c) { 397 | return 48 <= c && c <= 57; 398 | } 399 | function resolveYamlInteger(data) { 400 | if (data === null) 401 | return false; 402 | var max = data.length, index = 0, hasDigits = false, ch; 403 | if (!max) 404 | return false; 405 | ch = data[index]; 406 | if (ch === "-" || ch === "+") { 407 | ch = data[++index]; 408 | } 409 | if (ch === "0") { 410 | if (index + 1 === max) 411 | return true; 412 | ch = data[++index]; 413 | if (ch === "b") { 414 | index++; 415 | for (; index < max; index++) { 416 | ch = data[index]; 417 | if (ch === "_") 418 | continue; 419 | if (ch !== "0" && ch !== "1") 420 | return false; 421 | hasDigits = true; 422 | } 423 | return hasDigits && ch !== "_"; 424 | } 425 | if (ch === "x") { 426 | index++; 427 | for (; index < max; index++) { 428 | ch = data[index]; 429 | if (ch === "_") 430 | continue; 431 | if (!isHexCode(data.charCodeAt(index))) 432 | return false; 433 | hasDigits = true; 434 | } 435 | return hasDigits && ch !== "_"; 436 | } 437 | if (ch === "o") { 438 | index++; 439 | for (; index < max; index++) { 440 | ch = data[index]; 441 | if (ch === "_") 442 | continue; 443 | if (!isOctCode(data.charCodeAt(index))) 444 | return false; 445 | hasDigits = true; 446 | } 447 | return hasDigits && ch !== "_"; 448 | } 449 | } 450 | if (ch === "_") 451 | return false; 452 | for (; index < max; index++) { 453 | ch = data[index]; 454 | if (ch === "_") 455 | continue; 456 | if (!isDecCode(data.charCodeAt(index))) { 457 | return false; 458 | } 459 | hasDigits = true; 460 | } 461 | if (!hasDigits || ch === "_") 462 | return false; 463 | return true; 464 | } 465 | function constructYamlInteger(data) { 466 | var value = data, sign = 1, ch; 467 | if (value.indexOf("_") !== -1) { 468 | value = value.replace(/_/g, ""); 469 | } 470 | ch = value[0]; 471 | if (ch === "-" || ch === "+") { 472 | if (ch === "-") 473 | sign = -1; 474 | value = value.slice(1); 475 | ch = value[0]; 476 | } 477 | if (value === "0") 478 | return 0; 479 | if (ch === "0") { 480 | if (value[1] === "b") 481 | return sign * parseInt(value.slice(2), 2); 482 | if (value[1] === "x") 483 | return sign * parseInt(value.slice(2), 16); 484 | if (value[1] === "o") 485 | return sign * parseInt(value.slice(2), 8); 486 | } 487 | return sign * parseInt(value, 10); 488 | } 489 | function isInteger(object) { 490 | return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object)); 491 | } 492 | var int = new type("tag:yaml.org,2002:int", { 493 | kind: "scalar", 494 | resolve: resolveYamlInteger, 495 | construct: constructYamlInteger, 496 | predicate: isInteger, 497 | represent: { 498 | binary: function(obj) { 499 | return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1); 500 | }, 501 | octal: function(obj) { 502 | return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1); 503 | }, 504 | decimal: function(obj) { 505 | return obj.toString(10); 506 | }, 507 | /* eslint-disable max-len */ 508 | hexadecimal: function(obj) { 509 | return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1); 510 | } 511 | }, 512 | defaultStyle: "decimal", 513 | styleAliases: { 514 | binary: [2, "bin"], 515 | octal: [8, "oct"], 516 | decimal: [10, "dec"], 517 | hexadecimal: [16, "hex"] 518 | } 519 | }); 520 | var YAML_FLOAT_PATTERN = new RegExp( 521 | // 2.5e4, 2.5 and integers 522 | "^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$" 523 | ); 524 | function resolveYamlFloat(data) { 525 | if (data === null) 526 | return false; 527 | if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_` 528 | // Probably should update regexp & check speed 529 | data[data.length - 1] === "_") { 530 | return false; 531 | } 532 | return true; 533 | } 534 | function constructYamlFloat(data) { 535 | var value, sign; 536 | value = data.replace(/_/g, "").toLowerCase(); 537 | sign = value[0] === "-" ? -1 : 1; 538 | if ("+-".indexOf(value[0]) >= 0) { 539 | value = value.slice(1); 540 | } 541 | if (value === ".inf") { 542 | return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; 543 | } else if (value === ".nan") { 544 | return NaN; 545 | } 546 | return sign * parseFloat(value, 10); 547 | } 548 | var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; 549 | function representYamlFloat(object, style) { 550 | var res; 551 | if (isNaN(object)) { 552 | switch (style) { 553 | case "lowercase": 554 | return ".nan"; 555 | case "uppercase": 556 | return ".NAN"; 557 | case "camelcase": 558 | return ".NaN"; 559 | } 560 | } else if (Number.POSITIVE_INFINITY === object) { 561 | switch (style) { 562 | case "lowercase": 563 | return ".inf"; 564 | case "uppercase": 565 | return ".INF"; 566 | case "camelcase": 567 | return ".Inf"; 568 | } 569 | } else if (Number.NEGATIVE_INFINITY === object) { 570 | switch (style) { 571 | case "lowercase": 572 | return "-.inf"; 573 | case "uppercase": 574 | return "-.INF"; 575 | case "camelcase": 576 | return "-.Inf"; 577 | } 578 | } else if (common.isNegativeZero(object)) { 579 | return "-0.0"; 580 | } 581 | res = object.toString(10); 582 | return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res; 583 | } 584 | function isFloat(object) { 585 | return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object)); 586 | } 587 | var float = new type("tag:yaml.org,2002:float", { 588 | kind: "scalar", 589 | resolve: resolveYamlFloat, 590 | construct: constructYamlFloat, 591 | predicate: isFloat, 592 | represent: representYamlFloat, 593 | defaultStyle: "lowercase" 594 | }); 595 | var json = failsafe.extend({ 596 | implicit: [ 597 | _null, 598 | bool, 599 | int, 600 | float 601 | ] 602 | }); 603 | var core = json; 604 | var YAML_DATE_REGEXP = new RegExp( 605 | "^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$" 606 | ); 607 | var YAML_TIMESTAMP_REGEXP = new RegExp( 608 | "^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$" 609 | ); 610 | function resolveYamlTimestamp(data) { 611 | if (data === null) 612 | return false; 613 | if (YAML_DATE_REGEXP.exec(data) !== null) 614 | return true; 615 | if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) 616 | return true; 617 | return false; 618 | } 619 | function constructYamlTimestamp(data) { 620 | var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date; 621 | match = YAML_DATE_REGEXP.exec(data); 622 | if (match === null) 623 | match = YAML_TIMESTAMP_REGEXP.exec(data); 624 | if (match === null) 625 | throw new Error("Date resolve error"); 626 | year = +match[1]; 627 | month = +match[2] - 1; 628 | day = +match[3]; 629 | if (!match[4]) { 630 | return new Date(Date.UTC(year, month, day)); 631 | } 632 | hour = +match[4]; 633 | minute = +match[5]; 634 | second = +match[6]; 635 | if (match[7]) { 636 | fraction = match[7].slice(0, 3); 637 | while (fraction.length < 3) { 638 | fraction += "0"; 639 | } 640 | fraction = +fraction; 641 | } 642 | if (match[9]) { 643 | tz_hour = +match[10]; 644 | tz_minute = +(match[11] || 0); 645 | delta = (tz_hour * 60 + tz_minute) * 6e4; 646 | if (match[9] === "-") 647 | delta = -delta; 648 | } 649 | date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); 650 | if (delta) 651 | date.setTime(date.getTime() - delta); 652 | return date; 653 | } 654 | function representYamlTimestamp(object) { 655 | return object.toISOString(); 656 | } 657 | var timestamp = new type("tag:yaml.org,2002:timestamp", { 658 | kind: "scalar", 659 | resolve: resolveYamlTimestamp, 660 | construct: constructYamlTimestamp, 661 | instanceOf: Date, 662 | represent: representYamlTimestamp 663 | }); 664 | function resolveYamlMerge(data) { 665 | return data === "<<" || data === null; 666 | } 667 | var merge = new type("tag:yaml.org,2002:merge", { 668 | kind: "scalar", 669 | resolve: resolveYamlMerge 670 | }); 671 | var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r"; 672 | function resolveYamlBinary(data) { 673 | if (data === null) 674 | return false; 675 | var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP; 676 | for (idx = 0; idx < max; idx++) { 677 | code = map2.indexOf(data.charAt(idx)); 678 | if (code > 64) 679 | continue; 680 | if (code < 0) 681 | return false; 682 | bitlen += 6; 683 | } 684 | return bitlen % 8 === 0; 685 | } 686 | function constructYamlBinary(data) { 687 | var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = []; 688 | for (idx = 0; idx < max; idx++) { 689 | if (idx % 4 === 0 && idx) { 690 | result.push(bits >> 16 & 255); 691 | result.push(bits >> 8 & 255); 692 | result.push(bits & 255); 693 | } 694 | bits = bits << 6 | map2.indexOf(input.charAt(idx)); 695 | } 696 | tailbits = max % 4 * 6; 697 | if (tailbits === 0) { 698 | result.push(bits >> 16 & 255); 699 | result.push(bits >> 8 & 255); 700 | result.push(bits & 255); 701 | } else if (tailbits === 18) { 702 | result.push(bits >> 10 & 255); 703 | result.push(bits >> 2 & 255); 704 | } else if (tailbits === 12) { 705 | result.push(bits >> 4 & 255); 706 | } 707 | return new Uint8Array(result); 708 | } 709 | function representYamlBinary(object) { 710 | var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP; 711 | for (idx = 0; idx < max; idx++) { 712 | if (idx % 3 === 0 && idx) { 713 | result += map2[bits >> 18 & 63]; 714 | result += map2[bits >> 12 & 63]; 715 | result += map2[bits >> 6 & 63]; 716 | result += map2[bits & 63]; 717 | } 718 | bits = (bits << 8) + object[idx]; 719 | } 720 | tail = max % 3; 721 | if (tail === 0) { 722 | result += map2[bits >> 18 & 63]; 723 | result += map2[bits >> 12 & 63]; 724 | result += map2[bits >> 6 & 63]; 725 | result += map2[bits & 63]; 726 | } else if (tail === 2) { 727 | result += map2[bits >> 10 & 63]; 728 | result += map2[bits >> 4 & 63]; 729 | result += map2[bits << 2 & 63]; 730 | result += map2[64]; 731 | } else if (tail === 1) { 732 | result += map2[bits >> 2 & 63]; 733 | result += map2[bits << 4 & 63]; 734 | result += map2[64]; 735 | result += map2[64]; 736 | } 737 | return result; 738 | } 739 | function isBinary(obj) { 740 | return Object.prototype.toString.call(obj) === "[object Uint8Array]"; 741 | } 742 | var binary = new type("tag:yaml.org,2002:binary", { 743 | kind: "scalar", 744 | resolve: resolveYamlBinary, 745 | construct: constructYamlBinary, 746 | predicate: isBinary, 747 | represent: representYamlBinary 748 | }); 749 | var _hasOwnProperty$3 = Object.prototype.hasOwnProperty; 750 | var _toString$2 = Object.prototype.toString; 751 | function resolveYamlOmap(data) { 752 | if (data === null) 753 | return true; 754 | var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data; 755 | for (index = 0, length = object.length; index < length; index += 1) { 756 | pair = object[index]; 757 | pairHasKey = false; 758 | if (_toString$2.call(pair) !== "[object Object]") 759 | return false; 760 | for (pairKey in pair) { 761 | if (_hasOwnProperty$3.call(pair, pairKey)) { 762 | if (!pairHasKey) 763 | pairHasKey = true; 764 | else 765 | return false; 766 | } 767 | } 768 | if (!pairHasKey) 769 | return false; 770 | if (objectKeys.indexOf(pairKey) === -1) 771 | objectKeys.push(pairKey); 772 | else 773 | return false; 774 | } 775 | return true; 776 | } 777 | function constructYamlOmap(data) { 778 | return data !== null ? data : []; 779 | } 780 | var omap = new type("tag:yaml.org,2002:omap", { 781 | kind: "sequence", 782 | resolve: resolveYamlOmap, 783 | construct: constructYamlOmap 784 | }); 785 | var _toString$1 = Object.prototype.toString; 786 | function resolveYamlPairs(data) { 787 | if (data === null) 788 | return true; 789 | var index, length, pair, keys, result, object = data; 790 | result = new Array(object.length); 791 | for (index = 0, length = object.length; index < length; index += 1) { 792 | pair = object[index]; 793 | if (_toString$1.call(pair) !== "[object Object]") 794 | return false; 795 | keys = Object.keys(pair); 796 | if (keys.length !== 1) 797 | return false; 798 | result[index] = [keys[0], pair[keys[0]]]; 799 | } 800 | return true; 801 | } 802 | function constructYamlPairs(data) { 803 | if (data === null) 804 | return []; 805 | var index, length, pair, keys, result, object = data; 806 | result = new Array(object.length); 807 | for (index = 0, length = object.length; index < length; index += 1) { 808 | pair = object[index]; 809 | keys = Object.keys(pair); 810 | result[index] = [keys[0], pair[keys[0]]]; 811 | } 812 | return result; 813 | } 814 | var pairs = new type("tag:yaml.org,2002:pairs", { 815 | kind: "sequence", 816 | resolve: resolveYamlPairs, 817 | construct: constructYamlPairs 818 | }); 819 | var _hasOwnProperty$2 = Object.prototype.hasOwnProperty; 820 | function resolveYamlSet(data) { 821 | if (data === null) 822 | return true; 823 | var key, object = data; 824 | for (key in object) { 825 | if (_hasOwnProperty$2.call(object, key)) { 826 | if (object[key] !== null) 827 | return false; 828 | } 829 | } 830 | return true; 831 | } 832 | function constructYamlSet(data) { 833 | return data !== null ? data : {}; 834 | } 835 | var set = new type("tag:yaml.org,2002:set", { 836 | kind: "mapping", 837 | resolve: resolveYamlSet, 838 | construct: constructYamlSet 839 | }); 840 | var _default = core.extend({ 841 | implicit: [ 842 | timestamp, 843 | merge 844 | ], 845 | explicit: [ 846 | binary, 847 | omap, 848 | pairs, 849 | set 850 | ] 851 | }); 852 | var _hasOwnProperty$1 = Object.prototype.hasOwnProperty; 853 | var CONTEXT_FLOW_IN = 1; 854 | var CONTEXT_FLOW_OUT = 2; 855 | var CONTEXT_BLOCK_IN = 3; 856 | var CONTEXT_BLOCK_OUT = 4; 857 | var CHOMPING_CLIP = 1; 858 | var CHOMPING_STRIP = 2; 859 | var CHOMPING_KEEP = 3; 860 | var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; 861 | var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; 862 | var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; 863 | var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; 864 | var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; 865 | function _class(obj) { 866 | return Object.prototype.toString.call(obj); 867 | } 868 | function is_EOL(c) { 869 | return c === 10 || c === 13; 870 | } 871 | function is_WHITE_SPACE(c) { 872 | return c === 9 || c === 32; 873 | } 874 | function is_WS_OR_EOL(c) { 875 | return c === 9 || c === 32 || c === 10 || c === 13; 876 | } 877 | function is_FLOW_INDICATOR(c) { 878 | return c === 44 || c === 91 || c === 93 || c === 123 || c === 125; 879 | } 880 | function fromHexCode(c) { 881 | var lc; 882 | if (48 <= c && c <= 57) { 883 | return c - 48; 884 | } 885 | lc = c | 32; 886 | if (97 <= lc && lc <= 102) { 887 | return lc - 97 + 10; 888 | } 889 | return -1; 890 | } 891 | function escapedHexLen(c) { 892 | if (c === 120) { 893 | return 2; 894 | } 895 | if (c === 117) { 896 | return 4; 897 | } 898 | if (c === 85) { 899 | return 8; 900 | } 901 | return 0; 902 | } 903 | function fromDecimalCode(c) { 904 | if (48 <= c && c <= 57) { 905 | return c - 48; 906 | } 907 | return -1; 908 | } 909 | function simpleEscapeSequence(c) { 910 | return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : ""; 911 | } 912 | function charFromCodepoint(c) { 913 | if (c <= 65535) { 914 | return String.fromCharCode(c); 915 | } 916 | return String.fromCharCode( 917 | (c - 65536 >> 10) + 55296, 918 | (c - 65536 & 1023) + 56320 919 | ); 920 | } 921 | var simpleEscapeCheck = new Array(256); 922 | var simpleEscapeMap = new Array(256); 923 | for (i = 0; i < 256; i++) { 924 | simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; 925 | simpleEscapeMap[i] = simpleEscapeSequence(i); 926 | } 927 | var i; 928 | function State$1(input, options) { 929 | this.input = input; 930 | this.filename = options["filename"] || null; 931 | this.schema = options["schema"] || _default; 932 | this.onWarning = options["onWarning"] || null; 933 | this.legacy = options["legacy"] || false; 934 | this.json = options["json"] || false; 935 | this.listener = options["listener"] || null; 936 | this.implicitTypes = this.schema.compiledImplicit; 937 | this.typeMap = this.schema.compiledTypeMap; 938 | this.length = input.length; 939 | this.position = 0; 940 | this.line = 0; 941 | this.lineStart = 0; 942 | this.lineIndent = 0; 943 | this.firstTabInLine = -1; 944 | this.documents = []; 945 | } 946 | function generateError(state, message) { 947 | var mark = { 948 | name: state.filename, 949 | buffer: state.input.slice(0, -1), 950 | // omit trailing \0 951 | position: state.position, 952 | line: state.line, 953 | column: state.position - state.lineStart 954 | }; 955 | mark.snippet = snippet(mark); 956 | return new exception(message, mark); 957 | } 958 | function throwError(state, message) { 959 | throw generateError(state, message); 960 | } 961 | function throwWarning(state, message) { 962 | if (state.onWarning) { 963 | state.onWarning.call(null, generateError(state, message)); 964 | } 965 | } 966 | var directiveHandlers = { 967 | YAML: function handleYamlDirective(state, name, args) { 968 | var match, major, minor; 969 | if (state.version !== null) { 970 | throwError(state, "duplication of %YAML directive"); 971 | } 972 | if (args.length !== 1) { 973 | throwError(state, "YAML directive accepts exactly one argument"); 974 | } 975 | match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); 976 | if (match === null) { 977 | throwError(state, "ill-formed argument of the YAML directive"); 978 | } 979 | major = parseInt(match[1], 10); 980 | minor = parseInt(match[2], 10); 981 | if (major !== 1) { 982 | throwError(state, "unacceptable YAML version of the document"); 983 | } 984 | state.version = args[0]; 985 | state.checkLineBreaks = minor < 2; 986 | if (minor !== 1 && minor !== 2) { 987 | throwWarning(state, "unsupported YAML version of the document"); 988 | } 989 | }, 990 | TAG: function handleTagDirective(state, name, args) { 991 | var handle, prefix; 992 | if (args.length !== 2) { 993 | throwError(state, "TAG directive accepts exactly two arguments"); 994 | } 995 | handle = args[0]; 996 | prefix = args[1]; 997 | if (!PATTERN_TAG_HANDLE.test(handle)) { 998 | throwError(state, "ill-formed tag handle (first argument) of the TAG directive"); 999 | } 1000 | if (_hasOwnProperty$1.call(state.tagMap, handle)) { 1001 | throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); 1002 | } 1003 | if (!PATTERN_TAG_URI.test(prefix)) { 1004 | throwError(state, "ill-formed tag prefix (second argument) of the TAG directive"); 1005 | } 1006 | try { 1007 | prefix = decodeURIComponent(prefix); 1008 | } catch (err) { 1009 | throwError(state, "tag prefix is malformed: " + prefix); 1010 | } 1011 | state.tagMap[handle] = prefix; 1012 | } 1013 | }; 1014 | function captureSegment(state, start, end, checkJson) { 1015 | var _position, _length, _character, _result; 1016 | if (start < end) { 1017 | _result = state.input.slice(start, end); 1018 | if (checkJson) { 1019 | for (_position = 0, _length = _result.length; _position < _length; _position += 1) { 1020 | _character = _result.charCodeAt(_position); 1021 | if (!(_character === 9 || 32 <= _character && _character <= 1114111)) { 1022 | throwError(state, "expected valid JSON character"); 1023 | } 1024 | } 1025 | } else if (PATTERN_NON_PRINTABLE.test(_result)) { 1026 | throwError(state, "the stream contains non-printable characters"); 1027 | } 1028 | state.result += _result; 1029 | } 1030 | } 1031 | function mergeMappings(state, destination, source, overridableKeys) { 1032 | var sourceKeys, key, index, quantity; 1033 | if (!common.isObject(source)) { 1034 | throwError(state, "cannot merge mappings; the provided source object is unacceptable"); 1035 | } 1036 | sourceKeys = Object.keys(source); 1037 | for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { 1038 | key = sourceKeys[index]; 1039 | if (!_hasOwnProperty$1.call(destination, key)) { 1040 | destination[key] = source[key]; 1041 | overridableKeys[key] = true; 1042 | } 1043 | } 1044 | } 1045 | function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) { 1046 | var index, quantity; 1047 | if (Array.isArray(keyNode)) { 1048 | keyNode = Array.prototype.slice.call(keyNode); 1049 | for (index = 0, quantity = keyNode.length; index < quantity; index += 1) { 1050 | if (Array.isArray(keyNode[index])) { 1051 | throwError(state, "nested arrays are not supported inside keys"); 1052 | } 1053 | if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") { 1054 | keyNode[index] = "[object Object]"; 1055 | } 1056 | } 1057 | } 1058 | if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") { 1059 | keyNode = "[object Object]"; 1060 | } 1061 | keyNode = String(keyNode); 1062 | if (_result === null) { 1063 | _result = {}; 1064 | } 1065 | if (keyTag === "tag:yaml.org,2002:merge") { 1066 | if (Array.isArray(valueNode)) { 1067 | for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { 1068 | mergeMappings(state, _result, valueNode[index], overridableKeys); 1069 | } 1070 | } else { 1071 | mergeMappings(state, _result, valueNode, overridableKeys); 1072 | } 1073 | } else { 1074 | if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) { 1075 | state.line = startLine || state.line; 1076 | state.lineStart = startLineStart || state.lineStart; 1077 | state.position = startPos || state.position; 1078 | throwError(state, "duplicated mapping key"); 1079 | } 1080 | if (keyNode === "__proto__") { 1081 | Object.defineProperty(_result, keyNode, { 1082 | configurable: true, 1083 | enumerable: true, 1084 | writable: true, 1085 | value: valueNode 1086 | }); 1087 | } else { 1088 | _result[keyNode] = valueNode; 1089 | } 1090 | delete overridableKeys[keyNode]; 1091 | } 1092 | return _result; 1093 | } 1094 | function readLineBreak(state) { 1095 | var ch; 1096 | ch = state.input.charCodeAt(state.position); 1097 | if (ch === 10) { 1098 | state.position++; 1099 | } else if (ch === 13) { 1100 | state.position++; 1101 | if (state.input.charCodeAt(state.position) === 10) { 1102 | state.position++; 1103 | } 1104 | } else { 1105 | throwError(state, "a line break is expected"); 1106 | } 1107 | state.line += 1; 1108 | state.lineStart = state.position; 1109 | state.firstTabInLine = -1; 1110 | } 1111 | function skipSeparationSpace(state, allowComments, checkIndent) { 1112 | var lineBreaks = 0, ch = state.input.charCodeAt(state.position); 1113 | while (ch !== 0) { 1114 | while (is_WHITE_SPACE(ch)) { 1115 | if (ch === 9 && state.firstTabInLine === -1) { 1116 | state.firstTabInLine = state.position; 1117 | } 1118 | ch = state.input.charCodeAt(++state.position); 1119 | } 1120 | if (allowComments && ch === 35) { 1121 | do { 1122 | ch = state.input.charCodeAt(++state.position); 1123 | } while (ch !== 10 && ch !== 13 && ch !== 0); 1124 | } 1125 | if (is_EOL(ch)) { 1126 | readLineBreak(state); 1127 | ch = state.input.charCodeAt(state.position); 1128 | lineBreaks++; 1129 | state.lineIndent = 0; 1130 | while (ch === 32) { 1131 | state.lineIndent++; 1132 | ch = state.input.charCodeAt(++state.position); 1133 | } 1134 | } else { 1135 | break; 1136 | } 1137 | } 1138 | if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { 1139 | throwWarning(state, "deficient indentation"); 1140 | } 1141 | return lineBreaks; 1142 | } 1143 | function testDocumentSeparator(state) { 1144 | var _position = state.position, ch; 1145 | ch = state.input.charCodeAt(_position); 1146 | if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) { 1147 | _position += 3; 1148 | ch = state.input.charCodeAt(_position); 1149 | if (ch === 0 || is_WS_OR_EOL(ch)) { 1150 | return true; 1151 | } 1152 | } 1153 | return false; 1154 | } 1155 | function writeFoldedLines(state, count) { 1156 | if (count === 1) { 1157 | state.result += " "; 1158 | } else if (count > 1) { 1159 | state.result += common.repeat("\n", count - 1); 1160 | } 1161 | } 1162 | function readPlainScalar(state, nodeIndent, withinFlowCollection) { 1163 | var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch; 1164 | ch = state.input.charCodeAt(state.position); 1165 | if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) { 1166 | return false; 1167 | } 1168 | if (ch === 63 || ch === 45) { 1169 | following = state.input.charCodeAt(state.position + 1); 1170 | if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) { 1171 | return false; 1172 | } 1173 | } 1174 | state.kind = "scalar"; 1175 | state.result = ""; 1176 | captureStart = captureEnd = state.position; 1177 | hasPendingContent = false; 1178 | while (ch !== 0) { 1179 | if (ch === 58) { 1180 | following = state.input.charCodeAt(state.position + 1); 1181 | if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) { 1182 | break; 1183 | } 1184 | } else if (ch === 35) { 1185 | preceding = state.input.charCodeAt(state.position - 1); 1186 | if (is_WS_OR_EOL(preceding)) { 1187 | break; 1188 | } 1189 | } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) { 1190 | break; 1191 | } else if (is_EOL(ch)) { 1192 | _line = state.line; 1193 | _lineStart = state.lineStart; 1194 | _lineIndent = state.lineIndent; 1195 | skipSeparationSpace(state, false, -1); 1196 | if (state.lineIndent >= nodeIndent) { 1197 | hasPendingContent = true; 1198 | ch = state.input.charCodeAt(state.position); 1199 | continue; 1200 | } else { 1201 | state.position = captureEnd; 1202 | state.line = _line; 1203 | state.lineStart = _lineStart; 1204 | state.lineIndent = _lineIndent; 1205 | break; 1206 | } 1207 | } 1208 | if (hasPendingContent) { 1209 | captureSegment(state, captureStart, captureEnd, false); 1210 | writeFoldedLines(state, state.line - _line); 1211 | captureStart = captureEnd = state.position; 1212 | hasPendingContent = false; 1213 | } 1214 | if (!is_WHITE_SPACE(ch)) { 1215 | captureEnd = state.position + 1; 1216 | } 1217 | ch = state.input.charCodeAt(++state.position); 1218 | } 1219 | captureSegment(state, captureStart, captureEnd, false); 1220 | if (state.result) { 1221 | return true; 1222 | } 1223 | state.kind = _kind; 1224 | state.result = _result; 1225 | return false; 1226 | } 1227 | function readSingleQuotedScalar(state, nodeIndent) { 1228 | var ch, captureStart, captureEnd; 1229 | ch = state.input.charCodeAt(state.position); 1230 | if (ch !== 39) { 1231 | return false; 1232 | } 1233 | state.kind = "scalar"; 1234 | state.result = ""; 1235 | state.position++; 1236 | captureStart = captureEnd = state.position; 1237 | while ((ch = state.input.charCodeAt(state.position)) !== 0) { 1238 | if (ch === 39) { 1239 | captureSegment(state, captureStart, state.position, true); 1240 | ch = state.input.charCodeAt(++state.position); 1241 | if (ch === 39) { 1242 | captureStart = state.position; 1243 | state.position++; 1244 | captureEnd = state.position; 1245 | } else { 1246 | return true; 1247 | } 1248 | } else if (is_EOL(ch)) { 1249 | captureSegment(state, captureStart, captureEnd, true); 1250 | writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); 1251 | captureStart = captureEnd = state.position; 1252 | } else if (state.position === state.lineStart && testDocumentSeparator(state)) { 1253 | throwError(state, "unexpected end of the document within a single quoted scalar"); 1254 | } else { 1255 | state.position++; 1256 | captureEnd = state.position; 1257 | } 1258 | } 1259 | throwError(state, "unexpected end of the stream within a single quoted scalar"); 1260 | } 1261 | function readDoubleQuotedScalar(state, nodeIndent) { 1262 | var captureStart, captureEnd, hexLength, hexResult, tmp, ch; 1263 | ch = state.input.charCodeAt(state.position); 1264 | if (ch !== 34) { 1265 | return false; 1266 | } 1267 | state.kind = "scalar"; 1268 | state.result = ""; 1269 | state.position++; 1270 | captureStart = captureEnd = state.position; 1271 | while ((ch = state.input.charCodeAt(state.position)) !== 0) { 1272 | if (ch === 34) { 1273 | captureSegment(state, captureStart, state.position, true); 1274 | state.position++; 1275 | return true; 1276 | } else if (ch === 92) { 1277 | captureSegment(state, captureStart, state.position, true); 1278 | ch = state.input.charCodeAt(++state.position); 1279 | if (is_EOL(ch)) { 1280 | skipSeparationSpace(state, false, nodeIndent); 1281 | } else if (ch < 256 && simpleEscapeCheck[ch]) { 1282 | state.result += simpleEscapeMap[ch]; 1283 | state.position++; 1284 | } else if ((tmp = escapedHexLen(ch)) > 0) { 1285 | hexLength = tmp; 1286 | hexResult = 0; 1287 | for (; hexLength > 0; hexLength--) { 1288 | ch = state.input.charCodeAt(++state.position); 1289 | if ((tmp = fromHexCode(ch)) >= 0) { 1290 | hexResult = (hexResult << 4) + tmp; 1291 | } else { 1292 | throwError(state, "expected hexadecimal character"); 1293 | } 1294 | } 1295 | state.result += charFromCodepoint(hexResult); 1296 | state.position++; 1297 | } else { 1298 | throwError(state, "unknown escape sequence"); 1299 | } 1300 | captureStart = captureEnd = state.position; 1301 | } else if (is_EOL(ch)) { 1302 | captureSegment(state, captureStart, captureEnd, true); 1303 | writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); 1304 | captureStart = captureEnd = state.position; 1305 | } else if (state.position === state.lineStart && testDocumentSeparator(state)) { 1306 | throwError(state, "unexpected end of the document within a double quoted scalar"); 1307 | } else { 1308 | state.position++; 1309 | captureEnd = state.position; 1310 | } 1311 | } 1312 | throwError(state, "unexpected end of the stream within a double quoted scalar"); 1313 | } 1314 | function readFlowCollection(state, nodeIndent) { 1315 | var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = /* @__PURE__ */ Object.create(null), keyNode, keyTag, valueNode, ch; 1316 | ch = state.input.charCodeAt(state.position); 1317 | if (ch === 91) { 1318 | terminator = 93; 1319 | isMapping = false; 1320 | _result = []; 1321 | } else if (ch === 123) { 1322 | terminator = 125; 1323 | isMapping = true; 1324 | _result = {}; 1325 | } else { 1326 | return false; 1327 | } 1328 | if (state.anchor !== null) { 1329 | state.anchorMap[state.anchor] = _result; 1330 | } 1331 | ch = state.input.charCodeAt(++state.position); 1332 | while (ch !== 0) { 1333 | skipSeparationSpace(state, true, nodeIndent); 1334 | ch = state.input.charCodeAt(state.position); 1335 | if (ch === terminator) { 1336 | state.position++; 1337 | state.tag = _tag; 1338 | state.anchor = _anchor; 1339 | state.kind = isMapping ? "mapping" : "sequence"; 1340 | state.result = _result; 1341 | return true; 1342 | } else if (!readNext) { 1343 | throwError(state, "missed comma between flow collection entries"); 1344 | } else if (ch === 44) { 1345 | throwError(state, "expected the node content, but found ','"); 1346 | } 1347 | keyTag = keyNode = valueNode = null; 1348 | isPair = isExplicitPair = false; 1349 | if (ch === 63) { 1350 | following = state.input.charCodeAt(state.position + 1); 1351 | if (is_WS_OR_EOL(following)) { 1352 | isPair = isExplicitPair = true; 1353 | state.position++; 1354 | skipSeparationSpace(state, true, nodeIndent); 1355 | } 1356 | } 1357 | _line = state.line; 1358 | _lineStart = state.lineStart; 1359 | _pos = state.position; 1360 | composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); 1361 | keyTag = state.tag; 1362 | keyNode = state.result; 1363 | skipSeparationSpace(state, true, nodeIndent); 1364 | ch = state.input.charCodeAt(state.position); 1365 | if ((isExplicitPair || state.line === _line) && ch === 58) { 1366 | isPair = true; 1367 | ch = state.input.charCodeAt(++state.position); 1368 | skipSeparationSpace(state, true, nodeIndent); 1369 | composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); 1370 | valueNode = state.result; 1371 | } 1372 | if (isMapping) { 1373 | storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos); 1374 | } else if (isPair) { 1375 | _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)); 1376 | } else { 1377 | _result.push(keyNode); 1378 | } 1379 | skipSeparationSpace(state, true, nodeIndent); 1380 | ch = state.input.charCodeAt(state.position); 1381 | if (ch === 44) { 1382 | readNext = true; 1383 | ch = state.input.charCodeAt(++state.position); 1384 | } else { 1385 | readNext = false; 1386 | } 1387 | } 1388 | throwError(state, "unexpected end of the stream within a flow collection"); 1389 | } 1390 | function readBlockScalar(state, nodeIndent) { 1391 | var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch; 1392 | ch = state.input.charCodeAt(state.position); 1393 | if (ch === 124) { 1394 | folding = false; 1395 | } else if (ch === 62) { 1396 | folding = true; 1397 | } else { 1398 | return false; 1399 | } 1400 | state.kind = "scalar"; 1401 | state.result = ""; 1402 | while (ch !== 0) { 1403 | ch = state.input.charCodeAt(++state.position); 1404 | if (ch === 43 || ch === 45) { 1405 | if (CHOMPING_CLIP === chomping) { 1406 | chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP; 1407 | } else { 1408 | throwError(state, "repeat of a chomping mode identifier"); 1409 | } 1410 | } else if ((tmp = fromDecimalCode(ch)) >= 0) { 1411 | if (tmp === 0) { 1412 | throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one"); 1413 | } else if (!detectedIndent) { 1414 | textIndent = nodeIndent + tmp - 1; 1415 | detectedIndent = true; 1416 | } else { 1417 | throwError(state, "repeat of an indentation width identifier"); 1418 | } 1419 | } else { 1420 | break; 1421 | } 1422 | } 1423 | if (is_WHITE_SPACE(ch)) { 1424 | do { 1425 | ch = state.input.charCodeAt(++state.position); 1426 | } while (is_WHITE_SPACE(ch)); 1427 | if (ch === 35) { 1428 | do { 1429 | ch = state.input.charCodeAt(++state.position); 1430 | } while (!is_EOL(ch) && ch !== 0); 1431 | } 1432 | } 1433 | while (ch !== 0) { 1434 | readLineBreak(state); 1435 | state.lineIndent = 0; 1436 | ch = state.input.charCodeAt(state.position); 1437 | while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) { 1438 | state.lineIndent++; 1439 | ch = state.input.charCodeAt(++state.position); 1440 | } 1441 | if (!detectedIndent && state.lineIndent > textIndent) { 1442 | textIndent = state.lineIndent; 1443 | } 1444 | if (is_EOL(ch)) { 1445 | emptyLines++; 1446 | continue; 1447 | } 1448 | if (state.lineIndent < textIndent) { 1449 | if (chomping === CHOMPING_KEEP) { 1450 | state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines); 1451 | } else if (chomping === CHOMPING_CLIP) { 1452 | if (didReadContent) { 1453 | state.result += "\n"; 1454 | } 1455 | } 1456 | break; 1457 | } 1458 | if (folding) { 1459 | if (is_WHITE_SPACE(ch)) { 1460 | atMoreIndented = true; 1461 | state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines); 1462 | } else if (atMoreIndented) { 1463 | atMoreIndented = false; 1464 | state.result += common.repeat("\n", emptyLines + 1); 1465 | } else if (emptyLines === 0) { 1466 | if (didReadContent) { 1467 | state.result += " "; 1468 | } 1469 | } else { 1470 | state.result += common.repeat("\n", emptyLines); 1471 | } 1472 | } else { 1473 | state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines); 1474 | } 1475 | didReadContent = true; 1476 | detectedIndent = true; 1477 | emptyLines = 0; 1478 | captureStart = state.position; 1479 | while (!is_EOL(ch) && ch !== 0) { 1480 | ch = state.input.charCodeAt(++state.position); 1481 | } 1482 | captureSegment(state, captureStart, state.position, false); 1483 | } 1484 | return true; 1485 | } 1486 | function readBlockSequence(state, nodeIndent) { 1487 | var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch; 1488 | if (state.firstTabInLine !== -1) 1489 | return false; 1490 | if (state.anchor !== null) { 1491 | state.anchorMap[state.anchor] = _result; 1492 | } 1493 | ch = state.input.charCodeAt(state.position); 1494 | while (ch !== 0) { 1495 | if (state.firstTabInLine !== -1) { 1496 | state.position = state.firstTabInLine; 1497 | throwError(state, "tab characters must not be used in indentation"); 1498 | } 1499 | if (ch !== 45) { 1500 | break; 1501 | } 1502 | following = state.input.charCodeAt(state.position + 1); 1503 | if (!is_WS_OR_EOL(following)) { 1504 | break; 1505 | } 1506 | detected = true; 1507 | state.position++; 1508 | if (skipSeparationSpace(state, true, -1)) { 1509 | if (state.lineIndent <= nodeIndent) { 1510 | _result.push(null); 1511 | ch = state.input.charCodeAt(state.position); 1512 | continue; 1513 | } 1514 | } 1515 | _line = state.line; 1516 | composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); 1517 | _result.push(state.result); 1518 | skipSeparationSpace(state, true, -1); 1519 | ch = state.input.charCodeAt(state.position); 1520 | if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) { 1521 | throwError(state, "bad indentation of a sequence entry"); 1522 | } else if (state.lineIndent < nodeIndent) { 1523 | break; 1524 | } 1525 | } 1526 | if (detected) { 1527 | state.tag = _tag; 1528 | state.anchor = _anchor; 1529 | state.kind = "sequence"; 1530 | state.result = _result; 1531 | return true; 1532 | } 1533 | return false; 1534 | } 1535 | function readBlockMapping(state, nodeIndent, flowIndent) { 1536 | var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = /* @__PURE__ */ Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch; 1537 | if (state.firstTabInLine !== -1) 1538 | return false; 1539 | if (state.anchor !== null) { 1540 | state.anchorMap[state.anchor] = _result; 1541 | } 1542 | ch = state.input.charCodeAt(state.position); 1543 | while (ch !== 0) { 1544 | if (!atExplicitKey && state.firstTabInLine !== -1) { 1545 | state.position = state.firstTabInLine; 1546 | throwError(state, "tab characters must not be used in indentation"); 1547 | } 1548 | following = state.input.charCodeAt(state.position + 1); 1549 | _line = state.line; 1550 | if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) { 1551 | if (ch === 63) { 1552 | if (atExplicitKey) { 1553 | storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); 1554 | keyTag = keyNode = valueNode = null; 1555 | } 1556 | detected = true; 1557 | atExplicitKey = true; 1558 | allowCompact = true; 1559 | } else if (atExplicitKey) { 1560 | atExplicitKey = false; 1561 | allowCompact = true; 1562 | } else { 1563 | throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"); 1564 | } 1565 | state.position += 1; 1566 | ch = following; 1567 | } else { 1568 | _keyLine = state.line; 1569 | _keyLineStart = state.lineStart; 1570 | _keyPos = state.position; 1571 | if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { 1572 | break; 1573 | } 1574 | if (state.line === _line) { 1575 | ch = state.input.charCodeAt(state.position); 1576 | while (is_WHITE_SPACE(ch)) { 1577 | ch = state.input.charCodeAt(++state.position); 1578 | } 1579 | if (ch === 58) { 1580 | ch = state.input.charCodeAt(++state.position); 1581 | if (!is_WS_OR_EOL(ch)) { 1582 | throwError(state, "a whitespace character is expected after the key-value separator within a block mapping"); 1583 | } 1584 | if (atExplicitKey) { 1585 | storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); 1586 | keyTag = keyNode = valueNode = null; 1587 | } 1588 | detected = true; 1589 | atExplicitKey = false; 1590 | allowCompact = false; 1591 | keyTag = state.tag; 1592 | keyNode = state.result; 1593 | } else if (detected) { 1594 | throwError(state, "can not read an implicit mapping pair; a colon is missed"); 1595 | } else { 1596 | state.tag = _tag; 1597 | state.anchor = _anchor; 1598 | return true; 1599 | } 1600 | } else if (detected) { 1601 | throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key"); 1602 | } else { 1603 | state.tag = _tag; 1604 | state.anchor = _anchor; 1605 | return true; 1606 | } 1607 | } 1608 | if (state.line === _line || state.lineIndent > nodeIndent) { 1609 | if (atExplicitKey) { 1610 | _keyLine = state.line; 1611 | _keyLineStart = state.lineStart; 1612 | _keyPos = state.position; 1613 | } 1614 | if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { 1615 | if (atExplicitKey) { 1616 | keyNode = state.result; 1617 | } else { 1618 | valueNode = state.result; 1619 | } 1620 | } 1621 | if (!atExplicitKey) { 1622 | storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos); 1623 | keyTag = keyNode = valueNode = null; 1624 | } 1625 | skipSeparationSpace(state, true, -1); 1626 | ch = state.input.charCodeAt(state.position); 1627 | } 1628 | if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) { 1629 | throwError(state, "bad indentation of a mapping entry"); 1630 | } else if (state.lineIndent < nodeIndent) { 1631 | break; 1632 | } 1633 | } 1634 | if (atExplicitKey) { 1635 | storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); 1636 | } 1637 | if (detected) { 1638 | state.tag = _tag; 1639 | state.anchor = _anchor; 1640 | state.kind = "mapping"; 1641 | state.result = _result; 1642 | } 1643 | return detected; 1644 | } 1645 | function readTagProperty(state) { 1646 | var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch; 1647 | ch = state.input.charCodeAt(state.position); 1648 | if (ch !== 33) 1649 | return false; 1650 | if (state.tag !== null) { 1651 | throwError(state, "duplication of a tag property"); 1652 | } 1653 | ch = state.input.charCodeAt(++state.position); 1654 | if (ch === 60) { 1655 | isVerbatim = true; 1656 | ch = state.input.charCodeAt(++state.position); 1657 | } else if (ch === 33) { 1658 | isNamed = true; 1659 | tagHandle = "!!"; 1660 | ch = state.input.charCodeAt(++state.position); 1661 | } else { 1662 | tagHandle = "!"; 1663 | } 1664 | _position = state.position; 1665 | if (isVerbatim) { 1666 | do { 1667 | ch = state.input.charCodeAt(++state.position); 1668 | } while (ch !== 0 && ch !== 62); 1669 | if (state.position < state.length) { 1670 | tagName = state.input.slice(_position, state.position); 1671 | ch = state.input.charCodeAt(++state.position); 1672 | } else { 1673 | throwError(state, "unexpected end of the stream within a verbatim tag"); 1674 | } 1675 | } else { 1676 | while (ch !== 0 && !is_WS_OR_EOL(ch)) { 1677 | if (ch === 33) { 1678 | if (!isNamed) { 1679 | tagHandle = state.input.slice(_position - 1, state.position + 1); 1680 | if (!PATTERN_TAG_HANDLE.test(tagHandle)) { 1681 | throwError(state, "named tag handle cannot contain such characters"); 1682 | } 1683 | isNamed = true; 1684 | _position = state.position + 1; 1685 | } else { 1686 | throwError(state, "tag suffix cannot contain exclamation marks"); 1687 | } 1688 | } 1689 | ch = state.input.charCodeAt(++state.position); 1690 | } 1691 | tagName = state.input.slice(_position, state.position); 1692 | if (PATTERN_FLOW_INDICATORS.test(tagName)) { 1693 | throwError(state, "tag suffix cannot contain flow indicator characters"); 1694 | } 1695 | } 1696 | if (tagName && !PATTERN_TAG_URI.test(tagName)) { 1697 | throwError(state, "tag name cannot contain such characters: " + tagName); 1698 | } 1699 | try { 1700 | tagName = decodeURIComponent(tagName); 1701 | } catch (err) { 1702 | throwError(state, "tag name is malformed: " + tagName); 1703 | } 1704 | if (isVerbatim) { 1705 | state.tag = tagName; 1706 | } else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) { 1707 | state.tag = state.tagMap[tagHandle] + tagName; 1708 | } else if (tagHandle === "!") { 1709 | state.tag = "!" + tagName; 1710 | } else if (tagHandle === "!!") { 1711 | state.tag = "tag:yaml.org,2002:" + tagName; 1712 | } else { 1713 | throwError(state, 'undeclared tag handle "' + tagHandle + '"'); 1714 | } 1715 | return true; 1716 | } 1717 | function readAnchorProperty(state) { 1718 | var _position, ch; 1719 | ch = state.input.charCodeAt(state.position); 1720 | if (ch !== 38) 1721 | return false; 1722 | if (state.anchor !== null) { 1723 | throwError(state, "duplication of an anchor property"); 1724 | } 1725 | ch = state.input.charCodeAt(++state.position); 1726 | _position = state.position; 1727 | while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { 1728 | ch = state.input.charCodeAt(++state.position); 1729 | } 1730 | if (state.position === _position) { 1731 | throwError(state, "name of an anchor node must contain at least one character"); 1732 | } 1733 | state.anchor = state.input.slice(_position, state.position); 1734 | return true; 1735 | } 1736 | function readAlias(state) { 1737 | var _position, alias, ch; 1738 | ch = state.input.charCodeAt(state.position); 1739 | if (ch !== 42) 1740 | return false; 1741 | ch = state.input.charCodeAt(++state.position); 1742 | _position = state.position; 1743 | while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { 1744 | ch = state.input.charCodeAt(++state.position); 1745 | } 1746 | if (state.position === _position) { 1747 | throwError(state, "name of an alias node must contain at least one character"); 1748 | } 1749 | alias = state.input.slice(_position, state.position); 1750 | if (!_hasOwnProperty$1.call(state.anchorMap, alias)) { 1751 | throwError(state, 'unidentified alias "' + alias + '"'); 1752 | } 1753 | state.result = state.anchorMap[alias]; 1754 | skipSeparationSpace(state, true, -1); 1755 | return true; 1756 | } 1757 | function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { 1758 | var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent; 1759 | if (state.listener !== null) { 1760 | state.listener("open", state); 1761 | } 1762 | state.tag = null; 1763 | state.anchor = null; 1764 | state.kind = null; 1765 | state.result = null; 1766 | allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext; 1767 | if (allowToSeek) { 1768 | if (skipSeparationSpace(state, true, -1)) { 1769 | atNewLine = true; 1770 | if (state.lineIndent > parentIndent) { 1771 | indentStatus = 1; 1772 | } else if (state.lineIndent === parentIndent) { 1773 | indentStatus = 0; 1774 | } else if (state.lineIndent < parentIndent) { 1775 | indentStatus = -1; 1776 | } 1777 | } 1778 | } 1779 | if (indentStatus === 1) { 1780 | while (readTagProperty(state) || readAnchorProperty(state)) { 1781 | if (skipSeparationSpace(state, true, -1)) { 1782 | atNewLine = true; 1783 | allowBlockCollections = allowBlockStyles; 1784 | if (state.lineIndent > parentIndent) { 1785 | indentStatus = 1; 1786 | } else if (state.lineIndent === parentIndent) { 1787 | indentStatus = 0; 1788 | } else if (state.lineIndent < parentIndent) { 1789 | indentStatus = -1; 1790 | } 1791 | } else { 1792 | allowBlockCollections = false; 1793 | } 1794 | } 1795 | } 1796 | if (allowBlockCollections) { 1797 | allowBlockCollections = atNewLine || allowCompact; 1798 | } 1799 | if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { 1800 | if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { 1801 | flowIndent = parentIndent; 1802 | } else { 1803 | flowIndent = parentIndent + 1; 1804 | } 1805 | blockIndent = state.position - state.lineStart; 1806 | if (indentStatus === 1) { 1807 | if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) { 1808 | hasContent = true; 1809 | } else { 1810 | if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) { 1811 | hasContent = true; 1812 | } else if (readAlias(state)) { 1813 | hasContent = true; 1814 | if (state.tag !== null || state.anchor !== null) { 1815 | throwError(state, "alias node should not have any properties"); 1816 | } 1817 | } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { 1818 | hasContent = true; 1819 | if (state.tag === null) { 1820 | state.tag = "?"; 1821 | } 1822 | } 1823 | if (state.anchor !== null) { 1824 | state.anchorMap[state.anchor] = state.result; 1825 | } 1826 | } 1827 | } else if (indentStatus === 0) { 1828 | hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); 1829 | } 1830 | } 1831 | if (state.tag === null) { 1832 | if (state.anchor !== null) { 1833 | state.anchorMap[state.anchor] = state.result; 1834 | } 1835 | } else if (state.tag === "?") { 1836 | if (state.result !== null && state.kind !== "scalar") { 1837 | throwError(state, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state.kind + '"'); 1838 | } 1839 | for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { 1840 | type2 = state.implicitTypes[typeIndex]; 1841 | if (type2.resolve(state.result)) { 1842 | state.result = type2.construct(state.result); 1843 | state.tag = type2.tag; 1844 | if (state.anchor !== null) { 1845 | state.anchorMap[state.anchor] = state.result; 1846 | } 1847 | break; 1848 | } 1849 | } 1850 | } else if (state.tag !== "!") { 1851 | if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) { 1852 | type2 = state.typeMap[state.kind || "fallback"][state.tag]; 1853 | } else { 1854 | type2 = null; 1855 | typeList = state.typeMap.multi[state.kind || "fallback"]; 1856 | for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) { 1857 | if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) { 1858 | type2 = typeList[typeIndex]; 1859 | break; 1860 | } 1861 | } 1862 | } 1863 | if (!type2) { 1864 | throwError(state, "unknown tag !<" + state.tag + ">"); 1865 | } 1866 | if (state.result !== null && type2.kind !== state.kind) { 1867 | throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"'); 1868 | } 1869 | if (!type2.resolve(state.result, state.tag)) { 1870 | throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag"); 1871 | } else { 1872 | state.result = type2.construct(state.result, state.tag); 1873 | if (state.anchor !== null) { 1874 | state.anchorMap[state.anchor] = state.result; 1875 | } 1876 | } 1877 | } 1878 | if (state.listener !== null) { 1879 | state.listener("close", state); 1880 | } 1881 | return state.tag !== null || state.anchor !== null || hasContent; 1882 | } 1883 | function readDocument(state) { 1884 | var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch; 1885 | state.version = null; 1886 | state.checkLineBreaks = state.legacy; 1887 | state.tagMap = /* @__PURE__ */ Object.create(null); 1888 | state.anchorMap = /* @__PURE__ */ Object.create(null); 1889 | while ((ch = state.input.charCodeAt(state.position)) !== 0) { 1890 | skipSeparationSpace(state, true, -1); 1891 | ch = state.input.charCodeAt(state.position); 1892 | if (state.lineIndent > 0 || ch !== 37) { 1893 | break; 1894 | } 1895 | hasDirectives = true; 1896 | ch = state.input.charCodeAt(++state.position); 1897 | _position = state.position; 1898 | while (ch !== 0 && !is_WS_OR_EOL(ch)) { 1899 | ch = state.input.charCodeAt(++state.position); 1900 | } 1901 | directiveName = state.input.slice(_position, state.position); 1902 | directiveArgs = []; 1903 | if (directiveName.length < 1) { 1904 | throwError(state, "directive name must not be less than one character in length"); 1905 | } 1906 | while (ch !== 0) { 1907 | while (is_WHITE_SPACE(ch)) { 1908 | ch = state.input.charCodeAt(++state.position); 1909 | } 1910 | if (ch === 35) { 1911 | do { 1912 | ch = state.input.charCodeAt(++state.position); 1913 | } while (ch !== 0 && !is_EOL(ch)); 1914 | break; 1915 | } 1916 | if (is_EOL(ch)) 1917 | break; 1918 | _position = state.position; 1919 | while (ch !== 0 && !is_WS_OR_EOL(ch)) { 1920 | ch = state.input.charCodeAt(++state.position); 1921 | } 1922 | directiveArgs.push(state.input.slice(_position, state.position)); 1923 | } 1924 | if (ch !== 0) 1925 | readLineBreak(state); 1926 | if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) { 1927 | directiveHandlers[directiveName](state, directiveName, directiveArgs); 1928 | } else { 1929 | throwWarning(state, 'unknown document directive "' + directiveName + '"'); 1930 | } 1931 | } 1932 | skipSeparationSpace(state, true, -1); 1933 | if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) { 1934 | state.position += 3; 1935 | skipSeparationSpace(state, true, -1); 1936 | } else if (hasDirectives) { 1937 | throwError(state, "directives end mark is expected"); 1938 | } 1939 | composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); 1940 | skipSeparationSpace(state, true, -1); 1941 | if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { 1942 | throwWarning(state, "non-ASCII line breaks are interpreted as content"); 1943 | } 1944 | state.documents.push(state.result); 1945 | if (state.position === state.lineStart && testDocumentSeparator(state)) { 1946 | if (state.input.charCodeAt(state.position) === 46) { 1947 | state.position += 3; 1948 | skipSeparationSpace(state, true, -1); 1949 | } 1950 | return; 1951 | } 1952 | if (state.position < state.length - 1) { 1953 | throwError(state, "end of the stream or a document separator is expected"); 1954 | } else { 1955 | return; 1956 | } 1957 | } 1958 | function loadDocuments(input, options) { 1959 | input = String(input); 1960 | options = options || {}; 1961 | if (input.length !== 0) { 1962 | if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) { 1963 | input += "\n"; 1964 | } 1965 | if (input.charCodeAt(0) === 65279) { 1966 | input = input.slice(1); 1967 | } 1968 | } 1969 | var state = new State$1(input, options); 1970 | var nullpos = input.indexOf("\0"); 1971 | if (nullpos !== -1) { 1972 | state.position = nullpos; 1973 | throwError(state, "null byte is not allowed in input"); 1974 | } 1975 | state.input += "\0"; 1976 | while (state.input.charCodeAt(state.position) === 32) { 1977 | state.lineIndent += 1; 1978 | state.position += 1; 1979 | } 1980 | while (state.position < state.length - 1) { 1981 | readDocument(state); 1982 | } 1983 | return state.documents; 1984 | } 1985 | function loadAll$1(input, iterator, options) { 1986 | if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") { 1987 | options = iterator; 1988 | iterator = null; 1989 | } 1990 | var documents = loadDocuments(input, options); 1991 | if (typeof iterator !== "function") { 1992 | return documents; 1993 | } 1994 | for (var index = 0, length = documents.length; index < length; index += 1) { 1995 | iterator(documents[index]); 1996 | } 1997 | } 1998 | function load$1(input, options) { 1999 | var documents = loadDocuments(input, options); 2000 | if (documents.length === 0) { 2001 | return void 0; 2002 | } else if (documents.length === 1) { 2003 | return documents[0]; 2004 | } 2005 | throw new exception("expected a single document in the stream, but found more"); 2006 | } 2007 | var loadAll_1 = loadAll$1; 2008 | var load_1 = load$1; 2009 | var loader = { 2010 | loadAll: loadAll_1, 2011 | load: load_1 2012 | }; 2013 | var _toString = Object.prototype.toString; 2014 | var _hasOwnProperty = Object.prototype.hasOwnProperty; 2015 | var CHAR_BOM = 65279; 2016 | var CHAR_TAB = 9; 2017 | var CHAR_LINE_FEED = 10; 2018 | var CHAR_CARRIAGE_RETURN = 13; 2019 | var CHAR_SPACE = 32; 2020 | var CHAR_EXCLAMATION = 33; 2021 | var CHAR_DOUBLE_QUOTE = 34; 2022 | var CHAR_SHARP = 35; 2023 | var CHAR_PERCENT = 37; 2024 | var CHAR_AMPERSAND = 38; 2025 | var CHAR_SINGLE_QUOTE = 39; 2026 | var CHAR_ASTERISK = 42; 2027 | var CHAR_COMMA = 44; 2028 | var CHAR_MINUS = 45; 2029 | var CHAR_COLON = 58; 2030 | var CHAR_EQUALS = 61; 2031 | var CHAR_GREATER_THAN = 62; 2032 | var CHAR_QUESTION = 63; 2033 | var CHAR_COMMERCIAL_AT = 64; 2034 | var CHAR_LEFT_SQUARE_BRACKET = 91; 2035 | var CHAR_RIGHT_SQUARE_BRACKET = 93; 2036 | var CHAR_GRAVE_ACCENT = 96; 2037 | var CHAR_LEFT_CURLY_BRACKET = 123; 2038 | var CHAR_VERTICAL_LINE = 124; 2039 | var CHAR_RIGHT_CURLY_BRACKET = 125; 2040 | var ESCAPE_SEQUENCES = {}; 2041 | ESCAPE_SEQUENCES[0] = "\\0"; 2042 | ESCAPE_SEQUENCES[7] = "\\a"; 2043 | ESCAPE_SEQUENCES[8] = "\\b"; 2044 | ESCAPE_SEQUENCES[9] = "\\t"; 2045 | ESCAPE_SEQUENCES[10] = "\\n"; 2046 | ESCAPE_SEQUENCES[11] = "\\v"; 2047 | ESCAPE_SEQUENCES[12] = "\\f"; 2048 | ESCAPE_SEQUENCES[13] = "\\r"; 2049 | ESCAPE_SEQUENCES[27] = "\\e"; 2050 | ESCAPE_SEQUENCES[34] = '\\"'; 2051 | ESCAPE_SEQUENCES[92] = "\\\\"; 2052 | ESCAPE_SEQUENCES[133] = "\\N"; 2053 | ESCAPE_SEQUENCES[160] = "\\_"; 2054 | ESCAPE_SEQUENCES[8232] = "\\L"; 2055 | ESCAPE_SEQUENCES[8233] = "\\P"; 2056 | var DEPRECATED_BOOLEANS_SYNTAX = [ 2057 | "y", 2058 | "Y", 2059 | "yes", 2060 | "Yes", 2061 | "YES", 2062 | "on", 2063 | "On", 2064 | "ON", 2065 | "n", 2066 | "N", 2067 | "no", 2068 | "No", 2069 | "NO", 2070 | "off", 2071 | "Off", 2072 | "OFF" 2073 | ]; 2074 | var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/; 2075 | function compileStyleMap(schema2, map2) { 2076 | var result, keys, index, length, tag, style, type2; 2077 | if (map2 === null) 2078 | return {}; 2079 | result = {}; 2080 | keys = Object.keys(map2); 2081 | for (index = 0, length = keys.length; index < length; index += 1) { 2082 | tag = keys[index]; 2083 | style = String(map2[tag]); 2084 | if (tag.slice(0, 2) === "!!") { 2085 | tag = "tag:yaml.org,2002:" + tag.slice(2); 2086 | } 2087 | type2 = schema2.compiledTypeMap["fallback"][tag]; 2088 | if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) { 2089 | style = type2.styleAliases[style]; 2090 | } 2091 | result[tag] = style; 2092 | } 2093 | return result; 2094 | } 2095 | function encodeHex(character) { 2096 | var string, handle, length; 2097 | string = character.toString(16).toUpperCase(); 2098 | if (character <= 255) { 2099 | handle = "x"; 2100 | length = 2; 2101 | } else if (character <= 65535) { 2102 | handle = "u"; 2103 | length = 4; 2104 | } else if (character <= 4294967295) { 2105 | handle = "U"; 2106 | length = 8; 2107 | } else { 2108 | throw new exception("code point within a string may not be greater than 0xFFFFFFFF"); 2109 | } 2110 | return "\\" + handle + common.repeat("0", length - string.length) + string; 2111 | } 2112 | var QUOTING_TYPE_SINGLE = 1; 2113 | var QUOTING_TYPE_DOUBLE = 2; 2114 | function State(options) { 2115 | this.schema = options["schema"] || _default; 2116 | this.indent = Math.max(1, options["indent"] || 2); 2117 | this.noArrayIndent = options["noArrayIndent"] || false; 2118 | this.skipInvalid = options["skipInvalid"] || false; 2119 | this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"]; 2120 | this.styleMap = compileStyleMap(this.schema, options["styles"] || null); 2121 | this.sortKeys = options["sortKeys"] || false; 2122 | this.lineWidth = options["lineWidth"] || 80; 2123 | this.noRefs = options["noRefs"] || false; 2124 | this.noCompatMode = options["noCompatMode"] || false; 2125 | this.condenseFlow = options["condenseFlow"] || false; 2126 | this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE; 2127 | this.forceQuotes = options["forceQuotes"] || false; 2128 | this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null; 2129 | this.implicitTypes = this.schema.compiledImplicit; 2130 | this.explicitTypes = this.schema.compiledExplicit; 2131 | this.tag = null; 2132 | this.result = ""; 2133 | this.duplicates = []; 2134 | this.usedDuplicates = null; 2135 | } 2136 | function indentString(string, spaces) { 2137 | var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length; 2138 | while (position < length) { 2139 | next = string.indexOf("\n", position); 2140 | if (next === -1) { 2141 | line = string.slice(position); 2142 | position = length; 2143 | } else { 2144 | line = string.slice(position, next + 1); 2145 | position = next + 1; 2146 | } 2147 | if (line.length && line !== "\n") 2148 | result += ind; 2149 | result += line; 2150 | } 2151 | return result; 2152 | } 2153 | function generateNextLine(state, level) { 2154 | return "\n" + common.repeat(" ", state.indent * level); 2155 | } 2156 | function testImplicitResolving(state, str2) { 2157 | var index, length, type2; 2158 | for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { 2159 | type2 = state.implicitTypes[index]; 2160 | if (type2.resolve(str2)) { 2161 | return true; 2162 | } 2163 | } 2164 | return false; 2165 | } 2166 | function isWhitespace(c) { 2167 | return c === CHAR_SPACE || c === CHAR_TAB; 2168 | } 2169 | function isPrintable(c) { 2170 | return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111; 2171 | } 2172 | function isNsCharOrWhitespace(c) { 2173 | return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED; 2174 | } 2175 | function isPlainSafe(c, prev, inblock) { 2176 | var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c); 2177 | var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c); 2178 | return ( 2179 | // ns-plain-safe 2180 | (inblock ? ( 2181 | // c = flow-in 2182 | cIsNsCharOrWhitespace 2183 | ) : cIsNsCharOrWhitespace && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && c !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar 2184 | ); 2185 | } 2186 | function isPlainSafeFirst(c) { 2187 | return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT; 2188 | } 2189 | function isPlainSafeLast(c) { 2190 | return !isWhitespace(c) && c !== CHAR_COLON; 2191 | } 2192 | function codePointAt(string, pos) { 2193 | var first = string.charCodeAt(pos), second; 2194 | if (first >= 55296 && first <= 56319 && pos + 1 < string.length) { 2195 | second = string.charCodeAt(pos + 1); 2196 | if (second >= 56320 && second <= 57343) { 2197 | return (first - 55296) * 1024 + second - 56320 + 65536; 2198 | } 2199 | } 2200 | return first; 2201 | } 2202 | function needIndentIndicator(string) { 2203 | var leadingSpaceRe = /^\n* /; 2204 | return leadingSpaceRe.test(string); 2205 | } 2206 | var STYLE_PLAIN = 1; 2207 | var STYLE_SINGLE = 2; 2208 | var STYLE_LITERAL = 3; 2209 | var STYLE_FOLDED = 4; 2210 | var STYLE_DOUBLE = 5; 2211 | function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) { 2212 | var i; 2213 | var char = 0; 2214 | var prevChar = null; 2215 | var hasLineBreak = false; 2216 | var hasFoldableLine = false; 2217 | var shouldTrackWidth = lineWidth !== -1; 2218 | var previousLineBreak = -1; 2219 | var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1)); 2220 | if (singleLineOnly || forceQuotes) { 2221 | for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) { 2222 | char = codePointAt(string, i); 2223 | if (!isPrintable(char)) { 2224 | return STYLE_DOUBLE; 2225 | } 2226 | plain = plain && isPlainSafe(char, prevChar, inblock); 2227 | prevChar = char; 2228 | } 2229 | } else { 2230 | for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) { 2231 | char = codePointAt(string, i); 2232 | if (char === CHAR_LINE_FEED) { 2233 | hasLineBreak = true; 2234 | if (shouldTrackWidth) { 2235 | hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented. 2236 | i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " "; 2237 | previousLineBreak = i; 2238 | } 2239 | } else if (!isPrintable(char)) { 2240 | return STYLE_DOUBLE; 2241 | } 2242 | plain = plain && isPlainSafe(char, prevChar, inblock); 2243 | prevChar = char; 2244 | } 2245 | hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " "); 2246 | } 2247 | if (!hasLineBreak && !hasFoldableLine) { 2248 | if (plain && !forceQuotes && !testAmbiguousType(string)) { 2249 | return STYLE_PLAIN; 2250 | } 2251 | return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; 2252 | } 2253 | if (indentPerLevel > 9 && needIndentIndicator(string)) { 2254 | return STYLE_DOUBLE; 2255 | } 2256 | if (!forceQuotes) { 2257 | return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL; 2258 | } 2259 | return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; 2260 | } 2261 | function writeScalar(state, string, level, iskey, inblock) { 2262 | state.dump = function() { 2263 | if (string.length === 0) { 2264 | return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''"; 2265 | } 2266 | if (!state.noCompatMode) { 2267 | if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) { 2268 | return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'"; 2269 | } 2270 | } 2271 | var indent = state.indent * Math.max(1, level); 2272 | var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); 2273 | var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel; 2274 | function testAmbiguity(string2) { 2275 | return testImplicitResolving(state, string2); 2276 | } 2277 | switch (chooseScalarStyle( 2278 | string, 2279 | singleLineOnly, 2280 | state.indent, 2281 | lineWidth, 2282 | testAmbiguity, 2283 | state.quotingType, 2284 | state.forceQuotes && !iskey, 2285 | inblock 2286 | )) { 2287 | case STYLE_PLAIN: 2288 | return string; 2289 | case STYLE_SINGLE: 2290 | return "'" + string.replace(/'/g, "''") + "'"; 2291 | case STYLE_LITERAL: 2292 | return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent)); 2293 | case STYLE_FOLDED: 2294 | return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent)); 2295 | case STYLE_DOUBLE: 2296 | return '"' + escapeString(string) + '"'; 2297 | default: 2298 | throw new exception("impossible error: invalid scalar style"); 2299 | } 2300 | }(); 2301 | } 2302 | function blockHeader(string, indentPerLevel) { 2303 | var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : ""; 2304 | var clip = string[string.length - 1] === "\n"; 2305 | var keep = clip && (string[string.length - 2] === "\n" || string === "\n"); 2306 | var chomp = keep ? "+" : clip ? "" : "-"; 2307 | return indentIndicator + chomp + "\n"; 2308 | } 2309 | function dropEndingNewline(string) { 2310 | return string[string.length - 1] === "\n" ? string.slice(0, -1) : string; 2311 | } 2312 | function foldString(string, width) { 2313 | var lineRe = /(\n+)([^\n]*)/g; 2314 | var result = function() { 2315 | var nextLF = string.indexOf("\n"); 2316 | nextLF = nextLF !== -1 ? nextLF : string.length; 2317 | lineRe.lastIndex = nextLF; 2318 | return foldLine(string.slice(0, nextLF), width); 2319 | }(); 2320 | var prevMoreIndented = string[0] === "\n" || string[0] === " "; 2321 | var moreIndented; 2322 | var match; 2323 | while (match = lineRe.exec(string)) { 2324 | var prefix = match[1], line = match[2]; 2325 | moreIndented = line[0] === " "; 2326 | result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width); 2327 | prevMoreIndented = moreIndented; 2328 | } 2329 | return result; 2330 | } 2331 | function foldLine(line, width) { 2332 | if (line === "" || line[0] === " ") 2333 | return line; 2334 | var breakRe = / [^ ]/g; 2335 | var match; 2336 | var start = 0, end, curr = 0, next = 0; 2337 | var result = ""; 2338 | while (match = breakRe.exec(line)) { 2339 | next = match.index; 2340 | if (next - start > width) { 2341 | end = curr > start ? curr : next; 2342 | result += "\n" + line.slice(start, end); 2343 | start = end + 1; 2344 | } 2345 | curr = next; 2346 | } 2347 | result += "\n"; 2348 | if (line.length - start > width && curr > start) { 2349 | result += line.slice(start, curr) + "\n" + line.slice(curr + 1); 2350 | } else { 2351 | result += line.slice(start); 2352 | } 2353 | return result.slice(1); 2354 | } 2355 | function escapeString(string) { 2356 | var result = ""; 2357 | var char = 0; 2358 | var escapeSeq; 2359 | for (var i = 0; i < string.length; char >= 65536 ? i += 2 : i++) { 2360 | char = codePointAt(string, i); 2361 | escapeSeq = ESCAPE_SEQUENCES[char]; 2362 | if (!escapeSeq && isPrintable(char)) { 2363 | result += string[i]; 2364 | if (char >= 65536) 2365 | result += string[i + 1]; 2366 | } else { 2367 | result += escapeSeq || encodeHex(char); 2368 | } 2369 | } 2370 | return result; 2371 | } 2372 | function writeFlowSequence(state, level, object) { 2373 | var _result = "", _tag = state.tag, index, length, value; 2374 | for (index = 0, length = object.length; index < length; index += 1) { 2375 | value = object[index]; 2376 | if (state.replacer) { 2377 | value = state.replacer.call(object, String(index), value); 2378 | } 2379 | if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) { 2380 | if (_result !== "") 2381 | _result += "," + (!state.condenseFlow ? " " : ""); 2382 | _result += state.dump; 2383 | } 2384 | } 2385 | state.tag = _tag; 2386 | state.dump = "[" + _result + "]"; 2387 | } 2388 | function writeBlockSequence(state, level, object, compact) { 2389 | var _result = "", _tag = state.tag, index, length, value; 2390 | for (index = 0, length = object.length; index < length; index += 1) { 2391 | value = object[index]; 2392 | if (state.replacer) { 2393 | value = state.replacer.call(object, String(index), value); 2394 | } 2395 | if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) { 2396 | if (!compact || _result !== "") { 2397 | _result += generateNextLine(state, level); 2398 | } 2399 | if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { 2400 | _result += "-"; 2401 | } else { 2402 | _result += "- "; 2403 | } 2404 | _result += state.dump; 2405 | } 2406 | } 2407 | state.tag = _tag; 2408 | state.dump = _result || "[]"; 2409 | } 2410 | function writeFlowMapping(state, level, object) { 2411 | var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer; 2412 | for (index = 0, length = objectKeyList.length; index < length; index += 1) { 2413 | pairBuffer = ""; 2414 | if (_result !== "") 2415 | pairBuffer += ", "; 2416 | if (state.condenseFlow) 2417 | pairBuffer += '"'; 2418 | objectKey = objectKeyList[index]; 2419 | objectValue = object[objectKey]; 2420 | if (state.replacer) { 2421 | objectValue = state.replacer.call(object, objectKey, objectValue); 2422 | } 2423 | if (!writeNode(state, level, objectKey, false, false)) { 2424 | continue; 2425 | } 2426 | if (state.dump.length > 1024) 2427 | pairBuffer += "? "; 2428 | pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " "); 2429 | if (!writeNode(state, level, objectValue, false, false)) { 2430 | continue; 2431 | } 2432 | pairBuffer += state.dump; 2433 | _result += pairBuffer; 2434 | } 2435 | state.tag = _tag; 2436 | state.dump = "{" + _result + "}"; 2437 | } 2438 | function writeBlockMapping(state, level, object, compact) { 2439 | var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer; 2440 | if (state.sortKeys === true) { 2441 | objectKeyList.sort(); 2442 | } else if (typeof state.sortKeys === "function") { 2443 | objectKeyList.sort(state.sortKeys); 2444 | } else if (state.sortKeys) { 2445 | throw new exception("sortKeys must be a boolean or a function"); 2446 | } 2447 | for (index = 0, length = objectKeyList.length; index < length; index += 1) { 2448 | pairBuffer = ""; 2449 | if (!compact || _result !== "") { 2450 | pairBuffer += generateNextLine(state, level); 2451 | } 2452 | objectKey = objectKeyList[index]; 2453 | objectValue = object[objectKey]; 2454 | if (state.replacer) { 2455 | objectValue = state.replacer.call(object, objectKey, objectValue); 2456 | } 2457 | if (!writeNode(state, level + 1, objectKey, true, true, true)) { 2458 | continue; 2459 | } 2460 | explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024; 2461 | if (explicitPair) { 2462 | if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { 2463 | pairBuffer += "?"; 2464 | } else { 2465 | pairBuffer += "? "; 2466 | } 2467 | } 2468 | pairBuffer += state.dump; 2469 | if (explicitPair) { 2470 | pairBuffer += generateNextLine(state, level); 2471 | } 2472 | if (!writeNode(state, level + 1, objectValue, true, explicitPair)) { 2473 | continue; 2474 | } 2475 | if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { 2476 | pairBuffer += ":"; 2477 | } else { 2478 | pairBuffer += ": "; 2479 | } 2480 | pairBuffer += state.dump; 2481 | _result += pairBuffer; 2482 | } 2483 | state.tag = _tag; 2484 | state.dump = _result || "{}"; 2485 | } 2486 | function detectType(state, object, explicit) { 2487 | var _result, typeList, index, length, type2, style; 2488 | typeList = explicit ? state.explicitTypes : state.implicitTypes; 2489 | for (index = 0, length = typeList.length; index < length; index += 1) { 2490 | type2 = typeList[index]; 2491 | if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) { 2492 | if (explicit) { 2493 | if (type2.multi && type2.representName) { 2494 | state.tag = type2.representName(object); 2495 | } else { 2496 | state.tag = type2.tag; 2497 | } 2498 | } else { 2499 | state.tag = "?"; 2500 | } 2501 | if (type2.represent) { 2502 | style = state.styleMap[type2.tag] || type2.defaultStyle; 2503 | if (_toString.call(type2.represent) === "[object Function]") { 2504 | _result = type2.represent(object, style); 2505 | } else if (_hasOwnProperty.call(type2.represent, style)) { 2506 | _result = type2.represent[style](object, style); 2507 | } else { 2508 | throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style'); 2509 | } 2510 | state.dump = _result; 2511 | } 2512 | return true; 2513 | } 2514 | } 2515 | return false; 2516 | } 2517 | function writeNode(state, level, object, block, compact, iskey, isblockseq) { 2518 | state.tag = null; 2519 | state.dump = object; 2520 | if (!detectType(state, object, false)) { 2521 | detectType(state, object, true); 2522 | } 2523 | var type2 = _toString.call(state.dump); 2524 | var inblock = block; 2525 | var tagStr; 2526 | if (block) { 2527 | block = state.flowLevel < 0 || state.flowLevel > level; 2528 | } 2529 | var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate; 2530 | if (objectOrArray) { 2531 | duplicateIndex = state.duplicates.indexOf(object); 2532 | duplicate = duplicateIndex !== -1; 2533 | } 2534 | if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) { 2535 | compact = false; 2536 | } 2537 | if (duplicate && state.usedDuplicates[duplicateIndex]) { 2538 | state.dump = "*ref_" + duplicateIndex; 2539 | } else { 2540 | if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { 2541 | state.usedDuplicates[duplicateIndex] = true; 2542 | } 2543 | if (type2 === "[object Object]") { 2544 | if (block && Object.keys(state.dump).length !== 0) { 2545 | writeBlockMapping(state, level, state.dump, compact); 2546 | if (duplicate) { 2547 | state.dump = "&ref_" + duplicateIndex + state.dump; 2548 | } 2549 | } else { 2550 | writeFlowMapping(state, level, state.dump); 2551 | if (duplicate) { 2552 | state.dump = "&ref_" + duplicateIndex + " " + state.dump; 2553 | } 2554 | } 2555 | } else if (type2 === "[object Array]") { 2556 | if (block && state.dump.length !== 0) { 2557 | if (state.noArrayIndent && !isblockseq && level > 0) { 2558 | writeBlockSequence(state, level - 1, state.dump, compact); 2559 | } else { 2560 | writeBlockSequence(state, level, state.dump, compact); 2561 | } 2562 | if (duplicate) { 2563 | state.dump = "&ref_" + duplicateIndex + state.dump; 2564 | } 2565 | } else { 2566 | writeFlowSequence(state, level, state.dump); 2567 | if (duplicate) { 2568 | state.dump = "&ref_" + duplicateIndex + " " + state.dump; 2569 | } 2570 | } 2571 | } else if (type2 === "[object String]") { 2572 | if (state.tag !== "?") { 2573 | writeScalar(state, state.dump, level, iskey, inblock); 2574 | } 2575 | } else if (type2 === "[object Undefined]") { 2576 | return false; 2577 | } else { 2578 | if (state.skipInvalid) 2579 | return false; 2580 | throw new exception("unacceptable kind of an object to dump " + type2); 2581 | } 2582 | if (state.tag !== null && state.tag !== "?") { 2583 | tagStr = encodeURI( 2584 | state.tag[0] === "!" ? state.tag.slice(1) : state.tag 2585 | ).replace(/!/g, "%21"); 2586 | if (state.tag[0] === "!") { 2587 | tagStr = "!" + tagStr; 2588 | } else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") { 2589 | tagStr = "!!" + tagStr.slice(18); 2590 | } else { 2591 | tagStr = "!<" + tagStr + ">"; 2592 | } 2593 | state.dump = tagStr + " " + state.dump; 2594 | } 2595 | } 2596 | return true; 2597 | } 2598 | function getDuplicateReferences(object, state) { 2599 | var objects = [], duplicatesIndexes = [], index, length; 2600 | inspectNode(object, objects, duplicatesIndexes); 2601 | for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { 2602 | state.duplicates.push(objects[duplicatesIndexes[index]]); 2603 | } 2604 | state.usedDuplicates = new Array(length); 2605 | } 2606 | function inspectNode(object, objects, duplicatesIndexes) { 2607 | var objectKeyList, index, length; 2608 | if (object !== null && typeof object === "object") { 2609 | index = objects.indexOf(object); 2610 | if (index !== -1) { 2611 | if (duplicatesIndexes.indexOf(index) === -1) { 2612 | duplicatesIndexes.push(index); 2613 | } 2614 | } else { 2615 | objects.push(object); 2616 | if (Array.isArray(object)) { 2617 | for (index = 0, length = object.length; index < length; index += 1) { 2618 | inspectNode(object[index], objects, duplicatesIndexes); 2619 | } 2620 | } else { 2621 | objectKeyList = Object.keys(object); 2622 | for (index = 0, length = objectKeyList.length; index < length; index += 1) { 2623 | inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes); 2624 | } 2625 | } 2626 | } 2627 | } 2628 | } 2629 | function dump$1(input, options) { 2630 | options = options || {}; 2631 | var state = new State(options); 2632 | if (!state.noRefs) 2633 | getDuplicateReferences(input, state); 2634 | var value = input; 2635 | if (state.replacer) { 2636 | value = state.replacer.call({ "": value }, "", value); 2637 | } 2638 | if (writeNode(state, 0, value, true, true)) 2639 | return state.dump + "\n"; 2640 | return ""; 2641 | } 2642 | var dump_1 = dump$1; 2643 | var dumper = { 2644 | dump: dump_1 2645 | }; 2646 | function renamed(from, to) { 2647 | return function() { 2648 | throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default."); 2649 | }; 2650 | } 2651 | var Type = type; 2652 | var Schema = schema; 2653 | var FAILSAFE_SCHEMA = failsafe; 2654 | var JSON_SCHEMA = json; 2655 | var CORE_SCHEMA = core; 2656 | var DEFAULT_SCHEMA = _default; 2657 | var load = loader.load; 2658 | var loadAll = loader.loadAll; 2659 | var dump = dumper.dump; 2660 | var YAMLException = exception; 2661 | var types = { 2662 | binary, 2663 | float, 2664 | map, 2665 | null: _null, 2666 | pairs, 2667 | set, 2668 | timestamp, 2669 | bool, 2670 | int, 2671 | merge, 2672 | omap, 2673 | seq, 2674 | str 2675 | }; 2676 | var safeLoad = renamed("safeLoad", "load"); 2677 | var safeLoadAll = renamed("safeLoadAll", "loadAll"); 2678 | var safeDump = renamed("safeDump", "dump"); 2679 | var jsYaml = { 2680 | Type, 2681 | Schema, 2682 | FAILSAFE_SCHEMA, 2683 | JSON_SCHEMA, 2684 | CORE_SCHEMA, 2685 | DEFAULT_SCHEMA, 2686 | load, 2687 | loadAll, 2688 | dump, 2689 | YAMLException, 2690 | types, 2691 | safeLoad, 2692 | safeLoadAll, 2693 | safeDump 2694 | }; 2695 | var js_yaml_default = jsYaml; 2696 | 2697 | // src/worker.js 2698 | function parse_hysteria(outbounds_n) { 2699 | let server = findFieldValue(outbounds_n, "server") || ""; 2700 | if (server.startsWith("127.0.0.1") || server === "") { 2701 | return ""; 2702 | } 2703 | let port = findFieldValue(outbounds_n, "server_port") || findFieldValue(outbounds_n, "port"); 2704 | let upmbps_str = findFieldValue(outbounds_n, "up_mbps") || findFieldValue(outbounds_n, "up"); 2705 | let downmbps_str = findFieldValue(outbounds_n, "down_mbps") || findFieldValue(outbounds_n, "down"); 2706 | let upmbps = parseInt(String(upmbps_str).replace(/\D/g, ""), 10) || 0; 2707 | let downmbps = parseInt(String(downmbps_str).replace(/\D/g, ""), 10) || 0; 2708 | let obfsParam = findFieldValue(outbounds_n, "obfs") || ""; 2709 | let auth = findFieldValue(outbounds_n, "auth_str") || findFieldValue(outbounds_n, "auth-str"); 2710 | let peer = findFieldValue(outbounds_n, "server_name") || findFieldValue(outbounds_n, "sni") || ""; 2711 | let protocolValue = findFieldValue(outbounds_n, "protocol"); 2712 | let protocol = protocolValue !== "hysteria" ? protocolValue : ""; 2713 | let insecureFieldValue = findFieldValue(outbounds_n, "insecure"); 2714 | let insecure = [null, true].includes(insecureFieldValue) ? 1 : ""; 2715 | let alpnValue = findFieldValue(outbounds_n, "alpn"); 2716 | let alpn; 2717 | if (typeof alpnValue === "string") { 2718 | alpn = alpnValue; 2719 | } else { 2720 | alpn = alpnValue.length === 1 ? alpnValue[0].toString() : alpnValue.join(","); 2721 | } 2722 | let hysteriaDict = { 2723 | upmbps, 2724 | downmbps, 2725 | obfsParam, 2726 | auth, 2727 | protocol, 2728 | insecure, 2729 | peer, 2730 | alpn 2731 | }; 2732 | const filteredParams = Object.fromEntries( 2733 | Object.entries(hysteriaDict).filter(([key, value]) => value !== "" && value !== null && value !== void 0) 2734 | ); 2735 | const encodedParams = new URLSearchParams(filteredParams).toString(); 2736 | return `hysteria://${server}:${port}?${encodedParams}#[hysteria]_${server}:${port}`; 2737 | } 2738 | function parse_hy2(outbounds_n) { 2739 | let server = findFieldValue(outbounds_n, "server") || ""; 2740 | if (server.startsWith("127.0.0.1") || server === "") { 2741 | return ""; 2742 | } 2743 | let port = findFieldValue(outbounds_n, "port"); 2744 | let genericAddressRegex = /^(?!.*:\d+$)(?!\[.*\].*:\d+$)/; 2745 | if (genericAddressRegex.test(server)) { 2746 | server = `${server}:${port}`; 2747 | } 2748 | let password = findFieldValue(outbounds_n, "password") || findFieldValue(outbounds_n, "auth"); 2749 | let obfs = findFieldValue(outbounds_n, "obfs") || ""; 2750 | let obfs_password = findFieldValue(outbounds_n, "obfs-password") || ""; 2751 | let sni = findFieldValue(outbounds_n, "sni") || ""; 2752 | let up = findFieldValue(outbounds_n, "up") || "80"; 2753 | let down = findFieldValue(outbounds_n, "down") || "100"; 2754 | let upmbps = parseInt(String(up).replace(/\D/g, ""), 10) || 0; 2755 | let downmbps = parseInt(String(down).replace(/\D/g, ""), 10) || 0; 2756 | let insecureFieldValue = findFieldValue(outbounds_n, "insecure"); 2757 | let insecure = [null, true].includes(insecureFieldValue) ? 1 : ""; 2758 | let hy2Dict = { 2759 | upmbps, 2760 | downmbps, 2761 | obfs, 2762 | "obfs-password": obfs_password, 2763 | sni, 2764 | insecure 2765 | }; 2766 | const filteredParams = Object.fromEntries( 2767 | Object.entries(hy2Dict).filter(([key, value]) => value !== "" && value !== null && value !== void 0) 2768 | ); 2769 | const encodedParams = new URLSearchParams(filteredParams).toString(); 2770 | return `hy2://${password}@${server}?${encodedParams}#[hy2]_${server}`; 2771 | } 2772 | function parse_vle55(outbounds_n) { 2773 | let address = findFieldValue(outbounds_n, "address") || findFieldValue(outbounds_n, "server") || ""; 2774 | if (address === "127.0.0.1" || address === "") { 2775 | return ""; 2776 | } 2777 | let port = findFieldValue(outbounds_n, "port"); 2778 | let uuid = findFieldValue(outbounds_n, "id") || findFieldValue(outbounds_n, "uuid"); 2779 | let encryption = findFieldValue(outbounds_n, "encryption") || "none"; 2780 | let flow = findFieldValue(outbounds_n, "flow") || ""; 2781 | let network = findFieldValue(outbounds_n, "network"); 2782 | let host = findFieldValue(outbounds_n, "Host") || findFieldValue(outbounds_n, "host") || ""; 2783 | let path = findFieldValue(outbounds_n, "path") || ""; 2784 | let public_key = findFieldValue(outbounds_n, "public-key") || findFieldValue(outbounds_n, "publicKey") || ""; 2785 | let short_id = findFieldValue(outbounds_n, "short-id") || findFieldValue(outbounds_n, "shortId") || ""; 2786 | let serverName = findFieldValue(outbounds_n, "serverName") || findFieldValue(outbounds_n, "servername") || ""; 2787 | if (host === "" && serverName === "") { 2788 | host = address; 2789 | } else if (host === "" && serverName !== "") { 2790 | host = serverName; 2791 | } 2792 | let tls_security; 2793 | if (public_key !== "") { 2794 | tls_security = "reality"; 2795 | } else { 2796 | let tls = findFieldValue(outbounds_n.streamSettings, "security") || findFieldValue(outbounds_n, "tls") || ""; 2797 | if (tls === "none") { 2798 | tls_security = ""; 2799 | } else if (tls === true) { 2800 | tls_security = "tls"; 2801 | } else { 2802 | tls_security = ""; 2803 | } 2804 | } 2805 | if (tls_security === "" && network === "ws" && serverName !== "") { 2806 | tls_security = "tls"; 2807 | } 2808 | let fp = findFieldValue(outbounds_n, "fingerprint") || findFieldValue(outbounds_n, "client-fingerprint") || ""; 2809 | let vle55Dict = { 2810 | encryption, 2811 | // 加密方式 2812 | flow, 2813 | security: tls_security, 2814 | // 传输层安全(TLS) 2815 | sni: serverName, 2816 | fp, 2817 | pbk: public_key, 2818 | sid: short_id, 2819 | type: network, 2820 | // 传输协议(network) 2821 | host, 2822 | // 伪装域名(host) 2823 | path, 2824 | headerType: "" 2825 | // 伪装类型(type) 2826 | }; 2827 | const filteredParams = Object.fromEntries( 2828 | Object.entries(vle55Dict).filter(([key, value]) => value !== "" && value !== null && value !== void 0) 2829 | ); 2830 | const encodedParams = new URLSearchParams(filteredParams).toString(); 2831 | return `${base64Decode("dmxlc3M6Ly8")}${uuid}@${address}:${port}?${encodedParams}#[${base64Decode("dmxlc3M")}]_${address}:${port}`; 2832 | } 2833 | function parse_vme55(outbounds_n) { 2834 | let address = findFieldValue(outbounds_n, "address") || findFieldValue(outbounds_n, "server") || ""; 2835 | if (address === "127.0.0.1" || address === "") { 2836 | return ""; 2837 | } 2838 | let port = findFieldValue(outbounds_n, "port"); 2839 | let uuid = findFieldValue(outbounds_n, "id") || findFieldValue(outbounds_n, "uuid"); 2840 | let alterId = findFieldValue(outbounds_n, "alterId") || 0; 2841 | let auto_security = findFieldValue(outbounds_n, "cipher") || findFieldValue(outbounds_n.settings, "security") || "auto"; 2842 | let network = findFieldValue(outbounds_n, "network"); 2843 | let type_encryption = findFieldValue(outbounds_n, "encryption") || "none"; 2844 | let tls = findFieldValue(outbounds_n.streamSettings, "security") || findFieldValue(outbounds_n, "tls") || ""; 2845 | let tls_security = tls === true ? "tls" : tls; 2846 | let path = findFieldValue(outbounds_n, "path") || findFieldValue(outbounds_n, "ws-path") || findFieldValue(outbounds_n, "grpc-service-name") || "/"; 2847 | let host = findFieldValue(outbounds_n, "Host") || findFieldValue(outbounds_n, "host") || ""; 2848 | let serverName = findFieldValue(outbounds_n, "sni") || findFieldValue(outbounds_n, "serverName") || ""; 2849 | if (serverName === "" && host === "") { 2850 | host = address; 2851 | } 2852 | let fp = findFieldValue(outbounds_n, "client-fingerprint") || findFieldValue(outbounds_n, "fingerprint") || ""; 2853 | let vme55Dict = { 2854 | v: "2", 2855 | ps: `[${base64Decode("dm1lc3M")}]_${address}:${port}`, 2856 | add: address, 2857 | port, 2858 | id: uuid, 2859 | aid: alterId, 2860 | // 额外ID(alterId) 2861 | scy: auto_security, 2862 | // 加密方式(security) 2863 | net: network, 2864 | // 传输协议(network) 2865 | type: type_encryption, 2866 | // 伪装类型(type) 2867 | host, 2868 | // 伪装域名(host) 2869 | path, 2870 | // 路径 2871 | tls: tls_security, 2872 | // 传输层安全(TLS) 2873 | sni: serverName, 2874 | alpn: "", 2875 | fp 2876 | }; 2877 | const jsonString = JSON.stringify(vme55Dict); 2878 | const base64EncodedString = base64Encode(jsonString); 2879 | return `${base64Decode("dm1lc3M6Ly8")}${base64EncodedString}`; 2880 | } 2881 | function parse_shadowsocks(outbounds_n) { 2882 | let address = findFieldValue(outbounds_n, "address") || findFieldValue(outbounds_n, "server") || ""; 2883 | if (address === "127.0.0.1" || address === "") { 2884 | return ""; 2885 | } 2886 | let port = findFieldValue(outbounds_n, "port"); 2887 | let method = findFieldValue(outbounds_n, "method") || findFieldValue(outbounds_n, "cipher"); 2888 | let password = findFieldValue(outbounds_n, "password"); 2889 | let method_with_password = `${method}:${password}`; 2890 | let base64EncodedString = base64Encode(method_with_password); 2891 | return `${base64Decode("c3M6Ly8")}${base64EncodedString}@${address}:${port}#[ss]_${address}`; 2892 | } 2893 | function parse_tr0jan(outbounds_n) { 2894 | let server = findFieldValue(outbounds_n, "server") || ""; 2895 | if (server.startsWith("127.0.0.1") || server === "") { 2896 | return ""; 2897 | } 2898 | let port = findFieldValue(outbounds_n, "port"); 2899 | let password = findFieldValue(outbounds_n, "password"); 2900 | let network = findFieldValue(outbounds_n, "network") || "tcp"; 2901 | let path = findFieldValue(outbounds_n, "path") || ""; 2902 | let host = findFieldValue(outbounds_n, "Host") || findFieldValue(outbounds_n, "host") || ""; 2903 | let sni = findFieldValue(outbounds_n, "sni") || ""; 2904 | let fp = findFieldValue(outbounds_n, "client-fingerprint") || findFieldValue(outbounds_n, "fingerprint") || ""; 2905 | let alpn = findFieldValue(outbounds_n, "alpn") || ""; 2906 | let tls_security = ""; 2907 | if (sni) { 2908 | tls_security = "tls"; 2909 | } 2910 | let tr0janDict = { 2911 | security: tls_security, 2912 | allowInsecure: 1, 2913 | sni, 2914 | fp, 2915 | type: network, 2916 | host, 2917 | alpn, 2918 | path 2919 | }; 2920 | const filteredParams = Object.fromEntries( 2921 | Object.entries(tr0janDict).filter(([key, value]) => value !== "" && value !== null && value !== void 0) 2922 | ); 2923 | const encodedParams = new URLSearchParams(filteredParams).toString(); 2924 | return `${base64Decode("dHJvamFuOi8v")}${password}@${server}:${port}?${encodedParams}#[${base64Decode("dHJvamFu")}]_${server}`; 2925 | } 2926 | function parse_tuic(outbounds_n) { 2927 | let uuid = findFieldValue(outbounds_n, "uuid"); 2928 | let password = findFieldValue(outbounds_n, "password"); 2929 | let server = findFieldValue(outbounds_n, "server") || ""; 2930 | if (server === "127.0.0.1" || server === "") { 2931 | return ""; 2932 | } 2933 | let port = findFieldValue(outbounds_n, "port"); 2934 | let congestion_controller = findFieldValue(outbounds_n, "congestion-controller"); 2935 | let udp_relay_mode = findFieldValue(outbounds_n, "udp-relay-mode"); 2936 | let sni = findFieldValue(outbounds_n, "sni") || ""; 2937 | let alpnValue = findFieldValue(outbounds_n, "alpn"); 2938 | var alpn; 2939 | if (alpnValue.length === 1) { 2940 | alpn = alpnValue[0].toString(); 2941 | } else { 2942 | alpn = alpnValue.join(","); 2943 | } 2944 | let tuicDict = { 2945 | congestion_control: congestion_controller, 2946 | udp_relay_mode, 2947 | alpn, 2948 | sni, 2949 | allow_insecure: 1 2950 | }; 2951 | const filteredParams = Object.fromEntries( 2952 | Object.entries(tuicDict).filter(([key, value]) => value !== "" && value !== null && value !== void 0) 2953 | ); 2954 | const encodedParams = new URLSearchParams(filteredParams).toString(); 2955 | return `tuic://${uuid}:${password}@${server}:${port}?${encodedParams}#[tuic]_${server}`; 2956 | } 2957 | function isJuicity(jsonObject) { 2958 | let juicity_listen = findFieldValue(jsonObject, "listen"); 2959 | let juicity_server = findFieldValue(jsonObject, "server"); 2960 | let juicity_uuid = findFieldValue(jsonObject, "uuid"); 2961 | let juicity_password = findFieldValue(jsonObject, "password"); 2962 | let juicity_sni = findFieldValue(jsonObject, "sni"); 2963 | let juicity_allow_insecure = findFieldValue(jsonObject, "allow_insecure"); 2964 | let juicity_congestion_control = findFieldValue(jsonObject, "congestion_control"); 2965 | if (juicity_listen && juicity_server && juicity_uuid && juicity_password && juicity_sni && juicity_allow_insecure && juicity_congestion_control) { 2966 | return true; 2967 | } else { 2968 | return false; 2969 | } 2970 | } 2971 | function isMieru(jsonObject) { 2972 | let mieru_exist_profiles = Array.isArray(findFieldValue(jsonObject, "profiles")); 2973 | let mieru_exist_portBindings = Array.isArray(findFieldValue(jsonObject, "portBindings")); 2974 | let mieru_ipAddress = findFieldValue(jsonObject, "ipAddress"); 2975 | let mieru_rpcPort = findFieldValue(jsonObject, "rpcPort"); 2976 | let mieru_activeProfile = findFieldValue(jsonObject, "activeProfile"); 2977 | if (mieru_exist_profiles && mieru_exist_portBindings && mieru_ipAddress && mieru_rpcPort && mieru_activeProfile) { 2978 | return true; 2979 | } else { 2980 | return false; 2981 | } 2982 | } 2983 | function findFieldValue(obj, targetField) { 2984 | for (const key in obj) { 2985 | if (obj.hasOwnProperty(key)) { 2986 | if (key === targetField) { 2987 | return obj[key]; 2988 | } else if (typeof obj[key] === "object") { 2989 | const result = findFieldValue(obj[key], targetField); 2990 | if (result != void 0) { 2991 | return result; 2992 | } 2993 | } 2994 | } 2995 | } 2996 | return null; 2997 | } 2998 | async function fetchWebPageContent(url) { 2999 | try { 3000 | let response = await fetch(url); 3001 | if (!response.ok) { 3002 | throw new Error(`\u83B7\u53D6\u5931\u8D25: ${response.status}`); 3003 | } 3004 | let content = (await response.text()).replace(/!/g, ""); 3005 | return stripHtmlTags(content); 3006 | } catch (error) { 3007 | console.error(`\u83B7\u53D6${url} \u7F51\u9875\u5185\u5BB9\u5931\u8D25: ${error.message}`); 3008 | return {}; 3009 | } 3010 | } 3011 | function stripHtmlTags(str2) { 3012 | const entities = { 3013 | "<": "<", 3014 | ">": ">" 3015 | // ..... 3016 | }; 3017 | const regex = new RegExp( 3018 | "&(" + Object.keys(entities).map((e) => e.slice(1, -1)).join("|") + ");", 3019 | "g" 3020 | ); 3021 | let replaced = str2.replace(regex, (match) => entities[match]); 3022 | return replaced.replace(/<[^>]*>/g, ""); 3023 | } 3024 | async function fetchAndProcessUrl(url) { 3025 | const content = await fetchWebPageContent(url); 3026 | let jsonObject; 3027 | let outbounds; 3028 | try { 3029 | jsonObject = JSON.parse(content); 3030 | outbounds = findFieldValue(jsonObject, "outbounds"); 3031 | } catch (e) { 3032 | let links = v2rayLinksHandle(content); 3033 | if (links.length > 0) { 3034 | const uniqueSet = /* @__PURE__ */ new Set(); 3035 | let proxyPrefix = [ 3036 | "aHlzdGVyaWE6Ly8", 3037 | "aHkyOi8v", 3038 | "dmxlc3M6Ly8", 3039 | "dm1lc3M6Ly8", 3040 | "dHJvamFuOi8v", 3041 | "c3M6Ly8", 3042 | "dHVpYzovLw", 3043 | "bmFpdmUraHR0cHM6Ly8" 3044 | ]; 3045 | links.split("\n").forEach((link) => { 3046 | if (proxyPrefix.some((prefix) => link.startsWith(base64Decode(prefix)))) 3047 | uniqueSet.add(link); 3048 | }); 3049 | const uniqueArray = Array.from(uniqueSet); 3050 | return uniqueArray; 3051 | } else { 3052 | let yamlObject = js_yaml_default.load(content); 3053 | if (yamlObject && typeof yamlObject === "object") { 3054 | outbounds = findFieldValue(yamlObject, "proxies"); 3055 | } 3056 | } 3057 | } 3058 | if (outbounds === null && jsonObject) { 3059 | let is_mieru = isMieru(jsonObject); 3060 | if (is_mieru) 3061 | return ""; 3062 | let is_juicity = isJuicity(jsonObject); 3063 | if (is_juicity) 3064 | return ""; 3065 | let server = findFieldValue(jsonObject, "server")?.replace(/,.*$/, "") || ""; 3066 | let pwd_auth = findFieldValue(jsonObject, "auth"); 3067 | let sni = findFieldValue(jsonObject, "sni"); 3068 | let insecureFieldValue = findFieldValue(jsonObject, "insecure"); 3069 | let insecure = [null, true].includes(insecureFieldValue) ? 1 : ""; 3070 | let upmbps = findFieldValue(jsonObject, "up_mbps"); 3071 | let downmbps = findFieldValue(jsonObject, "down_mbps"); 3072 | let obfsParam = findFieldValue(jsonObject, "obfs") || ""; 3073 | let auth = findFieldValue(jsonObject, "auth_str") || ""; 3074 | let protocol = findFieldValue(jsonObject, "protocol") || ""; 3075 | let peer = findFieldValue(jsonObject, "server_name") || ""; 3076 | let alpn = findFieldValue(jsonObject, "alpn"); 3077 | let recv_window = findFieldValue(jsonObject, "recv_window") || ""; 3078 | let recv_window_conn = findFieldValue(jsonObject, "recv_window_conn") || ""; 3079 | let proxyFieldValue = findFieldValue(jsonObject, "proxy"); 3080 | const pattern = /^https:\/\/.*@.*$/; 3081 | const isMatch = pattern.test(proxyFieldValue); 3082 | if (server && pwd_auth) { 3083 | return `hy2://${pwd_auth}@${server}?insecure=${insecure}&sni=${sni}#[hy2]_${server}`; 3084 | } else if (server && auth && alpn && upmbps !== null && downmbps !== null) { 3085 | let hysteriaDict = { 3086 | upmbps, 3087 | downmbps, 3088 | obfs: "xplus", 3089 | obfsParam, 3090 | auth, 3091 | protocol, 3092 | insecure, 3093 | peer, 3094 | alpn, 3095 | recv_window, 3096 | recv_window_conn 3097 | }; 3098 | if (hysteriaDict["obfsParam"] === "") { 3099 | delete hysteriaDict["obfs"]; 3100 | } 3101 | const filteredParams = Object.fromEntries( 3102 | Object.entries(hysteriaDict).filter(([key, value]) => value !== "" && value !== null && value !== void 0) 3103 | ); 3104 | const encodedParams = new URLSearchParams(filteredParams).toString(); 3105 | return `${base64Decode("aHlzdGVyaWE6Ly8")}${server}?${encodedParams}#[hysteria]_${server}`; 3106 | } else if (proxyFieldValue && isMatch && typeof proxyFieldValue === "string") { 3107 | const colonIndex = proxyFieldValue.lastIndexOf(":"); 3108 | const atIndex = proxyFieldValue.lastIndexOf("@"); 3109 | const extractedContent = proxyFieldValue.substring(atIndex + 1, colonIndex); 3110 | return `naive+${proxyFieldValue}#[naive]_${extractedContent}`; 3111 | } 3112 | } else if (outbounds && Array.isArray(outbounds)) { 3113 | const uniqueSet = /* @__PURE__ */ new Set(); 3114 | let allProxyType = ["aHlzdGVyaWE", "aHky", "dmxlc3M", "dm1lc3M", "dHJvamFu", "c3M", "dHVpYw"]; 3115 | for (var i = 0; i < outbounds.length; i++) { 3116 | let proxyType = findFieldValue(outbounds[i], "protocol"); 3117 | if (!allProxyType.includes(proxyType)) { 3118 | proxyType = findFieldValue(outbounds[i], "type"); 3119 | } 3120 | if (proxyType === base64Decode("aHlzdGVyaWE")) { 3121 | let hy1 = parse_hysteria(outbounds[i]); 3122 | if (hy1) { 3123 | uniqueSet.add(hy1); 3124 | } 3125 | } else if (proxyType === base64Decode("aHky")) { 3126 | let hy2 = parse_hy2(outbounds[i]); 3127 | if (hy2) { 3128 | uniqueSet.add(hy2); 3129 | } 3130 | } else if (proxyType === base64Decode("c3M")) { 3131 | let ss = parse_shadowsocks(outbounds[i]); 3132 | if (ss) { 3133 | uniqueSet.add(ss); 3134 | } 3135 | } else if (proxyType === base64Decode("dmxlc3M")) { 3136 | let vle55 = parse_vle55(outbounds[i]); 3137 | if (vle55) { 3138 | uniqueSet.add(vle55); 3139 | } 3140 | } else if (proxyType === base64Decode("dm1lc3M")) { 3141 | let vme55 = parse_vme55(outbounds[i]); 3142 | if (vme55) { 3143 | uniqueSet.add(vme55); 3144 | } 3145 | } else if (proxyType === base64Decode("dHJvamFu")) { 3146 | let tr0jan = parse_tr0jan(outbounds[i]); 3147 | if (tr0jan) { 3148 | uniqueSet.add(tr0jan); 3149 | } 3150 | } else if (proxyType === base64Decode("dHVpYw")) { 3151 | let tuic = parse_tuic(outbounds[i]); 3152 | if (tuic) { 3153 | uniqueSet.add(tuic); 3154 | } 3155 | } 3156 | } 3157 | const uniqueArray = Array.from(uniqueSet); 3158 | return uniqueArray; 3159 | } 3160 | } 3161 | function base64Encode(str2) { 3162 | const encoder = new TextEncoder(); 3163 | const uint8Array = encoder.encode(str2); 3164 | const chunkSize = 32768; 3165 | let binary2 = ""; 3166 | for (let i = 0; i < uint8Array.length; i += chunkSize) { 3167 | const chunk = uint8Array.subarray(i, i + chunkSize); 3168 | binary2 += String.fromCharCode.apply(null, chunk); 3169 | } 3170 | return btoa(binary2); 3171 | } 3172 | function base64Decode(base64Str) { 3173 | let binary2 = atob(base64Str); 3174 | let bytes = new Uint8Array([...binary2].map((char) => char.charCodeAt(0))); 3175 | let decoder = new TextDecoder(); 3176 | return decoder.decode(bytes); 3177 | } 3178 | function isValidBase64(str2) { 3179 | if (typeof str2 !== "string") 3180 | return false; 3181 | str2 = str2.trim(); 3182 | if (str2 === "") 3183 | return false; 3184 | const base64Regex = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/; 3185 | if (!base64Regex.test(str2)) 3186 | return false; 3187 | if (str2.length % 4 !== 0) 3188 | return false; 3189 | try { 3190 | const binaryStr = atob(str2); 3191 | new Uint8Array([...binaryStr].map((c) => c.charCodeAt(0))); 3192 | return true; 3193 | } catch (e) { 3194 | return false; 3195 | } 3196 | } 3197 | function v2rayLinksHandle(str2) { 3198 | let isBase64Str = isValidBase64(str2); 3199 | let proxyPrefix = [ 3200 | "aHlzdGVyaWE6Ly8", 3201 | "aHkyOi8v", 3202 | "dmxlc3M6Ly8", 3203 | "dm1lc3M6Ly8", 3204 | "dHJvamFuOi8v", 3205 | "c3M6Ly8", 3206 | "dHVpYzovLw", 3207 | "bmFpdmUraHR0cHM6Ly8" 3208 | ]; 3209 | if (typeof str2 === "string" && !isBase64Str && proxyPrefix.some((prefix) => str2.includes(base64Decode(prefix)))) { 3210 | return str2; 3211 | } else if (!isBase64Str) { 3212 | return ""; 3213 | } 3214 | try { 3215 | return base64Decode(str2); 3216 | } catch (e) { 3217 | return ""; 3218 | } 3219 | } 3220 | var targetUrls = [ 3221 | // ChromeGo/EdgeGo的订阅链接(已剔除内容重复的订阅链接) 3222 | "https://fastly.jsdelivr.net/gh/Alvin9999/PAC@latest/backup/img/1/2/ipp/naiveproxy/2/config.json", 3223 | "https://fastly.jsdelivr.net/gh/Alvin9999/PAC@latest/backup/img/1/2/ipp/hysteria2/2/config.json", 3224 | "https://www.gitlabip.xyz/Alvin9999/PAC/master/backup/img/1/2/ipp/hysteria2/3/config.json", 3225 | "https://www.gitlabip.xyz/Alvin9999/PAC/master/backup/img/1/2/ipp/naiveproxy/1/config.json", 3226 | "https://fastly.jsdelivr.net/gh/Alvin9999/PAC@latest/backup/img/1/2/ipp/xray/2/config.json", 3227 | "https://fastly.jsdelivr.net/gh/Alvin9999/PAC@latest/backup/img/1/2/ipp/xray/4/config.json", 3228 | "https://fastly.jsdelivr.net/gh/Alvin9999/PAC@latest/backup/img/1/2/ip/singbox/2/config.json", 3229 | "https://www.gitlabip.xyz/Alvin9999/PAC/master/backup/img/1/2/ipp/singbox/1/config.json", 3230 | "https://fastly.jsdelivr.net/gh/Alvin9999/PAC@latest/backup/img/1/2/ipp/hysteria/2/config.json", 3231 | "https://www.gitlabip.xyz/Alvin9999/PAC/master/backup/img/1/2/ipp/hysteria/3/config.json", 3232 | "https://www.gitlabip.xyz/Alvin9999/PAC/master/backup/img/1/2/ipp/hysteria/1/config.json", 3233 | "https://gitlab.com/free9999/ipupdate/-/raw/master/backup/img/1/2/ipp/hysteria/3/config.json", 3234 | "https://gitlab.com/free9999/ipupdate/-/raw/master/backup/img/1/2/ip/singbox/config.json", 3235 | "https://gitlab.com/free9999/ipupdate/-/raw/master/hysteria/2/config.json", 3236 | "https://gitlab.com/free9999/ipupdate/-/raw/master/hysteria2/2/config.json", 3237 | "https://www.gitlabip.xyz/Alvin9999/PAC/master/backup/img/1/2/ipp/clash.meta2/5/config.yaml", 3238 | "https://fastly.jsdelivr.net/gh/Alvin9999/PAC@latest/backup/img/1/2/ipp/clash.meta2/4/config.yaml", 3239 | "https://www.gitlabip.xyz/Alvin9999/PAC/master/backup/img/1/2/ipp/clash.meta2/1/config.yaml", 3240 | // 'https://fastly.jsdelivr.net/gh/jsvpn/jsproxy@dev/yule/20200325/1299699.md', 3241 | "https://www.gitlabip.xyz/Alvin9999/PAC/master/backup/img/1/2/ip/clash.meta2/1/config.yaml", 3242 | "https://fastly.jsdelivr.net/gh/Alvin9999/pac2@latest/quick/config.yaml", 3243 | "https://fastly.jsdelivr.net/gh/Alvin9999/pac2@latest/quick/4/config.yaml", 3244 | // 也可以添加其它来源且数据格式为json或yaml的订阅链接 3245 | "https://raw.githubusercontent.com/aiboboxx/clashfree/main/clash.yml", 3246 | // 可以添加明文v2ray分享链接的订阅或base64订阅链接 3247 | "https://raw.githubusercontent.com/aiboboxx/v2rayfree/main/v2", 3248 | "https://ghfast.top/https://raw.githubusercontent.com/free18/v2ray/refs/heads/main/v.txt" 3249 | ]; 3250 | async function processUrls(targetUrls2) { 3251 | const results = []; 3252 | const maxConcurrency = 3; 3253 | const asyncPool = async (poolLimit, array, iteratorFn) => { 3254 | const results2 = []; 3255 | const executing = []; 3256 | for (const item of array) { 3257 | const promise = Promise.resolve().then(() => iteratorFn(item)); 3258 | results2.push(promise); 3259 | if (executing.length < poolLimit) { 3260 | const executingPromise = promise.then(() => executing.splice(executing.indexOf(executingPromise), 1)); 3261 | executing.push(executingPromise); 3262 | } else { 3263 | await Promise.race(executing); 3264 | } 3265 | } 3266 | return Promise.all(results2); 3267 | }; 3268 | await asyncPool(maxConcurrency, targetUrls2, async (url) => { 3269 | const link = await fetchAndProcessUrl(url); 3270 | if (Array.isArray(link)) { 3271 | link.forEach((item) => { 3272 | if (!results.includes(item)) { 3273 | results.push(item); 3274 | } 3275 | }); 3276 | } else if (link && !results.includes(link)) { 3277 | results.push(link); 3278 | } 3279 | }); 3280 | return results; 3281 | } 3282 | var worker_default = { 3283 | async fetch(request, env, ctx) { 3284 | try { 3285 | let resultsArray = await processUrls(targetUrls); 3286 | let uniqueStrings = [...new Set(resultsArray)]; 3287 | let sortedArray = uniqueStrings.sort((a, b) => { 3288 | const compareByLetters = a.localeCompare(b); 3289 | if (compareByLetters === 0) { 3290 | const numA = parseInt(a, 10) || 0; 3291 | const numB = parseInt(b, 10) || 0; 3292 | const compareByNumbers = numA - numB; 3293 | if (compareByNumbers === 0) { 3294 | return a.length - b.length; 3295 | } 3296 | return compareByNumbers; 3297 | } 3298 | return compareByLetters; 3299 | }); 3300 | let resultString = sortedArray.join("\n"); 3301 | let base64String = base64Encode(resultString); 3302 | return new Response(base64String, { 3303 | status: 200, 3304 | headers: { 3305 | "Content-Type": "text/plain; charset=UTF-8" 3306 | } 3307 | }); 3308 | } catch (error) { 3309 | console.error(`Error in fetch function: ${error.message}`); 3310 | return new Response(`Error fetching web page: ${error.message}`, { 3311 | status: 500 3312 | }); 3313 | } 3314 | } 3315 | }; 3316 | export { 3317 | worker_default as default 3318 | }; 3319 | /*! Bundled license information: 3320 | 3321 | js-yaml/dist/js-yaml.mjs: 3322 | (*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT *) 3323 | */ 3324 | //# sourceMappingURL=worker.js.map 3325 | -------------------------------------------------------------------------------- /images/FortiGuard Intrusion Prevention - Access Blocked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juerson/config_to_sub/1e7712cc32d643f6a59d81635643618680697418/images/FortiGuard Intrusion Prevention - Access Blocked.png -------------------------------------------------------------------------------- /images/转换示意.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juerson/config_to_sub/1e7712cc32d643f6a59d81635643618680697418/images/转换示意.png -------------------------------------------------------------------------------- /images/错误1102.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juerson/config_to_sub/1e7712cc32d643f6a59d81635643618680697418/images/错误1102.png -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "worker-bitter-boat-a8af", 3 | "version": "0.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "worker-bitter-boat-a8af", 9 | "version": "0.0.0", 10 | "dependencies": { 11 | "js-yaml": "^4.1.0" 12 | }, 13 | "devDependencies": { 14 | "wrangler": "^3.25.0" 15 | } 16 | }, 17 | "node_modules/@cloudflare/kv-asset-handler": { 18 | "version": "0.2.0", 19 | "resolved": "https://registry.npmjs.org/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.2.0.tgz", 20 | "integrity": "sha512-MVbXLbTcAotOPUj0pAMhVtJ+3/kFkwJqc5qNOleOZTv6QkZZABDMS21dSrSlVswEHwrpWC03e4fWytjqKvuE2A==", 21 | "dev": true, 22 | "dependencies": { 23 | "mime": "^3.0.0" 24 | } 25 | }, 26 | "node_modules/@cloudflare/workerd-darwin-64": { 27 | "version": "1.20231218.0", 28 | "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20231218.0.tgz", 29 | "integrity": "sha512-547gOmTIVmRdDy7HNAGJUPELa+fSDm2Y0OCxqAtQOz0GLTDu1vX61xYmsb2rn91+v3xW6eMttEIpbYokKjtfJA==", 30 | "cpu": [ 31 | "x64" 32 | ], 33 | "dev": true, 34 | "optional": true, 35 | "os": [ 36 | "darwin" 37 | ], 38 | "engines": { 39 | "node": ">=16" 40 | } 41 | }, 42 | "node_modules/@cloudflare/workerd-darwin-arm64": { 43 | "version": "1.20231218.0", 44 | "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20231218.0.tgz", 45 | "integrity": "sha512-b39qrU1bKolCfmKFDAnX4vXcqzISkEUVE/V8sMBsFzxrIpNAbcUHBZAQPYmS/OHIGB94KjOVokvDi7J6UNurPw==", 46 | "cpu": [ 47 | "arm64" 48 | ], 49 | "dev": true, 50 | "optional": true, 51 | "os": [ 52 | "darwin" 53 | ], 54 | "engines": { 55 | "node": ">=16" 56 | } 57 | }, 58 | "node_modules/@cloudflare/workerd-linux-64": { 59 | "version": "1.20231218.0", 60 | "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20231218.0.tgz", 61 | "integrity": "sha512-dMUF1wA+0mybm6hHNOCgY/WMNMwomPPs4I7vvYCgwHSkch0Q2Wb7TnxQZSt8d1PK/myibaBwadrlIxpjxmpz3w==", 62 | "cpu": [ 63 | "x64" 64 | ], 65 | "dev": true, 66 | "optional": true, 67 | "os": [ 68 | "linux" 69 | ], 70 | "engines": { 71 | "node": ">=16" 72 | } 73 | }, 74 | "node_modules/@cloudflare/workerd-linux-arm64": { 75 | "version": "1.20231218.0", 76 | "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20231218.0.tgz", 77 | "integrity": "sha512-2s5uc8IHt0QmWyKxAr1Fy+4b8Xy0b/oUtlPnm5MrKi2gDRlZzR7JvxENPJCpCnYENydS8lzvkMiAFECPBccmyQ==", 78 | "cpu": [ 79 | "arm64" 80 | ], 81 | "dev": true, 82 | "optional": true, 83 | "os": [ 84 | "linux" 85 | ], 86 | "engines": { 87 | "node": ">=16" 88 | } 89 | }, 90 | "node_modules/@cloudflare/workerd-windows-64": { 91 | "version": "1.20231218.0", 92 | "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20231218.0.tgz", 93 | "integrity": "sha512-oN5hz6TXUDB5YKUN5N3QWAv6cYz9JjTZ9g16HVyoegVFEL6/zXU3tV19MBX2IvlE11ab/mRogEv9KXVIrHfKmA==", 94 | "cpu": [ 95 | "x64" 96 | ], 97 | "dev": true, 98 | "optional": true, 99 | "os": [ 100 | "win32" 101 | ], 102 | "engines": { 103 | "node": ">=16" 104 | } 105 | }, 106 | "node_modules/@cspotcode/source-map-support": { 107 | "version": "0.8.1", 108 | "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", 109 | "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", 110 | "dev": true, 111 | "dependencies": { 112 | "@jridgewell/trace-mapping": "0.3.9" 113 | }, 114 | "engines": { 115 | "node": ">=12" 116 | } 117 | }, 118 | "node_modules/@esbuild-plugins/node-globals-polyfill": { 119 | "version": "0.2.3", 120 | "resolved": "https://registry.npmjs.org/@esbuild-plugins/node-globals-polyfill/-/node-globals-polyfill-0.2.3.tgz", 121 | "integrity": "sha512-r3MIryXDeXDOZh7ih1l/yE9ZLORCd5e8vWg02azWRGj5SPTuoh69A2AIyn0Z31V/kHBfZ4HgWJ+OK3GTTwLmnw==", 122 | "dev": true, 123 | "peerDependencies": { 124 | "esbuild": "*" 125 | } 126 | }, 127 | "node_modules/@esbuild-plugins/node-modules-polyfill": { 128 | "version": "0.2.2", 129 | "resolved": "https://registry.npmjs.org/@esbuild-plugins/node-modules-polyfill/-/node-modules-polyfill-0.2.2.tgz", 130 | "integrity": "sha512-LXV7QsWJxRuMYvKbiznh+U1ilIop3g2TeKRzUxOG5X3YITc8JyyTa90BmLwqqv0YnX4v32CSlG+vsziZp9dMvA==", 131 | "dev": true, 132 | "dependencies": { 133 | "escape-string-regexp": "^4.0.0", 134 | "rollup-plugin-node-polyfills": "^0.2.1" 135 | }, 136 | "peerDependencies": { 137 | "esbuild": "*" 138 | } 139 | }, 140 | "node_modules/@esbuild/android-arm": { 141 | "version": "0.17.19", 142 | "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.19.tgz", 143 | "integrity": "sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==", 144 | "cpu": [ 145 | "arm" 146 | ], 147 | "dev": true, 148 | "optional": true, 149 | "os": [ 150 | "android" 151 | ], 152 | "engines": { 153 | "node": ">=12" 154 | } 155 | }, 156 | "node_modules/@esbuild/android-arm64": { 157 | "version": "0.17.19", 158 | "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz", 159 | "integrity": "sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==", 160 | "cpu": [ 161 | "arm64" 162 | ], 163 | "dev": true, 164 | "optional": true, 165 | "os": [ 166 | "android" 167 | ], 168 | "engines": { 169 | "node": ">=12" 170 | } 171 | }, 172 | "node_modules/@esbuild/android-x64": { 173 | "version": "0.17.19", 174 | "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.19.tgz", 175 | "integrity": "sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==", 176 | "cpu": [ 177 | "x64" 178 | ], 179 | "dev": true, 180 | "optional": true, 181 | "os": [ 182 | "android" 183 | ], 184 | "engines": { 185 | "node": ">=12" 186 | } 187 | }, 188 | "node_modules/@esbuild/darwin-arm64": { 189 | "version": "0.17.19", 190 | "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz", 191 | "integrity": "sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==", 192 | "cpu": [ 193 | "arm64" 194 | ], 195 | "dev": true, 196 | "optional": true, 197 | "os": [ 198 | "darwin" 199 | ], 200 | "engines": { 201 | "node": ">=12" 202 | } 203 | }, 204 | "node_modules/@esbuild/darwin-x64": { 205 | "version": "0.17.19", 206 | "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz", 207 | "integrity": "sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw==", 208 | "cpu": [ 209 | "x64" 210 | ], 211 | "dev": true, 212 | "optional": true, 213 | "os": [ 214 | "darwin" 215 | ], 216 | "engines": { 217 | "node": ">=12" 218 | } 219 | }, 220 | "node_modules/@esbuild/freebsd-arm64": { 221 | "version": "0.17.19", 222 | "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz", 223 | "integrity": "sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==", 224 | "cpu": [ 225 | "arm64" 226 | ], 227 | "dev": true, 228 | "optional": true, 229 | "os": [ 230 | "freebsd" 231 | ], 232 | "engines": { 233 | "node": ">=12" 234 | } 235 | }, 236 | "node_modules/@esbuild/freebsd-x64": { 237 | "version": "0.17.19", 238 | "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz", 239 | "integrity": "sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==", 240 | "cpu": [ 241 | "x64" 242 | ], 243 | "dev": true, 244 | "optional": true, 245 | "os": [ 246 | "freebsd" 247 | ], 248 | "engines": { 249 | "node": ">=12" 250 | } 251 | }, 252 | "node_modules/@esbuild/linux-arm": { 253 | "version": "0.17.19", 254 | "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz", 255 | "integrity": "sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==", 256 | "cpu": [ 257 | "arm" 258 | ], 259 | "dev": true, 260 | "optional": true, 261 | "os": [ 262 | "linux" 263 | ], 264 | "engines": { 265 | "node": ">=12" 266 | } 267 | }, 268 | "node_modules/@esbuild/linux-arm64": { 269 | "version": "0.17.19", 270 | "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz", 271 | "integrity": "sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==", 272 | "cpu": [ 273 | "arm64" 274 | ], 275 | "dev": true, 276 | "optional": true, 277 | "os": [ 278 | "linux" 279 | ], 280 | "engines": { 281 | "node": ">=12" 282 | } 283 | }, 284 | "node_modules/@esbuild/linux-ia32": { 285 | "version": "0.17.19", 286 | "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz", 287 | "integrity": "sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==", 288 | "cpu": [ 289 | "ia32" 290 | ], 291 | "dev": true, 292 | "optional": true, 293 | "os": [ 294 | "linux" 295 | ], 296 | "engines": { 297 | "node": ">=12" 298 | } 299 | }, 300 | "node_modules/@esbuild/linux-loong64": { 301 | "version": "0.17.19", 302 | "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz", 303 | "integrity": "sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==", 304 | "cpu": [ 305 | "loong64" 306 | ], 307 | "dev": true, 308 | "optional": true, 309 | "os": [ 310 | "linux" 311 | ], 312 | "engines": { 313 | "node": ">=12" 314 | } 315 | }, 316 | "node_modules/@esbuild/linux-mips64el": { 317 | "version": "0.17.19", 318 | "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz", 319 | "integrity": "sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==", 320 | "cpu": [ 321 | "mips64el" 322 | ], 323 | "dev": true, 324 | "optional": true, 325 | "os": [ 326 | "linux" 327 | ], 328 | "engines": { 329 | "node": ">=12" 330 | } 331 | }, 332 | "node_modules/@esbuild/linux-ppc64": { 333 | "version": "0.17.19", 334 | "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz", 335 | "integrity": "sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==", 336 | "cpu": [ 337 | "ppc64" 338 | ], 339 | "dev": true, 340 | "optional": true, 341 | "os": [ 342 | "linux" 343 | ], 344 | "engines": { 345 | "node": ">=12" 346 | } 347 | }, 348 | "node_modules/@esbuild/linux-riscv64": { 349 | "version": "0.17.19", 350 | "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz", 351 | "integrity": "sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==", 352 | "cpu": [ 353 | "riscv64" 354 | ], 355 | "dev": true, 356 | "optional": true, 357 | "os": [ 358 | "linux" 359 | ], 360 | "engines": { 361 | "node": ">=12" 362 | } 363 | }, 364 | "node_modules/@esbuild/linux-s390x": { 365 | "version": "0.17.19", 366 | "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz", 367 | "integrity": "sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==", 368 | "cpu": [ 369 | "s390x" 370 | ], 371 | "dev": true, 372 | "optional": true, 373 | "os": [ 374 | "linux" 375 | ], 376 | "engines": { 377 | "node": ">=12" 378 | } 379 | }, 380 | "node_modules/@esbuild/linux-x64": { 381 | "version": "0.17.19", 382 | "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz", 383 | "integrity": "sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw==", 384 | "cpu": [ 385 | "x64" 386 | ], 387 | "dev": true, 388 | "optional": true, 389 | "os": [ 390 | "linux" 391 | ], 392 | "engines": { 393 | "node": ">=12" 394 | } 395 | }, 396 | "node_modules/@esbuild/netbsd-x64": { 397 | "version": "0.17.19", 398 | "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz", 399 | "integrity": "sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==", 400 | "cpu": [ 401 | "x64" 402 | ], 403 | "dev": true, 404 | "optional": true, 405 | "os": [ 406 | "netbsd" 407 | ], 408 | "engines": { 409 | "node": ">=12" 410 | } 411 | }, 412 | "node_modules/@esbuild/openbsd-x64": { 413 | "version": "0.17.19", 414 | "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz", 415 | "integrity": "sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==", 416 | "cpu": [ 417 | "x64" 418 | ], 419 | "dev": true, 420 | "optional": true, 421 | "os": [ 422 | "openbsd" 423 | ], 424 | "engines": { 425 | "node": ">=12" 426 | } 427 | }, 428 | "node_modules/@esbuild/sunos-x64": { 429 | "version": "0.17.19", 430 | "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz", 431 | "integrity": "sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==", 432 | "cpu": [ 433 | "x64" 434 | ], 435 | "dev": true, 436 | "optional": true, 437 | "os": [ 438 | "sunos" 439 | ], 440 | "engines": { 441 | "node": ">=12" 442 | } 443 | }, 444 | "node_modules/@esbuild/win32-arm64": { 445 | "version": "0.17.19", 446 | "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz", 447 | "integrity": "sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==", 448 | "cpu": [ 449 | "arm64" 450 | ], 451 | "dev": true, 452 | "optional": true, 453 | "os": [ 454 | "win32" 455 | ], 456 | "engines": { 457 | "node": ">=12" 458 | } 459 | }, 460 | "node_modules/@esbuild/win32-ia32": { 461 | "version": "0.17.19", 462 | "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz", 463 | "integrity": "sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==", 464 | "cpu": [ 465 | "ia32" 466 | ], 467 | "dev": true, 468 | "optional": true, 469 | "os": [ 470 | "win32" 471 | ], 472 | "engines": { 473 | "node": ">=12" 474 | } 475 | }, 476 | "node_modules/@esbuild/win32-x64": { 477 | "version": "0.17.19", 478 | "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz", 479 | "integrity": "sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==", 480 | "cpu": [ 481 | "x64" 482 | ], 483 | "dev": true, 484 | "optional": true, 485 | "os": [ 486 | "win32" 487 | ], 488 | "engines": { 489 | "node": ">=12" 490 | } 491 | }, 492 | "node_modules/@fastify/busboy": { 493 | "version": "2.1.0", 494 | "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.0.tgz", 495 | "integrity": "sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==", 496 | "dev": true, 497 | "engines": { 498 | "node": ">=14" 499 | } 500 | }, 501 | "node_modules/@jridgewell/resolve-uri": { 502 | "version": "3.1.1", 503 | "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", 504 | "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", 505 | "dev": true, 506 | "engines": { 507 | "node": ">=6.0.0" 508 | } 509 | }, 510 | "node_modules/@jridgewell/sourcemap-codec": { 511 | "version": "1.4.15", 512 | "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", 513 | "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", 514 | "dev": true 515 | }, 516 | "node_modules/@jridgewell/trace-mapping": { 517 | "version": "0.3.9", 518 | "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", 519 | "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", 520 | "dev": true, 521 | "dependencies": { 522 | "@jridgewell/resolve-uri": "^3.0.3", 523 | "@jridgewell/sourcemap-codec": "^1.4.10" 524 | } 525 | }, 526 | "node_modules/@types/node": { 527 | "version": "20.11.6", 528 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.6.tgz", 529 | "integrity": "sha512-+EOokTnksGVgip2PbYbr3xnR7kZigh4LbybAfBAw5BpnQ+FqBYUsvCEjYd70IXKlbohQ64mzEYmMtlWUY8q//Q==", 530 | "dev": true, 531 | "dependencies": { 532 | "undici-types": "~5.26.4" 533 | } 534 | }, 535 | "node_modules/@types/node-forge": { 536 | "version": "1.3.11", 537 | "resolved": "https://registry.npmjs.org/@types/node-forge/-/node-forge-1.3.11.tgz", 538 | "integrity": "sha512-FQx220y22OKNTqaByeBGqHWYz4cl94tpcxeFdvBo3wjG6XPBuZ0BNgNZRV5J5TFmmcsJ4IzsLkmGRiQbnYsBEQ==", 539 | "dev": true, 540 | "dependencies": { 541 | "@types/node": "*" 542 | } 543 | }, 544 | "node_modules/acorn": { 545 | "version": "8.11.3", 546 | "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", 547 | "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", 548 | "dev": true, 549 | "bin": { 550 | "acorn": "bin/acorn" 551 | }, 552 | "engines": { 553 | "node": ">=0.4.0" 554 | } 555 | }, 556 | "node_modules/acorn-walk": { 557 | "version": "8.3.2", 558 | "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz", 559 | "integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==", 560 | "dev": true, 561 | "engines": { 562 | "node": ">=0.4.0" 563 | } 564 | }, 565 | "node_modules/anymatch": { 566 | "version": "3.1.3", 567 | "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", 568 | "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", 569 | "dev": true, 570 | "dependencies": { 571 | "normalize-path": "^3.0.0", 572 | "picomatch": "^2.0.4" 573 | }, 574 | "engines": { 575 | "node": ">= 8" 576 | } 577 | }, 578 | "node_modules/argparse": { 579 | "version": "2.0.1", 580 | "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", 581 | "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" 582 | }, 583 | "node_modules/as-table": { 584 | "version": "1.0.55", 585 | "resolved": "https://registry.npmjs.org/as-table/-/as-table-1.0.55.tgz", 586 | "integrity": "sha512-xvsWESUJn0JN421Xb9MQw6AsMHRCUknCe0Wjlxvjud80mU4E6hQf1A6NzQKcYNmYw62MfzEtXc+badstZP3JpQ==", 587 | "dev": true, 588 | "dependencies": { 589 | "printable-characters": "^1.0.42" 590 | } 591 | }, 592 | "node_modules/binary-extensions": { 593 | "version": "2.2.0", 594 | "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", 595 | "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", 596 | "dev": true, 597 | "engines": { 598 | "node": ">=8" 599 | } 600 | }, 601 | "node_modules/blake3-wasm": { 602 | "version": "2.1.5", 603 | "resolved": "https://registry.npmjs.org/blake3-wasm/-/blake3-wasm-2.1.5.tgz", 604 | "integrity": "sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g==", 605 | "dev": true 606 | }, 607 | "node_modules/braces": { 608 | "version": "3.0.2", 609 | "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", 610 | "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", 611 | "dev": true, 612 | "dependencies": { 613 | "fill-range": "^7.0.1" 614 | }, 615 | "engines": { 616 | "node": ">=8" 617 | } 618 | }, 619 | "node_modules/capnp-ts": { 620 | "version": "0.7.0", 621 | "resolved": "https://registry.npmjs.org/capnp-ts/-/capnp-ts-0.7.0.tgz", 622 | "integrity": "sha512-XKxXAC3HVPv7r674zP0VC3RTXz+/JKhfyw94ljvF80yynK6VkTnqE3jMuN8b3dUVmmc43TjyxjW4KTsmB3c86g==", 623 | "dev": true, 624 | "dependencies": { 625 | "debug": "^4.3.1", 626 | "tslib": "^2.2.0" 627 | } 628 | }, 629 | "node_modules/chokidar": { 630 | "version": "3.5.3", 631 | "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", 632 | "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", 633 | "dev": true, 634 | "funding": [ 635 | { 636 | "type": "individual", 637 | "url": "https://paulmillr.com/funding/" 638 | } 639 | ], 640 | "dependencies": { 641 | "anymatch": "~3.1.2", 642 | "braces": "~3.0.2", 643 | "glob-parent": "~5.1.2", 644 | "is-binary-path": "~2.1.0", 645 | "is-glob": "~4.0.1", 646 | "normalize-path": "~3.0.0", 647 | "readdirp": "~3.6.0" 648 | }, 649 | "engines": { 650 | "node": ">= 8.10.0" 651 | }, 652 | "optionalDependencies": { 653 | "fsevents": "~2.3.2" 654 | } 655 | }, 656 | "node_modules/cookie": { 657 | "version": "0.5.0", 658 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", 659 | "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", 660 | "dev": true, 661 | "engines": { 662 | "node": ">= 0.6" 663 | } 664 | }, 665 | "node_modules/data-uri-to-buffer": { 666 | "version": "2.0.2", 667 | "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-2.0.2.tgz", 668 | "integrity": "sha512-ND9qDTLc6diwj+Xe5cdAgVTbLVdXbtxTJRXRhli8Mowuaan+0EJOtdqJ0QCHNSSPyoXGx9HX2/VMnKeC34AChA==", 669 | "dev": true 670 | }, 671 | "node_modules/debug": { 672 | "version": "4.3.4", 673 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", 674 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", 675 | "dev": true, 676 | "dependencies": { 677 | "ms": "2.1.2" 678 | }, 679 | "engines": { 680 | "node": ">=6.0" 681 | }, 682 | "peerDependenciesMeta": { 683 | "supports-color": { 684 | "optional": true 685 | } 686 | } 687 | }, 688 | "node_modules/esbuild": { 689 | "version": "0.17.19", 690 | "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.19.tgz", 691 | "integrity": "sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw==", 692 | "dev": true, 693 | "hasInstallScript": true, 694 | "bin": { 695 | "esbuild": "bin/esbuild" 696 | }, 697 | "engines": { 698 | "node": ">=12" 699 | }, 700 | "optionalDependencies": { 701 | "@esbuild/android-arm": "0.17.19", 702 | "@esbuild/android-arm64": "0.17.19", 703 | "@esbuild/android-x64": "0.17.19", 704 | "@esbuild/darwin-arm64": "0.17.19", 705 | "@esbuild/darwin-x64": "0.17.19", 706 | "@esbuild/freebsd-arm64": "0.17.19", 707 | "@esbuild/freebsd-x64": "0.17.19", 708 | "@esbuild/linux-arm": "0.17.19", 709 | "@esbuild/linux-arm64": "0.17.19", 710 | "@esbuild/linux-ia32": "0.17.19", 711 | "@esbuild/linux-loong64": "0.17.19", 712 | "@esbuild/linux-mips64el": "0.17.19", 713 | "@esbuild/linux-ppc64": "0.17.19", 714 | "@esbuild/linux-riscv64": "0.17.19", 715 | "@esbuild/linux-s390x": "0.17.19", 716 | "@esbuild/linux-x64": "0.17.19", 717 | "@esbuild/netbsd-x64": "0.17.19", 718 | "@esbuild/openbsd-x64": "0.17.19", 719 | "@esbuild/sunos-x64": "0.17.19", 720 | "@esbuild/win32-arm64": "0.17.19", 721 | "@esbuild/win32-ia32": "0.17.19", 722 | "@esbuild/win32-x64": "0.17.19" 723 | } 724 | }, 725 | "node_modules/escape-string-regexp": { 726 | "version": "4.0.0", 727 | "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", 728 | "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", 729 | "dev": true, 730 | "engines": { 731 | "node": ">=10" 732 | }, 733 | "funding": { 734 | "url": "https://github.com/sponsors/sindresorhus" 735 | } 736 | }, 737 | "node_modules/estree-walker": { 738 | "version": "0.6.1", 739 | "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", 740 | "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", 741 | "dev": true 742 | }, 743 | "node_modules/exit-hook": { 744 | "version": "2.2.1", 745 | "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-2.2.1.tgz", 746 | "integrity": "sha512-eNTPlAD67BmP31LDINZ3U7HSF8l57TxOY2PmBJ1shpCvpnxBF93mWCE8YHBnXs8qiUZJc9WDcWIeC3a2HIAMfw==", 747 | "dev": true, 748 | "engines": { 749 | "node": ">=6" 750 | }, 751 | "funding": { 752 | "url": "https://github.com/sponsors/sindresorhus" 753 | } 754 | }, 755 | "node_modules/fill-range": { 756 | "version": "7.0.1", 757 | "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", 758 | "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", 759 | "dev": true, 760 | "dependencies": { 761 | "to-regex-range": "^5.0.1" 762 | }, 763 | "engines": { 764 | "node": ">=8" 765 | } 766 | }, 767 | "node_modules/fsevents": { 768 | "version": "2.3.3", 769 | "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", 770 | "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", 771 | "dev": true, 772 | "hasInstallScript": true, 773 | "optional": true, 774 | "os": [ 775 | "darwin" 776 | ], 777 | "engines": { 778 | "node": "^8.16.0 || ^10.6.0 || >=11.0.0" 779 | } 780 | }, 781 | "node_modules/function-bind": { 782 | "version": "1.1.2", 783 | "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", 784 | "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", 785 | "dev": true, 786 | "funding": { 787 | "url": "https://github.com/sponsors/ljharb" 788 | } 789 | }, 790 | "node_modules/get-source": { 791 | "version": "2.0.12", 792 | "resolved": "https://registry.npmjs.org/get-source/-/get-source-2.0.12.tgz", 793 | "integrity": "sha512-X5+4+iD+HoSeEED+uwrQ07BOQr0kEDFMVqqpBuI+RaZBpBpHCuXxo70bjar6f0b0u/DQJsJ7ssurpP0V60Az+w==", 794 | "dev": true, 795 | "dependencies": { 796 | "data-uri-to-buffer": "^2.0.0", 797 | "source-map": "^0.6.1" 798 | } 799 | }, 800 | "node_modules/glob-parent": { 801 | "version": "5.1.2", 802 | "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", 803 | "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", 804 | "dev": true, 805 | "dependencies": { 806 | "is-glob": "^4.0.1" 807 | }, 808 | "engines": { 809 | "node": ">= 6" 810 | } 811 | }, 812 | "node_modules/glob-to-regexp": { 813 | "version": "0.4.1", 814 | "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", 815 | "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==", 816 | "dev": true 817 | }, 818 | "node_modules/hasown": { 819 | "version": "2.0.0", 820 | "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", 821 | "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", 822 | "dev": true, 823 | "dependencies": { 824 | "function-bind": "^1.1.2" 825 | }, 826 | "engines": { 827 | "node": ">= 0.4" 828 | } 829 | }, 830 | "node_modules/is-binary-path": { 831 | "version": "2.1.0", 832 | "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", 833 | "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", 834 | "dev": true, 835 | "dependencies": { 836 | "binary-extensions": "^2.0.0" 837 | }, 838 | "engines": { 839 | "node": ">=8" 840 | } 841 | }, 842 | "node_modules/is-core-module": { 843 | "version": "2.13.1", 844 | "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz", 845 | "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==", 846 | "dev": true, 847 | "dependencies": { 848 | "hasown": "^2.0.0" 849 | }, 850 | "funding": { 851 | "url": "https://github.com/sponsors/ljharb" 852 | } 853 | }, 854 | "node_modules/is-extglob": { 855 | "version": "2.1.1", 856 | "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", 857 | "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", 858 | "dev": true, 859 | "engines": { 860 | "node": ">=0.10.0" 861 | } 862 | }, 863 | "node_modules/is-glob": { 864 | "version": "4.0.3", 865 | "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", 866 | "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", 867 | "dev": true, 868 | "dependencies": { 869 | "is-extglob": "^2.1.1" 870 | }, 871 | "engines": { 872 | "node": ">=0.10.0" 873 | } 874 | }, 875 | "node_modules/is-number": { 876 | "version": "7.0.0", 877 | "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", 878 | "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", 879 | "dev": true, 880 | "engines": { 881 | "node": ">=0.12.0" 882 | } 883 | }, 884 | "node_modules/js-yaml": { 885 | "version": "4.1.0", 886 | "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", 887 | "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", 888 | "dependencies": { 889 | "argparse": "^2.0.1" 890 | }, 891 | "bin": { 892 | "js-yaml": "bin/js-yaml.js" 893 | } 894 | }, 895 | "node_modules/magic-string": { 896 | "version": "0.25.9", 897 | "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz", 898 | "integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==", 899 | "dev": true, 900 | "dependencies": { 901 | "sourcemap-codec": "^1.4.8" 902 | } 903 | }, 904 | "node_modules/mime": { 905 | "version": "3.0.0", 906 | "resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz", 907 | "integrity": "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==", 908 | "dev": true, 909 | "bin": { 910 | "mime": "cli.js" 911 | }, 912 | "engines": { 913 | "node": ">=10.0.0" 914 | } 915 | }, 916 | "node_modules/miniflare": { 917 | "version": "3.20231218.4", 918 | "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-3.20231218.4.tgz", 919 | "integrity": "sha512-2mpxvDiRBxGGGVnTKC0SZy0FtTXxFs3tM1ol67EoIJABGzvWFf33GThwh+/dRmaHSjKKId/FI8rEl5JxXXXZgQ==", 920 | "dev": true, 921 | "dependencies": { 922 | "@cspotcode/source-map-support": "0.8.1", 923 | "acorn": "^8.8.0", 924 | "acorn-walk": "^8.2.0", 925 | "capnp-ts": "^0.7.0", 926 | "exit-hook": "^2.2.1", 927 | "glob-to-regexp": "^0.4.1", 928 | "stoppable": "^1.1.0", 929 | "undici": "^5.28.2", 930 | "workerd": "1.20231218.0", 931 | "ws": "^8.11.0", 932 | "youch": "^3.2.2", 933 | "zod": "^3.20.6" 934 | }, 935 | "bin": { 936 | "miniflare": "bootstrap.js" 937 | }, 938 | "engines": { 939 | "node": ">=16.13" 940 | } 941 | }, 942 | "node_modules/ms": { 943 | "version": "2.1.2", 944 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 945 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", 946 | "dev": true 947 | }, 948 | "node_modules/mustache": { 949 | "version": "4.2.0", 950 | "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz", 951 | "integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==", 952 | "dev": true, 953 | "bin": { 954 | "mustache": "bin/mustache" 955 | } 956 | }, 957 | "node_modules/nanoid": { 958 | "version": "3.3.7", 959 | "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", 960 | "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", 961 | "dev": true, 962 | "funding": [ 963 | { 964 | "type": "github", 965 | "url": "https://github.com/sponsors/ai" 966 | } 967 | ], 968 | "bin": { 969 | "nanoid": "bin/nanoid.cjs" 970 | }, 971 | "engines": { 972 | "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" 973 | } 974 | }, 975 | "node_modules/node-forge": { 976 | "version": "1.3.1", 977 | "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", 978 | "integrity": "sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==", 979 | "dev": true, 980 | "engines": { 981 | "node": ">= 6.13.0" 982 | } 983 | }, 984 | "node_modules/normalize-path": { 985 | "version": "3.0.0", 986 | "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", 987 | "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", 988 | "dev": true, 989 | "engines": { 990 | "node": ">=0.10.0" 991 | } 992 | }, 993 | "node_modules/path-parse": { 994 | "version": "1.0.7", 995 | "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", 996 | "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", 997 | "dev": true 998 | }, 999 | "node_modules/path-to-regexp": { 1000 | "version": "6.2.1", 1001 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.1.tgz", 1002 | "integrity": "sha512-JLyh7xT1kizaEvcaXOQwOc2/Yhw6KZOvPf1S8401UyLk86CU79LN3vl7ztXGm/pZ+YjoyAJ4rxmHwbkBXJX+yw==", 1003 | "dev": true 1004 | }, 1005 | "node_modules/picomatch": { 1006 | "version": "2.3.1", 1007 | "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", 1008 | "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", 1009 | "dev": true, 1010 | "engines": { 1011 | "node": ">=8.6" 1012 | }, 1013 | "funding": { 1014 | "url": "https://github.com/sponsors/jonschlinkert" 1015 | } 1016 | }, 1017 | "node_modules/printable-characters": { 1018 | "version": "1.0.42", 1019 | "resolved": "https://registry.npmjs.org/printable-characters/-/printable-characters-1.0.42.tgz", 1020 | "integrity": "sha512-dKp+C4iXWK4vVYZmYSd0KBH5F/h1HoZRsbJ82AVKRO3PEo8L4lBS/vLwhVtpwwuYcoIsVY+1JYKR268yn480uQ==", 1021 | "dev": true 1022 | }, 1023 | "node_modules/readdirp": { 1024 | "version": "3.6.0", 1025 | "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", 1026 | "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", 1027 | "dev": true, 1028 | "dependencies": { 1029 | "picomatch": "^2.2.1" 1030 | }, 1031 | "engines": { 1032 | "node": ">=8.10.0" 1033 | } 1034 | }, 1035 | "node_modules/resolve": { 1036 | "version": "1.22.8", 1037 | "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", 1038 | "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", 1039 | "dev": true, 1040 | "dependencies": { 1041 | "is-core-module": "^2.13.0", 1042 | "path-parse": "^1.0.7", 1043 | "supports-preserve-symlinks-flag": "^1.0.0" 1044 | }, 1045 | "bin": { 1046 | "resolve": "bin/resolve" 1047 | }, 1048 | "funding": { 1049 | "url": "https://github.com/sponsors/ljharb" 1050 | } 1051 | }, 1052 | "node_modules/resolve.exports": { 1053 | "version": "2.0.2", 1054 | "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.2.tgz", 1055 | "integrity": "sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==", 1056 | "dev": true, 1057 | "engines": { 1058 | "node": ">=10" 1059 | } 1060 | }, 1061 | "node_modules/rollup-plugin-inject": { 1062 | "version": "3.0.2", 1063 | "resolved": "https://registry.npmjs.org/rollup-plugin-inject/-/rollup-plugin-inject-3.0.2.tgz", 1064 | "integrity": "sha512-ptg9PQwzs3orn4jkgXJ74bfs5vYz1NCZlSQMBUA0wKcGp5i5pA1AO3fOUEte8enhGUC+iapTCzEWw2jEFFUO/w==", 1065 | "deprecated": "This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.", 1066 | "dev": true, 1067 | "dependencies": { 1068 | "estree-walker": "^0.6.1", 1069 | "magic-string": "^0.25.3", 1070 | "rollup-pluginutils": "^2.8.1" 1071 | } 1072 | }, 1073 | "node_modules/rollup-plugin-node-polyfills": { 1074 | "version": "0.2.1", 1075 | "resolved": "https://registry.npmjs.org/rollup-plugin-node-polyfills/-/rollup-plugin-node-polyfills-0.2.1.tgz", 1076 | "integrity": "sha512-4kCrKPTJ6sK4/gLL/U5QzVT8cxJcofO0OU74tnB19F40cmuAKSzH5/siithxlofFEjwvw1YAhPmbvGNA6jEroA==", 1077 | "dev": true, 1078 | "dependencies": { 1079 | "rollup-plugin-inject": "^3.0.0" 1080 | } 1081 | }, 1082 | "node_modules/rollup-pluginutils": { 1083 | "version": "2.8.2", 1084 | "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", 1085 | "integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==", 1086 | "dev": true, 1087 | "dependencies": { 1088 | "estree-walker": "^0.6.1" 1089 | } 1090 | }, 1091 | "node_modules/selfsigned": { 1092 | "version": "2.4.1", 1093 | "resolved": "https://registry.npmjs.org/selfsigned/-/selfsigned-2.4.1.tgz", 1094 | "integrity": "sha512-th5B4L2U+eGLq1TVh7zNRGBapioSORUeymIydxgFpwww9d2qyKvtuPU2jJuHvYAwwqi2Y596QBL3eEqcPEYL8Q==", 1095 | "dev": true, 1096 | "dependencies": { 1097 | "@types/node-forge": "^1.3.0", 1098 | "node-forge": "^1" 1099 | }, 1100 | "engines": { 1101 | "node": ">=10" 1102 | } 1103 | }, 1104 | "node_modules/source-map": { 1105 | "version": "0.6.1", 1106 | "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", 1107 | "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", 1108 | "dev": true, 1109 | "engines": { 1110 | "node": ">=0.10.0" 1111 | } 1112 | }, 1113 | "node_modules/sourcemap-codec": { 1114 | "version": "1.4.8", 1115 | "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", 1116 | "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", 1117 | "deprecated": "Please use @jridgewell/sourcemap-codec instead", 1118 | "dev": true 1119 | }, 1120 | "node_modules/stacktracey": { 1121 | "version": "2.1.8", 1122 | "resolved": "https://registry.npmjs.org/stacktracey/-/stacktracey-2.1.8.tgz", 1123 | "integrity": "sha512-Kpij9riA+UNg7TnphqjH7/CzctQ/owJGNbFkfEeve4Z4uxT5+JapVLFXcsurIfN34gnTWZNJ/f7NMG0E8JDzTw==", 1124 | "dev": true, 1125 | "dependencies": { 1126 | "as-table": "^1.0.36", 1127 | "get-source": "^2.0.12" 1128 | } 1129 | }, 1130 | "node_modules/stoppable": { 1131 | "version": "1.1.0", 1132 | "resolved": "https://registry.npmjs.org/stoppable/-/stoppable-1.1.0.tgz", 1133 | "integrity": "sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==", 1134 | "dev": true, 1135 | "engines": { 1136 | "node": ">=4", 1137 | "npm": ">=6" 1138 | } 1139 | }, 1140 | "node_modules/supports-preserve-symlinks-flag": { 1141 | "version": "1.0.0", 1142 | "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", 1143 | "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", 1144 | "dev": true, 1145 | "engines": { 1146 | "node": ">= 0.4" 1147 | }, 1148 | "funding": { 1149 | "url": "https://github.com/sponsors/ljharb" 1150 | } 1151 | }, 1152 | "node_modules/to-regex-range": { 1153 | "version": "5.0.1", 1154 | "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", 1155 | "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", 1156 | "dev": true, 1157 | "dependencies": { 1158 | "is-number": "^7.0.0" 1159 | }, 1160 | "engines": { 1161 | "node": ">=8.0" 1162 | } 1163 | }, 1164 | "node_modules/tslib": { 1165 | "version": "2.6.2", 1166 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", 1167 | "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", 1168 | "dev": true 1169 | }, 1170 | "node_modules/undici": { 1171 | "version": "5.28.2", 1172 | "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.2.tgz", 1173 | "integrity": "sha512-wh1pHJHnUeQV5Xa8/kyQhO7WFa8M34l026L5P/+2TYiakvGy5Rdc8jWZVyG7ieht/0WgJLEd3kcU5gKx+6GC8w==", 1174 | "dev": true, 1175 | "dependencies": { 1176 | "@fastify/busboy": "^2.0.0" 1177 | }, 1178 | "engines": { 1179 | "node": ">=14.0" 1180 | } 1181 | }, 1182 | "node_modules/undici-types": { 1183 | "version": "5.26.5", 1184 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", 1185 | "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", 1186 | "dev": true 1187 | }, 1188 | "node_modules/workerd": { 1189 | "version": "1.20231218.0", 1190 | "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20231218.0.tgz", 1191 | "integrity": "sha512-AGIsDvqCrcwhoA9kb1hxOhVAe53/xJeaGZxL4FbYI9FvO17DZwrnqGq+6eqItJ6Cfw1ZLmf3BM+QdMWaL2bFWQ==", 1192 | "dev": true, 1193 | "hasInstallScript": true, 1194 | "bin": { 1195 | "workerd": "bin/workerd" 1196 | }, 1197 | "engines": { 1198 | "node": ">=16" 1199 | }, 1200 | "optionalDependencies": { 1201 | "@cloudflare/workerd-darwin-64": "1.20231218.0", 1202 | "@cloudflare/workerd-darwin-arm64": "1.20231218.0", 1203 | "@cloudflare/workerd-linux-64": "1.20231218.0", 1204 | "@cloudflare/workerd-linux-arm64": "1.20231218.0", 1205 | "@cloudflare/workerd-windows-64": "1.20231218.0" 1206 | } 1207 | }, 1208 | "node_modules/wrangler": { 1209 | "version": "3.25.0", 1210 | "resolved": "https://registry.npmjs.org/wrangler/-/wrangler-3.25.0.tgz", 1211 | "integrity": "sha512-eU47Ez1QLu1B/wutm5ow+VwZnY4OqA+D/iy6BORAu5tABujoDr9p1yBxY/1DS/DxxDWqqY3sBBS6TzcC4NSLUQ==", 1212 | "dev": true, 1213 | "dependencies": { 1214 | "@cloudflare/kv-asset-handler": "^0.2.0", 1215 | "@esbuild-plugins/node-globals-polyfill": "^0.2.3", 1216 | "@esbuild-plugins/node-modules-polyfill": "^0.2.2", 1217 | "blake3-wasm": "^2.1.5", 1218 | "chokidar": "^3.5.3", 1219 | "esbuild": "0.17.19", 1220 | "miniflare": "3.20231218.4", 1221 | "nanoid": "^3.3.3", 1222 | "path-to-regexp": "^6.2.0", 1223 | "resolve": "^1.22.8", 1224 | "resolve.exports": "^2.0.2", 1225 | "selfsigned": "^2.0.1", 1226 | "source-map": "0.6.1", 1227 | "xxhash-wasm": "^1.0.1" 1228 | }, 1229 | "bin": { 1230 | "wrangler": "bin/wrangler.js", 1231 | "wrangler2": "bin/wrangler.js" 1232 | }, 1233 | "engines": { 1234 | "node": ">=16.17.0" 1235 | }, 1236 | "optionalDependencies": { 1237 | "fsevents": "~2.3.2" 1238 | } 1239 | }, 1240 | "node_modules/ws": { 1241 | "version": "8.16.0", 1242 | "resolved": "https://registry.npmjs.org/ws/-/ws-8.16.0.tgz", 1243 | "integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==", 1244 | "dev": true, 1245 | "engines": { 1246 | "node": ">=10.0.0" 1247 | }, 1248 | "peerDependencies": { 1249 | "bufferutil": "^4.0.1", 1250 | "utf-8-validate": ">=5.0.2" 1251 | }, 1252 | "peerDependenciesMeta": { 1253 | "bufferutil": { 1254 | "optional": true 1255 | }, 1256 | "utf-8-validate": { 1257 | "optional": true 1258 | } 1259 | } 1260 | }, 1261 | "node_modules/xxhash-wasm": { 1262 | "version": "1.0.2", 1263 | "resolved": "https://registry.npmjs.org/xxhash-wasm/-/xxhash-wasm-1.0.2.tgz", 1264 | "integrity": "sha512-ibF0Or+FivM9lNrg+HGJfVX8WJqgo+kCLDc4vx6xMeTce7Aj+DLttKbxxRR/gNLSAelRc1omAPlJ77N/Jem07A==", 1265 | "dev": true 1266 | }, 1267 | "node_modules/youch": { 1268 | "version": "3.3.3", 1269 | "resolved": "https://registry.npmjs.org/youch/-/youch-3.3.3.tgz", 1270 | "integrity": "sha512-qSFXUk3UZBLfggAW3dJKg0BMblG5biqSF8M34E06o5CSsZtH92u9Hqmj2RzGiHDi64fhe83+4tENFP2DB6t6ZA==", 1271 | "dev": true, 1272 | "dependencies": { 1273 | "cookie": "^0.5.0", 1274 | "mustache": "^4.2.0", 1275 | "stacktracey": "^2.1.8" 1276 | } 1277 | }, 1278 | "node_modules/zod": { 1279 | "version": "3.22.4", 1280 | "resolved": "https://registry.npmjs.org/zod/-/zod-3.22.4.tgz", 1281 | "integrity": "sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==", 1282 | "dev": true, 1283 | "funding": { 1284 | "url": "https://github.com/sponsors/colinhacks" 1285 | } 1286 | } 1287 | } 1288 | } 1289 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "worker-bitter-boat-a8af", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "deploy": "wrangler deploy", 7 | "dev": "wrangler dev", 8 | "start": "wrangler dev" 9 | }, 10 | "devDependencies": { 11 | "wrangler": "^3.25.0" 12 | }, 13 | "dependencies": { 14 | "js-yaml": "^4.1.0" 15 | } 16 | } -------------------------------------------------------------------------------- /src/worker.js: -------------------------------------------------------------------------------- 1 | import yaml from 'js-yaml'; // npm install js-yaml 2 | 3 | // ----------------------------------------- 解析和构建 hysteria 节点 --------------------------------------- 4 | 5 | function parse_hysteria(outbounds_n) { 6 | let server = findFieldValue(outbounds_n, 'server') || ''; 7 | if (server.startsWith('127.0.0.1') || server === '') { 8 | return ''; 9 | } 10 | let port = findFieldValue(outbounds_n, 'server_port') || findFieldValue(outbounds_n, 'port'); 11 | 12 | let upmbps_str = findFieldValue(outbounds_n, 'up_mbps') || findFieldValue(outbounds_n, 'up'); 13 | let downmbps_str = findFieldValue(outbounds_n, 'down_mbps') || findFieldValue(outbounds_n, 'down'); 14 | // 提取字符串中的数字,然后转换为数字类型 15 | let upmbps = parseInt(String(upmbps_str).replace(/\D/g, ''), 10) || 0; // 上传速度 16 | let downmbps = parseInt(String(downmbps_str).replace(/\D/g, ''), 10) || 0; // 下载速度 17 | let obfsParam = findFieldValue(outbounds_n, 'obfs') || ''; // 混淆密码 18 | let auth = findFieldValue(outbounds_n, 'auth_str') || findFieldValue(outbounds_n, 'auth-str'); // 认证有效载荷 19 | let peer = findFieldValue(outbounds_n, 'server_name') || findFieldValue(outbounds_n, 'sni') || ''; // SNI 20 | 21 | let protocolValue = findFieldValue(outbounds_n, 'protocol'); 22 | let protocol = protocolValue !== 'hysteria' ? protocolValue : ''; 23 | 24 | let insecureFieldValue = findFieldValue(outbounds_n, 'insecure'); 25 | let insecure = [null, true].includes(insecureFieldValue) ? 1 : ''; 26 | 27 | let alpnValue = findFieldValue(outbounds_n, 'alpn'); 28 | let alpn; 29 | if (typeof alpnValue === 'string') { 30 | alpn = alpnValue; 31 | } else { 32 | alpn = alpnValue.length === 1 ? alpnValue[0].toString() : alpnValue.join(','); 33 | } 34 | 35 | let hysteriaDict = { 36 | upmbps: upmbps, 37 | downmbps: downmbps, 38 | obfsParam: obfsParam, 39 | auth: auth, 40 | protocol: protocol, 41 | insecure: insecure, 42 | peer: peer, 43 | alpn: alpn, 44 | }; 45 | // 过滤掉值为空的键值对 46 | const filteredParams = Object.fromEntries( 47 | Object.entries(hysteriaDict).filter(([key, value]) => value !== '' && value !== null && value !== undefined) 48 | ); 49 | // 进行 URL 参数编码 50 | const encodedParams = new URLSearchParams(filteredParams).toString(); 51 | 52 | return `hysteria://${server}:${port}?${encodedParams}#[hysteria]_${server}:${port}`; 53 | } 54 | 55 | // ------------------------------------------ 解析和构建 hy2 节点 ------------------------------------------- 56 | 57 | function parse_hy2(outbounds_n) { 58 | let server = findFieldValue(outbounds_n, 'server') || ''; 59 | if (server.startsWith('127.0.0.1') || server === '') { 60 | return ''; 61 | } 62 | let port = findFieldValue(outbounds_n, 'port'); 63 | 64 | // 排除"domain:port"、"ipv4:port" 或 "ipv6:port" 这三种情况地址的正则表达式 65 | let genericAddressRegex = /^(?!.*:\d+$)(?!\[.*\].*:\d+$)/; 66 | if (genericAddressRegex.test(server)) { 67 | server = `${server}:${port}`; 68 | } 69 | 70 | let password = findFieldValue(outbounds_n, 'password') || findFieldValue(outbounds_n, 'auth'); 71 | let obfs = findFieldValue(outbounds_n, 'obfs') || ''; 72 | let obfs_password = findFieldValue(outbounds_n, 'obfs-password') || ''; 73 | let sni = findFieldValue(outbounds_n, 'sni') || ''; 74 | 75 | let up = findFieldValue(outbounds_n, 'up') || '80'; 76 | let down = findFieldValue(outbounds_n, 'down') || '100'; 77 | // 提取字符串中的数字,然后转换为数字类型 78 | let upmbps = parseInt(String(up).replace(/\D/g, ''), 10) || 0; 79 | let downmbps = parseInt(String(down).replace(/\D/g, ''), 10) || 0; 80 | 81 | let insecureFieldValue = findFieldValue(outbounds_n, 'insecure'); 82 | let insecure = [null, true].includes(insecureFieldValue) ? 1 : ''; 83 | 84 | let hy2Dict = { 85 | upmbps: upmbps, 86 | downmbps: downmbps, 87 | obfs: obfs, 88 | 'obfs-password': obfs_password, 89 | sni: sni, 90 | insecure: insecure, 91 | }; 92 | 93 | // 过滤掉值为空的键值对 94 | const filteredParams = Object.fromEntries( 95 | Object.entries(hy2Dict).filter(([key, value]) => value !== '' && value !== null && value !== undefined) 96 | ); 97 | // 进行 URL 参数编码 98 | const encodedParams = new URLSearchParams(filteredParams).toString(); 99 | 100 | return `hy2://${password}@${server}?${encodedParams}#[hy2]_${server}`; 101 | } 102 | 103 | // ----------------------------------------- 解析和构建 vless 节点 ------------------------------------------ 104 | 105 | function parse_vle55(outbounds_n) { 106 | let address = findFieldValue(outbounds_n, 'address') || findFieldValue(outbounds_n, 'server') || ''; 107 | if (address === '127.0.0.1' || address === '') { 108 | return ''; 109 | } 110 | let port = findFieldValue(outbounds_n, 'port'); 111 | let uuid = findFieldValue(outbounds_n, 'id') || findFieldValue(outbounds_n, 'uuid'); 112 | let encryption = findFieldValue(outbounds_n, 'encryption') || 'none'; // 加密方式 113 | let flow = findFieldValue(outbounds_n, 'flow') || ''; 114 | let network = findFieldValue(outbounds_n, 'network'); 115 | let host = findFieldValue(outbounds_n, 'Host') || findFieldValue(outbounds_n, 'host') || ''; 116 | let path = findFieldValue(outbounds_n, 'path') || ''; 117 | // 目前发现publicKey和shortId是reality独有 118 | let public_key = findFieldValue(outbounds_n, 'public-key') || findFieldValue(outbounds_n, 'publicKey') || ''; 119 | let short_id = findFieldValue(outbounds_n, 'short-id') || findFieldValue(outbounds_n, 'shortId') || ''; 120 | // sni 121 | let serverName = findFieldValue(outbounds_n, 'serverName') || findFieldValue(outbounds_n, 'servername') || ''; 122 | if (host === '' && serverName === '') { 123 | host = address; 124 | } else if (host === '' && serverName !== '') { 125 | host = serverName; 126 | } 127 | // 传输层安全(TLS) 128 | let tls_security; 129 | if (public_key !== '') { 130 | tls_security = 'reality'; 131 | } else { 132 | let tls = findFieldValue(outbounds_n.streamSettings, 'security') || findFieldValue(outbounds_n, 'tls') || ''; 133 | if (tls === 'none') { 134 | tls_security = ''; 135 | } else if (tls === true) { 136 | tls_security = 'tls'; 137 | } else { 138 | tls_security = ''; 139 | } 140 | } 141 | if (tls_security === '' && network === 'ws' && serverName !== '') { 142 | tls_security = 'tls'; 143 | } 144 | let fp = findFieldValue(outbounds_n, 'fingerprint') || findFieldValue(outbounds_n, 'client-fingerprint') || ''; 145 | let vle55Dict = { 146 | encryption: encryption, // 加密方式 147 | flow: flow, 148 | security: tls_security, // 传输层安全(TLS) 149 | sni: serverName, 150 | fp: fp, 151 | pbk: public_key, 152 | sid: short_id, 153 | type: network, // 传输协议(network) 154 | host: host, // 伪装域名(host) 155 | path: path, 156 | headerType: '', // 伪装类型(type) 157 | }; 158 | 159 | // 过滤掉值为空的键值对 160 | const filteredParams = Object.fromEntries( 161 | Object.entries(vle55Dict).filter(([key, value]) => value !== '' && value !== null && value !== undefined) 162 | ); 163 | // 进行 URL 参数编码 164 | const encodedParams = new URLSearchParams(filteredParams).toString(); 165 | 166 | return `${base64Decode('dmxlc3M6Ly8')}${uuid}@${address}:${port}?${encodedParams}#[${base64Decode('dmxlc3M')}]_${address}:${port}`; 167 | } 168 | 169 | // ----------------------------------------- 解析和构建 vmess 节点 ------------------------------------------ 170 | 171 | function parse_vme55(outbounds_n) { 172 | let address = findFieldValue(outbounds_n, 'address') || findFieldValue(outbounds_n, 'server') || ''; 173 | if (address === '127.0.0.1' || address === '') { 174 | return ''; 175 | } 176 | let port = findFieldValue(outbounds_n, 'port'); 177 | let uuid = findFieldValue(outbounds_n, 'id') || findFieldValue(outbounds_n, 'uuid'); 178 | let alterId = findFieldValue(outbounds_n, 'alterId') || 0; 179 | 180 | // 加密方式(security) 181 | let auto_security = findFieldValue(outbounds_n, 'cipher') || findFieldValue(outbounds_n.settings, 'security') || 'auto'; 182 | 183 | // 传输协议(network) 184 | let network = findFieldValue(outbounds_n, 'network'); 185 | // 伪装类型(type) 186 | let type_encryption = findFieldValue(outbounds_n, 'encryption') || 'none'; 187 | 188 | // 传输层安全(TLS) 189 | let tls = findFieldValue(outbounds_n.streamSettings, 'security') || findFieldValue(outbounds_n, 'tls') || ''; 190 | let tls_security = tls === true ? 'tls' || '' : tls; 191 | 192 | let path = 193 | findFieldValue(outbounds_n, 'path') || 194 | findFieldValue(outbounds_n, 'ws-path') || 195 | findFieldValue(outbounds_n, 'grpc-service-name') || 196 | '/'; 197 | // 伪装域名(host) 198 | let host = findFieldValue(outbounds_n, 'Host') || findFieldValue(outbounds_n, 'host') || ''; 199 | let serverName = findFieldValue(outbounds_n, 'sni') || findFieldValue(outbounds_n, 'serverName') || ''; 200 | if (serverName === '' && host === '') { 201 | host = address; 202 | } 203 | let fp = findFieldValue(outbounds_n, 'client-fingerprint') || findFieldValue(outbounds_n, 'fingerprint') || ''; 204 | let vme55Dict = { 205 | v: '2', 206 | ps: `[${base64Decode('dm1lc3M')}]_${address}:${port}`, 207 | add: address, 208 | port: port, 209 | id: uuid, 210 | aid: alterId, // 额外ID(alterId) 211 | scy: auto_security, // 加密方式(security) 212 | net: network, // 传输协议(network) 213 | type: type_encryption, // 伪装类型(type) 214 | host: host, // 伪装域名(host) 215 | path: path, // 路径 216 | tls: tls_security, // 传输层安全(TLS) 217 | sni: serverName, 218 | alpn: '', 219 | fp: fp, 220 | }; 221 | // 将对象转换为 JSON 字符串(方便后面进行base64编码) 222 | const jsonString = JSON.stringify(vme55Dict); 223 | 224 | const base64EncodedString = base64Encode(jsonString); 225 | 226 | return `${base64Decode('dm1lc3M6Ly8')}${base64EncodedString}`; 227 | } 228 | 229 | // -------------------------------------- 解析和构建 shadowsocks 节点 --------------------------------------- 230 | 231 | function parse_shadowsocks(outbounds_n) { 232 | let address = findFieldValue(outbounds_n, 'address') || findFieldValue(outbounds_n, 'server') || ''; 233 | if (address === '127.0.0.1' || address === '') { 234 | return ''; 235 | } 236 | 237 | let port = findFieldValue(outbounds_n, 'port'); 238 | let method = findFieldValue(outbounds_n, 'method') || findFieldValue(outbounds_n, 'cipher'); 239 | let password = findFieldValue(outbounds_n, 'password'); 240 | let method_with_password = `${method}:${password}`; 241 | let base64EncodedString = base64Encode(method_with_password); 242 | 243 | return `${base64Decode('c3M6Ly8')}${base64EncodedString}@${address}:${port}#[ss]_${address}`; 244 | } 245 | 246 | // ----------------------------------------- 解析和构建 trojan 节点 ----------------------------------------- 247 | 248 | function parse_tr0jan(outbounds_n) { 249 | let server = findFieldValue(outbounds_n, 'server') || ''; 250 | if (server.startsWith('127.0.0.1') || server === '') { 251 | return ''; 252 | } 253 | let port = findFieldValue(outbounds_n, 'port'); 254 | let password = findFieldValue(outbounds_n, 'password'); 255 | let network = findFieldValue(outbounds_n, 'network') || 'tcp'; 256 | let path = findFieldValue(outbounds_n, 'path') || ''; 257 | let host = findFieldValue(outbounds_n, 'Host') || findFieldValue(outbounds_n, 'host') || ''; 258 | let sni = findFieldValue(outbounds_n, 'sni') || ''; 259 | let fp = findFieldValue(outbounds_n, 'client-fingerprint') || findFieldValue(outbounds_n, 'fingerprint') || ''; 260 | let alpn = findFieldValue(outbounds_n, 'alpn') || ''; // 没有确定字段是否这个名字 261 | let tls_security = ''; 262 | if (sni) { 263 | tls_security = 'tls'; 264 | } 265 | 266 | let tr0janDict = { 267 | security: tls_security, 268 | allowInsecure: 1, 269 | sni: sni, 270 | fp: fp, 271 | type: network, 272 | host: host, 273 | alpn: alpn, 274 | path: path, 275 | }; 276 | 277 | // 过滤掉值为空的键值对 278 | const filteredParams = Object.fromEntries( 279 | Object.entries(tr0janDict).filter(([key, value]) => value !== '' && value !== null && value !== undefined) 280 | ); 281 | // 进行 URL 参数编码 282 | const encodedParams = new URLSearchParams(filteredParams).toString(); 283 | 284 | return `${base64Decode('dHJvamFuOi8v')}${password}@${server}:${port}?${encodedParams}#[${base64Decode('dHJvamFu')}]_${server}`; 285 | } 286 | 287 | // ------------------------------------------ 解析和构建 tuic 节点 ------------------------------------------ 288 | 289 | function parse_tuic(outbounds_n) { 290 | let uuid = findFieldValue(outbounds_n, 'uuid'); 291 | let password = findFieldValue(outbounds_n, 'password'); 292 | let server = findFieldValue(outbounds_n, 'server') || ''; 293 | if (server === '127.0.0.1' || server === '') { 294 | return ''; 295 | } 296 | let port = findFieldValue(outbounds_n, 'port'); 297 | let congestion_controller = findFieldValue(outbounds_n, 'congestion-controller'); 298 | let udp_relay_mode = findFieldValue(outbounds_n, 'udp-relay-mode'); 299 | let sni = findFieldValue(outbounds_n, 'sni') || ''; 300 | let alpnValue = findFieldValue(outbounds_n, 'alpn'); 301 | var alpn; 302 | if (alpnValue.length === 1) { 303 | // 如果数组只有一个元素,直接获取该元素 304 | alpn = alpnValue[0].toString(); 305 | } else { 306 | // 如果数组有多个元素,使用逗号连接 307 | alpn = alpnValue.join(','); 308 | } 309 | let tuicDict = { 310 | congestion_control: congestion_controller, 311 | udp_relay_mode: udp_relay_mode, 312 | alpn: alpn, 313 | sni: sni, 314 | allow_insecure: 1, 315 | }; 316 | // 过滤掉值为空的键值对 317 | const filteredParams = Object.fromEntries( 318 | Object.entries(tuicDict).filter(([key, value]) => value !== '' && value !== null && value !== undefined) 319 | ); 320 | // 进行 URL 参数编码 321 | const encodedParams = new URLSearchParams(filteredParams).toString(); 322 | 323 | return `tuic://${uuid}:${password}@${server}:${port}?${encodedParams}#[tuic]_${server}`; 324 | } 325 | 326 | // ------------------------------------- 判断是否为mieru或juicity的代理 ------------------------------------- 327 | 328 | function isJuicity(jsonObject) { 329 | let juicity_listen = findFieldValue(jsonObject, 'listen'); 330 | let juicity_server = findFieldValue(jsonObject, 'server'); 331 | let juicity_uuid = findFieldValue(jsonObject, 'uuid'); 332 | let juicity_password = findFieldValue(jsonObject, 'password'); 333 | let juicity_sni = findFieldValue(jsonObject, 'sni'); 334 | let juicity_allow_insecure = findFieldValue(jsonObject, 'allow_insecure'); 335 | let juicity_congestion_control = findFieldValue(jsonObject, 'congestion_control'); 336 | 337 | if ( 338 | juicity_listen && 339 | juicity_server && 340 | juicity_uuid && 341 | juicity_password && 342 | juicity_sni && 343 | juicity_allow_insecure && 344 | juicity_congestion_control 345 | ) { 346 | return true; 347 | } else { 348 | return false; 349 | } 350 | } 351 | 352 | function isMieru(jsonObject) { 353 | let mieru_exist_profiles = Array.isArray(findFieldValue(jsonObject, 'profiles')); 354 | let mieru_exist_portBindings = Array.isArray(findFieldValue(jsonObject, 'portBindings')); 355 | let mieru_ipAddress = findFieldValue(jsonObject, 'ipAddress'); 356 | let mieru_rpcPort = findFieldValue(jsonObject, 'rpcPort'); 357 | let mieru_activeProfile = findFieldValue(jsonObject, 'activeProfile'); 358 | if (mieru_exist_profiles && mieru_exist_portBindings && mieru_ipAddress && mieru_rpcPort && mieru_activeProfile) { 359 | return true; 360 | } else { 361 | return false; 362 | } 363 | } 364 | 365 | // ------------------------------------------- 递归查找字段对应的值 ------------------------------------------ 366 | 367 | function findFieldValue(obj, targetField) { 368 | for (const key in obj) { 369 | if (obj.hasOwnProperty(key)) { 370 | if (key === targetField) { 371 | return obj[key]; 372 | } else if (typeof obj[key] === 'object') { 373 | const result = findFieldValue(obj[key], targetField); 374 | if (result != undefined) { 375 | return result; 376 | } 377 | } 378 | } 379 | } 380 | return null; // 如果未找到字段,返回null 381 | } 382 | 383 | // ------------------------------------------- 抓取网页内容的函数 ------------------------------------------- 384 | 385 | async function fetchWebPageContent(url) { 386 | try { 387 | // 发送请求 388 | let response = await fetch(url); 389 | 390 | if (!response.ok) { 391 | throw new Error(`获取失败: ${response.status}`); 392 | } 393 | 394 | // 读取并返回文本内容,同时替换可能出现的"!"字符 395 | let content = (await response.text()).replace(/!/g, ''); 396 | 397 | // 去掉HTML标签,包括HTML实体字符 398 | return stripHtmlTags(content); 399 | } catch (error) { 400 | console.error(`获取${url} 网页内容失败: ${error.message}`); 401 | return {}; 402 | } 403 | } 404 | 405 | // 删除网页内容中多余的HTML标签 406 | function stripHtmlTags(str) { 407 | const entities = { 408 | '<': '<', 409 | '>': '>', 410 | // ..... 411 | }; 412 | // 动态生成正则表达式,匹配所有实体 413 | const regex = new RegExp( 414 | '&(' + 415 | Object.keys(entities) 416 | .map((e) => e.slice(1, -1)) 417 | .join('|') + 418 | ');', 419 | 'g' 420 | ); 421 | // 替换HTML实体 422 | let replaced = str.replace(regex, (match) => entities[match]); 423 | // 去掉HTML标签 424 | return replaced.replace(/<[^>]*>/g, ''); 425 | } 426 | 427 | // ---------------------------------- 去抓取网页、处理节点,返回节点的分享链接 ---------------------------------- 428 | 429 | async function fetchAndProcessUrl(url) { 430 | const content = await fetchWebPageContent(url); 431 | let jsonObject; 432 | let outbounds; // 可能是字段outbounds值的列表,也可能是字段proxies值的列表 433 | try { 434 | jsonObject = JSON.parse(content); 435 | outbounds = findFieldValue(jsonObject, 'outbounds'); 436 | } catch (e) { 437 | let links = v2rayLinksHandle(content); 438 | if (links.length > 0) { 439 | // 存储多个节点链接 440 | const uniqueSet = new Set(); 441 | // let proxyPrefix = ['hysteria://', 'hy2://', 'vless://', 'vmess://', 'trojan://', 'ss://', 'tuic://', 'naive+https://']; 442 | let proxyPrefix = [ 443 | 'aHlzdGVyaWE6Ly8', 444 | 'aHkyOi8v', 445 | 'dmxlc3M6Ly8', 446 | 'dm1lc3M6Ly8', 447 | 'dHJvamFuOi8v', 448 | 'c3M6Ly8', 449 | 'dHVpYzovLw', 450 | 'bmFpdmUraHR0cHM6Ly8', 451 | ]; 452 | links.split('\n').forEach((link) => { 453 | if (proxyPrefix.some((prefix) => link.startsWith(base64Decode(prefix)))) uniqueSet.add(link); 454 | }); 455 | // 转换为数组 456 | const uniqueArray = Array.from(uniqueSet); 457 | return uniqueArray; 458 | } else { 459 | let yamlObject = yaml.load(content); // 使用js-yaml库解析yaml 460 | if (yamlObject && typeof yamlObject === 'object') { 461 | outbounds = findFieldValue(yamlObject, 'proxies'); 462 | } 463 | } 464 | } 465 | 466 | if (outbounds === null && jsonObject) { 467 | /** 处理一个节点 */ 468 | 469 | // mieru 470 | let is_mieru = isMieru(jsonObject); 471 | if (is_mieru) return ''; // 丢弃 472 | 473 | // juicity 474 | let is_juicity = isJuicity(jsonObject); 475 | if (is_juicity) return ''; // 丢弃 476 | 477 | // hy2 478 | let server = findFieldValue(jsonObject, 'server')?.replace(/,.*$/, '') || ''; // 如果字符串中含有逗号,就删除逗号及其后面的字符 479 | let pwd_auth = findFieldValue(jsonObject, 'auth'); 480 | let sni = findFieldValue(jsonObject, 'sni'); 481 | 482 | let insecureFieldValue = findFieldValue(jsonObject, 'insecure'); 483 | let insecure = [null, true].includes(insecureFieldValue) ? 1 : ''; 484 | 485 | // hy1 486 | let upmbps = findFieldValue(jsonObject, 'up_mbps'); 487 | let downmbps = findFieldValue(jsonObject, 'down_mbps'); 488 | let obfsParam = findFieldValue(jsonObject, 'obfs') || ''; 489 | let auth = findFieldValue(jsonObject, 'auth_str') || ''; 490 | let protocol = findFieldValue(jsonObject, 'protocol') || ''; 491 | let peer = findFieldValue(jsonObject, 'server_name') || ''; 492 | let alpn = findFieldValue(jsonObject, 'alpn'); 493 | let recv_window = findFieldValue(jsonObject, 'recv_window') || ''; 494 | let recv_window_conn = findFieldValue(jsonObject, 'recv_window_conn') || ''; 495 | 496 | // naive 497 | let proxyFieldValue = findFieldValue(jsonObject, 'proxy'); 498 | 499 | // 使用正则表达式进行匹配naive配置文件中proxy中的值 500 | const pattern = /^https:\/\/.*@.*$/; 501 | const isMatch = pattern.test(proxyFieldValue); 502 | 503 | if (server && pwd_auth) { 504 | // 判断是hy2 505 | 506 | return `hy2://${pwd_auth}@${server}?insecure=${insecure}&sni=${sni}#[hy2]_${server}`; 507 | } else if (server && auth && alpn && upmbps !== null && downmbps !== null) { 508 | // 判断是hy1 509 | 510 | let hysteriaDict = { 511 | upmbps: upmbps, 512 | downmbps: downmbps, 513 | obfs: 'xplus', 514 | obfsParam: obfsParam, 515 | auth: auth, 516 | protocol: protocol, 517 | insecure: insecure, 518 | peer: peer, 519 | alpn: alpn, 520 | recv_window: recv_window, 521 | recv_window_conn: recv_window_conn, 522 | }; 523 | // 没有对应的值,就从hysteriaDict中删除 524 | if (hysteriaDict['obfsParam'] === '') { 525 | delete hysteriaDict['obfs']; 526 | } 527 | // 过滤掉值为空的键值对 528 | const filteredParams = Object.fromEntries( 529 | Object.entries(hysteriaDict).filter(([key, value]) => value !== '' && value !== null && value !== undefined) 530 | ); 531 | // 进行 URL 参数编码 532 | const encodedParams = new URLSearchParams(filteredParams).toString(); 533 | 534 | // hy1的节点链接 535 | return `${base64Decode('aHlzdGVyaWE6Ly8')}${server}?${encodedParams}#[hysteria]_${server}`; 536 | } else if (proxyFieldValue && isMatch && typeof proxyFieldValue === 'string') { 537 | // 判断是naive 538 | 539 | // 从右侧找到 ":" 和 "@" 的索引 540 | const colonIndex = proxyFieldValue.lastIndexOf(':'); 541 | const atIndex = proxyFieldValue.lastIndexOf('@'); 542 | // 截取 "@" 后到 ":" 之间的内容 543 | const extractedContent = proxyFieldValue.substring(atIndex + 1, colonIndex); 544 | 545 | return `naive+${proxyFieldValue}#[naive]_${extractedContent}`; 546 | } 547 | } else if (outbounds && Array.isArray(outbounds)) { 548 | /** 处理多个节点 */ 549 | 550 | // 存储多个节点链接 551 | const uniqueSet = new Set(); 552 | 553 | // let allProxyType = ['hysteria', 'hy2', 'vless', 'vmess', 'trojan', 'ss', 'tuic']; 554 | let allProxyType = ['aHlzdGVyaWE', 'aHky', 'dmxlc3M', 'dm1lc3M', 'dHJvamFu', 'c3M', 'dHVpYw']; 555 | // 遍历数组中的节点 556 | for (var i = 0; i < outbounds.length; i++) { 557 | let proxyType = findFieldValue(outbounds[i], 'protocol'); 558 | if (!allProxyType.includes(proxyType)) { 559 | proxyType = findFieldValue(outbounds[i], 'type'); 560 | } 561 | // 检查到是hysteria类型的节点 562 | if (proxyType === base64Decode('aHlzdGVyaWE')) { 563 | let hy1 = parse_hysteria(outbounds[i]); 564 | if (hy1) { 565 | uniqueSet.add(hy1); 566 | } 567 | // 检查到是hy2类型的节点 568 | } else if (proxyType === base64Decode('aHky')) { 569 | let hy2 = parse_hy2(outbounds[i]); 570 | if (hy2) { 571 | uniqueSet.add(hy2); 572 | } 573 | // 检查到是shadowsocks类型的节点 574 | } else if (proxyType === base64Decode('c3M')) { 575 | let ss = parse_shadowsocks(outbounds[i]); 576 | if (ss) { 577 | uniqueSet.add(ss); 578 | } 579 | // 检查到是vless类型的节点 580 | } else if (proxyType === base64Decode('dmxlc3M')) { 581 | let vle55 = parse_vle55(outbounds[i]); 582 | if (vle55) { 583 | uniqueSet.add(vle55); 584 | } 585 | // 检查到是vmess类型的节点 586 | } else if (proxyType === base64Decode('dm1lc3M')) { 587 | let vme55 = parse_vme55(outbounds[i]); 588 | if (vme55) { 589 | uniqueSet.add(vme55); 590 | } 591 | // 检查到是trojan类型的节点 592 | } else if (proxyType === base64Decode('dHJvamFu')) { 593 | let tr0jan = parse_tr0jan(outbounds[i]); 594 | if (tr0jan) { 595 | uniqueSet.add(tr0jan); 596 | } 597 | // 检查到是tuic类型的节点 598 | } else if (proxyType === base64Decode('dHVpYw')) { 599 | let tuic = parse_tuic(outbounds[i]); 600 | if (tuic) { 601 | uniqueSet.add(tuic); 602 | } 603 | } 604 | } 605 | // 转换为数组 606 | const uniqueArray = Array.from(uniqueSet); 607 | 608 | return uniqueArray; 609 | } 610 | } 611 | 612 | // ----------------------------------------- base64编码与base64解码 ------------------------------------------ 613 | // base64编码 614 | function base64Encode(str) { 615 | const encoder = new TextEncoder(); 616 | const uint8Array = encoder.encode(str); 617 | const chunkSize = 0x8000; // 每个块的大小 (32768) 618 | let binary = ''; 619 | 620 | // 分块处理,避免一次性展开整个数组导致调用栈溢出 621 | for (let i = 0; i < uint8Array.length; i += chunkSize) { 622 | const chunk = uint8Array.subarray(i, i + chunkSize); 623 | // 使用 Function.prototype.apply 将小块转换为字符串 624 | binary += String.fromCharCode.apply(null, chunk); 625 | } 626 | 627 | return btoa(binary); 628 | } 629 | 630 | // base64解码 631 | function base64Decode(base64Str) { 632 | let binary = atob(base64Str); 633 | let bytes = new Uint8Array([...binary].map((char) => char.charCodeAt(0))); 634 | let decoder = new TextDecoder(); 635 | return decoder.decode(bytes); 636 | } 637 | 638 | // 判断是否是有效的Base64编码字符串 639 | function isValidBase64(str) { 640 | if (typeof str !== 'string') return false; 641 | 642 | str = str.trim(); 643 | if (str === '') return false; 644 | 645 | // Base64正则匹配规则,确保格式正确 646 | const base64Regex = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/; 647 | if (!base64Regex.test(str)) return false; 648 | 649 | // 长度必须是4的倍数 650 | if (str.length % 4 !== 0) return false; 651 | 652 | try { 653 | // 尝试解码,确保不会报错 654 | const binaryStr = atob(str); 655 | new Uint8Array([...binaryStr].map((c) => c.charCodeAt(0))); 656 | return true; 657 | } catch (e) { 658 | return false; 659 | } 660 | } 661 | 662 | // ------------------------------- 抓取的网页内容是否为v2ray/nekoray分享链接? ------------------------------- 663 | 664 | function v2rayLinksHandle(str) { 665 | let isBase64Str = isValidBase64(str); 666 | 667 | // let proxyPrefix = ['hysteria://', 'hy2://', 'vless://', 'vmess://', 'trojan://', 'ss://', 'tuic://', 'naive+https://']; 668 | let proxyPrefix = [ 669 | 'aHlzdGVyaWE6Ly8', 670 | 'aHkyOi8v', 671 | 'dmxlc3M6Ly8', 672 | 'dm1lc3M6Ly8', 673 | 'dHJvamFuOi8v', 674 | 'c3M6Ly8', 675 | 'dHVpYzovLw', 676 | 'bmFpdmUraHR0cHM6Ly8', 677 | ]; 678 | // 粗略判断是否为明文分享链接,是则原字符串返回 679 | if (typeof str === 'string' && !isBase64Str && proxyPrefix.some((prefix) => str.includes(base64Decode(prefix)))) { 680 | return str; 681 | } else if (!isBase64Str) { 682 | return ''; // 不是有效的 Base64,直接返回空字符串 683 | } 684 | 685 | try { 686 | return base64Decode(str); 687 | } catch (e) { 688 | return ''; // 如果解码失败,也返回空字符串 689 | } 690 | } 691 | 692 | // -------------------------------------------- 要抓取的网页链接 -------------------------------------------- 693 | 694 | /** 695 | * 要抓取的网页,目标urls集,顺序随意,json、yaml、v2ray明文/base64加密的订阅数据都可以 696 | * 订阅地址的链接不能太多,容易出现"Error: Too many subrequests"错误, 697 | * 免费计划:每个 Worker 最多 50 个子请求(包括 fetch() 请求) 698 | * 付费计划:最多 1000 个子请求 699 | * 700 | * https://github.com/juerson/subscription_helper 701 | * 使用这个工具可以对订阅链接的内容比较,找出内容互不相同的链接,内容相同就选择其中的一个链接 702 | */ 703 | const targetUrls = [ 704 | // ChromeGo/EdgeGo的订阅链接(已剔除内容重复的订阅链接) 705 | 'https://fastly.jsdelivr.net/gh/Alvin9999/PAC@latest/backup/img/1/2/ipp/naiveproxy/2/config.json', 706 | 'https://fastly.jsdelivr.net/gh/Alvin9999/PAC@latest/backup/img/1/2/ipp/hysteria2/2/config.json', 707 | 'https://www.gitlabip.xyz/Alvin9999/PAC/master/backup/img/1/2/ipp/hysteria2/3/config.json', 708 | 'https://www.gitlabip.xyz/Alvin9999/PAC/master/backup/img/1/2/ipp/naiveproxy/1/config.json', 709 | 'https://fastly.jsdelivr.net/gh/Alvin9999/PAC@latest/backup/img/1/2/ipp/xray/2/config.json', 710 | 'https://fastly.jsdelivr.net/gh/Alvin9999/PAC@latest/backup/img/1/2/ipp/xray/4/config.json', 711 | 'https://fastly.jsdelivr.net/gh/Alvin9999/PAC@latest/backup/img/1/2/ip/singbox/2/config.json', 712 | 'https://www.gitlabip.xyz/Alvin9999/PAC/master/backup/img/1/2/ipp/singbox/1/config.json', 713 | 'https://fastly.jsdelivr.net/gh/Alvin9999/PAC@latest/backup/img/1/2/ipp/hysteria/2/config.json', 714 | 'https://www.gitlabip.xyz/Alvin9999/PAC/master/backup/img/1/2/ipp/hysteria/3/config.json', 715 | 'https://www.gitlabip.xyz/Alvin9999/PAC/master/backup/img/1/2/ipp/hysteria/1/config.json', 716 | 'https://gitlab.com/free9999/ipupdate/-/raw/master/backup/img/1/2/ipp/hysteria/3/config.json', 717 | 'https://gitlab.com/free9999/ipupdate/-/raw/master/backup/img/1/2/ip/singbox/config.json', 718 | 'https://gitlab.com/free9999/ipupdate/-/raw/master/hysteria/2/config.json', 719 | 'https://gitlab.com/free9999/ipupdate/-/raw/master/hysteria2/2/config.json', 720 | 'https://www.gitlabip.xyz/Alvin9999/PAC/master/backup/img/1/2/ipp/clash.meta2/5/config.yaml', 721 | 'https://fastly.jsdelivr.net/gh/Alvin9999/PAC@latest/backup/img/1/2/ipp/clash.meta2/4/config.yaml', 722 | 'https://www.gitlabip.xyz/Alvin9999/PAC/master/backup/img/1/2/ipp/clash.meta2/1/config.yaml', 723 | // 'https://fastly.jsdelivr.net/gh/jsvpn/jsproxy@dev/yule/20200325/1299699.md', 724 | 'https://www.gitlabip.xyz/Alvin9999/PAC/master/backup/img/1/2/ip/clash.meta2/1/config.yaml', 725 | 'https://fastly.jsdelivr.net/gh/Alvin9999/pac2@latest/quick/config.yaml', 726 | 'https://fastly.jsdelivr.net/gh/Alvin9999/pac2@latest/quick/4/config.yaml', 727 | // 也可以添加其它来源且数据格式为json或yaml的订阅链接 728 | 'https://raw.githubusercontent.com/aiboboxx/clashfree/main/clash.yml', 729 | // 可以添加明文v2ray分享链接的订阅或base64订阅链接 730 | 'https://raw.githubusercontent.com/aiboboxx/v2rayfree/main/v2', 731 | 'https://ghfast.top/https://raw.githubusercontent.com/free18/v2ray/refs/heads/main/v.txt', 732 | ]; 733 | 734 | // --------------------------------------- 操作targetUrls和构建节点的入口 ------------------------------------ 735 | 736 | async function processUrls(targetUrls) { 737 | const results = []; 738 | // 最大并发数 739 | const maxConcurrency = 3; 740 | // 辅助函数,限制并发执行的异步任务数量 741 | const asyncPool = async (poolLimit, array, iteratorFn) => { 742 | const results = []; 743 | const executing = []; 744 | 745 | for (const item of array) { 746 | const promise = Promise.resolve().then(() => iteratorFn(item)); 747 | results.push(promise); 748 | if (executing.length < poolLimit) { 749 | const executingPromise = promise.then(() => executing.splice(executing.indexOf(executingPromise), 1)); 750 | executing.push(executingPromise); 751 | } else { 752 | await Promise.race(executing); 753 | } 754 | } 755 | return Promise.all(results); 756 | }; 757 | 758 | // 使用asyncPool并发执行异步任务 759 | await asyncPool(maxConcurrency, targetUrls, async (url) => { 760 | const link = await fetchAndProcessUrl(url); 761 | if (Array.isArray(link)) { 762 | // 剔除重复的link节点链接 763 | link.forEach((item) => { 764 | if (!results.includes(item)) { 765 | results.push(item); 766 | } 767 | }); 768 | } else if (link && !results.includes(link)) { 769 | // 直接将link节点链接放入results数组中 770 | results.push(link); 771 | } 772 | }); 773 | 774 | // 返回结果数组 775 | return results; 776 | } 777 | 778 | // ----------------------------------------- Cloudflare worker 入口 ---------------------------------------- 779 | 780 | export default { 781 | async fetch(request, env, ctx) { 782 | try { 783 | // 调用函数并处理结果 784 | let resultsArray = await processUrls(targetUrls); 785 | 786 | // 使用Set数据结构的特性去重(再次去重) 787 | let uniqueStrings = [...new Set(resultsArray)]; 788 | 789 | // 排序 790 | let sortedArray = uniqueStrings.sort((a, b) => { 791 | // 先按字母顺序排序 792 | const compareByLetters = a.localeCompare(b); 793 | // 如果字母相同,则按数字大小排序 794 | if (compareByLetters === 0) { 795 | const numA = parseInt(a, 10) || 0; // 将非数字的字符串转换为0 796 | const numB = parseInt(b, 10) || 0; 797 | const compareByNumbers = numA - numB; 798 | 799 | // 如果数字相同,则按字符串长度排序 800 | if (compareByNumbers === 0) { 801 | return a.length - b.length; 802 | } 803 | return compareByNumbers; 804 | } 805 | return compareByLetters; 806 | }); 807 | 808 | // 将数组拼接成一个字符串 809 | let resultString = sortedArray.join('\n'); 810 | let base64String = base64Encode(resultString); 811 | 812 | // 返回一个带有结果的响应 813 | return new Response(base64String, { 814 | status: 200, 815 | headers: { 816 | 'Content-Type': 'text/plain; charset=UTF-8', 817 | }, 818 | }); 819 | } catch (error) { 820 | console.error(`Error in fetch function: ${error.message}`); 821 | // 返回一个带有错误信息的响应 822 | return new Response(`Error fetching web page: ${error.message}`, { 823 | status: 500, 824 | }); 825 | } 826 | }, 827 | }; 828 | -------------------------------------------------------------------------------- /wrangler.toml: -------------------------------------------------------------------------------- 1 | name = "worker-bitter-boat-a8af" 2 | main = "src/worker.js" 3 | compatibility_date = "2023-12-18" 4 | workers_dev = true --------------------------------------------------------------------------------