PageSourceSearch

https://www.007icu.top/assets/node-D-rPrXY2.js

js 007icu.top collected 2026-10-09 04:34:43 UTC 27,336 bytes, 4 lines download raw bytes

1import{n as e}from"./rolldown-runtime-CMxvf4Kt.js";import{a as t,c as n,d as r,i,m as a,n as o,p as s,r as c}from"./utils-52664384-zQO3JEdK.js";import{n as l,t as u}from"./base-80a1f760-C2zjpM5S.js";import{a as d,c as f,i as p,l as m,n as ee,o as h,r as te,s as ne,t as re}from"./consoleHook-59e792cb-BszIP1RK.js";function ie(e,t){switch(t){case`s`:return e;case`d`:case`i`:return Number(e);case`j`:return JSON.stringify(e);case`o`:{if(typeof e==`string`)return e;let t=JSON.stringify(e);return t===`{}`||t===`[]`||/^\[object .+?\]$/.test(t)?e:t}}}function g(e,...t){if(t.length===0)return e;let n=0,r=e.replace(H,(e,r,i,a)=>{let o=t[n],s=ie(o,a);return r?e:(n++,s)});return n<t.length&&(r+=` ${t.slice(n).join(` `)}`),r=r.replace(/%{2,2}/g,`%`),r}function ae(e){if(!e.stack)return;let t=e.stack.split(`
2`);t.splice(1,U),e.stack=t.join(`
3`)}function oe(e){return function(t,...n){if(q===`true`){let r=()=>t.includes(`sender`)?`${ue}sender`:t.includes(`receiver`)?`${de}receiver`:``,i=t.replace(/\[.+\]:/,``);console.debug(`${he[e]}${e}:${r()}${le}:${i}`,...n)}}}var _,v,y,b,x,S,C,w,se,T,ce,E,D,O,k,A,j,M,N,P,F,I,L,R,z,B,V,H,U,W,G,K,q,le,ue,de,fe,pe,me,J,he,Y,ge,X,_e,ve,Z,ye,be,xe,Se,Ce,we,Q,Te,Ee,De=e((()=>{_=Object.create,v=Object.defineProperty,y=Object.getOwnPropertyDescriptor,b=Object.getOwnPropertyNames,x=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty,C=(e,t,n)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>function(){return t||(0,e[b(e)[0]])((t={exports:{}}).exports,t),t.exports},se=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of b(t))!S.call(e,i)&&i!==n&&v(e,i,{get:()=>t[i],enumerable:!(r=y(t,i))||r.enumerable});return e},T=(e,t,n)=>(n=e==null?{}:_(x(e)),se(t||!e||!e.__esModule?v(n,`default`,{value:e,enumerable:!0}):n,e)),ce=(e,t,n)=>(C(e,typeof t==`symbol`?t:t+``,n),n),E=(e,t,n)=>{if(!t.has(e))throw TypeError(`Cannot `+n)},D=(e,t,n)=>(E(e,t,`read from private field`),n?n.call(e):t.get(e)),O=(e,t,n)=>{if(t.has(e))throw TypeError(`Cannot add the same private member more than once`);t instanceof WeakSet?t.add(e):t.set(e,n)},k=(e,t,n,r)=>(E(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),A=(e,t,n)=>(E(e,t,`access private method`),n),j=w({"../../node_modules/.pnpm/[email protected]/node_modules/cuid/lib/pad.js"(e,t){t.exports=function(e,t){var n=`000000000`+e;return n.substr(n.length-t)}}}),M=w({"../../node_modules/.pnpm/[email protected]/node_modules/cuid/lib/fingerprint.browser.js"(e,t){var n=j(),r=Object.keys(typeof window==`object`?window:self).length,i=n(((navigator.mimeTypes?navigator.mimeTypes.length:0)+navigator.userAgent.length).toString(36)+r.toString(36),4);t.exports=function(){return i}}}),N=w({"../../node_modules/.pnpm/[email protected]/node_modules/cuid/lib/getRandomValue.browser.js"(e,t){var n,r=typeof window<`u`&&(window.crypto||window.msCrypto)||typeof self<`u`&&self.crypto;r?(i=2**32-1,n=function(){return Math.abs(r.getRandomValues(new Uint32Array(1))[0]/i)}):n=Math.random;var i;t.exports=n}}),P=w({"../../node_modules/.pnpm/[email protected]/node_modules/cuid/index.js"(e,t){var n=M(),r=j(),i=N(),a=0,o=4,s=36,c=s**+o;function l(){return r((i()*c<<0).toString(s),o)}function u(){return a=a<c?a:0,a++,a-1}function d(){var e=`c`,t=new Date().getTime().toString(s),i=r(u().toString(s),o),a=n(),c=l()+l();return e+t+i+a+c}d.slug=function(){var e=new Date().getTime().toString(36),t=u().toString(36).slice(-4),r=n().slice(0,1)+n().slice(-1),i=l().slice(-2);return e.slice(-2)+t+r+i},d.isCuid=function(e){return typeof e==`string`?!!e.startsWith(`c`):!1},d.isSlug=function(e){if(typeof e!=`string`)return!1;var t=e.length;return t>=7&&t<=10},d.fingerprint=n,t.exports=d}}),F=w({"../../node_modules/.pnpm/@[email protected]/node_modules/@open-draft/deferred-promise/build/createDeferredExecutor.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.createDeferredExecutor=void 0;function t(){let e=(t,n)=>{e.state=`pending`,e.resolve=n=>e.state===`pending`?(e.result=n,t(n instanceof Promise?n:Promise.resolve(n).then(t=>(e.state=`fulfilled`,t)))):void 0,e.reject=t=>{if(e.state===`pending`)return queueMicrotask(()=>{e.state=`rejected`}),n(e.rejectionReason=t)}};return e}e.createDeferredExecutor=t}}),I=w({"../../node_modules/.pnpm/@[email protected]/node_modules/@open-draft/deferred-promise/build/DeferredPromise.js"(e){Object.defineProperty(e,"__esMo
3dule",{value:!0}),e.DeferredPromise=void 0;var t=F();e.DeferredPromise=class extends Promise{#e;resolve;reject;constructor(e=null){let n=(0,t.createDeferredExecutor)();super((t,r)=>{n(t,r),e?.(n.resolve,n.reject)}),this.#e=n,this.resolve=this.#e.resolve,this.reject=this.#e.reject}get state(){return this.#e.state}get rejectionReason(){return this.#e.rejectionReason}then(e,t){return this.#t(super.then(e,t))}catch(e){return this.#t(super.catch(e))}finally(e){return this.#t(super.finally(e))}#t(e){return Object.defineProperties(e,{resolve:{configurable:!0,value:this.resolve},reject:{configurable:!0,value:this.reject}})}}}}),L=w({"../../node_modules/.pnpm/@[email protected]/node_modules/@open-draft/deferred-promise/build/index.js"(e){var t=e&&e.__createBinding||(Object.create?function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}),n=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(F(),e),n(I(),e)}}),R=w({"../../node_modules/.pnpm/[email protected]/node_modules/strict-event-emitter/lib/MemoryLeakError.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.MemoryLeakError=void 0,e.MemoryLeakError=class extends Error{emitter;type;count;constructor(e,t,n){super(`Possible EventEmitter memory leak detected. ${n} ${t.toString()} listeners added. Use emitter.setMaxListeners() to increase limit`),this.emitter=e,this.type=t,this.count=n,this.name=`MaxListenersExceededWarning`}}}}),z=w({"../../node_modules/.pnpm/[email protected]/node_modules/strict-event-emitter/lib/Emitter.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Emitter=void 0;var t=R(),n,r,i,a,o,s,c,l,u,d,f,p=class{constructor(){O(this,a),O(this,s),O(this,l),O(this,d),O(this,n,void 0),O(this,r,void 0),O(this,i,void 0),k(this,n,new Map),k(this,r,p.defaultMaxListeners),k(this,i,!1)}static listenerCount(e,t){return e.listenerCount(t)}setMaxListeners(e){return k(this,r,e),this}getMaxListeners(){return D(this,r)}eventNames(){return Array.from(D(this,n).keys())}emit(e,...t){let n=A(this,a,o).call(this,e);return n.forEach(e=>{e.apply(this,t)}),n.length>0}addListener(e,s){A(this,d,f).call(this,`newListener`,e,s);let c=A(this,a,o).call(this,e).concat(s);if(D(this,n).set(e,c),D(this,r)>0&&this.listenerCount(e)>D(this,r)&&!D(this,i)){k(this,i,!0);let n=new t.MemoryLeakError(this,e,this.listenerCount(e));console.warn(n)}return this}on(e,t){return this.addListener(e,t)}once(e,t){return this.addListener(e,A(this,l,u).call(this,e,t))}prependListener(e,t){let r=A(this,a,o).call(this,e);if(r.length>0){let i=[t].concat(r);D(this,n).set(e,i)}else D(this,n).set(e,r.concat(t));return this}prependOnceListener(e,t){return this.prependListener(e,A(this,l,u).call(this,e,t))}removeListener(e,t){let r=A(this,a,o).call(this,e);return r.length>0&&(A(this,s,c).call(this,r,t),D(this,n).set(e,r),A(this,d,f).call(this,`removeListener`,e,t)),this}off(e,t){return this.removeListener(e,t)}removeAllListeners(e){return e?D(this,n).delete(e):D(this,n).clear(),this}listeners(e){return Array.from(A(this,a,o).call(this,e))}listenerCount(e){return A(this,a,o).call(this,e).length}rawListeners(e){return this.listeners(e)}},m=p;n=new WeakMap,r=new WeakMap,i=new WeakMap,a=new WeakSet,o=function(e){return D(this,n).get(e)||[]},s=new WeakSet,c=function(e,t){let n=e.indexOf(t);return n>-1&&e.splice(n,1),[]},l=new WeakSet,u=function(e,t){let n=(...r)=>{this.removeListener(e,n),t.apply(this,r)};return n},d=new WeakSet,f=function(e,t,n){this.emit(e,t,n)},ce(m,`defaultMaxListeners`,10),e.Emitter=m}}),B=w({"../../node_modules/.pnpm/[email protected]/node_modules/strict-event-emitter/lib/index.js"(e){var t=e&&e.__createBinding||(Object.create?function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}
3),Object.defineProperty(e,r,i)}:function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}),n=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(z(),e),n(R(),e)}}),V=T(P()),H=/(%?)(%([sdjo]))/g,U=2,W=class extends Error{constructor(e,...t){super(e),this.message=e,this.name=`Invariant Violation`,this.message=g(e,...t),ae(this)}},G=(e,t,...n)=>{if(!e)throw new W(t,...n)},G.as=(e,t,n,...r)=>{if(!t)throw e.prototype.name==null?e(g(n,r)):new e(g(n,r))},K=T(L()),q=window.localStorage.CSB_EMULATOR_DEBUG,le=`\x1B[0m`,ue=`\x1B[32;1m`,de=`\x1B[31m`,fe=`\x1B[34m`,pe=`\x1B[33;1m`,me=`\x1B[35;1m`,J=`\x1B[36;1m`,he={preview:pe,emulator:me,runtime:J,bridge:fe,"runtime:worker":J},Y=oe(`emulator`),ge=class{constructor(e){this.target=e,this.emitter=new EventTarget,this.channel=new MessageChannel,this.receiverPort=this.channel.port1;let t=new K.DeferredPromise,n=e=>{e.data.type===`internal/ready`&&(Y(`[message-sender]: runtime is ready`),t.resolve())};window.addEventListener(`message`,n),t.then(()=>{window.removeEventListener(`message`,n)}),this.receiverReadyPromise=t,this.receiverPort.onmessage=e=>{let t=e.data;t.type!=null&&(Y(`[message-sender]: emitting "%s" event...`,t.type,t.payload),this.emitter.dispatchEvent(new MessageEvent(t.type,{data:t.payload})))}}emitter;channel;receiverPort;receiverReadyPromise;async handshake(){let e=new K.DeferredPromise;await this.receiverReadyPromise,Y(`[message-sender]: sending handshake`),this.target.postMessage({type:`internal/handshake`},`*`,[this.channel.port2]),this.on(`internal/handshake/done`,()=>{e.resolve(),clearTimeout(t)});let t=setTimeout(()=>{e.reject(Error(`MessageSender: Handshake timeout`))},5e3);return e}on(e,t,n){Y(`[message-sender]: add listener "%s"`,e),this.emitter.addEventListener(e,e=>{e instanceof MessageEvent&&t(e)},n)}off(e,t,n){this.emitter.removeEventListener(e,t,n)}async send(e,...t){let n=new K.DeferredPromise,r=(0,V.default)(),i=t[0]||{};Y(`[message-sender]: send "%s" (%s)`,e,r,i),this.receiverPort.postMessage({type:e,payload:{operationId:r,payload:i}}),Y(`[message-sender]: adding done listener for "%s" (%s)`,e,r);let a=t=>{let{data:i}=t;if(i.operationId===r){let t=i.listenerPayload||{};Y(`[message-sender]: resolving "%s (%s) promise!`,e,r),n.resolve({...t,operationId:i.operationId})}},o=t=>{let{data:i}=t;i.operationId===r&&(Y(`[message-sender]: rejecting "%s (%s) promise!`,e,r),n.reject(i.error))};return this.on(`internal/operation/done`,a),this.on(`internal/operation/failed`,o),n.finally(()=>{this.emitter.removeEventListener(`internal/operation/done`,a),this.emitter.removeEventListener(`internal/operation/failed`,o)})}},X=T(L()),_e=T(P()),ve=class{constructor(e){this.channel=e}async init(e){await this.channel.send(`fs/init`,{files:e})}async readFile(e,t){let n=await this.channel.send(`fs/readFile`,{path:e,encoding:t}).catch(t=>{throw Error(g(`Failed to read file at path "%s"`,e),{cause:t})});if(!n)throw Error(`File not found`);return n.data}async writeFile(e,t,n){let r,i=!1;typeof n==`object`?(r=n.encoding,i=!!n.recursive):typeof n==`string`&&(r=n),await this.channel.send(`fs/writeFile`,{path:e,content:t,encoding:r,recursive:i}
3).catch(t=>{throw Error(g(`Failed to write file at path "%s"`,e),{cause:t})})}async readdir(e){let t=await this.channel.send(`fs/readdir`,{path:e}).catch(t=>{throw Error(g(`Failed to read directory at path "%s"`,e),{cause:t})});if(!t)throw Error(`Directory not found`);return t.data}async mkdir(e,t){let n=!!t?.recursive;await this.channel.send(`fs/mkdir`,{path:e,recursive:n}).catch(t=>{throw Error(g(`Failed to make directory at path "%s"`,e),{cause:t})})}async stat(e){let t=await this.channel.send(`fs/stat`,{path:e}).catch(t=>{throw Error(g(`Failed to stat file at path "%s"`,e),{cause:t})});if(!t)throw Error(`File not found`);return t.data}async rm(e,t){let{force:n,recursive:r}=t||{};await this.channel.send(`fs/rm`,{path:e,force:n,recursive:r}).catch(t=>{throw Error(g(`Failed to remove file at path "%s"`,e),{cause:t})})}async watch(e,t,n){let r=(0,_e.default)();return await this.channel.send(`fs/watch`,{watcherId:r,includes:e,excludes:t}),this.channel.on(`fs/watch-event`,({data:e})=>{if(e.watcherId===r&&n){let t={...e};delete t.watcherId,n(t)}}),{dispose:()=>this.channel.send(`fs/unwatch`,{watcherId:r})}}},Z=T(B()),ye=class{constructor(e){this.channel=e}create(){return new be(this.channel)}},be=class{constructor(e){this.channel=e,this.state=`running`,this.stdout=new Z.Emitter,this.stderr=new Z.Emitter,this.stdin={write:e=>{if(!this.id)throw Error(`Failed to write to stdin, no process is currently running`);return this.channel.send(`shell/stdin`,{data:e,workerId:this.id})}},this.forwardStdEvents()}id;state;stdout;stderr;stdin;forwardStdEvents(){this.channel.on(`worker/tty`,e=>{let{data:t}=e;if(t.workerId===this.id)switch(t.payload.type){case`out`:this.stdout.emit(`data`,t.payload.data);break;case`err`:this.stderr.emit(`data`,t.payload.data);break}})}async runCommand(e,t,n={}){G(!this.id,`Failed to run "runCommand" on a ShellProcess: there is already a process running.`);let r=await this.channel.send(`shell/runCommand`,{command:e,args:t,options:n});return G(r,`Failed to run "runCommand" on a ShellProcess: was not able to retrieve a running process.`),this.id=r.id,this.state=`running`,r}async on(e,t){switch(e){case`progress`:this.channel.on(`worker/progress`,({data:e})=>{t(e.status)});return;case`exit`:this.channel.on(`worker/exit`,({data:e})=>{e.workerId===this.id&&t(e.exitCode,e.error)});return}}async kill(){G(this.id,`Failed to run "kill" on a ShellProcess: there is no process running. Did you forget to run it?`),this.state=`idle`,await this.channel.send(`shell/exit`,{id:this.id}).catch(e=>{throw Error(g(`Failed to kill shell with ID "%s"`,this.id),{cause:e})}),this.id=void 0}},xe=T(L()),Se=2e4,Ce=class{constructor(e){this.channel=e}async waitFor(e,t,n=Se){let r=new xe.DeferredPromise,i=setTimeout(()=>{r.reject()},n),a=await this.channel.send(`preview/get/info`,e).catch(t=>{r.reject(Error(g(`Failed to look up preview information for shell ID "%s" (port: %d)`,e.sourceShellId,e.port)))}),o=a&&t(a);return o&&r.resolve({url:a.url,port:a.port,sourceShellId:a.sourceShellId}),this.channel.on(`preview/port/ready`,({data:e})=>{!o&&t(e)&&r.resolve({url:e.url,port:e.port,sourceShellId:e.sourceShellId})}),r.finally(()=>{clearTimeout(i)})}async getByShellId(e,t){return this.waitFor({sourceShellId:e},t=>t.sourceShellId===e,t).catch(t=>{throw Error(g(`Failed to get shell by ID "%s"`,e),{cause:t})})}async waitForPort(e,t){return this.waitFor({port:e},t=>t.port===e,t).catch(t=>{throw Error(g(`Failed to await port %d`,e),{cause:t})})}},we=`https://nodebox-runtime.codesandbox.io`,Q=oe(`emulator`),Te=class{constructor(e){this.options=e,G(this.options.iframe,`Failed to create a Nodebox: expected "iframe" argument to be a reference to an <iframe> element but got %j`,this.options.iframe),this.url=this.options.runtimeUrl||we,this.isConnected=!1}channel=null;isConnected;url;fileSystemApi=null;shellApi=null;previewApi=null;async connect(){let{iframe:e,cdnUrl:t}=this.options;Q(`[message-sender]: Connecting to node emulator...`);let n=new X.DeferredPromise;this.url||n.reject(Error(`Nodebox URL is missing. Did you forget to provide it when creating this Nodebox instance?`)),G(e.contentWindow,`Failed to create a MessageChannel with the Nodebox iframe: no content window found`),this.channel=new ge(e.contentWindow);let r=new X.DeferredPromise;return e.setAttribute(`src`,this.url),e.addEventListener(`load`,()=>{r.resolve()},{once:!0}),e.addEventListener(`error`,e=>{r.reject(e.error)},{once:!0}),await r,Q(`[message-sender]: IFrame loaded...`),await this.channel.handshake(),Q(`[message-sender]: Handshake completed...`),this.channel.send(`connect`,{cdnUrl:t}),this.channel.on(`runtime/ready`,()=>{n.resolve()}),n.then(()=>{Q(`[message-sender]: Connected to runtime...`),this.isConnected=!0})}get fs(){return G(this.isConnected,`Failed to access the File System API: consumer is not connected. Did you forget to run "connect()"?`),this.fileSystemApi||=new ve(this.channel),this.fileSystemApi}get shell(){return G(this.isConnected,`Failed to access the Shell API: consumer is not connected. Did you forget to run "connect()"?`),this.shellApi||=new ye(this.channel),this.shellApi}get preview(){return G(this.isConnected,`Failed to access the Preview API: consumer is not connected. Did you forget to run "connect()"?`),this.previewApi||=new Ce(this.channel),this.previewApi}},Ee=`INJECT_AND_INVOKE`}));function Oe(e,r){return c(this,void 0,void 0,function(){var i,a,o,c,l;return t(this,function(t){return i=e.contentWindow,s(i,`Failed to await preview iframe: no content window found`),a=9e4,o=20,c=0,[2,new Promise(function(t,i){var s=function(){var u=function(){clearTimeout(l),c=o,t(),e.removeEventListener(`load`,u)};if(c>=o){i(n(`Could not able to connect to preview.`));return}e.setAttribute(`src`,r),l=setTimeout(function(){s(),e.removeEventListener(`load`,u)},a),c+=1,e.addEventListener(`load`,u)};e.addEventListener(`error`,function(){return i(Error(`Iframe error`))}),e.addEventListener(`abort`,function(){return i(Error(`Aborted`))}),s()})]})})}function ke(e){var t=e.scope,n=window.history.__proto__,r=[],i=0,a=function(e){parent.postMessage({type:`urlchange`,url:e,back:i>0,forward:i<r.length-1,channelId:t.channelId},`*`)};function o(e,t){r.splice(i+1),r.push({url:e,state:t}),i=r.length-1}Object.assign(window.history,{go:function(e){var t=i+e;if(t>=0&&t<=r.length-1){i=t;var o=r[i],s=o.url,c=o.state;n.replaceState.call(window.history,c,``,s);var l=document.location.href;a(l),window.dispatchEvent(new PopStateEvent(`popstate`,{state:c}))}},back:function(){window.history.go(-1)},forward:function(){window.history.go(1)},pushState:function(e,t,r){n.replaceState.call(window.history,e,t,r),o(r,e),a(document.location.href)},replaceState:function(e,t,o){n.replaceState.call(window.history,e,t,o),r[i]={state:e,url:o},a(document.location.href)}});function s(e){var t=e.data;t.type===`urlback`?history.back():t.type===`urlforward`?history.forward():t.type===`refresh`&&document.location.reload()}window.addEventListener(`message`,s)}function Ae(e){var t=e.scope,n=0;function r(){if(typeof window>`u`)return 0;var e=document.body,t=document.documentElement;return Math.max(e.scrollHeight,e.offsetHeight,t.offsetHeight)}function i(){var e=r();n!==e&&window.parent.postMessage({type:`resize`,height:e,codesandbox:!0,channelId:t.channelId},`*`),n=e}i();var a;new MutationObserver(function(){a===void 0&&(i(),a=setTimeout(function(){a=void 0},300))}).observe(document,{attributes:!0,childList:!0,subtree:!0}),setInterval(i,300)}var $,je,Me,Ne;e((()=>{r(),De(),l(),ne(),a(),$=function(e,t){e.style.border=`0`,e.style.width=t.width||`100%`,e.style.height=t.height||`100%`,e.style.overflow=`hidden`,e.allow=`cross-origin-isolated`},je=[{code:ke.toString(),id:`historyListener`},{code:`function consoleHook({ scope }) {`+ee+`
4};`,id:`consoleHook`},{code:Ae.toString(),id:`watchResize`}],Me=function(e,t){je.forEach(function(n){var r,i=n.code,a={uid:n.id,type:Ee,code:`exports.activate = ${i}`,scope:{channelId:t}};
4(r=e.contentWindow)==null||r.postMessage(a,`*`)})},Ne=function(e){i(r,e);function r(t,n,r){r===void 0&&(r={});var i=e.call(this,t,n,o(o({},r),{bundlerURL:r.bundlerURL}))||this;return i._modulesCache=new Map,i.messageChannelId=d(),i._initPromise=null,i.emitter=new re,i.manageIframes(t),i.emulator=new Te({iframe:i.emulatorIframe,runtimeUrl:i.options.bundlerURL}),i.updateSandbox(n),i}return r.prototype._init=function(e){return c(this,void 0,void 0,function(){return t(this,function(t){switch(t.label){case 0:return[4,this.emulator.connect()];case 1:return t.sent(),[4,this.emulator.fs.init(e)];case 2:return t.sent(),[4,this.globalListeners()];case 3:return t.sent(),[2]}})})},r.prototype.compile=function(e){return c(this,void 0,void 0,function(){var n,r;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,5,,6]),this.status=`initializing`,this.dispatch({type:`start`,firstLoad:!0}),this._initPromise||=this._init(e),[4,this._initPromise];case 1:return t.sent(),this.dispatch({type:`connected`}),[4,this.createShellProcessFromTask(e)];case 2:return n=t.sent().id,[4,this.createPreviewURLFromId(n)];case 3:return t.sent(),[4,this.setLocationURLIntoIFrame()];case 4:return t.sent(),this.dispatchDoneMessage(),[3,6];case 5:return r=t.sent(),this.dispatch({type:`action`,action:`notification`,notificationType:`error`,title:h(r)}),this.dispatch({type:`done`,compilatonError:!0}),[3,6];case 6:return[2]}})})},r.prototype.createShellProcessFromTask=function(e){return c(this,void 0,void 0,function(){var r,i,a=this;return t(this,function(t){switch(t.label){case 0:return r=f(e[`/package.json`]),this.emulatorCommand=te(r),this.emulatorShellProcess=this.emulator.shell.create(),[4,this.emulatorShellProcess.on(`exit`,function(e){a.dispatch({type:`action`,action:`notification`,notificationType:`error`,title:n(`Error: process.exit(${e}) called.`)})})];case 1:return t.sent(),[4,this.emulatorShellProcess.on(`progress`,function(e){if(e.state===`command_running`||e.state===`starting_command`){a.dispatch({type:`shell/progress`,data:o(o({},e),{command:[a.emulatorCommand?.[0],a.emulatorCommand?.[1].join(` `)].join(` `)})}),a.status=`installing-dependencies`;return}a.dispatch({type:`shell/progress`,data:e})})];case 2:return t.sent(),this.emulatorShellProcess.stdout.on(`data`,function(e){a.dispatch({type:`stdout`,payload:{data:e,type:`out`}})}),this.emulatorShellProcess.stderr.on(`data`,function(e){a.dispatch({type:`stdout`,payload:{data:e,type:`err`}})}),[4,(i=this.emulatorShellProcess).runCommand.apply(i,this.emulatorCommand)];case 3:return[2,t.sent()]}})})},r.prototype.createPreviewURLFromId=function(e){return c(this,void 0,void 0,function(){var n;return t(this,function(t){switch(t.label){case 0:return this.iframePreviewUrl=void 0,[4,this.emulator.preview.getByShellId(e)];case 1:return n=t.sent().url,this.iframePreviewUrl=n+(this.options.startRoute??``),[2]}})})},r.prototype.manageIframes=function(e){var t;if(typeof e==`string`){var n=document.querySelector(e);s(n,`The element '${e}' was not found`),this.iframe=document.createElement(`iframe`),n?.appendChild(this.iframe)}else this.iframe=e;$(this.iframe,this.options),s(this.iframe.parentNode,`The given iframe does not have a parent.`),this.emulatorIframe=document.createElement(`iframe`),this.emulatorIframe.classList.add(`sp-bridge-frame`),(t=this.iframe.parentNode)==null||t.appendChild(this.emulatorIframe)},r.prototype.setLocationURLIntoIFrame=function(){return c(this,void 0,void 0,function(){return t(this,function(e){switch(e.label){case 0:return this.iframePreviewUrl?[4,Oe(this.iframe,this.iframePreviewUrl)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})},r.prototype.dispatchDoneMessage=function(){this.status=`done`,this.dispatch({type:`done`,compilatonError:!1}),this.iframePreviewUrl&&this.dispatch({type:`urlchange`,url:this.iframePreviewUrl,back:!1,forward:!1})},r.prototype.globalListeners=function(){return c(this,void 0,void 0,function(){var e=this;return t(this,function(n){switch(n.label){case 0:return window.addEventListener(`message`,function(t){t.data.type===`PREVIEW_LOADED`&&Me(e.iframe,e.messageChannelId),t.data.type===`urlchange`&&t.data.channelId===e.messageChannelId?e.dispatch({type:`urlchange`,url:t.data.url,back:t.data.back,forward:t.data.forward}):t.data.channelId===e.messageChannelId&&e.dispatch(t.data)}),[4,this.emulator.fs.watch([`*`],[`.next`,`node_modules`,`build`,`dist`,`vendor`,`.config`,`.vuepress`],function(n){return c(e,void 0,void 0,function(){var e,r,i,a,o,s,c;return t(this,function(t){switch(t.label){case 0:return n?(e=n,r=`newPath`in e?e.newPath:`path`in e?e.path:``,[4,this.emulator.fs.stat(r)]):[2];case 1:if(i=t.sent().type,i!==`file`)return[2,null];t.label=2;case 2:switch(t.trys.push([2,10,,11]),a=e.type,a){case`change`:return[3,3];case`create`:return[3,3];case`remove`:return[3,5];case`rename`:return[3,6];case`close`:return[3,8]}return[3,9];case 3:return[4,this.emulator.fs.readFile(e.path,`utf8`)];case 4:return o=t.sent(),this.dispatch({type:`fs/change`,path:e.path,content:o}),this._modulesCache.set(e.path,m(o)),[3,9];case 5:return this.dispatch({type:`fs/remove`,path:e.path}),this._modulesCache.delete(e.path),[3,9];case 6:return this.dispatch({type:`fs/remove`,path:e.oldPath}),this._modulesCache.delete(e.oldPath),[4,this.emulator.fs.readFile(e.newPath,`utf8`)];case 7:return s=t.sent(),this.dispatch({type:`fs/change`,path:e.newPath,content:s}),this._modulesCache.set(e.newPath,m(s)),[3,9];case 8:return[3,9];case 9:return[3,11];case 10:return c=t.sent(),this.dispatch({type:`action`,action:`notification`,notificationType:`error`,title:h(c)}),[3,11];case 11:return[2]}})})})];case 1:return n.sent(),[2]}})})},r.prototype.restartShellProcess=function(){var e;return c(this,void 0,void 0,function(){return t(this,function(t){switch(t.label){case 0:return this.emulatorShellProcess&&this.emulatorCommand?(this.dispatch({type:`start`,firstLoad:!0}),this.status=`initializing`,[4,this.emulatorShellProcess.kill()]):[3,3];case 1:return t.sent(),(e=this.iframe)==null||e.removeAttribute(`attr`),this.emulator.fs.rm(`/node_modules/.vite`,{recursive:!0,force:!0}),[4,this.compile(Object.fromEntries(this._modulesCache))];case 2:t.sent(),t.label=3;case 3:return[2]}})})},r.prototype.updateSandbox=function(e){var t=this,n=p(e.files);if(this.emulatorShellProcess?.state===`running`){Object.entries(n).forEac
4h(function(e){var n=e[0],r=e[1];(!t._modulesCache.get(n)||f(r)!==f(t._modulesCache.get(n)))&&t.emulator.fs.writeFile(n,r,{recursive:!0})});return}this.dispatch({codesandbox:!0,modules:n,template:e.template,type:`compile`}),Object.entries(n).forEach(function(e){var n=e[0],r=e[1];t._modulesCache.set(n,m(r))})},r.prototype.dispatch=function(e){var n;return c(this,void 0,void 0,function(){var r;return t(this,function(t){switch(t.label){case 0:switch(r=e.type,r){case`compile`:return[3,1];case`refresh`:return[3,2];case`urlback`:return[3,4];case`urlforward`:return[3,4];case`shell/restart`:return[3,5];case`shell/openPreview`:return[3,6]}return[3,7];case 1:return this.compile(e.modules),[3,8];case 2:return[4,this.setLocationURLIntoIFrame()];case 3:return t.sent(),[3,8];case 4:return(n=this.iframe?.contentWindow)==null||n.postMessage(e,`*`),[3,8];case 5:return this.restartShellProcess(),[3,8];case 6:return window.open(this.iframePreviewUrl,`_blank`),[3,8];case 7:this.emitter.dispatch(e),t.label=8;case 8:return[2]}})})},r.prototype.listen=function(e){return this.emitter.listener(e)},r.prototype.destroy=function(){this.emulatorIframe.remove(),this.emitter.cleanup()},r}(u)}))();export{Ne as SandpackNode};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.