├── .gitignore ├── .pnp.cjs ├── .pnp.loader.mjs ├── README.md ├── image └── ui.png ├── package-lock.json ├── package.json ├── sql └── schema.sql ├── src ├── cf_api.ts ├── index.ts └── parser │ ├── cursor.js │ └── index.js ├── wrangler.toml.example └── yarn.lock /.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 | 173 | 174 | wrangler.toml 175 | .wrangler/ 176 | wrangler.toml.prod -------------------------------------------------------------------------------- /.pnp.loader.mjs: -------------------------------------------------------------------------------- 1 | import { URL as URL$1, fileURLToPath, pathToFileURL } from 'url'; 2 | import fs from 'fs'; 3 | import path from 'path'; 4 | import moduleExports, { Module } from 'module'; 5 | import { EOL } from 'os'; 6 | import assert from 'assert'; 7 | 8 | const SAFE_TIME = 456789e3; 9 | 10 | const PortablePath = { 11 | root: `/`, 12 | dot: `.`, 13 | parent: `..` 14 | }; 15 | const npath = Object.create(path); 16 | const ppath = Object.create(path.posix); 17 | npath.cwd = () => process.cwd(); 18 | ppath.cwd = () => toPortablePath(process.cwd()); 19 | ppath.resolve = (...segments) => { 20 | if (segments.length > 0 && ppath.isAbsolute(segments[0])) { 21 | return path.posix.resolve(...segments); 22 | } else { 23 | return path.posix.resolve(ppath.cwd(), ...segments); 24 | } 25 | }; 26 | const contains = function(pathUtils, from, to) { 27 | from = pathUtils.normalize(from); 28 | to = pathUtils.normalize(to); 29 | if (from === to) 30 | return `.`; 31 | if (!from.endsWith(pathUtils.sep)) 32 | from = from + pathUtils.sep; 33 | if (to.startsWith(from)) { 34 | return to.slice(from.length); 35 | } else { 36 | return null; 37 | } 38 | }; 39 | npath.fromPortablePath = fromPortablePath; 40 | npath.toPortablePath = toPortablePath; 41 | npath.contains = (from, to) => contains(npath, from, to); 42 | ppath.contains = (from, to) => contains(ppath, from, to); 43 | const WINDOWS_PATH_REGEXP = /^([a-zA-Z]:.*)$/; 44 | const UNC_WINDOWS_PATH_REGEXP = /^\/\/(\.\/)?(.*)$/; 45 | const PORTABLE_PATH_REGEXP = /^\/([a-zA-Z]:.*)$/; 46 | const UNC_PORTABLE_PATH_REGEXP = /^\/unc\/(\.dot\/)?(.*)$/; 47 | function fromPortablePath(p) { 48 | if (process.platform !== `win32`) 49 | return p; 50 | let portablePathMatch, uncPortablePathMatch; 51 | if (portablePathMatch = p.match(PORTABLE_PATH_REGEXP)) 52 | p = portablePathMatch[1]; 53 | else if (uncPortablePathMatch = p.match(UNC_PORTABLE_PATH_REGEXP)) 54 | p = `\\\\${uncPortablePathMatch[1] ? `.\\` : ``}${uncPortablePathMatch[2]}`; 55 | else 56 | return p; 57 | return p.replace(/\//g, `\\`); 58 | } 59 | function toPortablePath(p) { 60 | if (process.platform !== `win32`) 61 | return p; 62 | p = p.replace(/\\/g, `/`); 63 | let windowsPathMatch, uncWindowsPathMatch; 64 | if (windowsPathMatch = p.match(WINDOWS_PATH_REGEXP)) 65 | p = `/${windowsPathMatch[1]}`; 66 | else if (uncWindowsPathMatch = p.match(UNC_WINDOWS_PATH_REGEXP)) 67 | p = `/unc/${uncWindowsPathMatch[1] ? `.dot/` : ``}${uncWindowsPathMatch[2]}`; 68 | return p; 69 | } 70 | function convertPath(targetPathUtils, sourcePath) { 71 | return targetPathUtils === npath ? fromPortablePath(sourcePath) : toPortablePath(sourcePath); 72 | } 73 | 74 | const defaultTime = new Date(SAFE_TIME * 1e3); 75 | async function copyPromise(destinationFs, destination, sourceFs, source, opts) { 76 | const normalizedDestination = destinationFs.pathUtils.normalize(destination); 77 | const normalizedSource = sourceFs.pathUtils.normalize(source); 78 | const prelayout = []; 79 | const postlayout = []; 80 | const { atime, mtime } = opts.stableTime ? { atime: defaultTime, mtime: defaultTime } : await sourceFs.lstatPromise(normalizedSource); 81 | await destinationFs.mkdirpPromise(destinationFs.pathUtils.dirname(destination), { utimes: [atime, mtime] }); 82 | const updateTime = typeof destinationFs.lutimesPromise === `function` ? destinationFs.lutimesPromise.bind(destinationFs) : destinationFs.utimesPromise.bind(destinationFs); 83 | await copyImpl(prelayout, postlayout, updateTime, destinationFs, normalizedDestination, sourceFs, normalizedSource, { ...opts, didParentExist: true }); 84 | for (const operation of prelayout) 85 | await operation(); 86 | await Promise.all(postlayout.map((operation) => { 87 | return operation(); 88 | })); 89 | } 90 | async function copyImpl(prelayout, postlayout, updateTime, destinationFs, destination, sourceFs, source, opts) { 91 | var _a, _b; 92 | const destinationStat = opts.didParentExist ? await maybeLStat(destinationFs, destination) : null; 93 | const sourceStat = await sourceFs.lstatPromise(source); 94 | const { atime, mtime } = opts.stableTime ? { atime: defaultTime, mtime: defaultTime } : sourceStat; 95 | let updated; 96 | switch (true) { 97 | case sourceStat.isDirectory(): 98 | { 99 | updated = await copyFolder(prelayout, postlayout, updateTime, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts); 100 | } 101 | break; 102 | case sourceStat.isFile(): 103 | { 104 | updated = await copyFile(prelayout, postlayout, updateTime, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts); 105 | } 106 | break; 107 | case sourceStat.isSymbolicLink(): 108 | { 109 | updated = await copySymlink(prelayout, postlayout, updateTime, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts); 110 | } 111 | break; 112 | default: 113 | { 114 | throw new Error(`Unsupported file type (${sourceStat.mode})`); 115 | } 116 | } 117 | if (updated || ((_a = destinationStat == null ? void 0 : destinationStat.mtime) == null ? void 0 : _a.getTime()) !== mtime.getTime() || ((_b = destinationStat == null ? void 0 : destinationStat.atime) == null ? void 0 : _b.getTime()) !== atime.getTime()) { 118 | postlayout.push(() => updateTime(destination, atime, mtime)); 119 | updated = true; 120 | } 121 | if (destinationStat === null || (destinationStat.mode & 511) !== (sourceStat.mode & 511)) { 122 | postlayout.push(() => destinationFs.chmodPromise(destination, sourceStat.mode & 511)); 123 | updated = true; 124 | } 125 | return updated; 126 | } 127 | async function maybeLStat(baseFs, p) { 128 | try { 129 | return await baseFs.lstatPromise(p); 130 | } catch (e) { 131 | return null; 132 | } 133 | } 134 | async function copyFolder(prelayout, postlayout, updateTime, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts) { 135 | if (destinationStat !== null && !destinationStat.isDirectory()) { 136 | if (opts.overwrite) { 137 | prelayout.push(async () => destinationFs.removePromise(destination)); 138 | destinationStat = null; 139 | } else { 140 | return false; 141 | } 142 | } 143 | let updated = false; 144 | if (destinationStat === null) { 145 | prelayout.push(async () => { 146 | try { 147 | await destinationFs.mkdirPromise(destination, { mode: sourceStat.mode }); 148 | } catch (err) { 149 | if (err.code !== `EEXIST`) { 150 | throw err; 151 | } 152 | } 153 | }); 154 | updated = true; 155 | } 156 | const entries = await sourceFs.readdirPromise(source); 157 | const nextOpts = opts.didParentExist && !destinationStat ? { ...opts, didParentExist: false } : opts; 158 | if (opts.stableSort) { 159 | for (const entry of entries.sort()) { 160 | if (await copyImpl(prelayout, postlayout, updateTime, destinationFs, destinationFs.pathUtils.join(destination, entry), sourceFs, sourceFs.pathUtils.join(source, entry), nextOpts)) { 161 | updated = true; 162 | } 163 | } 164 | } else { 165 | const entriesUpdateStatus = await Promise.all(entries.map(async (entry) => { 166 | await copyImpl(prelayout, postlayout, updateTime, destinationFs, destinationFs.pathUtils.join(destination, entry), sourceFs, sourceFs.pathUtils.join(source, entry), nextOpts); 167 | })); 168 | if (entriesUpdateStatus.some((status) => status)) { 169 | updated = true; 170 | } 171 | } 172 | return updated; 173 | } 174 | const isCloneSupportedCache = /* @__PURE__ */ new WeakMap(); 175 | function makeLinkOperation(opFs, destination, source, sourceStat, linkStrategy) { 176 | return async () => { 177 | await opFs.linkPromise(source, destination); 178 | if (linkStrategy === "readOnly" /* ReadOnly */) { 179 | sourceStat.mode &= ~146; 180 | await opFs.chmodPromise(destination, sourceStat.mode); 181 | } 182 | }; 183 | } 184 | function makeCloneLinkOperation(opFs, destination, source, sourceStat, linkStrategy) { 185 | const isCloneSupported = isCloneSupportedCache.get(opFs); 186 | if (typeof isCloneSupported === `undefined`) { 187 | return async () => { 188 | try { 189 | await opFs.copyFilePromise(source, destination, fs.constants.COPYFILE_FICLONE_FORCE); 190 | isCloneSupportedCache.set(opFs, true); 191 | } catch (err) { 192 | if (err.code === `ENOSYS` || err.code === `ENOTSUP`) { 193 | isCloneSupportedCache.set(opFs, false); 194 | await makeLinkOperation(opFs, destination, source, sourceStat, linkStrategy)(); 195 | } else { 196 | throw err; 197 | } 198 | } 199 | }; 200 | } else { 201 | if (isCloneSupported) { 202 | return async () => opFs.copyFilePromise(source, destination, fs.constants.COPYFILE_FICLONE_FORCE); 203 | } else { 204 | return makeLinkOperation(opFs, destination, source, sourceStat, linkStrategy); 205 | } 206 | } 207 | } 208 | async function copyFile(prelayout, postlayout, updateTime, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts) { 209 | var _a; 210 | if (destinationStat !== null) { 211 | if (opts.overwrite) { 212 | prelayout.push(async () => destinationFs.removePromise(destination)); 213 | destinationStat = null; 214 | } else { 215 | return false; 216 | } 217 | } 218 | const linkStrategy = (_a = opts.linkStrategy) != null ? _a : null; 219 | const op = destinationFs === sourceFs ? linkStrategy !== null ? makeCloneLinkOperation(destinationFs, destination, source, sourceStat, linkStrategy) : async () => destinationFs.copyFilePromise(source, destination, fs.constants.COPYFILE_FICLONE) : linkStrategy !== null ? makeLinkOperation(destinationFs, destination, source, sourceStat, linkStrategy) : async () => destinationFs.writeFilePromise(destination, await sourceFs.readFilePromise(source)); 220 | prelayout.push(async () => op()); 221 | return true; 222 | } 223 | async function copySymlink(prelayout, postlayout, updateTime, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts) { 224 | if (destinationStat !== null) { 225 | if (opts.overwrite) { 226 | prelayout.push(async () => destinationFs.removePromise(destination)); 227 | destinationStat = null; 228 | } else { 229 | return false; 230 | } 231 | } 232 | prelayout.push(async () => { 233 | await destinationFs.symlinkPromise(convertPath(destinationFs.pathUtils, await sourceFs.readlinkPromise(source)), destination); 234 | }); 235 | return true; 236 | } 237 | 238 | function makeError(code, message) { 239 | return Object.assign(new Error(`${code}: ${message}`), { code }); 240 | } 241 | function ENOSYS(message, reason) { 242 | return makeError(`ENOSYS`, `${message}, ${reason}`); 243 | } 244 | 245 | class FakeFS { 246 | constructor(pathUtils) { 247 | this.pathUtils = pathUtils; 248 | } 249 | async *genTraversePromise(init, { stableSort = false } = {}) { 250 | const stack = [init]; 251 | while (stack.length > 0) { 252 | const p = stack.shift(); 253 | const entry = await this.lstatPromise(p); 254 | if (entry.isDirectory()) { 255 | const entries = await this.readdirPromise(p); 256 | if (stableSort) { 257 | for (const entry2 of entries.sort()) { 258 | stack.push(this.pathUtils.join(p, entry2)); 259 | } 260 | } else { 261 | throw new Error(`Not supported`); 262 | } 263 | } else { 264 | yield p; 265 | } 266 | } 267 | } 268 | async removePromise(p, { recursive = true, maxRetries = 5 } = {}) { 269 | let stat; 270 | try { 271 | stat = await this.lstatPromise(p); 272 | } catch (error) { 273 | if (error.code === `ENOENT`) { 274 | return; 275 | } else { 276 | throw error; 277 | } 278 | } 279 | if (stat.isDirectory()) { 280 | if (recursive) { 281 | const entries = await this.readdirPromise(p); 282 | await Promise.all(entries.map((entry) => { 283 | return this.removePromise(this.pathUtils.resolve(p, entry)); 284 | })); 285 | } 286 | for (let t = 0; t <= maxRetries; t++) { 287 | try { 288 | await this.rmdirPromise(p); 289 | break; 290 | } catch (error) { 291 | if (error.code !== `EBUSY` && error.code !== `ENOTEMPTY`) { 292 | throw error; 293 | } else if (t < maxRetries) { 294 | await new Promise((resolve) => setTimeout(resolve, t * 100)); 295 | } 296 | } 297 | } 298 | } else { 299 | await this.unlinkPromise(p); 300 | } 301 | } 302 | removeSync(p, { recursive = true } = {}) { 303 | let stat; 304 | try { 305 | stat = this.lstatSync(p); 306 | } catch (error) { 307 | if (error.code === `ENOENT`) { 308 | return; 309 | } else { 310 | throw error; 311 | } 312 | } 313 | if (stat.isDirectory()) { 314 | if (recursive) 315 | for (const entry of this.readdirSync(p)) 316 | this.removeSync(this.pathUtils.resolve(p, entry)); 317 | this.rmdirSync(p); 318 | } else { 319 | this.unlinkSync(p); 320 | } 321 | } 322 | async mkdirpPromise(p, { chmod, utimes } = {}) { 323 | p = this.resolve(p); 324 | if (p === this.pathUtils.dirname(p)) 325 | return void 0; 326 | const parts = p.split(this.pathUtils.sep); 327 | let createdDirectory; 328 | for (let u = 2; u <= parts.length; ++u) { 329 | const subPath = parts.slice(0, u).join(this.pathUtils.sep); 330 | if (!this.existsSync(subPath)) { 331 | try { 332 | await this.mkdirPromise(subPath); 333 | } catch (error) { 334 | if (error.code === `EEXIST`) { 335 | continue; 336 | } else { 337 | throw error; 338 | } 339 | } 340 | createdDirectory != null ? createdDirectory : createdDirectory = subPath; 341 | if (chmod != null) 342 | await this.chmodPromise(subPath, chmod); 343 | if (utimes != null) { 344 | await this.utimesPromise(subPath, utimes[0], utimes[1]); 345 | } else { 346 | const parentStat = await this.statPromise(this.pathUtils.dirname(subPath)); 347 | await this.utimesPromise(subPath, parentStat.atime, parentStat.mtime); 348 | } 349 | } 350 | } 351 | return createdDirectory; 352 | } 353 | mkdirpSync(p, { chmod, utimes } = {}) { 354 | p = this.resolve(p); 355 | if (p === this.pathUtils.dirname(p)) 356 | return void 0; 357 | const parts = p.split(this.pathUtils.sep); 358 | let createdDirectory; 359 | for (let u = 2; u <= parts.length; ++u) { 360 | const subPath = parts.slice(0, u).join(this.pathUtils.sep); 361 | if (!this.existsSync(subPath)) { 362 | try { 363 | this.mkdirSync(subPath); 364 | } catch (error) { 365 | if (error.code === `EEXIST`) { 366 | continue; 367 | } else { 368 | throw error; 369 | } 370 | } 371 | createdDirectory != null ? createdDirectory : createdDirectory = subPath; 372 | if (chmod != null) 373 | this.chmodSync(subPath, chmod); 374 | if (utimes != null) { 375 | this.utimesSync(subPath, utimes[0], utimes[1]); 376 | } else { 377 | const parentStat = this.statSync(this.pathUtils.dirname(subPath)); 378 | this.utimesSync(subPath, parentStat.atime, parentStat.mtime); 379 | } 380 | } 381 | } 382 | return createdDirectory; 383 | } 384 | async copyPromise(destination, source, { baseFs = this, overwrite = true, stableSort = false, stableTime = false, linkStrategy = null } = {}) { 385 | return await copyPromise(this, destination, baseFs, source, { overwrite, stableSort, stableTime, linkStrategy }); 386 | } 387 | copySync(destination, source, { baseFs = this, overwrite = true } = {}) { 388 | const stat = baseFs.lstatSync(source); 389 | const exists = this.existsSync(destination); 390 | if (stat.isDirectory()) { 391 | this.mkdirpSync(destination); 392 | const directoryListing = baseFs.readdirSync(source); 393 | for (const entry of directoryListing) { 394 | this.copySync(this.pathUtils.join(destination, entry), baseFs.pathUtils.join(source, entry), { baseFs, overwrite }); 395 | } 396 | } else if (stat.isFile()) { 397 | if (!exists || overwrite) { 398 | if (exists) 399 | this.removeSync(destination); 400 | const content = baseFs.readFileSync(source); 401 | this.writeFileSync(destination, content); 402 | } 403 | } else if (stat.isSymbolicLink()) { 404 | if (!exists || overwrite) { 405 | if (exists) 406 | this.removeSync(destination); 407 | const target = baseFs.readlinkSync(source); 408 | this.symlinkSync(convertPath(this.pathUtils, target), destination); 409 | } 410 | } else { 411 | throw new Error(`Unsupported file type (file: ${source}, mode: 0o${stat.mode.toString(8).padStart(6, `0`)})`); 412 | } 413 | const mode = stat.mode & 511; 414 | this.chmodSync(destination, mode); 415 | } 416 | async changeFilePromise(p, content, opts = {}) { 417 | if (Buffer.isBuffer(content)) { 418 | return this.changeFileBufferPromise(p, content, opts); 419 | } else { 420 | return this.changeFileTextPromise(p, content, opts); 421 | } 422 | } 423 | async changeFileBufferPromise(p, content, { mode } = {}) { 424 | let current = Buffer.alloc(0); 425 | try { 426 | current = await this.readFilePromise(p); 427 | } catch (error) { 428 | } 429 | if (Buffer.compare(current, content) === 0) 430 | return; 431 | await this.writeFilePromise(p, content, { mode }); 432 | } 433 | async changeFileTextPromise(p, content, { automaticNewlines, mode } = {}) { 434 | let current = ``; 435 | try { 436 | current = await this.readFilePromise(p, `utf8`); 437 | } catch (error) { 438 | } 439 | const normalizedContent = automaticNewlines ? normalizeLineEndings(current, content) : content; 440 | if (current === normalizedContent) 441 | return; 442 | await this.writeFilePromise(p, normalizedContent, { mode }); 443 | } 444 | changeFileSync(p, content, opts = {}) { 445 | if (Buffer.isBuffer(content)) { 446 | return this.changeFileBufferSync(p, content, opts); 447 | } else { 448 | return this.changeFileTextSync(p, content, opts); 449 | } 450 | } 451 | changeFileBufferSync(p, content, { mode } = {}) { 452 | let current = Buffer.alloc(0); 453 | try { 454 | current = this.readFileSync(p); 455 | } catch (error) { 456 | } 457 | if (Buffer.compare(current, content) === 0) 458 | return; 459 | this.writeFileSync(p, content, { mode }); 460 | } 461 | changeFileTextSync(p, content, { automaticNewlines = false, mode } = {}) { 462 | let current = ``; 463 | try { 464 | current = this.readFileSync(p, `utf8`); 465 | } catch (error) { 466 | } 467 | const normalizedContent = automaticNewlines ? normalizeLineEndings(current, content) : content; 468 | if (current === normalizedContent) 469 | return; 470 | this.writeFileSync(p, normalizedContent, { mode }); 471 | } 472 | async movePromise(fromP, toP) { 473 | try { 474 | await this.renamePromise(fromP, toP); 475 | } catch (error) { 476 | if (error.code === `EXDEV`) { 477 | await this.copyPromise(toP, fromP); 478 | await this.removePromise(fromP); 479 | } else { 480 | throw error; 481 | } 482 | } 483 | } 484 | moveSync(fromP, toP) { 485 | try { 486 | this.renameSync(fromP, toP); 487 | } catch (error) { 488 | if (error.code === `EXDEV`) { 489 | this.copySync(toP, fromP); 490 | this.removeSync(fromP); 491 | } else { 492 | throw error; 493 | } 494 | } 495 | } 496 | async lockPromise(affectedPath, callback) { 497 | const lockPath = `${affectedPath}.flock`; 498 | const interval = 1e3 / 60; 499 | const startTime = Date.now(); 500 | let fd = null; 501 | const isAlive = async () => { 502 | let pid; 503 | try { 504 | [pid] = await this.readJsonPromise(lockPath); 505 | } catch (error) { 506 | return Date.now() - startTime < 500; 507 | } 508 | try { 509 | process.kill(pid, 0); 510 | return true; 511 | } catch (error) { 512 | return false; 513 | } 514 | }; 515 | while (fd === null) { 516 | try { 517 | fd = await this.openPromise(lockPath, `wx`); 518 | } catch (error) { 519 | if (error.code === `EEXIST`) { 520 | if (!await isAlive()) { 521 | try { 522 | await this.unlinkPromise(lockPath); 523 | continue; 524 | } catch (error2) { 525 | } 526 | } 527 | if (Date.now() - startTime < 60 * 1e3) { 528 | await new Promise((resolve) => setTimeout(resolve, interval)); 529 | } else { 530 | throw new Error(`Couldn't acquire a lock in a reasonable time (via ${lockPath})`); 531 | } 532 | } else { 533 | throw error; 534 | } 535 | } 536 | } 537 | await this.writePromise(fd, JSON.stringify([process.pid])); 538 | try { 539 | return await callback(); 540 | } finally { 541 | try { 542 | await this.closePromise(fd); 543 | await this.unlinkPromise(lockPath); 544 | } catch (error) { 545 | } 546 | } 547 | } 548 | async readJsonPromise(p) { 549 | const content = await this.readFilePromise(p, `utf8`); 550 | try { 551 | return JSON.parse(content); 552 | } catch (error) { 553 | error.message += ` (in ${p})`; 554 | throw error; 555 | } 556 | } 557 | readJsonSync(p) { 558 | const content = this.readFileSync(p, `utf8`); 559 | try { 560 | return JSON.parse(content); 561 | } catch (error) { 562 | error.message += ` (in ${p})`; 563 | throw error; 564 | } 565 | } 566 | async writeJsonPromise(p, data) { 567 | return await this.writeFilePromise(p, `${JSON.stringify(data, null, 2)} 568 | `); 569 | } 570 | writeJsonSync(p, data) { 571 | return this.writeFileSync(p, `${JSON.stringify(data, null, 2)} 572 | `); 573 | } 574 | async preserveTimePromise(p, cb) { 575 | const stat = await this.lstatPromise(p); 576 | const result = await cb(); 577 | if (typeof result !== `undefined`) 578 | p = result; 579 | if (this.lutimesPromise) { 580 | await this.lutimesPromise(p, stat.atime, stat.mtime); 581 | } else if (!stat.isSymbolicLink()) { 582 | await this.utimesPromise(p, stat.atime, stat.mtime); 583 | } 584 | } 585 | async preserveTimeSync(p, cb) { 586 | const stat = this.lstatSync(p); 587 | const result = cb(); 588 | if (typeof result !== `undefined`) 589 | p = result; 590 | if (this.lutimesSync) { 591 | this.lutimesSync(p, stat.atime, stat.mtime); 592 | } else if (!stat.isSymbolicLink()) { 593 | this.utimesSync(p, stat.atime, stat.mtime); 594 | } 595 | } 596 | } 597 | class BasePortableFakeFS extends FakeFS { 598 | constructor() { 599 | super(ppath); 600 | } 601 | } 602 | function getEndOfLine(content) { 603 | const matches = content.match(/\r?\n/g); 604 | if (matches === null) 605 | return EOL; 606 | const crlf = matches.filter((nl) => nl === `\r 607 | `).length; 608 | const lf = matches.length - crlf; 609 | return crlf > lf ? `\r 610 | ` : ` 611 | `; 612 | } 613 | function normalizeLineEndings(originalContent, newContent) { 614 | return newContent.replace(/\r?\n/g, getEndOfLine(originalContent)); 615 | } 616 | 617 | class NodeFS extends BasePortableFakeFS { 618 | constructor(realFs = fs) { 619 | super(); 620 | this.realFs = realFs; 621 | if (typeof this.realFs.lutimes !== `undefined`) { 622 | this.lutimesPromise = this.lutimesPromiseImpl; 623 | this.lutimesSync = this.lutimesSyncImpl; 624 | } 625 | } 626 | getExtractHint() { 627 | return false; 628 | } 629 | getRealPath() { 630 | return PortablePath.root; 631 | } 632 | resolve(p) { 633 | return ppath.resolve(p); 634 | } 635 | async openPromise(p, flags, mode) { 636 | return await new Promise((resolve, reject) => { 637 | this.realFs.open(npath.fromPortablePath(p), flags, mode, this.makeCallback(resolve, reject)); 638 | }); 639 | } 640 | openSync(p, flags, mode) { 641 | return this.realFs.openSync(npath.fromPortablePath(p), flags, mode); 642 | } 643 | async opendirPromise(p, opts) { 644 | return await new Promise((resolve, reject) => { 645 | if (typeof opts !== `undefined`) { 646 | this.realFs.opendir(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); 647 | } else { 648 | this.realFs.opendir(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); 649 | } 650 | }).then((dir) => { 651 | return Object.defineProperty(dir, `path`, { value: p, configurable: true, writable: true }); 652 | }); 653 | } 654 | opendirSync(p, opts) { 655 | const dir = typeof opts !== `undefined` ? this.realFs.opendirSync(npath.fromPortablePath(p), opts) : this.realFs.opendirSync(npath.fromPortablePath(p)); 656 | return Object.defineProperty(dir, `path`, { value: p, configurable: true, writable: true }); 657 | } 658 | async readPromise(fd, buffer, offset = 0, length = 0, position = -1) { 659 | return await new Promise((resolve, reject) => { 660 | this.realFs.read(fd, buffer, offset, length, position, (error, bytesRead) => { 661 | if (error) { 662 | reject(error); 663 | } else { 664 | resolve(bytesRead); 665 | } 666 | }); 667 | }); 668 | } 669 | readSync(fd, buffer, offset, length, position) { 670 | return this.realFs.readSync(fd, buffer, offset, length, position); 671 | } 672 | async writePromise(fd, buffer, offset, length, position) { 673 | return await new Promise((resolve, reject) => { 674 | if (typeof buffer === `string`) { 675 | return this.realFs.write(fd, buffer, offset, this.makeCallback(resolve, reject)); 676 | } else { 677 | return this.realFs.write(fd, buffer, offset, length, position, this.makeCallback(resolve, reject)); 678 | } 679 | }); 680 | } 681 | writeSync(fd, buffer, offset, length, position) { 682 | if (typeof buffer === `string`) { 683 | return this.realFs.writeSync(fd, buffer, offset); 684 | } else { 685 | return this.realFs.writeSync(fd, buffer, offset, length, position); 686 | } 687 | } 688 | async closePromise(fd) { 689 | await new Promise((resolve, reject) => { 690 | this.realFs.close(fd, this.makeCallback(resolve, reject)); 691 | }); 692 | } 693 | closeSync(fd) { 694 | this.realFs.closeSync(fd); 695 | } 696 | createReadStream(p, opts) { 697 | const realPath = p !== null ? npath.fromPortablePath(p) : p; 698 | return this.realFs.createReadStream(realPath, opts); 699 | } 700 | createWriteStream(p, opts) { 701 | const realPath = p !== null ? npath.fromPortablePath(p) : p; 702 | return this.realFs.createWriteStream(realPath, opts); 703 | } 704 | async realpathPromise(p) { 705 | return await new Promise((resolve, reject) => { 706 | this.realFs.realpath(npath.fromPortablePath(p), {}, this.makeCallback(resolve, reject)); 707 | }).then((path) => { 708 | return npath.toPortablePath(path); 709 | }); 710 | } 711 | realpathSync(p) { 712 | return npath.toPortablePath(this.realFs.realpathSync(npath.fromPortablePath(p), {})); 713 | } 714 | async existsPromise(p) { 715 | return await new Promise((resolve) => { 716 | this.realFs.exists(npath.fromPortablePath(p), resolve); 717 | }); 718 | } 719 | accessSync(p, mode) { 720 | return this.realFs.accessSync(npath.fromPortablePath(p), mode); 721 | } 722 | async accessPromise(p, mode) { 723 | return await new Promise((resolve, reject) => { 724 | this.realFs.access(npath.fromPortablePath(p), mode, this.makeCallback(resolve, reject)); 725 | }); 726 | } 727 | existsSync(p) { 728 | return this.realFs.existsSync(npath.fromPortablePath(p)); 729 | } 730 | async statPromise(p, opts) { 731 | return await new Promise((resolve, reject) => { 732 | if (opts) { 733 | this.realFs.stat(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); 734 | } else { 735 | this.realFs.stat(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); 736 | } 737 | }); 738 | } 739 | statSync(p, opts) { 740 | if (opts) { 741 | return this.realFs.statSync(npath.fromPortablePath(p), opts); 742 | } else { 743 | return this.realFs.statSync(npath.fromPortablePath(p)); 744 | } 745 | } 746 | async fstatPromise(fd, opts) { 747 | return await new Promise((resolve, reject) => { 748 | if (opts) { 749 | this.realFs.fstat(fd, opts, this.makeCallback(resolve, reject)); 750 | } else { 751 | this.realFs.fstat(fd, this.makeCallback(resolve, reject)); 752 | } 753 | }); 754 | } 755 | fstatSync(fd, opts) { 756 | if (opts) { 757 | return this.realFs.fstatSync(fd, opts); 758 | } else { 759 | return this.realFs.fstatSync(fd); 760 | } 761 | } 762 | async lstatPromise(p, opts) { 763 | return await new Promise((resolve, reject) => { 764 | if (opts) { 765 | this.realFs.lstat(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); 766 | } else { 767 | this.realFs.lstat(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); 768 | } 769 | }); 770 | } 771 | lstatSync(p, opts) { 772 | if (opts) { 773 | return this.realFs.lstatSync(npath.fromPortablePath(p), opts); 774 | } else { 775 | return this.realFs.lstatSync(npath.fromPortablePath(p)); 776 | } 777 | } 778 | async fchmodPromise(fd, mask) { 779 | return await new Promise((resolve, reject) => { 780 | this.realFs.fchmod(fd, mask, this.makeCallback(resolve, reject)); 781 | }); 782 | } 783 | fchmodSync(fd, mask) { 784 | return this.realFs.fchmodSync(fd, mask); 785 | } 786 | async chmodPromise(p, mask) { 787 | return await new Promise((resolve, reject) => { 788 | this.realFs.chmod(npath.fromPortablePath(p), mask, this.makeCallback(resolve, reject)); 789 | }); 790 | } 791 | chmodSync(p, mask) { 792 | return this.realFs.chmodSync(npath.fromPortablePath(p), mask); 793 | } 794 | async fchownPromise(fd, uid, gid) { 795 | return await new Promise((resolve, reject) => { 796 | this.realFs.fchown(fd, uid, gid, this.makeCallback(resolve, reject)); 797 | }); 798 | } 799 | fchownSync(fd, uid, gid) { 800 | return this.realFs.fchownSync(fd, uid, gid); 801 | } 802 | async chownPromise(p, uid, gid) { 803 | return await new Promise((resolve, reject) => { 804 | this.realFs.chown(npath.fromPortablePath(p), uid, gid, this.makeCallback(resolve, reject)); 805 | }); 806 | } 807 | chownSync(p, uid, gid) { 808 | return this.realFs.chownSync(npath.fromPortablePath(p), uid, gid); 809 | } 810 | async renamePromise(oldP, newP) { 811 | return await new Promise((resolve, reject) => { 812 | this.realFs.rename(npath.fromPortablePath(oldP), npath.fromPortablePath(newP), this.makeCallback(resolve, reject)); 813 | }); 814 | } 815 | renameSync(oldP, newP) { 816 | return this.realFs.renameSync(npath.fromPortablePath(oldP), npath.fromPortablePath(newP)); 817 | } 818 | async copyFilePromise(sourceP, destP, flags = 0) { 819 | return await new Promise((resolve, reject) => { 820 | this.realFs.copyFile(npath.fromPortablePath(sourceP), npath.fromPortablePath(destP), flags, this.makeCallback(resolve, reject)); 821 | }); 822 | } 823 | copyFileSync(sourceP, destP, flags = 0) { 824 | return this.realFs.copyFileSync(npath.fromPortablePath(sourceP), npath.fromPortablePath(destP), flags); 825 | } 826 | async appendFilePromise(p, content, opts) { 827 | return await new Promise((resolve, reject) => { 828 | const fsNativePath = typeof p === `string` ? npath.fromPortablePath(p) : p; 829 | if (opts) { 830 | this.realFs.appendFile(fsNativePath, content, opts, this.makeCallback(resolve, reject)); 831 | } else { 832 | this.realFs.appendFile(fsNativePath, content, this.makeCallback(resolve, reject)); 833 | } 834 | }); 835 | } 836 | appendFileSync(p, content, opts) { 837 | const fsNativePath = typeof p === `string` ? npath.fromPortablePath(p) : p; 838 | if (opts) { 839 | this.realFs.appendFileSync(fsNativePath, content, opts); 840 | } else { 841 | this.realFs.appendFileSync(fsNativePath, content); 842 | } 843 | } 844 | async writeFilePromise(p, content, opts) { 845 | return await new Promise((resolve, reject) => { 846 | const fsNativePath = typeof p === `string` ? npath.fromPortablePath(p) : p; 847 | if (opts) { 848 | this.realFs.writeFile(fsNativePath, content, opts, this.makeCallback(resolve, reject)); 849 | } else { 850 | this.realFs.writeFile(fsNativePath, content, this.makeCallback(resolve, reject)); 851 | } 852 | }); 853 | } 854 | writeFileSync(p, content, opts) { 855 | const fsNativePath = typeof p === `string` ? npath.fromPortablePath(p) : p; 856 | if (opts) { 857 | this.realFs.writeFileSync(fsNativePath, content, opts); 858 | } else { 859 | this.realFs.writeFileSync(fsNativePath, content); 860 | } 861 | } 862 | async unlinkPromise(p) { 863 | return await new Promise((resolve, reject) => { 864 | this.realFs.unlink(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); 865 | }); 866 | } 867 | unlinkSync(p) { 868 | return this.realFs.unlinkSync(npath.fromPortablePath(p)); 869 | } 870 | async utimesPromise(p, atime, mtime) { 871 | return await new Promise((resolve, reject) => { 872 | this.realFs.utimes(npath.fromPortablePath(p), atime, mtime, this.makeCallback(resolve, reject)); 873 | }); 874 | } 875 | utimesSync(p, atime, mtime) { 876 | this.realFs.utimesSync(npath.fromPortablePath(p), atime, mtime); 877 | } 878 | async lutimesPromiseImpl(p, atime, mtime) { 879 | const lutimes = this.realFs.lutimes; 880 | if (typeof lutimes === `undefined`) 881 | throw ENOSYS(`unavailable Node binding`, `lutimes '${p}'`); 882 | return await new Promise((resolve, reject) => { 883 | lutimes.call(this.realFs, npath.fromPortablePath(p), atime, mtime, this.makeCallback(resolve, reject)); 884 | }); 885 | } 886 | lutimesSyncImpl(p, atime, mtime) { 887 | const lutimesSync = this.realFs.lutimesSync; 888 | if (typeof lutimesSync === `undefined`) 889 | throw ENOSYS(`unavailable Node binding`, `lutimes '${p}'`); 890 | lutimesSync.call(this.realFs, npath.fromPortablePath(p), atime, mtime); 891 | } 892 | async mkdirPromise(p, opts) { 893 | return await new Promise((resolve, reject) => { 894 | this.realFs.mkdir(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); 895 | }); 896 | } 897 | mkdirSync(p, opts) { 898 | return this.realFs.mkdirSync(npath.fromPortablePath(p), opts); 899 | } 900 | async rmdirPromise(p, opts) { 901 | return await new Promise((resolve, reject) => { 902 | if (opts) { 903 | this.realFs.rmdir(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); 904 | } else { 905 | this.realFs.rmdir(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); 906 | } 907 | }); 908 | } 909 | rmdirSync(p, opts) { 910 | return this.realFs.rmdirSync(npath.fromPortablePath(p), opts); 911 | } 912 | async linkPromise(existingP, newP) { 913 | return await new Promise((resolve, reject) => { 914 | this.realFs.link(npath.fromPortablePath(existingP), npath.fromPortablePath(newP), this.makeCallback(resolve, reject)); 915 | }); 916 | } 917 | linkSync(existingP, newP) { 918 | return this.realFs.linkSync(npath.fromPortablePath(existingP), npath.fromPortablePath(newP)); 919 | } 920 | async symlinkPromise(target, p, type) { 921 | return await new Promise((resolve, reject) => { 922 | this.realFs.symlink(npath.fromPortablePath(target.replace(/\/+$/, ``)), npath.fromPortablePath(p), type, this.makeCallback(resolve, reject)); 923 | }); 924 | } 925 | symlinkSync(target, p, type) { 926 | return this.realFs.symlinkSync(npath.fromPortablePath(target.replace(/\/+$/, ``)), npath.fromPortablePath(p), type); 927 | } 928 | async readFilePromise(p, encoding) { 929 | return await new Promise((resolve, reject) => { 930 | const fsNativePath = typeof p === `string` ? npath.fromPortablePath(p) : p; 931 | this.realFs.readFile(fsNativePath, encoding, this.makeCallback(resolve, reject)); 932 | }); 933 | } 934 | readFileSync(p, encoding) { 935 | const fsNativePath = typeof p === `string` ? npath.fromPortablePath(p) : p; 936 | return this.realFs.readFileSync(fsNativePath, encoding); 937 | } 938 | async readdirPromise(p, opts) { 939 | return await new Promise((resolve, reject) => { 940 | if (opts == null ? void 0 : opts.withFileTypes) { 941 | this.realFs.readdir(npath.fromPortablePath(p), { withFileTypes: true }, this.makeCallback(resolve, reject)); 942 | } else { 943 | this.realFs.readdir(npath.fromPortablePath(p), this.makeCallback((value) => resolve(value), reject)); 944 | } 945 | }); 946 | } 947 | readdirSync(p, opts) { 948 | if (opts == null ? void 0 : opts.withFileTypes) { 949 | return this.realFs.readdirSync(npath.fromPortablePath(p), { withFileTypes: true }); 950 | } else { 951 | return this.realFs.readdirSync(npath.fromPortablePath(p)); 952 | } 953 | } 954 | async readlinkPromise(p) { 955 | return await new Promise((resolve, reject) => { 956 | this.realFs.readlink(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); 957 | }).then((path) => { 958 | return npath.toPortablePath(path); 959 | }); 960 | } 961 | readlinkSync(p) { 962 | return npath.toPortablePath(this.realFs.readlinkSync(npath.fromPortablePath(p))); 963 | } 964 | async truncatePromise(p, len) { 965 | return await new Promise((resolve, reject) => { 966 | this.realFs.truncate(npath.fromPortablePath(p), len, this.makeCallback(resolve, reject)); 967 | }); 968 | } 969 | truncateSync(p, len) { 970 | return this.realFs.truncateSync(npath.fromPortablePath(p), len); 971 | } 972 | async ftruncatePromise(fd, len) { 973 | return await new Promise((resolve, reject) => { 974 | this.realFs.ftruncate(fd, len, this.makeCallback(resolve, reject)); 975 | }); 976 | } 977 | ftruncateSync(fd, len) { 978 | return this.realFs.ftruncateSync(fd, len); 979 | } 980 | watch(p, a, b) { 981 | return this.realFs.watch( 982 | npath.fromPortablePath(p), 983 | a, 984 | b 985 | ); 986 | } 987 | watchFile(p, a, b) { 988 | return this.realFs.watchFile( 989 | npath.fromPortablePath(p), 990 | a, 991 | b 992 | ); 993 | } 994 | unwatchFile(p, cb) { 995 | return this.realFs.unwatchFile(npath.fromPortablePath(p), cb); 996 | } 997 | makeCallback(resolve, reject) { 998 | return (err, result) => { 999 | if (err) { 1000 | reject(err); 1001 | } else { 1002 | resolve(result); 1003 | } 1004 | }; 1005 | } 1006 | } 1007 | 1008 | class ProxiedFS extends FakeFS { 1009 | getExtractHint(hints) { 1010 | return this.baseFs.getExtractHint(hints); 1011 | } 1012 | resolve(path) { 1013 | return this.mapFromBase(this.baseFs.resolve(this.mapToBase(path))); 1014 | } 1015 | getRealPath() { 1016 | return this.mapFromBase(this.baseFs.getRealPath()); 1017 | } 1018 | async openPromise(p, flags, mode) { 1019 | return this.baseFs.openPromise(this.mapToBase(p), flags, mode); 1020 | } 1021 | openSync(p, flags, mode) { 1022 | return this.baseFs.openSync(this.mapToBase(p), flags, mode); 1023 | } 1024 | async opendirPromise(p, opts) { 1025 | return Object.assign(await this.baseFs.opendirPromise(this.mapToBase(p), opts), { path: p }); 1026 | } 1027 | opendirSync(p, opts) { 1028 | return Object.assign(this.baseFs.opendirSync(this.mapToBase(p), opts), { path: p }); 1029 | } 1030 | async readPromise(fd, buffer, offset, length, position) { 1031 | return await this.baseFs.readPromise(fd, buffer, offset, length, position); 1032 | } 1033 | readSync(fd, buffer, offset, length, position) { 1034 | return this.baseFs.readSync(fd, buffer, offset, length, position); 1035 | } 1036 | async writePromise(fd, buffer, offset, length, position) { 1037 | if (typeof buffer === `string`) { 1038 | return await this.baseFs.writePromise(fd, buffer, offset); 1039 | } else { 1040 | return await this.baseFs.writePromise(fd, buffer, offset, length, position); 1041 | } 1042 | } 1043 | writeSync(fd, buffer, offset, length, position) { 1044 | if (typeof buffer === `string`) { 1045 | return this.baseFs.writeSync(fd, buffer, offset); 1046 | } else { 1047 | return this.baseFs.writeSync(fd, buffer, offset, length, position); 1048 | } 1049 | } 1050 | async closePromise(fd) { 1051 | return this.baseFs.closePromise(fd); 1052 | } 1053 | closeSync(fd) { 1054 | this.baseFs.closeSync(fd); 1055 | } 1056 | createReadStream(p, opts) { 1057 | return this.baseFs.createReadStream(p !== null ? this.mapToBase(p) : p, opts); 1058 | } 1059 | createWriteStream(p, opts) { 1060 | return this.baseFs.createWriteStream(p !== null ? this.mapToBase(p) : p, opts); 1061 | } 1062 | async realpathPromise(p) { 1063 | return this.mapFromBase(await this.baseFs.realpathPromise(this.mapToBase(p))); 1064 | } 1065 | realpathSync(p) { 1066 | return this.mapFromBase(this.baseFs.realpathSync(this.mapToBase(p))); 1067 | } 1068 | async existsPromise(p) { 1069 | return this.baseFs.existsPromise(this.mapToBase(p)); 1070 | } 1071 | existsSync(p) { 1072 | return this.baseFs.existsSync(this.mapToBase(p)); 1073 | } 1074 | accessSync(p, mode) { 1075 | return this.baseFs.accessSync(this.mapToBase(p), mode); 1076 | } 1077 | async accessPromise(p, mode) { 1078 | return this.baseFs.accessPromise(this.mapToBase(p), mode); 1079 | } 1080 | async statPromise(p, opts) { 1081 | return this.baseFs.statPromise(this.mapToBase(p), opts); 1082 | } 1083 | statSync(p, opts) { 1084 | return this.baseFs.statSync(this.mapToBase(p), opts); 1085 | } 1086 | async fstatPromise(fd, opts) { 1087 | return this.baseFs.fstatPromise(fd, opts); 1088 | } 1089 | fstatSync(fd, opts) { 1090 | return this.baseFs.fstatSync(fd, opts); 1091 | } 1092 | lstatPromise(p, opts) { 1093 | return this.baseFs.lstatPromise(this.mapToBase(p), opts); 1094 | } 1095 | lstatSync(p, opts) { 1096 | return this.baseFs.lstatSync(this.mapToBase(p), opts); 1097 | } 1098 | async fchmodPromise(fd, mask) { 1099 | return this.baseFs.fchmodPromise(fd, mask); 1100 | } 1101 | fchmodSync(fd, mask) { 1102 | return this.baseFs.fchmodSync(fd, mask); 1103 | } 1104 | async chmodPromise(p, mask) { 1105 | return this.baseFs.chmodPromise(this.mapToBase(p), mask); 1106 | } 1107 | chmodSync(p, mask) { 1108 | return this.baseFs.chmodSync(this.mapToBase(p), mask); 1109 | } 1110 | async fchownPromise(fd, uid, gid) { 1111 | return this.baseFs.fchownPromise(fd, uid, gid); 1112 | } 1113 | fchownSync(fd, uid, gid) { 1114 | return this.baseFs.fchownSync(fd, uid, gid); 1115 | } 1116 | async chownPromise(p, uid, gid) { 1117 | return this.baseFs.chownPromise(this.mapToBase(p), uid, gid); 1118 | } 1119 | chownSync(p, uid, gid) { 1120 | return this.baseFs.chownSync(this.mapToBase(p), uid, gid); 1121 | } 1122 | async renamePromise(oldP, newP) { 1123 | return this.baseFs.renamePromise(this.mapToBase(oldP), this.mapToBase(newP)); 1124 | } 1125 | renameSync(oldP, newP) { 1126 | return this.baseFs.renameSync(this.mapToBase(oldP), this.mapToBase(newP)); 1127 | } 1128 | async copyFilePromise(sourceP, destP, flags = 0) { 1129 | return this.baseFs.copyFilePromise(this.mapToBase(sourceP), this.mapToBase(destP), flags); 1130 | } 1131 | copyFileSync(sourceP, destP, flags = 0) { 1132 | return this.baseFs.copyFileSync(this.mapToBase(sourceP), this.mapToBase(destP), flags); 1133 | } 1134 | async appendFilePromise(p, content, opts) { 1135 | return this.baseFs.appendFilePromise(this.fsMapToBase(p), content, opts); 1136 | } 1137 | appendFileSync(p, content, opts) { 1138 | return this.baseFs.appendFileSync(this.fsMapToBase(p), content, opts); 1139 | } 1140 | async writeFilePromise(p, content, opts) { 1141 | return this.baseFs.writeFilePromise(this.fsMapToBase(p), content, opts); 1142 | } 1143 | writeFileSync(p, content, opts) { 1144 | return this.baseFs.writeFileSync(this.fsMapToBase(p), content, opts); 1145 | } 1146 | async unlinkPromise(p) { 1147 | return this.baseFs.unlinkPromise(this.mapToBase(p)); 1148 | } 1149 | unlinkSync(p) { 1150 | return this.baseFs.unlinkSync(this.mapToBase(p)); 1151 | } 1152 | async utimesPromise(p, atime, mtime) { 1153 | return this.baseFs.utimesPromise(this.mapToBase(p), atime, mtime); 1154 | } 1155 | utimesSync(p, atime, mtime) { 1156 | return this.baseFs.utimesSync(this.mapToBase(p), atime, mtime); 1157 | } 1158 | async mkdirPromise(p, opts) { 1159 | return this.baseFs.mkdirPromise(this.mapToBase(p), opts); 1160 | } 1161 | mkdirSync(p, opts) { 1162 | return this.baseFs.mkdirSync(this.mapToBase(p), opts); 1163 | } 1164 | async rmdirPromise(p, opts) { 1165 | return this.baseFs.rmdirPromise(this.mapToBase(p), opts); 1166 | } 1167 | rmdirSync(p, opts) { 1168 | return this.baseFs.rmdirSync(this.mapToBase(p), opts); 1169 | } 1170 | async linkPromise(existingP, newP) { 1171 | return this.baseFs.linkPromise(this.mapToBase(existingP), this.mapToBase(newP)); 1172 | } 1173 | linkSync(existingP, newP) { 1174 | return this.baseFs.linkSync(this.mapToBase(existingP), this.mapToBase(newP)); 1175 | } 1176 | async symlinkPromise(target, p, type) { 1177 | const mappedP = this.mapToBase(p); 1178 | if (this.pathUtils.isAbsolute(target)) 1179 | return this.baseFs.symlinkPromise(this.mapToBase(target), mappedP, type); 1180 | const mappedAbsoluteTarget = this.mapToBase(this.pathUtils.join(this.pathUtils.dirname(p), target)); 1181 | const mappedTarget = this.baseFs.pathUtils.relative(this.baseFs.pathUtils.dirname(mappedP), mappedAbsoluteTarget); 1182 | return this.baseFs.symlinkPromise(mappedTarget, mappedP, type); 1183 | } 1184 | symlinkSync(target, p, type) { 1185 | const mappedP = this.mapToBase(p); 1186 | if (this.pathUtils.isAbsolute(target)) 1187 | return this.baseFs.symlinkSync(this.mapToBase(target), mappedP, type); 1188 | const mappedAbsoluteTarget = this.mapToBase(this.pathUtils.join(this.pathUtils.dirname(p), target)); 1189 | const mappedTarget = this.baseFs.pathUtils.relative(this.baseFs.pathUtils.dirname(mappedP), mappedAbsoluteTarget); 1190 | return this.baseFs.symlinkSync(mappedTarget, mappedP, type); 1191 | } 1192 | async readFilePromise(p, encoding) { 1193 | if (encoding === `utf8`) { 1194 | return this.baseFs.readFilePromise(this.fsMapToBase(p), encoding); 1195 | } else { 1196 | return this.baseFs.readFilePromise(this.fsMapToBase(p), encoding); 1197 | } 1198 | } 1199 | readFileSync(p, encoding) { 1200 | if (encoding === `utf8`) { 1201 | return this.baseFs.readFileSync(this.fsMapToBase(p), encoding); 1202 | } else { 1203 | return this.baseFs.readFileSync(this.fsMapToBase(p), encoding); 1204 | } 1205 | } 1206 | async readdirPromise(p, opts) { 1207 | return this.baseFs.readdirPromise(this.mapToBase(p), opts); 1208 | } 1209 | readdirSync(p, opts) { 1210 | return this.baseFs.readdirSync(this.mapToBase(p), opts); 1211 | } 1212 | async readlinkPromise(p) { 1213 | return this.mapFromBase(await this.baseFs.readlinkPromise(this.mapToBase(p))); 1214 | } 1215 | readlinkSync(p) { 1216 | return this.mapFromBase(this.baseFs.readlinkSync(this.mapToBase(p))); 1217 | } 1218 | async truncatePromise(p, len) { 1219 | return this.baseFs.truncatePromise(this.mapToBase(p), len); 1220 | } 1221 | truncateSync(p, len) { 1222 | return this.baseFs.truncateSync(this.mapToBase(p), len); 1223 | } 1224 | async ftruncatePromise(fd, len) { 1225 | return this.baseFs.ftruncatePromise(fd, len); 1226 | } 1227 | ftruncateSync(fd, len) { 1228 | return this.baseFs.ftruncateSync(fd, len); 1229 | } 1230 | watch(p, a, b) { 1231 | return this.baseFs.watch( 1232 | this.mapToBase(p), 1233 | a, 1234 | b 1235 | ); 1236 | } 1237 | watchFile(p, a, b) { 1238 | return this.baseFs.watchFile( 1239 | this.mapToBase(p), 1240 | a, 1241 | b 1242 | ); 1243 | } 1244 | unwatchFile(p, cb) { 1245 | return this.baseFs.unwatchFile(this.mapToBase(p), cb); 1246 | } 1247 | fsMapToBase(p) { 1248 | if (typeof p === `number`) { 1249 | return p; 1250 | } else { 1251 | return this.mapToBase(p); 1252 | } 1253 | } 1254 | } 1255 | 1256 | const NUMBER_REGEXP = /^[0-9]+$/; 1257 | const VIRTUAL_REGEXP = /^(\/(?:[^/]+\/)*?(?:\$\$virtual|__virtual__))((?:\/((?:[^/]+-)?[a-f0-9]+)(?:\/([^/]+))?)?((?:\/.*)?))$/; 1258 | const VALID_COMPONENT = /^([^/]+-)?[a-f0-9]+$/; 1259 | class VirtualFS extends ProxiedFS { 1260 | constructor({ baseFs = new NodeFS() } = {}) { 1261 | super(ppath); 1262 | this.baseFs = baseFs; 1263 | } 1264 | static makeVirtualPath(base, component, to) { 1265 | if (ppath.basename(base) !== `__virtual__`) 1266 | throw new Error(`Assertion failed: Virtual folders must be named "__virtual__"`); 1267 | if (!ppath.basename(component).match(VALID_COMPONENT)) 1268 | throw new Error(`Assertion failed: Virtual components must be ended by an hexadecimal hash`); 1269 | const target = ppath.relative(ppath.dirname(base), to); 1270 | const segments = target.split(`/`); 1271 | let depth = 0; 1272 | while (depth < segments.length && segments[depth] === `..`) 1273 | depth += 1; 1274 | const finalSegments = segments.slice(depth); 1275 | const fullVirtualPath = ppath.join(base, component, String(depth), ...finalSegments); 1276 | return fullVirtualPath; 1277 | } 1278 | static resolveVirtual(p) { 1279 | const match = p.match(VIRTUAL_REGEXP); 1280 | if (!match || !match[3] && match[5]) 1281 | return p; 1282 | const target = ppath.dirname(match[1]); 1283 | if (!match[3] || !match[4]) 1284 | return target; 1285 | const isnum = NUMBER_REGEXP.test(match[4]); 1286 | if (!isnum) 1287 | return p; 1288 | const depth = Number(match[4]); 1289 | const backstep = `../`.repeat(depth); 1290 | const subpath = match[5] || `.`; 1291 | return VirtualFS.resolveVirtual(ppath.join(target, backstep, subpath)); 1292 | } 1293 | getExtractHint(hints) { 1294 | return this.baseFs.getExtractHint(hints); 1295 | } 1296 | getRealPath() { 1297 | return this.baseFs.getRealPath(); 1298 | } 1299 | realpathSync(p) { 1300 | const match = p.match(VIRTUAL_REGEXP); 1301 | if (!match) 1302 | return this.baseFs.realpathSync(p); 1303 | if (!match[5]) 1304 | return p; 1305 | const realpath = this.baseFs.realpathSync(this.mapToBase(p)); 1306 | return VirtualFS.makeVirtualPath(match[1], match[3], realpath); 1307 | } 1308 | async realpathPromise(p) { 1309 | const match = p.match(VIRTUAL_REGEXP); 1310 | if (!match) 1311 | return await this.baseFs.realpathPromise(p); 1312 | if (!match[5]) 1313 | return p; 1314 | const realpath = await this.baseFs.realpathPromise(this.mapToBase(p)); 1315 | return VirtualFS.makeVirtualPath(match[1], match[3], realpath); 1316 | } 1317 | mapToBase(p) { 1318 | if (p === ``) 1319 | return p; 1320 | if (this.pathUtils.isAbsolute(p)) 1321 | return VirtualFS.resolveVirtual(p); 1322 | const resolvedRoot = VirtualFS.resolveVirtual(this.baseFs.resolve(PortablePath.dot)); 1323 | const resolvedP = VirtualFS.resolveVirtual(this.baseFs.resolve(p)); 1324 | return ppath.relative(resolvedRoot, resolvedP) || PortablePath.dot; 1325 | } 1326 | mapFromBase(p) { 1327 | return p; 1328 | } 1329 | } 1330 | 1331 | const [major, minor] = process.versions.node.split(`.`).map((value) => parseInt(value, 10)); 1332 | const HAS_CONSOLIDATED_HOOKS = major > 16 || major === 16 && minor >= 12; 1333 | const HAS_UNFLAGGED_JSON_MODULES = major > 17 || major === 17 && minor >= 5 || major === 16 && minor >= 15; 1334 | const HAS_JSON_IMPORT_ASSERTION_REQUIREMENT = major > 17 || major === 17 && minor >= 1 || major === 16 && minor > 14; 1335 | const WATCH_MODE_MESSAGE_USES_ARRAYS = major > 19 || major === 19 && minor >= 2 || major === 18 && minor >= 13; 1336 | const HAS_LAZY_LOADED_TRANSLATORS = major > 19 || major === 19 && minor >= 3; 1337 | 1338 | const builtinModules = new Set(Module.builtinModules || Object.keys(process.binding(`natives`))); 1339 | const isBuiltinModule = (request) => request.startsWith(`node:`) || builtinModules.has(request); 1340 | function readPackageScope(checkPath) { 1341 | const rootSeparatorIndex = checkPath.indexOf(npath.sep); 1342 | let separatorIndex; 1343 | do { 1344 | separatorIndex = checkPath.lastIndexOf(npath.sep); 1345 | checkPath = checkPath.slice(0, separatorIndex); 1346 | if (checkPath.endsWith(`${npath.sep}node_modules`)) 1347 | return false; 1348 | const pjson = readPackage(checkPath + npath.sep); 1349 | if (pjson) { 1350 | return { 1351 | data: pjson, 1352 | path: checkPath 1353 | }; 1354 | } 1355 | } while (separatorIndex > rootSeparatorIndex); 1356 | return false; 1357 | } 1358 | function readPackage(requestPath) { 1359 | const jsonPath = npath.resolve(requestPath, `package.json`); 1360 | if (!fs.existsSync(jsonPath)) 1361 | return null; 1362 | return JSON.parse(fs.readFileSync(jsonPath, `utf8`)); 1363 | } 1364 | 1365 | async function tryReadFile$1(path2) { 1366 | try { 1367 | return await fs.promises.readFile(path2, `utf8`); 1368 | } catch (error) { 1369 | if (error.code === `ENOENT`) 1370 | return null; 1371 | throw error; 1372 | } 1373 | } 1374 | function tryParseURL(str, base) { 1375 | try { 1376 | return new URL$1(str, base); 1377 | } catch { 1378 | return null; 1379 | } 1380 | } 1381 | let entrypointPath = null; 1382 | function setEntrypointPath(file) { 1383 | entrypointPath = file; 1384 | } 1385 | function getFileFormat(filepath) { 1386 | var _a, _b; 1387 | const ext = path.extname(filepath); 1388 | switch (ext) { 1389 | case `.mjs`: { 1390 | return `module`; 1391 | } 1392 | case `.cjs`: { 1393 | return `commonjs`; 1394 | } 1395 | case `.wasm`: { 1396 | throw new Error( 1397 | `Unknown file extension ".wasm" for ${filepath}` 1398 | ); 1399 | } 1400 | case `.json`: { 1401 | if (HAS_UNFLAGGED_JSON_MODULES) 1402 | return `json`; 1403 | throw new Error( 1404 | `Unknown file extension ".json" for ${filepath}` 1405 | ); 1406 | } 1407 | case `.js`: { 1408 | const pkg = readPackageScope(filepath); 1409 | if (!pkg) 1410 | return `commonjs`; 1411 | return (_a = pkg.data.type) != null ? _a : `commonjs`; 1412 | } 1413 | default: { 1414 | if (entrypointPath !== filepath) 1415 | return null; 1416 | const pkg = readPackageScope(filepath); 1417 | if (!pkg) 1418 | return `commonjs`; 1419 | if (pkg.data.type === `module`) 1420 | return null; 1421 | return (_b = pkg.data.type) != null ? _b : `commonjs`; 1422 | } 1423 | } 1424 | } 1425 | 1426 | async function getFormat$1(resolved, context, defaultGetFormat) { 1427 | const url = tryParseURL(resolved); 1428 | if ((url == null ? void 0 : url.protocol) !== `file:`) 1429 | return defaultGetFormat(resolved, context, defaultGetFormat); 1430 | const format = getFileFormat(fileURLToPath(url)); 1431 | if (format) { 1432 | return { 1433 | format 1434 | }; 1435 | } 1436 | return defaultGetFormat(resolved, context, defaultGetFormat); 1437 | } 1438 | 1439 | async function getSource$1(urlString, context, defaultGetSource) { 1440 | const url = tryParseURL(urlString); 1441 | if ((url == null ? void 0 : url.protocol) !== `file:`) 1442 | return defaultGetSource(urlString, context, defaultGetSource); 1443 | return { 1444 | source: await fs.promises.readFile(fileURLToPath(url), `utf8`) 1445 | }; 1446 | } 1447 | 1448 | async function load$1(urlString, context, nextLoad) { 1449 | var _a; 1450 | const url = tryParseURL(urlString); 1451 | if ((url == null ? void 0 : url.protocol) !== `file:`) 1452 | return nextLoad(urlString, context, nextLoad); 1453 | const filePath = fileURLToPath(url); 1454 | const format = getFileFormat(filePath); 1455 | if (!format) 1456 | return nextLoad(urlString, context, nextLoad); 1457 | if (HAS_JSON_IMPORT_ASSERTION_REQUIREMENT && format === `json` && ((_a = context.importAssertions) == null ? void 0 : _a.type) !== `json`) { 1458 | const err = new TypeError(`[ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module "${urlString}" needs an import assertion of type "json"`); 1459 | err.code = `ERR_IMPORT_ASSERTION_TYPE_MISSING`; 1460 | throw err; 1461 | } 1462 | if (process.env.WATCH_REPORT_DEPENDENCIES && process.send) { 1463 | const pathToSend = pathToFileURL( 1464 | npath.fromPortablePath( 1465 | VirtualFS.resolveVirtual(npath.toPortablePath(filePath)) 1466 | ) 1467 | ).href; 1468 | process.send({ 1469 | "watch:import": WATCH_MODE_MESSAGE_USES_ARRAYS ? [pathToSend] : pathToSend 1470 | }); 1471 | } 1472 | return { 1473 | format, 1474 | source: await fs.promises.readFile(filePath, `utf8`), 1475 | shortCircuit: true 1476 | }; 1477 | } 1478 | 1479 | const ArrayIsArray = Array.isArray; 1480 | const JSONStringify = JSON.stringify; 1481 | const ObjectGetOwnPropertyNames = Object.getOwnPropertyNames; 1482 | const ObjectPrototypeHasOwnProperty = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop); 1483 | const RegExpPrototypeExec = (obj, string) => RegExp.prototype.exec.call(obj, string); 1484 | const RegExpPrototypeSymbolReplace = (obj, ...rest) => RegExp.prototype[Symbol.replace].apply(obj, rest); 1485 | const StringPrototypeEndsWith = (str, ...rest) => String.prototype.endsWith.apply(str, rest); 1486 | const StringPrototypeIncludes = (str, ...rest) => String.prototype.includes.apply(str, rest); 1487 | const StringPrototypeLastIndexOf = (str, ...rest) => String.prototype.lastIndexOf.apply(str, rest); 1488 | const StringPrototypeIndexOf = (str, ...rest) => String.prototype.indexOf.apply(str, rest); 1489 | const StringPrototypeReplace = (str, ...rest) => String.prototype.replace.apply(str, rest); 1490 | const StringPrototypeSlice = (str, ...rest) => String.prototype.slice.apply(str, rest); 1491 | const StringPrototypeStartsWith = (str, ...rest) => String.prototype.startsWith.apply(str, rest); 1492 | const SafeMap = Map; 1493 | const JSONParse = JSON.parse; 1494 | 1495 | function createErrorType(code, messageCreator, errorType) { 1496 | return class extends errorType { 1497 | constructor(...args) { 1498 | super(messageCreator(...args)); 1499 | this.code = code; 1500 | this.name = `${errorType.name} [${code}]`; 1501 | } 1502 | }; 1503 | } 1504 | const ERR_PACKAGE_IMPORT_NOT_DEFINED = createErrorType( 1505 | `ERR_PACKAGE_IMPORT_NOT_DEFINED`, 1506 | (specifier, packagePath, base) => { 1507 | return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ``} imported from ${base}`; 1508 | }, 1509 | TypeError 1510 | ); 1511 | const ERR_INVALID_MODULE_SPECIFIER = createErrorType( 1512 | `ERR_INVALID_MODULE_SPECIFIER`, 1513 | (request, reason, base = void 0) => { 1514 | return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ``}`; 1515 | }, 1516 | TypeError 1517 | ); 1518 | const ERR_INVALID_PACKAGE_TARGET = createErrorType( 1519 | `ERR_INVALID_PACKAGE_TARGET`, 1520 | (pkgPath, key, target, isImport = false, base = void 0) => { 1521 | const relError = typeof target === `string` && !isImport && target.length && !StringPrototypeStartsWith(target, `./`); 1522 | if (key === `.`) { 1523 | assert(isImport === false); 1524 | return `Invalid "exports" main target ${JSONStringify(target)} defined in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ``}${relError ? `; targets must start with "./"` : ``}`; 1525 | } 1526 | return `Invalid "${isImport ? `imports` : `exports`}" target ${JSONStringify( 1527 | target 1528 | )} defined for '${key}' in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ``}${relError ? `; targets must start with "./"` : ``}`; 1529 | }, 1530 | Error 1531 | ); 1532 | const ERR_INVALID_PACKAGE_CONFIG = createErrorType( 1533 | `ERR_INVALID_PACKAGE_CONFIG`, 1534 | (path, base, message) => { 1535 | return `Invalid package config ${path}${base ? ` while importing ${base}` : ``}${message ? `. ${message}` : ``}`; 1536 | }, 1537 | Error 1538 | ); 1539 | 1540 | function filterOwnProperties(source, keys) { 1541 | const filtered = /* @__PURE__ */ Object.create(null); 1542 | for (let i = 0; i < keys.length; i++) { 1543 | const key = keys[i]; 1544 | if (ObjectPrototypeHasOwnProperty(source, key)) { 1545 | filtered[key] = source[key]; 1546 | } 1547 | } 1548 | return filtered; 1549 | } 1550 | 1551 | const packageJSONCache = new SafeMap(); 1552 | function getPackageConfig(path, specifier, base, readFileSyncFn) { 1553 | const existing = packageJSONCache.get(path); 1554 | if (existing !== void 0) { 1555 | return existing; 1556 | } 1557 | const source = readFileSyncFn(path); 1558 | if (source === void 0) { 1559 | const packageConfig2 = { 1560 | pjsonPath: path, 1561 | exists: false, 1562 | main: void 0, 1563 | name: void 0, 1564 | type: "none", 1565 | exports: void 0, 1566 | imports: void 0 1567 | }; 1568 | packageJSONCache.set(path, packageConfig2); 1569 | return packageConfig2; 1570 | } 1571 | let packageJSON; 1572 | try { 1573 | packageJSON = JSONParse(source); 1574 | } catch (error) { 1575 | throw new ERR_INVALID_PACKAGE_CONFIG( 1576 | path, 1577 | (base ? `"${specifier}" from ` : "") + fileURLToPath(base || specifier), 1578 | error.message 1579 | ); 1580 | } 1581 | let { imports, main, name, type } = filterOwnProperties(packageJSON, [ 1582 | "imports", 1583 | "main", 1584 | "name", 1585 | "type" 1586 | ]); 1587 | const exports = ObjectPrototypeHasOwnProperty(packageJSON, "exports") ? packageJSON.exports : void 0; 1588 | if (typeof imports !== "object" || imports === null) { 1589 | imports = void 0; 1590 | } 1591 | if (typeof main !== "string") { 1592 | main = void 0; 1593 | } 1594 | if (typeof name !== "string") { 1595 | name = void 0; 1596 | } 1597 | if (type !== "module" && type !== "commonjs") { 1598 | type = "none"; 1599 | } 1600 | const packageConfig = { 1601 | pjsonPath: path, 1602 | exists: true, 1603 | main, 1604 | name, 1605 | type, 1606 | exports, 1607 | imports 1608 | }; 1609 | packageJSONCache.set(path, packageConfig); 1610 | return packageConfig; 1611 | } 1612 | function getPackageScopeConfig(resolved, readFileSyncFn) { 1613 | let packageJSONUrl = new URL("./package.json", resolved); 1614 | while (true) { 1615 | const packageJSONPath2 = packageJSONUrl.pathname; 1616 | if (StringPrototypeEndsWith(packageJSONPath2, "node_modules/package.json")) { 1617 | break; 1618 | } 1619 | const packageConfig2 = getPackageConfig( 1620 | fileURLToPath(packageJSONUrl), 1621 | resolved, 1622 | void 0, 1623 | readFileSyncFn 1624 | ); 1625 | if (packageConfig2.exists) { 1626 | return packageConfig2; 1627 | } 1628 | const lastPackageJSONUrl = packageJSONUrl; 1629 | packageJSONUrl = new URL("../package.json", packageJSONUrl); 1630 | if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) { 1631 | break; 1632 | } 1633 | } 1634 | const packageJSONPath = fileURLToPath(packageJSONUrl); 1635 | const packageConfig = { 1636 | pjsonPath: packageJSONPath, 1637 | exists: false, 1638 | main: void 0, 1639 | name: void 0, 1640 | type: "none", 1641 | exports: void 0, 1642 | imports: void 0 1643 | }; 1644 | packageJSONCache.set(packageJSONPath, packageConfig); 1645 | return packageConfig; 1646 | } 1647 | 1648 | /** 1649 | @license 1650 | Copyright Node.js contributors. All rights reserved. 1651 | 1652 | Permission is hereby granted, free of charge, to any person obtaining a copy 1653 | of this software and associated documentation files (the "Software"), to 1654 | deal in the Software without restriction, including without limitation the 1655 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 1656 | sell copies of the Software, and to permit persons to whom the Software is 1657 | furnished to do so, subject to the following conditions: 1658 | 1659 | The above copyright notice and this permission notice shall be included in 1660 | all copies or substantial portions of the Software. 1661 | 1662 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1663 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1664 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1665 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1666 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 1667 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 1668 | IN THE SOFTWARE. 1669 | */ 1670 | function throwImportNotDefined(specifier, packageJSONUrl, base) { 1671 | throw new ERR_PACKAGE_IMPORT_NOT_DEFINED( 1672 | specifier, 1673 | packageJSONUrl && fileURLToPath(new URL(".", packageJSONUrl)), 1674 | fileURLToPath(base) 1675 | ); 1676 | } 1677 | function throwInvalidSubpath(subpath, packageJSONUrl, internal, base) { 1678 | const reason = `request is not a valid subpath for the "${internal ? "imports" : "exports"}" resolution of ${fileURLToPath(packageJSONUrl)}`; 1679 | throw new ERR_INVALID_MODULE_SPECIFIER( 1680 | subpath, 1681 | reason, 1682 | base && fileURLToPath(base) 1683 | ); 1684 | } 1685 | function throwInvalidPackageTarget(subpath, target, packageJSONUrl, internal, base) { 1686 | if (typeof target === "object" && target !== null) { 1687 | target = JSONStringify(target, null, ""); 1688 | } else { 1689 | target = `${target}`; 1690 | } 1691 | throw new ERR_INVALID_PACKAGE_TARGET( 1692 | fileURLToPath(new URL(".", packageJSONUrl)), 1693 | subpath, 1694 | target, 1695 | internal, 1696 | base && fileURLToPath(base) 1697 | ); 1698 | } 1699 | const invalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i; 1700 | const patternRegEx = /\*/g; 1701 | function resolvePackageTargetString(target, subpath, match, packageJSONUrl, base, pattern, internal, conditions) { 1702 | if (subpath !== "" && !pattern && target[target.length - 1] !== "/") 1703 | throwInvalidPackageTarget(match, target, packageJSONUrl, internal, base); 1704 | if (!StringPrototypeStartsWith(target, "./")) { 1705 | if (internal && !StringPrototypeStartsWith(target, "../") && !StringPrototypeStartsWith(target, "/")) { 1706 | let isURL = false; 1707 | try { 1708 | new URL(target); 1709 | isURL = true; 1710 | } catch { 1711 | } 1712 | if (!isURL) { 1713 | const exportTarget = pattern ? RegExpPrototypeSymbolReplace(patternRegEx, target, () => subpath) : target + subpath; 1714 | return exportTarget; 1715 | } 1716 | } 1717 | throwInvalidPackageTarget(match, target, packageJSONUrl, internal, base); 1718 | } 1719 | if (RegExpPrototypeExec( 1720 | invalidSegmentRegEx, 1721 | StringPrototypeSlice(target, 2) 1722 | ) !== null) 1723 | throwInvalidPackageTarget(match, target, packageJSONUrl, internal, base); 1724 | const resolved = new URL(target, packageJSONUrl); 1725 | const resolvedPath = resolved.pathname; 1726 | const packagePath = new URL(".", packageJSONUrl).pathname; 1727 | if (!StringPrototypeStartsWith(resolvedPath, packagePath)) 1728 | throwInvalidPackageTarget(match, target, packageJSONUrl, internal, base); 1729 | if (subpath === "") 1730 | return resolved; 1731 | if (RegExpPrototypeExec(invalidSegmentRegEx, subpath) !== null) { 1732 | const request = pattern ? StringPrototypeReplace(match, "*", () => subpath) : match + subpath; 1733 | throwInvalidSubpath(request, packageJSONUrl, internal, base); 1734 | } 1735 | if (pattern) { 1736 | return new URL( 1737 | RegExpPrototypeSymbolReplace(patternRegEx, resolved.href, () => subpath) 1738 | ); 1739 | } 1740 | return new URL(subpath, resolved); 1741 | } 1742 | function isArrayIndex(key) { 1743 | const keyNum = +key; 1744 | if (`${keyNum}` !== key) 1745 | return false; 1746 | return keyNum >= 0 && keyNum < 4294967295; 1747 | } 1748 | function resolvePackageTarget(packageJSONUrl, target, subpath, packageSubpath, base, pattern, internal, conditions) { 1749 | if (typeof target === "string") { 1750 | return resolvePackageTargetString( 1751 | target, 1752 | subpath, 1753 | packageSubpath, 1754 | packageJSONUrl, 1755 | base, 1756 | pattern, 1757 | internal); 1758 | } else if (ArrayIsArray(target)) { 1759 | if (target.length === 0) { 1760 | return null; 1761 | } 1762 | let lastException; 1763 | for (let i = 0; i < target.length; i++) { 1764 | const targetItem = target[i]; 1765 | let resolveResult; 1766 | try { 1767 | resolveResult = resolvePackageTarget( 1768 | packageJSONUrl, 1769 | targetItem, 1770 | subpath, 1771 | packageSubpath, 1772 | base, 1773 | pattern, 1774 | internal, 1775 | conditions 1776 | ); 1777 | } catch (e) { 1778 | lastException = e; 1779 | if (e.code === "ERR_INVALID_PACKAGE_TARGET") { 1780 | continue; 1781 | } 1782 | throw e; 1783 | } 1784 | if (resolveResult === void 0) { 1785 | continue; 1786 | } 1787 | if (resolveResult === null) { 1788 | lastException = null; 1789 | continue; 1790 | } 1791 | return resolveResult; 1792 | } 1793 | if (lastException === void 0 || lastException === null) 1794 | return lastException; 1795 | throw lastException; 1796 | } else if (typeof target === "object" && target !== null) { 1797 | const keys = ObjectGetOwnPropertyNames(target); 1798 | for (let i = 0; i < keys.length; i++) { 1799 | const key = keys[i]; 1800 | if (isArrayIndex(key)) { 1801 | throw new ERR_INVALID_PACKAGE_CONFIG( 1802 | fileURLToPath(packageJSONUrl), 1803 | base, 1804 | '"exports" cannot contain numeric property keys.' 1805 | ); 1806 | } 1807 | } 1808 | for (let i = 0; i < keys.length; i++) { 1809 | const key = keys[i]; 1810 | if (key === "default" || conditions.has(key)) { 1811 | const conditionalTarget = target[key]; 1812 | const resolveResult = resolvePackageTarget( 1813 | packageJSONUrl, 1814 | conditionalTarget, 1815 | subpath, 1816 | packageSubpath, 1817 | base, 1818 | pattern, 1819 | internal, 1820 | conditions 1821 | ); 1822 | if (resolveResult === void 0) 1823 | continue; 1824 | return resolveResult; 1825 | } 1826 | } 1827 | return void 0; 1828 | } else if (target === null) { 1829 | return null; 1830 | } 1831 | throwInvalidPackageTarget( 1832 | packageSubpath, 1833 | target, 1834 | packageJSONUrl, 1835 | internal, 1836 | base 1837 | ); 1838 | } 1839 | function patternKeyCompare(a, b) { 1840 | const aPatternIndex = StringPrototypeIndexOf(a, "*"); 1841 | const bPatternIndex = StringPrototypeIndexOf(b, "*"); 1842 | const baseLenA = aPatternIndex === -1 ? a.length : aPatternIndex + 1; 1843 | const baseLenB = bPatternIndex === -1 ? b.length : bPatternIndex + 1; 1844 | if (baseLenA > baseLenB) 1845 | return -1; 1846 | if (baseLenB > baseLenA) 1847 | return 1; 1848 | if (aPatternIndex === -1) 1849 | return 1; 1850 | if (bPatternIndex === -1) 1851 | return -1; 1852 | if (a.length > b.length) 1853 | return -1; 1854 | if (b.length > a.length) 1855 | return 1; 1856 | return 0; 1857 | } 1858 | function packageImportsResolve({ name, base, conditions, readFileSyncFn }) { 1859 | if (name === "#" || StringPrototypeStartsWith(name, "#/") || StringPrototypeEndsWith(name, "/")) { 1860 | const reason = "is not a valid internal imports specifier name"; 1861 | throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, fileURLToPath(base)); 1862 | } 1863 | let packageJSONUrl; 1864 | const packageConfig = getPackageScopeConfig(base, readFileSyncFn); 1865 | if (packageConfig.exists) { 1866 | packageJSONUrl = pathToFileURL(packageConfig.pjsonPath); 1867 | const imports = packageConfig.imports; 1868 | if (imports) { 1869 | if (ObjectPrototypeHasOwnProperty(imports, name) && !StringPrototypeIncludes(name, "*")) { 1870 | const resolveResult = resolvePackageTarget( 1871 | packageJSONUrl, 1872 | imports[name], 1873 | "", 1874 | name, 1875 | base, 1876 | false, 1877 | true, 1878 | conditions 1879 | ); 1880 | if (resolveResult != null) { 1881 | return resolveResult; 1882 | } 1883 | } else { 1884 | let bestMatch = ""; 1885 | let bestMatchSubpath; 1886 | const keys = ObjectGetOwnPropertyNames(imports); 1887 | for (let i = 0; i < keys.length; i++) { 1888 | const key = keys[i]; 1889 | const patternIndex = StringPrototypeIndexOf(key, "*"); 1890 | if (patternIndex !== -1 && StringPrototypeStartsWith( 1891 | name, 1892 | StringPrototypeSlice(key, 0, patternIndex) 1893 | )) { 1894 | const patternTrailer = StringPrototypeSlice(key, patternIndex + 1); 1895 | if (name.length >= key.length && StringPrototypeEndsWith(name, patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && StringPrototypeLastIndexOf(key, "*") === patternIndex) { 1896 | bestMatch = key; 1897 | bestMatchSubpath = StringPrototypeSlice( 1898 | name, 1899 | patternIndex, 1900 | name.length - patternTrailer.length 1901 | ); 1902 | } 1903 | } 1904 | } 1905 | if (bestMatch) { 1906 | const target = imports[bestMatch]; 1907 | const resolveResult = resolvePackageTarget( 1908 | packageJSONUrl, 1909 | target, 1910 | bestMatchSubpath, 1911 | bestMatch, 1912 | base, 1913 | true, 1914 | true, 1915 | conditions 1916 | ); 1917 | if (resolveResult != null) { 1918 | return resolveResult; 1919 | } 1920 | } 1921 | } 1922 | } 1923 | } 1924 | throwImportNotDefined(name, packageJSONUrl, base); 1925 | } 1926 | 1927 | const pathRegExp = /^(?![a-zA-Z]:[\\/]|\\\\|\.{0,2}(?:\/|$))((?:node:)?(?:@[^/]+\/)?[^/]+)\/*(.*|)$/; 1928 | const isRelativeRegexp = /^\.{0,2}\//; 1929 | function tryReadFile(filePath) { 1930 | try { 1931 | return fs.readFileSync(filePath, `utf8`); 1932 | } catch (err) { 1933 | if (err.code === `ENOENT`) 1934 | return void 0; 1935 | throw err; 1936 | } 1937 | } 1938 | async function resolvePrivateRequest(specifier, issuer, context, nextResolve) { 1939 | const resolved = packageImportsResolve({ 1940 | name: specifier, 1941 | base: pathToFileURL(issuer), 1942 | conditions: new Set(context.conditions), 1943 | readFileSyncFn: tryReadFile 1944 | }); 1945 | if (resolved instanceof URL$1) { 1946 | return { url: resolved.href, shortCircuit: true }; 1947 | } else { 1948 | if (resolved.startsWith(`#`)) 1949 | throw new Error(`Mapping from one private import to another isn't allowed`); 1950 | return resolve$1(resolved, context, nextResolve); 1951 | } 1952 | } 1953 | async function resolve$1(originalSpecifier, context, nextResolve) { 1954 | var _a; 1955 | const { findPnpApi } = moduleExports; 1956 | if (!findPnpApi || isBuiltinModule(originalSpecifier)) 1957 | return nextResolve(originalSpecifier, context, nextResolve); 1958 | let specifier = originalSpecifier; 1959 | const url = tryParseURL(specifier, isRelativeRegexp.test(specifier) ? context.parentURL : void 0); 1960 | if (url) { 1961 | if (url.protocol !== `file:`) 1962 | return nextResolve(originalSpecifier, context, nextResolve); 1963 | specifier = fileURLToPath(url); 1964 | } 1965 | const { parentURL, conditions = [] } = context; 1966 | const issuer = parentURL ? fileURLToPath(parentURL) : process.cwd(); 1967 | const pnpapi = (_a = findPnpApi(issuer)) != null ? _a : url ? findPnpApi(specifier) : null; 1968 | if (!pnpapi) 1969 | return nextResolve(originalSpecifier, context, nextResolve); 1970 | if (specifier.startsWith(`#`)) 1971 | return resolvePrivateRequest(specifier, issuer, context, nextResolve); 1972 | const dependencyNameMatch = specifier.match(pathRegExp); 1973 | let allowLegacyResolve = false; 1974 | if (dependencyNameMatch) { 1975 | const [, dependencyName, subPath] = dependencyNameMatch; 1976 | if (subPath === `` && dependencyName !== `pnpapi`) { 1977 | const resolved = pnpapi.resolveToUnqualified(`${dependencyName}/package.json`, issuer); 1978 | if (resolved) { 1979 | const content = await tryReadFile$1(resolved); 1980 | if (content) { 1981 | const pkg = JSON.parse(content); 1982 | allowLegacyResolve = pkg.exports == null; 1983 | } 1984 | } 1985 | } 1986 | } 1987 | let result; 1988 | try { 1989 | result = pnpapi.resolveRequest(specifier, issuer, { 1990 | conditions: new Set(conditions), 1991 | extensions: allowLegacyResolve ? void 0 : [] 1992 | }); 1993 | } catch (err) { 1994 | if (err instanceof Error && `code` in err && err.code === `MODULE_NOT_FOUND`) 1995 | err.code = `ERR_MODULE_NOT_FOUND`; 1996 | throw err; 1997 | } 1998 | if (!result) 1999 | throw new Error(`Resolving '${specifier}' from '${issuer}' failed`); 2000 | const resultURL = pathToFileURL(result); 2001 | if (url) { 2002 | resultURL.search = url.search; 2003 | resultURL.hash = url.hash; 2004 | } 2005 | if (!parentURL) 2006 | setEntrypointPath(fileURLToPath(resultURL)); 2007 | return { 2008 | url: resultURL.href, 2009 | shortCircuit: true 2010 | }; 2011 | } 2012 | 2013 | if (!HAS_LAZY_LOADED_TRANSLATORS) { 2014 | const binding = process.binding(`fs`); 2015 | const originalfstat = binding.fstat; 2016 | const ZIP_MASK = 4278190080; 2017 | const ZIP_MAGIC = 704643072; 2018 | binding.fstat = function(...args) { 2019 | const [fd, useBigint, req] = args; 2020 | if ((fd & ZIP_MASK) === ZIP_MAGIC && useBigint === false && req === void 0) { 2021 | try { 2022 | const stats = fs.fstatSync(fd); 2023 | return new Float64Array([ 2024 | stats.dev, 2025 | stats.mode, 2026 | stats.nlink, 2027 | stats.uid, 2028 | stats.gid, 2029 | stats.rdev, 2030 | stats.blksize, 2031 | stats.ino, 2032 | stats.size, 2033 | stats.blocks 2034 | ]); 2035 | } catch { 2036 | } 2037 | } 2038 | return originalfstat.apply(this, args); 2039 | }; 2040 | } 2041 | 2042 | const resolve = resolve$1; 2043 | const getFormat = HAS_CONSOLIDATED_HOOKS ? void 0 : getFormat$1; 2044 | const getSource = HAS_CONSOLIDATED_HOOKS ? void 0 : getSource$1; 2045 | const load = HAS_CONSOLIDATED_HOOKS ? load$1 : void 0; 2046 | 2047 | export { getFormat, getSource, load, resolve }; 2048 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # email_worker_parser 2 | 3 | ![](./image/ui.png) 4 | 5 | # 6 | ``` shell 7 | 8 | wrangler d1 create Create D1 database 9 | 10 | wrangler d1 execute --file ./sql/schema.sql 11 | ``` 12 | 13 | ### change wrangler.toml 14 | ``` 15 | [[d1_databases]] 16 | binding = "DB" # i.e. available in your Worker on env.DB 17 | database_name = "cf_email_xxx" 18 | database_id = "202c0469-b860-4993-ba42-xxxxx" 19 | 20 | [vars] 21 | forward_address = "xxx@email.com;yyy@email.com" 22 | CLOUDFLARE_EMAIL = "" 23 | CLOUDFLARE_API_KEY = "" 24 | ZONE_ID = "" 25 | ACCOUNT_ID = "" 26 | EMAIL_DOMAIN = "" 27 | ``` 28 | 29 | ``` 30 | wrangler deploy 31 | ``` 32 | 33 | ``` 34 | # create a new email address 35 | get https://yourname.workers.dev/email/create 36 | 37 | { 38 | "success": true, 39 | "data": { 40 | "fetch_endpoint": "/email/v75pwnekqwisy3efdlk3tq@example.com", 41 | "address": "v75pwnekqwisy3efdlk3tq@example.com" 42 | } 43 | } 44 | 45 | # get email list 46 | get https://yourname.workers.dev/email/{address}?parser=cursor 47 | 48 | { 49 | "data": [ 50 | { 51 | "id": 2, 52 | "subject": "Re: hi", 53 | "from": "xxxx", 54 | "to": "xxx", 55 | "html": null, 56 | "text": null, 57 | "createdAt": "2024-06-26 06:01:05", 58 | "parsed_code": "703589" 59 | } 60 | 61 | ], 62 | "success": true 63 | } 64 | 65 | ``` 66 | 67 | ### Usage 68 | ``` 69 | "text": "发件人: \"Cursor\" 解析后的 JSON 响应 79 | */ 80 | public async _request( 81 | method: string, 82 | endpoint: string, 83 | queryParams?: URLSearchParams, 84 | body?: any 85 | ): Promise { 86 | const url = new URL(`${this.baseUrl}${endpoint}`); 87 | if (queryParams) { 88 | url.search = queryParams.toString(); 89 | } 90 | 91 | console.log(`Fetching URL: ${method.toUpperCase()} ${url.toString()}`); // 添加日志 92 | 93 | // --- 修改请求头 --- 94 | const headers: HeadersInit = { 95 | // 'Authorization': `Bearer ${this.apiKey}`, // 使用此行替代下面两行,如果你用的是 API Token 96 | 'X-Auth-Key': this.apiKey, // Global API Key 97 | 'X-Auth-Email': this.clientEmail || '', // 使用存储的 email 字符串。如果未提供,则为空字符串 (可能导致 API 错误) 98 | 'Content-Type': 'application/json' 99 | }; 100 | 101 | // 如果 email 是严格必需的,可以在这里添加检查 102 | // if (!this.clientEmail) { 103 | // throw new Error("Cloudflare email is required for this API request but was not provided."); 104 | // } 105 | 106 | const options: RequestInit = { 107 | method: method.toUpperCase(), 108 | headers: headers, 109 | }; 110 | 111 | if (body && !['GET', 'HEAD'].includes(method.toUpperCase())) { 112 | options.body = JSON.stringify(body); 113 | } 114 | 115 | try { 116 | const response = await fetch(url.toString(), options); 117 | 118 | if (!response.ok) { 119 | const errorBody = await response.text(); 120 | console.error(`Cloudflare API Error: ${response.status} ${response.statusText}`, errorBody); 121 | throw new Error(`Cloudflare API request failed: ${response.status} ${response.statusText} - ${errorBody}`); 122 | } 123 | 124 | if (response.status === 204) { // No Content 125 | return null; 126 | } 127 | 128 | const text = await response.text(); 129 | return text ? JSON.parse(text) : null; // Handle empty responses that are not 204 130 | 131 | } catch (error) { 132 | console.error(`Error fetching from Cloudflare API (${method} ${endpoint}):`, error); 133 | throw error; 134 | } 135 | } 136 | } 137 | 138 | // --- Email 相关 API --- 139 | class EmailAPI { 140 | constructor(private client: CloudflareClient) { 141 | // 初始化 Email 下的子资源 142 | this.rules = new EmailRulesAPI(client); 143 | // 可以添加其他 email 相关资源, e.g., this.settings = ... 144 | } 145 | public readonly rules: EmailRulesAPI; 146 | // public readonly settings: EmailSettingsAPI; 147 | } 148 | 149 | // --- Email Routing Rules API --- 150 | class EmailRulesAPI { 151 | constructor(private client: CloudflareClient) { } 152 | 153 | /** 154 | * 创建邮件路由规则 155 | * @param params 创建规则所需的参数,包括 zoneId 156 | * @returns Promise Cloudflare API 响应 157 | */ 158 | async create(params: CreateEmailRuleParams): Promise<{ success: boolean; result: EmailRule; errors: any[]; messages: any[] } | null> { 159 | const { zoneId, ...ruleData } = params; // 从参数中分离 zoneId 和规则数据 160 | if (!zoneId) { 161 | throw new Error("zoneId is required to create an email rule."); 162 | } 163 | const endpoint = `/zones/${zoneId}/email/routing/rules`; 164 | 165 | // 确保请求体符合 API 预期格式 166 | const body: Partial = { 167 | name: ruleData.name, 168 | enabled: ruleData.enabled ?? true, // 默认为 true 169 | priority: ruleData.priority ?? 0, // 默认为 0 170 | matchers: ruleData.matchers, 171 | actions: ruleData.actions 172 | }; 173 | 174 | console.log(`Attempting to create email rule '${ruleData.name}' in zone ${zoneId}`); 175 | try { 176 | const result = await this.client._request('POST', endpoint, undefined, body); 177 | console.log('Email rule created successfully:', result); 178 | return result; 179 | } catch (error) { 180 | console.error(`Failed to create email rule '${ruleData.name}':`, error); 181 | throw error; // 重新抛出,让上层处理 182 | } 183 | } 184 | 185 | // --- 这里可以添加 list, get, update, delete 等其他规则操作 --- 186 | // async list(zoneId: string): Promise { ... } 187 | // async get(zoneId: string, ruleId: string): Promise { ... } 188 | // async update(zoneId: string, ruleId: string, params: UpdateEmailRuleParams): Promise { ... } 189 | // async delete(zoneId: string, ruleId: string): Promise { ... } 190 | } 191 | 192 | // --- 导出客户端类,但不导出内部实现细节 --- 193 | export { CloudflareClient }; 194 | 195 | // --- 不再需要旧的 create_email_rule 函数 --- 196 | // export async function create_email_rule(...) { ... } 197 | 198 | 199 | /* 200 | // --- 示例如何调用 (需要配置环境变量) --- 201 | async function main() { 202 | const apiKey = process.env.CLOUDFLARE_API_KEY; 203 | const zoneId = process.env.ZONE_ID; 204 | const yourDomain = process.env.YOUR_DOMAIN; // e.g., example.com 205 | 206 | if (!apiKey || !zoneId || !yourDomain) { 207 | console.error('Error: 请设置 CLOUDFLARE_API_KEY, ZONE_ID, 和 YOUR_DOMAIN 环境变量。'); 208 | return; 209 | } 210 | 211 | // 1. 创建 Cloudflare 客户端实例 212 | const client = new CloudflareClient({ apiKey: apiKey }); 213 | 214 | // 2. 定义规则参数 215 | const ruleName = 'Forward Test Email'; 216 | const matchToEmail = `test@${yourDomain}`; // 匹配发送到 test@your-domain.com 的邮件 217 | const forwardTo = 'your-personal-email@gmail.com'; // 修改为你的目标邮箱 218 | 219 | const ruleParams: CreateEmailRuleParams = { 220 | zoneId: zoneId, 221 | name: ruleName, 222 | enabled: true, 223 | priority: 10, // 可以设置优先级 224 | matchers: [ 225 | { type: "literal", field: "to", value: matchToEmail } 226 | ], 227 | actions: [ 228 | { type: "forward", value: [forwardTo] } 229 | ] 230 | }; 231 | 232 | try { 233 | // 3. 调用客户端方法创建规则 234 | console.log(`Creating rule: ${ruleName}`); 235 | const ruleResult = await client.email.rules.create(ruleParams); 236 | 237 | if (ruleResult && ruleResult.success) { 238 | console.log('Successfully created rule:', ruleResult.result.name, 'with ID:', ruleResult.result.tag); 239 | } else { 240 | // 处理 API 返回的错误或无结果的情况 241 | console.log('Rule creation request processed, but Cloudflare API indicated potential issues or no result data.'); 242 | if (ruleResult) { 243 | console.error('Errors:', ruleResult.errors); 244 | console.warn('Messages:', ruleResult.messages); 245 | } 246 | } 247 | } catch (err) { 248 | console.error('Rule creation failed in main:', err); 249 | } 250 | } 251 | 252 | // main(); // 取消注释以运行示例 253 | */ 254 | 255 | 256 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import PostalMime, { Email } from 'postal-mime'; 2 | import { CloudflareClient } from './cf_api'; 3 | import { parsers } from './parser/index.js'; 4 | import { EmailMessage } from "cloudflare:email"; 5 | 6 | interface Event { 7 | raw: ReadableStream; 8 | rawSize: number; 9 | forward: (email: string) => Promise; 10 | } 11 | 12 | export interface Env { 13 | DB: D1Database; 14 | forward_address: string; 15 | CLOUDFLARE_EMAIL: string; 16 | CLOUDFLARE_API_KEY: string; 17 | ZONE_ID: string; 18 | ACCOUNT_ID: string; 19 | EMAIL_DOMAIN: string; 20 | } 21 | 22 | interface Ctx { } 23 | 24 | async function streamToArrayBuffer(stream: ReadableStream, streamSize: number): Promise { 25 | const result = new Uint8Array(streamSize); 26 | let bytesRead = 0; 27 | const reader = stream.getReader(); 28 | while (true) { 29 | const { done, value } = await reader.read(); 30 | if (done) break; 31 | result.set(value, bytesRead); 32 | bytesRead += value.length; 33 | } 34 | return result; 35 | } 36 | 37 | // --- 简易路由系统 --- 38 | type Handler = (request: Request, env: Env, ctx: Ctx, params: Record) => Promise; 39 | const routes: { method: string; path: string; handler: Handler }[] = []; 40 | 41 | function register(method: string, path: string, handler: Handler) { 42 | routes.push({ method, path, handler }); 43 | } 44 | 45 | function matchRoute(method: string, url: string): { handler: Handler, params: Record } | null { 46 | for (const route of routes) { 47 | if (route.method !== method) continue; 48 | 49 | const routeParts = route.path.split('/').filter(Boolean); 50 | const urlParts = url.split('/').filter(Boolean); 51 | 52 | if (routeParts.length !== urlParts.length) continue; 53 | 54 | const params: Record = {}; 55 | let matched = true; 56 | 57 | for (let i = 0; i < routeParts.length; i++) { 58 | if (routeParts[i].startsWith(':')) { 59 | params[routeParts[i].substring(1)] = decodeURIComponent(urlParts[i]); 60 | } else if (routeParts[i] !== urlParts[i]) { 61 | matched = false; 62 | break; 63 | } 64 | } 65 | 66 | if (matched) return { handler: route.handler, params }; 67 | } 68 | return null; 69 | } 70 | 71 | // --- 路由处理逻辑 --- 72 | 73 | // 创建 Email 地址 74 | register('GET', '/email/create', async (request, env, ctx, params) => { 75 | const client = new CloudflareClient({ 76 | apiKey: env.CLOUDFLARE_API_KEY, 77 | email: env.CLOUDFLARE_EMAIL, 78 | accountId: env.ACCOUNT_ID, 79 | zoneId: env.ZONE_ID 80 | }); 81 | 82 | const randomEmail = Math.random().toString(36).substring(2, 15) 83 | + Math.random().toString(36).substring(2, 15) 84 | + '@' + env.EMAIL_DOMAIN; 85 | 86 | try { 87 | const rule = await client.email.rules.create({ 88 | zoneId: env.ZONE_ID, 89 | name: `Forward to ${randomEmail}`, 90 | enabled: true, 91 | priority: 10, 92 | matchers: [{ type: 'literal', field: 'to', value: randomEmail }], 93 | actions: [{ type: 'worker', value: ['email_worker_parser'] }] 94 | }); 95 | 96 | if (rule && rule.success) { 97 | return new Response(JSON.stringify({ 98 | success: true, 99 | data: { 100 | fetch_endpoint: `/email/${randomEmail}`, 101 | address: randomEmail 102 | } 103 | }), { headers: { 'content-type': 'application/json' } }); 104 | } else { 105 | return new Response(JSON.stringify({ 106 | success: false, 107 | error: 'Failed to create email rule via Cloudflare API', 108 | details: rule?.errors ?? 'Unknown API error' 109 | }), { status: 500, headers: { 'content-type': 'application/json' } }); 110 | } 111 | } catch (error: any) { 112 | return new Response(JSON.stringify({ 113 | success: false, 114 | error: 'Error communicating with Cloudflare API', 115 | details: error.message 116 | }), { status: 500, headers: { 'content-type': 'application/json' } }); 117 | } 118 | }); 119 | 120 | // email/:address 路由处理 121 | register('GET', '/email/:address', async (request, env, ctx, params) => { 122 | const { address } = params; // 获取 :address 部分 123 | const url = new URL(request.url); 124 | 125 | // 获取查询参数 'limit' 和 'parser' 126 | const limit = url.searchParams.get('limit'); 127 | const parserName = url.searchParams.get('parser'); 128 | 129 | // 默认情况下限制结果数量 130 | const maxResults = limit ? parseInt(limit, 10) : 10; // 默认10条记录 131 | const parser = parserName ? parsers[parserName] : null; 132 | 133 | try { 134 | const { results, success, meta } = await env.DB 135 | .prepare('SELECT "subject", "from", "to", "html", "text", "createdAt" FROM Email WHERE "to" = ? ORDER BY createdAt DESC LIMIT ?') 136 | .bind(address, maxResults) // 绑定 address 和 limit 137 | .run(); 138 | 139 | if (success) { 140 | // 如果存在解析器,解析邮件内容 141 | if (parser) { 142 | results.forEach((item) => { 143 | const code = parser(item.text); 144 | item['parsed_code'] = code; 145 | }); 146 | } 147 | 148 | return new Response(JSON.stringify({ success: true, data: results }), { 149 | headers: { 'content-type': 'application/json' }, 150 | }); 151 | } else { 152 | console.error("D1 query failed:", meta); 153 | return new Response(JSON.stringify({ success: false, error: 'Failed to retrieve emails' }), { 154 | status: 500, 155 | headers: { 'content-type': 'application/json' }, 156 | }); 157 | } 158 | } catch (e: any) { 159 | console.error("Error fetching from D1:", e); 160 | return new Response(JSON.stringify({ success: false, error: 'Query error', details: e.message }), { 161 | status: 500, 162 | headers: { 'content-type': 'application/json' }, 163 | }); 164 | } 165 | }); 166 | 167 | // help 168 | register('GET', '/help', async (request, env, ctx, params) => { 169 | // 返回帮助信息 html 170 | const html = ` 171 | 172 | 173 | 174 | 175 | 176 | Help Page 177 | 206 | 207 | 208 |

API Help & Documentation

209 |

Welcome to the API documentation! Below are the available endpoints and their usage:

210 |
    211 |
  • /email/create - Create a random email address and get the endpoint to forward emails
  • 212 |
  • /email/:address - Get the email content received by a specific address
  • 213 |
214 | 215 |

Parameters for /email/:address:

216 |
    217 |
  • limit: Optional. Limits the number of emails returned. Default is 10.
  • 218 |
  • parser: Optional. Specifies the parser to be used for email content.
  • 219 |
220 | 221 |

Example Usage:

222 |
223 | GET /email/create
224 | POST /email/:address?limit=5&parser=exampleParser
225 |             
226 |

For more information, feel free to contact support.

227 | 228 | UI 229 | 230 | 231 | `; 232 | 233 | return new Response(html, { 234 | headers: { 'Content-Type': 'text/html' }, 235 | }); 236 | }); 237 | 238 | // ui 239 | register('GET', '/ui', async (request, env, ctx, params) => { 240 | const html = ` 241 | 242 | 243 | 244 | 245 | 246 | Interface 247 | 375 | 376 | 377 |
378 | 381 | Github 382 | Help 383 | 384 |
385 |

Email Interface

386 | 387 | 388 | 389 | 390 | 391 | 392 | 464 | 465 | 466 | `; 467 | 468 | return new Response(html, { 469 | headers: { 'Content-Type': 'text/html' }, 470 | }); 471 | }); 472 | 473 | 474 | 475 | // index 476 | register('GET', '/', async (request, env, ctx, params) => { 477 | const url = new URL(request.url); 478 | const UI_URL = new URL('/ui', url.origin).toString(); 479 | return Response.redirect(UI_URL); 480 | }); 481 | 482 | 483 | export default { 484 | async fetch(request: Request, env: Env, ctx: Ctx): Promise { 485 | const url = new URL(request.url); 486 | const match = matchRoute(request.method, url.pathname); 487 | if (match) { 488 | return await match.handler(request, env, ctx, match.params); 489 | } 490 | 491 | return new Response(JSON.stringify({ 492 | error: 'Invalid path. Use /email/create or /email/:address' 493 | }), { status: 404, headers: { 'content-type': 'application/json' } }); 494 | }, 495 | 496 | async email(message: EmailMessage, env: Env, ctx: Ctx): Promise { 497 | try { 498 | const rawEmail = await streamToArrayBuffer(message.raw, message.rawSize); 499 | const parser = new PostalMime(); 500 | const parsedEmail: Email = await parser.parse(rawEmail); 501 | 502 | await env.DB.prepare( 503 | `INSERT INTO Email ("subject", "from", "to", "html", "text") VALUES (?, ?, ?, ?, ?)` 504 | ) 505 | .bind( 506 | parsedEmail.subject ?? 'None', 507 | parsedEmail.from?.address, 508 | parsedEmail.to[0]?.address ?? 'None', 509 | parsedEmail.html, 510 | parsedEmail.text 511 | ) 512 | .run(); 513 | } catch (error) { 514 | console.error('Insert email error:', error.message); 515 | } finally { 516 | const list = env.forward_address.split(';'); 517 | for (const address of list) { 518 | await message.forward(address); 519 | } 520 | } 521 | }, 522 | }; 523 | -------------------------------------------------------------------------------- /src/parser/cursor.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 解析包含换行符的验证码文本 3 | * @param {string} text - 需要解析的文本 4 | * @returns {string|null} - 返回解析到的验证码,如果没有找到则返回null 5 | */ 6 | export default function parse(text) { 7 | // 清理文本:去除多余的空白字符和换行符 8 | const cleanText = text.replace(/\s+/g, ' ').trim(); 9 | 10 | const pattern = /one-time code is:?\s*(\d+)/i; 11 | 12 | const match = cleanText.match(pattern); 13 | if (match && match[1]) { 14 | return match[1]; 15 | } 16 | 17 | // 如果上面的匹配失败,尝试直接匹配数字 18 | const numberMatch = cleanText.match(/\d{6}/); 19 | return numberMatch ? numberMatch[0] : null; 20 | } 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/parser/index.js: -------------------------------------------------------------------------------- 1 | import cursor from './cursor.js'; 2 | 3 | export const parsers = { 4 | cursor, 5 | }; 6 | -------------------------------------------------------------------------------- /wrangler.toml.example: -------------------------------------------------------------------------------- 1 | name = "email_worker_parser" 2 | main = "src/index.ts" 3 | compatibility_date = "2024-06-06" 4 | 5 | [[d1_databases]] 6 | binding = "DB" # i.e. available in your Worker on env.DB 7 | database_name = "cf_email_1" 8 | database_id = "" 9 | 10 | [vars] 11 | forward_address = "" 12 | CLOUDFLARE_EMAIL = "" 13 | CLOUDFLARE_API_KEY = "" 14 | ZONE_ID = "" 15 | ACCOUNT_ID = "" 16 | EMAIL_DOMAIN = "" -------------------------------------------------------------------------------- /yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | "@babel/runtime-corejs3@^7.15.4": 6 | version "7.21.5" 7 | resolved "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.21.5.tgz" 8 | integrity sha512-FRqFlFKNazWYykft5zvzuEl1YyTDGsIRrjV9rvxvYkUC7W/ueBng1X68Xd6uRMzAaJ0xMKn08/wem5YS1lpX8w== 9 | dependencies: 10 | core-js-pure "^3.25.1" 11 | regenerator-runtime "^0.13.11" 12 | 13 | "@babel/runtime@^7.15.4": 14 | version "7.21.5" 15 | resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.21.5.tgz" 16 | integrity sha512-8jI69toZqqcsnqGGqwGS4Qb1VwLOEp4hz+CXPywcvjs60u3B4Pom/U/7rm4W8tMOYEB+E9wgD0mW1l3r8qlI9Q== 17 | dependencies: 18 | regenerator-runtime "^0.13.11" 19 | 20 | "@cloudflare/kv-asset-handler@0.3.3": 21 | version "0.3.3" 22 | resolved "https://registry.npmjs.org/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.3.3.tgz" 23 | integrity sha512-wpE+WiWW2kUNwNE0xyl4CtTAs+STjGtouHGiZPGRaisGB7eXXdbvfZdOrQJQVKgTxZiNAgVgmc7fj0sUmd8zyA== 24 | dependencies: 25 | mime "^3.0.0" 26 | 27 | "@cloudflare/workerd-windows-64@1.20240610.1": 28 | version "1.20240610.1" 29 | resolved "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20240610.1.tgz" 30 | integrity sha512-B0LyT3DB6rXHWNptnntYHPaoJIy0rXnGfeDBM3nEVV8JIsQrx8MEFn2F2jYioH1FkUVavsaqKO/zUosY3tZXVA== 31 | 32 | "@cspotcode/source-map-support@0.8.1": 33 | version "0.8.1" 34 | resolved "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz" 35 | integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw== 36 | dependencies: 37 | "@jridgewell/trace-mapping" "0.3.9" 38 | 39 | "@esbuild-plugins/node-globals-polyfill@^0.2.3": 40 | version "0.2.3" 41 | resolved "https://registry.npmjs.org/@esbuild-plugins/node-globals-polyfill/-/node-globals-polyfill-0.2.3.tgz" 42 | integrity sha512-r3MIryXDeXDOZh7ih1l/yE9ZLORCd5e8vWg02azWRGj5SPTuoh69A2AIyn0Z31V/kHBfZ4HgWJ+OK3GTTwLmnw== 43 | 44 | "@esbuild-plugins/node-modules-polyfill@^0.2.2": 45 | version "0.2.2" 46 | resolved "https://registry.npmjs.org/@esbuild-plugins/node-modules-polyfill/-/node-modules-polyfill-0.2.2.tgz" 47 | integrity sha512-LXV7QsWJxRuMYvKbiznh+U1ilIop3g2TeKRzUxOG5X3YITc8JyyTa90BmLwqqv0YnX4v32CSlG+vsziZp9dMvA== 48 | dependencies: 49 | escape-string-regexp "^4.0.0" 50 | rollup-plugin-node-polyfills "^0.2.1" 51 | 52 | "@esbuild/win32-x64@0.17.19": 53 | version "0.17.19" 54 | resolved "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz" 55 | integrity sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA== 56 | 57 | "@fastify/busboy@^2.0.0": 58 | version "2.1.1" 59 | resolved "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz" 60 | integrity sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA== 61 | 62 | "@jridgewell/resolve-uri@^3.0.3": 63 | version "3.1.2" 64 | resolved "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz" 65 | integrity sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw== 66 | 67 | "@jridgewell/sourcemap-codec@^1.4.10": 68 | version "1.4.15" 69 | resolved "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz" 70 | integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== 71 | 72 | "@jridgewell/trace-mapping@0.3.9": 73 | version "0.3.9" 74 | resolved "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz" 75 | integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== 76 | dependencies: 77 | "@jridgewell/resolve-uri" "^3.0.3" 78 | "@jridgewell/sourcemap-codec" "^1.4.10" 79 | 80 | "@tsconfig/esm@^1.0.2": 81 | version "1.0.3" 82 | resolved "https://registry.npmjs.org/@tsconfig/esm/-/esm-1.0.3.tgz" 83 | integrity sha512-Gp56rIc3R8ab032nXMUitmc7YIb4nAi8DQ6Qt47tuL0Ssn9LIOm+o2FQmqPu3jX4z0TsqgzWwkmVygxcq+yHYg== 84 | 85 | "@tsconfig/node18@^2.0.0": 86 | version "2.0.1" 87 | resolved "https://registry.npmjs.org/@tsconfig/node18/-/node18-2.0.1.tgz" 88 | integrity sha512-UqdfvuJK0SArA2CxhKWwwAWfnVSXiYe63bVpMutc27vpngCntGUZQETO24pEJ46zU6XM+7SpqYoMgcO3bM11Ew== 89 | 90 | "@tsconfig/strictest@^2.0.0": 91 | version "2.0.1" 92 | resolved "https://registry.npmjs.org/@tsconfig/strictest/-/strictest-2.0.1.tgz" 93 | integrity sha512-7JHHCbyCsGUxLd0pDbp24yz3zjxw2t673W5oAP6HCEdr/UUhaRhYd3SSnUsGCk+VnPVJVA4mXROzbhI+nyIk+w== 94 | 95 | "@types/node@^20.1.2": 96 | version "20.1.4" 97 | resolved "https://registry.npmjs.org/@types/node/-/node-20.1.4.tgz" 98 | integrity sha512-At4pvmIOki8yuwLtd7BNHl3CiWNbtclUbNtScGx4OHfBd4/oWoJC8KRCIxXwkdndzhxOsPXihrsOoydxBjlE9Q== 99 | 100 | acorn-walk@^8.2.0: 101 | version "8.3.3" 102 | resolved "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.3.tgz" 103 | integrity sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw== 104 | dependencies: 105 | acorn "^8.11.0" 106 | 107 | acorn@^8.11.0, acorn@^8.8.0: 108 | version "8.12.0" 109 | resolved "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz" 110 | integrity sha512-RTvkC4w+KNXrM39/lWCUaG0IbRkWdCv7W/IOW9oU6SawyxulvkQy5HQPVTKxEjczcUvapcrw3cFx/60VN/NRNw== 111 | 112 | anymatch@~3.1.2: 113 | version "3.1.3" 114 | resolved "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz" 115 | integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== 116 | dependencies: 117 | normalize-path "^3.0.0" 118 | picomatch "^2.0.4" 119 | 120 | as-table@^1.0.36: 121 | version "1.0.55" 122 | resolved "https://registry.npmjs.org/as-table/-/as-table-1.0.55.tgz" 123 | integrity sha512-xvsWESUJn0JN421Xb9MQw6AsMHRCUknCe0Wjlxvjud80mU4E6hQf1A6NzQKcYNmYw62MfzEtXc+badstZP3JpQ== 124 | dependencies: 125 | printable-characters "^1.0.42" 126 | 127 | binary-extensions@^2.0.0: 128 | version "2.2.0" 129 | resolved "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz" 130 | integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== 131 | 132 | blake3-wasm@^2.1.5: 133 | version "2.1.5" 134 | resolved "https://registry.npmjs.org/blake3-wasm/-/blake3-wasm-2.1.5.tgz" 135 | integrity sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g== 136 | 137 | braces@~3.0.2: 138 | version "3.0.2" 139 | resolved "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz" 140 | integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== 141 | dependencies: 142 | fill-range "^7.0.1" 143 | 144 | capnp-ts@^0.7.0: 145 | version "0.7.0" 146 | resolved "https://registry.npmjs.org/capnp-ts/-/capnp-ts-0.7.0.tgz" 147 | integrity sha512-XKxXAC3HVPv7r674zP0VC3RTXz+/JKhfyw94ljvF80yynK6VkTnqE3jMuN8b3dUVmmc43TjyxjW4KTsmB3c86g== 148 | dependencies: 149 | debug "^4.3.1" 150 | tslib "^2.2.0" 151 | 152 | chokidar@^3.5.3: 153 | version "3.5.3" 154 | resolved "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz" 155 | integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== 156 | dependencies: 157 | anymatch "~3.1.2" 158 | braces "~3.0.2" 159 | glob-parent "~5.1.2" 160 | is-binary-path "~2.1.0" 161 | is-glob "~4.0.1" 162 | normalize-path "~3.0.0" 163 | readdirp "~3.6.0" 164 | optionalDependencies: 165 | fsevents "~2.3.2" 166 | 167 | consola@^3.2.3: 168 | version "3.2.3" 169 | resolved "https://registry.npmjs.org/consola/-/consola-3.2.3.tgz" 170 | integrity sha512-I5qxpzLv+sJhTVEoLYNcTW+bThDCPsit0vLNKShZx6rLtpilNpmmeTPaeqJb9ZE9dV3DGaeby6Vuhrw38WjeyQ== 171 | 172 | cookie@^0.5.0: 173 | version "0.5.0" 174 | resolved "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz" 175 | integrity sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw== 176 | 177 | core-js-pure@^3.25.1: 178 | version "3.30.2" 179 | resolved "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.30.2.tgz" 180 | integrity sha512-p/npFUJXXBkCCTIlEGBdghofn00jWG6ZOtdoIXSJmAu2QBvN0IqpZXWweOytcwE6cfx8ZvVUy1vw8zxhe4Y2vg== 181 | 182 | data-uri-to-buffer@^2.0.0: 183 | version "2.0.2" 184 | resolved "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-2.0.2.tgz" 185 | integrity sha512-ND9qDTLc6diwj+Xe5cdAgVTbLVdXbtxTJRXRhli8Mowuaan+0EJOtdqJ0QCHNSSPyoXGx9HX2/VMnKeC34AChA== 186 | 187 | debug@^4.3.1: 188 | version "4.3.5" 189 | resolved "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz" 190 | integrity sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg== 191 | dependencies: 192 | ms "2.1.2" 193 | 194 | defu@^6.1.4: 195 | version "6.1.4" 196 | resolved "https://registry.npmjs.org/defu/-/defu-6.1.4.tgz" 197 | integrity sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg== 198 | 199 | esbuild@*, esbuild@0.17.19: 200 | version "0.17.19" 201 | resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.17.19.tgz" 202 | integrity sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw== 203 | optionalDependencies: 204 | "@esbuild/android-arm" "0.17.19" 205 | "@esbuild/android-arm64" "0.17.19" 206 | "@esbuild/android-x64" "0.17.19" 207 | "@esbuild/darwin-arm64" "0.17.19" 208 | "@esbuild/darwin-x64" "0.17.19" 209 | "@esbuild/freebsd-arm64" "0.17.19" 210 | "@esbuild/freebsd-x64" "0.17.19" 211 | "@esbuild/linux-arm" "0.17.19" 212 | "@esbuild/linux-arm64" "0.17.19" 213 | "@esbuild/linux-ia32" "0.17.19" 214 | "@esbuild/linux-loong64" "0.17.19" 215 | "@esbuild/linux-mips64el" "0.17.19" 216 | "@esbuild/linux-ppc64" "0.17.19" 217 | "@esbuild/linux-riscv64" "0.17.19" 218 | "@esbuild/linux-s390x" "0.17.19" 219 | "@esbuild/linux-x64" "0.17.19" 220 | "@esbuild/netbsd-x64" "0.17.19" 221 | "@esbuild/openbsd-x64" "0.17.19" 222 | "@esbuild/sunos-x64" "0.17.19" 223 | "@esbuild/win32-arm64" "0.17.19" 224 | "@esbuild/win32-ia32" "0.17.19" 225 | "@esbuild/win32-x64" "0.17.19" 226 | 227 | escape-string-regexp@^4.0.0: 228 | version "4.0.0" 229 | resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz" 230 | integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== 231 | 232 | estree-walker@^0.6.1: 233 | version "0.6.1" 234 | resolved "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz" 235 | integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w== 236 | 237 | exit-hook@^2.2.1: 238 | version "2.2.1" 239 | resolved "https://registry.npmjs.org/exit-hook/-/exit-hook-2.2.1.tgz" 240 | integrity sha512-eNTPlAD67BmP31LDINZ3U7HSF8l57TxOY2PmBJ1shpCvpnxBF93mWCE8YHBnXs8qiUZJc9WDcWIeC3a2HIAMfw== 241 | 242 | fill-range@^7.0.1: 243 | version "7.0.1" 244 | resolved "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz" 245 | integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== 246 | dependencies: 247 | to-regex-range "^5.0.1" 248 | 249 | function-bind@^1.1.2: 250 | version "1.1.2" 251 | resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz" 252 | integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== 253 | 254 | get-source@^2.0.12: 255 | version "2.0.12" 256 | resolved "https://registry.npmjs.org/get-source/-/get-source-2.0.12.tgz" 257 | integrity sha512-X5+4+iD+HoSeEED+uwrQ07BOQr0kEDFMVqqpBuI+RaZBpBpHCuXxo70bjar6f0b0u/DQJsJ7ssurpP0V60Az+w== 258 | dependencies: 259 | data-uri-to-buffer "^2.0.0" 260 | source-map "^0.6.1" 261 | 262 | glob-parent@~5.1.2: 263 | version "5.1.2" 264 | resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz" 265 | integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== 266 | dependencies: 267 | is-glob "^4.0.1" 268 | 269 | glob-to-regexp@^0.4.1: 270 | version "0.4.1" 271 | resolved "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz" 272 | integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== 273 | 274 | hasown@^2.0.2: 275 | version "2.0.2" 276 | resolved "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz" 277 | integrity sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ== 278 | dependencies: 279 | function-bind "^1.1.2" 280 | 281 | is-binary-path@~2.1.0: 282 | version "2.1.0" 283 | resolved "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz" 284 | integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== 285 | dependencies: 286 | binary-extensions "^2.0.0" 287 | 288 | is-core-module@^2.13.0: 289 | version "2.14.0" 290 | resolved "https://registry.npmjs.org/is-core-module/-/is-core-module-2.14.0.tgz" 291 | integrity sha512-a5dFJih5ZLYlRtDc0dZWP7RiKr6xIKzmn/oAYCDvdLThadVgyJwlaoQPmRtMSpz+rk0OGAgIu+TcM9HUF0fk1A== 292 | dependencies: 293 | hasown "^2.0.2" 294 | 295 | is-extglob@^2.1.1: 296 | version "2.1.1" 297 | resolved "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz" 298 | integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== 299 | 300 | is-glob@^4.0.1, is-glob@~4.0.1: 301 | version "4.0.3" 302 | resolved "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz" 303 | integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== 304 | dependencies: 305 | is-extglob "^2.1.1" 306 | 307 | is-number@^7.0.0: 308 | version "7.0.0" 309 | resolved "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz" 310 | integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== 311 | 312 | js-base64@^3.7.5: 313 | version "3.7.5" 314 | resolved "https://registry.npmjs.org/js-base64/-/js-base64-3.7.5.tgz" 315 | integrity sha512-3MEt5DTINKqfScXKfJFrRbxkrnk2AxPWGBL/ycjz4dK8iqiSJ06UxD8jh8xuh6p10TX4t2+7FsBYVxxQbMg+qA== 316 | 317 | magic-string@^0.25.3: 318 | version "0.25.9" 319 | resolved "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz" 320 | integrity sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ== 321 | dependencies: 322 | sourcemap-codec "^1.4.8" 323 | 324 | mime-db@1.52.0: 325 | version "1.52.0" 326 | resolved "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz" 327 | integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== 328 | 329 | mime-types@^2.1.35: 330 | version "2.1.35" 331 | resolved "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz" 332 | integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== 333 | dependencies: 334 | mime-db "1.52.0" 335 | 336 | mime@^3.0.0: 337 | version "3.0.0" 338 | resolved "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz" 339 | integrity sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A== 340 | 341 | mimetext@^3.0.10: 342 | version "3.0.10" 343 | resolved "https://registry.npmjs.org/mimetext/-/mimetext-3.0.10.tgz" 344 | integrity sha512-O2/5wt5Jb6Yv7KL//Qlu2YadVHWtixgD04LMxlf48G3sdsh6UsWh/Z7FWd2GOfs3ITN8fWWdEWVLFubY4NGmow== 345 | dependencies: 346 | "@babel/runtime" "^7.15.4" 347 | "@babel/runtime-corejs3" "^7.15.4" 348 | "@tsconfig/esm" "^1.0.2" 349 | "@tsconfig/node18" "^2.0.0" 350 | "@tsconfig/strictest" "^2.0.0" 351 | "@types/node" "^20.1.2" 352 | js-base64 "^3.7.5" 353 | mime-types "^2.1.35" 354 | 355 | miniflare@3.20240610.1: 356 | version "3.20240610.1" 357 | resolved "https://registry.npmjs.org/miniflare/-/miniflare-3.20240610.1.tgz" 358 | integrity sha512-ZkfSpBmX3nJW00yYhvF2kGvjb6f77TOimRR6+2GQvsArbwo6e0iYqLGM9aB/cnJzgFjLMvOv1qj4756iynSxJQ== 359 | dependencies: 360 | "@cspotcode/source-map-support" "0.8.1" 361 | acorn "^8.8.0" 362 | acorn-walk "^8.2.0" 363 | capnp-ts "^0.7.0" 364 | exit-hook "^2.2.1" 365 | glob-to-regexp "^0.4.1" 366 | stoppable "^1.1.0" 367 | undici "^5.28.4" 368 | workerd "1.20240610.1" 369 | ws "^8.14.2" 370 | youch "^3.2.2" 371 | zod "^3.22.3" 372 | 373 | ms@2.1.2: 374 | version "2.1.2" 375 | resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz" 376 | integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== 377 | 378 | mustache@^4.2.0: 379 | version "4.2.0" 380 | resolved "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz" 381 | integrity sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ== 382 | 383 | nanoid@^3.3.3: 384 | version "3.3.4" 385 | resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz" 386 | integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw== 387 | 388 | node-fetch-native@^1.6.4: 389 | version "1.6.4" 390 | resolved "https://registry.npmjs.org/node-fetch-native/-/node-fetch-native-1.6.4.tgz" 391 | integrity sha512-IhOigYzAKHd244OC0JIMIUrjzctirCmPkaIfhDeGcEETWof5zKYUW7e7MYvChGWh/4CJeXEgsRyGzuF334rOOQ== 392 | 393 | node-forge@^1: 394 | version "1.3.1" 395 | resolved "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz" 396 | integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA== 397 | 398 | normalize-path@^3.0.0, normalize-path@~3.0.0: 399 | version "3.0.0" 400 | resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz" 401 | integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== 402 | 403 | path-parse@^1.0.7: 404 | version "1.0.7" 405 | resolved "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz" 406 | integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== 407 | 408 | path-to-regexp@^6.2.0: 409 | version "6.2.1" 410 | resolved "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.1.tgz" 411 | integrity sha512-JLyh7xT1kizaEvcaXOQwOc2/Yhw6KZOvPf1S8401UyLk86CU79LN3vl7ztXGm/pZ+YjoyAJ4rxmHwbkBXJX+yw== 412 | 413 | pathe@^1.1.2: 414 | version "1.1.2" 415 | resolved "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz" 416 | integrity sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ== 417 | 418 | picomatch@^2.0.4, picomatch@^2.2.1: 419 | version "2.3.1" 420 | resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz" 421 | integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== 422 | 423 | postal-mime@^1.0.16: 424 | version "1.0.16" 425 | resolved "https://registry.npmjs.org/postal-mime/-/postal-mime-1.0.16.tgz" 426 | integrity sha512-DIpZ6HfV8GIGerAOui+Q3YEE9EZNK3sdZdH2yGVhbVsB7F6bbD3L4D+W2wch7aV+aOkY5EMjMuKYbRDQGdSQBA== 427 | 428 | printable-characters@^1.0.42: 429 | version "1.0.42" 430 | resolved "https://registry.npmjs.org/printable-characters/-/printable-characters-1.0.42.tgz" 431 | integrity sha512-dKp+C4iXWK4vVYZmYSd0KBH5F/h1HoZRsbJ82AVKRO3PEo8L4lBS/vLwhVtpwwuYcoIsVY+1JYKR268yn480uQ== 432 | 433 | readdirp@~3.6.0: 434 | version "3.6.0" 435 | resolved "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz" 436 | integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== 437 | dependencies: 438 | picomatch "^2.2.1" 439 | 440 | regenerator-runtime@^0.13.11: 441 | version "0.13.11" 442 | resolved "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz" 443 | integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg== 444 | 445 | resolve.exports@^2.0.2: 446 | version "2.0.2" 447 | resolved "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.2.tgz" 448 | integrity sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg== 449 | 450 | resolve@^1.22.8: 451 | version "1.22.8" 452 | resolved "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz" 453 | integrity sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw== 454 | dependencies: 455 | is-core-module "^2.13.0" 456 | path-parse "^1.0.7" 457 | supports-preserve-symlinks-flag "^1.0.0" 458 | 459 | rollup-plugin-inject@^3.0.0: 460 | version "3.0.2" 461 | resolved "https://registry.npmjs.org/rollup-plugin-inject/-/rollup-plugin-inject-3.0.2.tgz" 462 | integrity sha512-ptg9PQwzs3orn4jkgXJ74bfs5vYz1NCZlSQMBUA0wKcGp5i5pA1AO3fOUEte8enhGUC+iapTCzEWw2jEFFUO/w== 463 | dependencies: 464 | estree-walker "^0.6.1" 465 | magic-string "^0.25.3" 466 | rollup-pluginutils "^2.8.1" 467 | 468 | rollup-plugin-node-polyfills@^0.2.1: 469 | version "0.2.1" 470 | resolved "https://registry.npmjs.org/rollup-plugin-node-polyfills/-/rollup-plugin-node-polyfills-0.2.1.tgz" 471 | integrity sha512-4kCrKPTJ6sK4/gLL/U5QzVT8cxJcofO0OU74tnB19F40cmuAKSzH5/siithxlofFEjwvw1YAhPmbvGNA6jEroA== 472 | dependencies: 473 | rollup-plugin-inject "^3.0.0" 474 | 475 | rollup-pluginutils@^2.8.1: 476 | version "2.8.2" 477 | resolved "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz" 478 | integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ== 479 | dependencies: 480 | estree-walker "^0.6.1" 481 | 482 | selfsigned@^2.0.1: 483 | version "2.1.1" 484 | resolved "https://registry.npmjs.org/selfsigned/-/selfsigned-2.1.1.tgz" 485 | integrity sha512-GSL3aowiF7wa/WtSFwnUrludWFoNhftq8bUkH9pkzjpN2XSPOAYEgg6e0sS9s0rZwgJzJiQRPU18A6clnoW5wQ== 486 | dependencies: 487 | node-forge "^1" 488 | 489 | source-map@^0.6.1: 490 | version "0.6.1" 491 | resolved "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz" 492 | integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== 493 | 494 | sourcemap-codec@^1.4.8: 495 | version "1.4.8" 496 | resolved "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz" 497 | integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA== 498 | 499 | stacktracey@^2.1.8: 500 | version "2.1.8" 501 | resolved "https://registry.npmjs.org/stacktracey/-/stacktracey-2.1.8.tgz" 502 | integrity sha512-Kpij9riA+UNg7TnphqjH7/CzctQ/owJGNbFkfEeve4Z4uxT5+JapVLFXcsurIfN34gnTWZNJ/f7NMG0E8JDzTw== 503 | dependencies: 504 | as-table "^1.0.36" 505 | get-source "^2.0.12" 506 | 507 | stoppable@^1.1.0: 508 | version "1.1.0" 509 | resolved "https://registry.npmjs.org/stoppable/-/stoppable-1.1.0.tgz" 510 | integrity sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw== 511 | 512 | supports-preserve-symlinks-flag@^1.0.0: 513 | version "1.0.0" 514 | resolved "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz" 515 | integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== 516 | 517 | to-regex-range@^5.0.1: 518 | version "5.0.1" 519 | resolved "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz" 520 | integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== 521 | dependencies: 522 | is-number "^7.0.0" 523 | 524 | tslib@^2.2.0: 525 | version "2.6.3" 526 | resolved "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz" 527 | integrity sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ== 528 | 529 | ufo@^1.5.3: 530 | version "1.5.3" 531 | resolved "https://registry.npmjs.org/ufo/-/ufo-1.5.3.tgz" 532 | integrity sha512-Y7HYmWaFwPUmkoQCUIAYpKqkOf+SbVj/2fJJZ4RJMCfZp0rTGwRbzQD+HghfnhKOjL9E01okqz+ncJskGYfBNw== 533 | 534 | undici@^5.28.4: 535 | version "5.28.4" 536 | resolved "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz" 537 | integrity sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g== 538 | dependencies: 539 | "@fastify/busboy" "^2.0.0" 540 | 541 | "unenv@npm:unenv-nightly@1.10.0-1717606461.a117952": 542 | version "1.10.0-1717606461.a117952" 543 | resolved "https://registry.npmjs.org/unenv-nightly/-/unenv-nightly-1.10.0-1717606461.a117952.tgz" 544 | integrity sha512-u3TfBX02WzbHTpaEfWEKwDijDSFAHcgXkayUZ+MVDrjhLFvgAJzFGTSTmwlEhwWi2exyRQey23ah9wELMM6etg== 545 | dependencies: 546 | consola "^3.2.3" 547 | defu "^6.1.4" 548 | mime "^3.0.0" 549 | node-fetch-native "^1.6.4" 550 | pathe "^1.1.2" 551 | ufo "^1.5.3" 552 | 553 | workerd@1.20240610.1: 554 | version "1.20240610.1" 555 | resolved "https://registry.npmjs.org/workerd/-/workerd-1.20240610.1.tgz" 556 | integrity sha512-Rtut5GrsODQMh6YU43b9WZ980Wd05Ov1/ds88pT/SoetmXFBvkBzdRfiHiATv+azmGX8KveE0i/Eqzk/yI01ug== 557 | optionalDependencies: 558 | "@cloudflare/workerd-darwin-64" "1.20240610.1" 559 | "@cloudflare/workerd-darwin-arm64" "1.20240610.1" 560 | "@cloudflare/workerd-linux-64" "1.20240610.1" 561 | "@cloudflare/workerd-linux-arm64" "1.20240610.1" 562 | "@cloudflare/workerd-windows-64" "1.20240610.1" 563 | 564 | wrangler@^3.61.0: 565 | version "3.61.0" 566 | resolved "https://registry.npmjs.org/wrangler/-/wrangler-3.61.0.tgz" 567 | integrity sha512-feVAp0986x9xL3Dc1zin0ZVXKaqzp7eZur7iPLnpEwjG1Xy4dkVEZ5a1LET94Iyejt1P+EX5lgGcz63H7EfzUw== 568 | dependencies: 569 | "@cloudflare/kv-asset-handler" "0.3.3" 570 | "@esbuild-plugins/node-globals-polyfill" "^0.2.3" 571 | "@esbuild-plugins/node-modules-polyfill" "^0.2.2" 572 | blake3-wasm "^2.1.5" 573 | chokidar "^3.5.3" 574 | esbuild "0.17.19" 575 | miniflare "3.20240610.1" 576 | nanoid "^3.3.3" 577 | path-to-regexp "^6.2.0" 578 | resolve "^1.22.8" 579 | resolve.exports "^2.0.2" 580 | selfsigned "^2.0.1" 581 | source-map "^0.6.1" 582 | unenv "npm:unenv-nightly@1.10.0-1717606461.a117952" 583 | xxhash-wasm "^1.0.1" 584 | optionalDependencies: 585 | fsevents "~2.3.2" 586 | 587 | ws@^8.14.2: 588 | version "8.17.1" 589 | resolved "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz" 590 | integrity sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ== 591 | 592 | xxhash-wasm@^1.0.1: 593 | version "1.0.2" 594 | resolved "https://registry.npmjs.org/xxhash-wasm/-/xxhash-wasm-1.0.2.tgz" 595 | integrity sha512-ibF0Or+FivM9lNrg+HGJfVX8WJqgo+kCLDc4vx6xMeTce7Aj+DLttKbxxRR/gNLSAelRc1omAPlJ77N/Jem07A== 596 | 597 | youch@^3.2.2: 598 | version "3.3.3" 599 | resolved "https://registry.npmjs.org/youch/-/youch-3.3.3.tgz" 600 | integrity sha512-qSFXUk3UZBLfggAW3dJKg0BMblG5biqSF8M34E06o5CSsZtH92u9Hqmj2RzGiHDi64fhe83+4tENFP2DB6t6ZA== 601 | dependencies: 602 | cookie "^0.5.0" 603 | mustache "^4.2.0" 604 | stacktracey "^2.1.8" 605 | 606 | zod@^3.22.3: 607 | version "3.23.8" 608 | resolved "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz" 609 | integrity sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g== 610 | --------------------------------------------------------------------------------