next.js/packages/next/src/compiled/write-file-atomic/index.js
index.js1 lines7.0 KB
(()=>{"use strict";var e={537:(e,t,i)=>{e.exports=writeFile;e.exports.sync=writeFileSync;e.exports._getTmpname=getTmpname;e.exports._cleanupOnExit=cleanupOnExit;const s=i(896);const n=i(598);const{onExit:r}=i(767);const o=i(928);const{promisify:c}=i(23);const a={};const l=function getId(){try{const e=i(167);return e.threadId}catch(e){return 0}}();let f=0;function getTmpname(e){return e+"."+n.createHash("sha1").update(__filename).update(String(process.pid)).update(String(l)).update(String(++f)).digest().readUInt32BE(0)}function cleanupOnExit(e){return()=>{try{s.unlinkSync(typeof e==="function"?e():e)}catch{}}}function serializeActiveFile(e){return new Promise((t=>{if(!a[e]){a[e]=[]}a[e].push(t);if(a[e].length===1){t()}}))}function isChownErrOk(e){if(e.code==="ENOSYS"){return true}const t=!process.getuid||process.getuid()!==0;if(t){if(e.code==="EINVAL"||e.code==="EPERM"){return true}}return false}async function writeFileAsync(e,t,i={}){if(typeof i==="string"){i={encoding:i}}let n;let l;const f=r(cleanupOnExit((()=>l)));const u=o.resolve(e);try{await serializeActiveFile(u);const r=await c(s.realpath)(e).catch((()=>e));l=getTmpname(r);if(!i.mode||!i.chown){const e=await c(s.stat)(r).catch((()=>{}));if(e){if(i.mode==null){i.mode=e.mode}if(i.chown==null&&process.getuid){i.chown={uid:e.uid,gid:e.gid}}}}n=await c(s.open)(l,"w",i.mode);if(i.tmpfileCreated){await i.tmpfileCreated(l)}if(ArrayBuffer.isView(t)){await c(s.write)(n,t,0,t.length,0)}else if(t!=null){await c(s.write)(n,String(t),0,String(i.encoding||"utf8"))}if(i.fsync!==false){await c(s.fsync)(n)}await c(s.close)(n);n=null;if(i.chown){await c(s.chown)(l,i.chown.uid,i.chown.gid).catch((e=>{if(!isChownErrOk(e)){throw e}}))}if(i.mode){await c(s.chmod)(l,i.mode).catch((e=>{if(!isChownErrOk(e)){throw e}}))}await c(s.rename)(l,r)}finally{if(n){await c(s.close)(n).catch((()=>{}))}f();await c(s.unlink)(l).catch((()=>{}));a[u].shift();if(a[u].length>0){a[u][0]()}else{delete a[u]}}}async function writeFile(e,t,i,s){if(i instanceof Function){s=i;i={}}const n=writeFileAsync(e,t,i);if(s){try{const e=await n;return s(e)}catch(e){return s(e)}}return n}function writeFileSync(e,t,i){if(typeof i==="string"){i={encoding:i}}else if(!i){i={}}try{e=s.realpathSync(e)}catch(e){}const n=getTmpname(e);if(!i.mode||!i.chown){try{const t=s.statSync(e);i=Object.assign({},i);if(!i.mode){i.mode=t.mode}if(!i.chown&&process.getuid){i.chown={uid:t.uid,gid:t.gid}}}catch(e){}}let o;const c=cleanupOnExit(n);const a=r(c);let l=true;try{o=s.openSync(n,"w",i.mode||438);if(i.tmpfileCreated){i.tmpfileCreated(n)}if(ArrayBuffer.isView(t)){s.writeSync(o,t,0,t.length,0)}else if(t!=null){s.writeSync(o,String(t),0,String(i.encoding||"utf8"))}if(i.fsync!==false){s.fsyncSync(o)}s.closeSync(o);o=null;if(i.chown){try{s.chownSync(n,i.chown.uid,i.chown.gid)}catch(e){if(!isChownErrOk(e)){throw e}}}if(i.mode){try{s.chmodSync(n,i.mode)}catch(e){if(!isChownErrOk(e)){throw e}}}s.renameSync(n,e);l=false}finally{if(o){try{s.closeSync(o)}catch(e){}}a();if(l){c()}}}},896:e=>{e.exports=require("fs")},598:e=>{e.exports=require("node:crypto")},928:e=>{e.exports=require("path")},23:e=>{e.exports=require("util")},167:e=>{e.exports=require("worker_threads")},767:(e,t,i)=>{var s;Object.defineProperty(t,"__esModule",{value:true});t.unload=t.load=t.onExit=t.signals=void 0;const n=i(362);Object.defineProperty(t,"signals",{enumerable:true,get:function(){return n.signals}});const processOk=e=>!!e&&typeof e==="object"&&typeof e.removeListener==="function"&&typeof e.emit==="function"&&typeof e.reallyExit==="function"&&typeof e.listeners==="function"&&typeof e.kill==="function"&&typeof e.pid==="number"&&typeof e.on==="function";const r=Symbol.for("signal-exit emitter");const o=globalThis;const c=Object.defineProperty.bind(Object);class Emitter{emitted={afterExit:false,exit:false};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(o[r]){return o[r]}c(o,r,{value:this,writable:false,enumerable:false,configurable:false})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){const i=this.listeners[e];const s=i.indexOf(t);if(s===-1){return}if(s===0&&i.length===1){i.length=0}else{i.splice(s,1)}}emit(e,t,i){if(this.emitted[e]){return false}this.emitted[e]=true;let s=false;for(const n of this.listeners[e]){s=n(t,i)===true||s}if(e==="exit"){s=this.emit("afterExit",t,i)||s}return s}}class SignalExitBase{}const signalExitWrap=e=>({onExit(t,i){return e.onExit(t,i)},load(){return e.load()},unload(){return e.unload()}});class SignalExitFallback extends SignalExitBase{onExit(){return()=>{}}load(){}unload(){}}class SignalExit extends SignalExitBase{#e=a.platform==="win32"?"SIGINT":"SIGHUP";#t=new Emitter;#i;#s;#n;#r={};#o=false;constructor(e){super();this.#i=e;this.#r={};for(const t of n.signals){this.#r[t]=()=>{const i=this.#i.listeners(t);let{count:s}=this.#t;const n=e;if(typeof n.__signal_exit_emitter__==="object"&&typeof n.__signal_exit_emitter__.count==="number"){s+=n.__signal_exit_emitter__.count}if(i.length===s){this.unload();const i=this.#t.emit("exit",null,t);const s=t==="SIGHUP"?this.#e:t;if(!i)e.kill(e.pid,s)}}}this.#n=e.reallyExit;this.#s=e.emit}onExit(e,t){if(!processOk(this.#i)){return()=>{}}if(this.#o===false){this.load()}const i=t?.alwaysLast?"afterExit":"exit";this.#t.on(i,e);return()=>{this.#t.removeListener(i,e);if(this.#t.listeners["exit"].length===0&&this.#t.listeners["afterExit"].length===0){this.unload()}}}load(){if(this.#o){return}this.#o=true;this.#t.count+=1;for(const e of n.signals){try{const t=this.#r[e];if(t)this.#i.on(e,t)}catch(e){}}this.#i.emit=(e,...t)=>this.#c(e,...t);this.#i.reallyExit=e=>this.#a(e)}unload(){if(!this.#o){return}this.#o=false;n.signals.forEach((e=>{const t=this.#r[e];if(!t){throw new Error("Listener not defined for signal: "+e)}try{this.#i.removeListener(e,t)}catch(e){}}));this.#i.emit=this.#s;this.#i.reallyExit=this.#n;this.#t.count-=1}#a(e){if(!processOk(this.#i)){return 0}this.#i.exitCode=e||0;this.#t.emit("exit",this.#i.exitCode,null);return this.#n.call(this.#i,this.#i.exitCode)}#c(e,...t){const i=this.#s;if(e==="exit"&&processOk(this.#i)){if(typeof t[0]==="number"){this.#i.exitCode=t[0]}const s=i.call(this.#i,e,...t);this.#t.emit("exit",this.#i.exitCode,null);return s}else{return i.call(this.#i,e,...t)}}}const a=globalThis.process;s=signalExitWrap(processOk(a)?new SignalExit(a):new SignalExitFallback),t.onExit=s.onExit,t.load=s.load,t.unload=s.unload},362:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.signals=void 0;t.signals=[];t.signals.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32"){t.signals.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT")}if(process.platform==="linux"){t.signals.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")}}};var t={};function __nccwpck_require__(i){var s=t[i];if(s!==undefined){return s.exports}var n=t[i]={exports:{}};var r=true;try{e[i](n,n.exports,__nccwpck_require__);r=false}finally{if(r)delete t[i]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var i=__nccwpck_require__(537);module.exports=i})();
Quest for Codev2.0.0
/
SIGN IN