@iconoma/studio 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/base-80a1f760-BT0jtgRF.js +1 -0
- package/dist/client/assets/consoleHook-59e792cb-Cx_lbHFa.js +2 -0
- package/dist/client/assets/index-599aeaf7-CQg58cdW.js +16 -0
- package/dist/client/assets/index-7c_AX7XK.js +800 -0
- package/dist/client/assets/index-Bdj-eDET.css +1 -0
- package/dist/client/assets/index-CbKTZMip.js +1 -0
- package/dist/client/assets/index-D98HewIt.js +4 -0
- package/dist/client/index.html +2 -2
- package/dist/server/assets/base-80a1f760--v78K3bW.js +40 -0
- package/dist/server/assets/consoleHook-59e792cb-KeP2TanF.js +250 -0
- package/dist/server/assets/index-599aeaf7-DI3wF-7N.js +8953 -0
- package/dist/server/assets/index-CIjBeg8V.js +1573 -0
- package/dist/server/assets/index-DXLUkVZK.js +3196 -0
- package/dist/server/entry-server.js +43230 -36739
- package/dist/server.js +65 -70
- package/package.json +7 -7
- package/dist/client/assets/base-80a1f760-DXByDNOn.js +0 -1
- package/dist/client/assets/consoleHook-59e792cb-Cc-Wa9Dv.js +0 -2
- package/dist/client/assets/index-2gul9srt.js +0 -810
- package/dist/client/assets/index-599aeaf7-CuvDGLig.js +0 -16
- package/dist/client/assets/index-B8EuJHGY.css +0 -1
- package/dist/client/assets/node-C6_XYplI.js +0 -4
- package/dist/client/assets/runtime-BL9Nzh_-.js +0 -1
- package/dist/server/assets/base-80a1f760-qtF4btYl.js +0 -31
- package/dist/server/assets/consoleHook-59e792cb-DzCtq2z9.js +0 -230
- package/dist/server/assets/index-599aeaf7-CrZ9wybV.js +0 -7378
- package/dist/server/assets/node-Cq9Cey_i.js +0 -1412
- package/dist/server/assets/runtime-Cj4RK1K3.js +0 -8158
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{_ as X,a as _,b as E,c as k,d as H,n as D}from"./index-7c_AX7XK.js";import{S as Q}from"./base-80a1f760-BT0jtgRF.js";import{g as W,r as F,f as Z,w as x,a as $,b as ee,E as te,c as re}from"./consoleHook-59e792cb-Cx_lbHFa.js";var ne=Object.create,T=Object.defineProperty,ie=Object.getOwnPropertyDescriptor,V=Object.getOwnPropertyNames,se=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty,ae=(t,n,e)=>n in t?T(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,P=(t,n)=>function(){return n||(0,t[V(t)[0]])((n={exports:{}}).exports,n),n.exports},ce=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of V(n))!oe.call(t,s)&&s!==e&&T(t,s,{get:()=>n[s],enumerable:!(r=ie(n,s))||r.enumerable});return t},j=(t,n,e)=>(e=t!=null?ne(se(t)):{},ce(!t||!t.__esModule?T(e,"default",{value:t,enumerable:!0}):e,t)),de=(t,n,e)=>(ae(t,n+"",e),e),R=(t,n,e)=>{if(!n.has(t))throw TypeError("Cannot "+e)},g=(t,n,e)=>(R(t,n,"read from private field"),e?e.call(t):n.get(t)),M=(t,n,e)=>{if(n.has(t))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(t):n.set(t,e)},O=(t,n,e,r)=>(R(t,n,"write to private field"),n.set(t,e),e),y=(t,n,e)=>(R(t,n,"access private method"),e),z=P({"../../node_modules/.pnpm/cuid@2.1.8/node_modules/cuid/lib/pad.js"(t,n){n.exports=function(r,s){var i="000000000"+r;return i.substr(i.length-s)}}}),le=P({"../../node_modules/.pnpm/cuid@2.1.8/node_modules/cuid/lib/fingerprint.browser.js"(t,n){var e=z(),r=typeof window=="object"?window:self,s=Object.keys(r).length,i=navigator.mimeTypes?navigator.mimeTypes.length:0,o=e((i+navigator.userAgent.length).toString(36)+s.toString(36),4);n.exports=function(){return o}}}),ue=P({"../../node_modules/.pnpm/cuid@2.1.8/node_modules/cuid/lib/getRandomValue.browser.js"(t,n){var e,r=typeof window<"u"&&(window.crypto||window.msCrypto)||typeof self<"u"&&self.crypto;r?(s=Math.pow(2,32)-1,e=function(){return Math.abs(r.getRandomValues(new Uint32Array(1))[0]/s)}):e=Math.random;var s;n.exports=e}}),G=P({"../../node_modules/.pnpm/cuid@2.1.8/node_modules/cuid/index.js"(t,n){var e=le(),r=z(),s=ue(),i=0,o=4,a=36,d=Math.pow(a,o);function l(){return r((s()*d<<0).toString(a),o)}function h(){return i=i<d?i:0,i++,i-1}function p(){var m="c",v=new Date().getTime().toString(a),b=r(h().toString(a),o),c=e(),u=l()+l();return m+v+b+c+u}p.slug=function(){var v=new Date().getTime().toString(36),b=h().toString(36).slice(-4),c=e().slice(0,1)+e().slice(-1),u=l().slice(-2);return v.slice(-2)+b+c+u},p.isCuid=function(v){return typeof v!="string"?!1:!!v.startsWith("c")},p.isSlug=function(v){if(typeof v!="string")return!1;var b=v.length;return b>=7&&b<=10},p.fingerprint=e,n.exports=p}}),J=P({"../../node_modules/.pnpm/@open-draft+deferred-promise@2.1.0/node_modules/@open-draft/deferred-promise/build/createDeferredExecutor.js"(t){Object.defineProperty(t,"__esModule",{value:!0}),t.createDeferredExecutor=void 0;function n(){const e=(r,s)=>{e.state="pending",e.resolve=i=>{if(e.state!=="pending")return;e.result=i;const o=a=>(e.state="fulfilled",a);return r(i instanceof Promise?i:Promise.resolve(i).then(o))},e.reject=i=>{if(e.state==="pending")return queueMicrotask(()=>{e.state="rejected"}),s(e.rejectionReason=i)}};return e}t.createDeferredExecutor=n}}),he=P({"../../node_modules/.pnpm/@open-draft+deferred-promise@2.1.0/node_modules/@open-draft/deferred-promise/build/DeferredPromise.js"(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DeferredPromise=void 0;var n=J(),e=class extends Promise{#e;resolve;reject;constructor(r=null){const s=(0,n.createDeferredExecutor)();super((i,o)=>{s(i,o),r?.(s.resolve,s.reject)}),this.#e=s,this.resolve=this.#e.resolve,this.reject=this.#e.reject}get state(){return this.#e.state}get rejectionReason(){return this.#e.rejectionReason}then(r,s){return this.#t(super.then(r,s))}catch(r){return this.#t(super.catch(r))}finally(r){return this.#t(super.finally(r))}#t(r){return Object.defineProperties(r,{resolve:{configurable:!0,value:this.resolve},reject:{configurable:!0,value:this.reject}})}};t.DeferredPromise=e}}),U=P({"../../node_modules/.pnpm/@open-draft+deferred-promise@2.1.0/node_modules/@open-draft/deferred-promise/build/index.js"(t){var n=t&&t.__createBinding||(Object.create?function(r,s,i,o){o===void 0&&(o=i);var a=Object.getOwnPropertyDescriptor(s,i);(!a||("get"in a?!s.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return s[i]}}),Object.defineProperty(r,o,a)}:function(r,s,i,o){o===void 0&&(o=i),r[o]=s[i]}),e=t&&t.__exportStar||function(r,s){for(var i in r)i!=="default"&&!Object.prototype.hasOwnProperty.call(s,i)&&n(s,r,i)};Object.defineProperty(t,"__esModule",{value:!0}),e(J(),t),e(he(),t)}}),Y=P({"../../node_modules/.pnpm/strict-event-emitter@0.4.3/node_modules/strict-event-emitter/lib/MemoryLeakError.js"(t){Object.defineProperty(t,"__esModule",{value:!0}),t.MemoryLeakError=void 0;var n=class extends Error{emitter;type;count;constructor(e,r,s){super(`Possible EventEmitter memory leak detected. ${s} ${r.toString()} listeners added. Use emitter.setMaxListeners() to increase limit`),this.emitter=e,this.type=r,this.count=s,this.name="MaxListenersExceededWarning"}};t.MemoryLeakError=n}}),fe=P({"../../node_modules/.pnpm/strict-event-emitter@0.4.3/node_modules/strict-event-emitter/lib/Emitter.js"(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Emitter=void 0;var n=Y(),e,r,s,i,o,a,d,l,h,p,m,v=class{constructor(){M(this,i),M(this,a),M(this,l),M(this,p),M(this,e,void 0),M(this,r,void 0),M(this,s,void 0),O(this,e,new Map),O(this,r,v.defaultMaxListeners),O(this,s,!1)}static listenerCount(c,u){return c.listenerCount(u)}setMaxListeners(c){return O(this,r,c),this}getMaxListeners(){return g(this,r)}eventNames(){return Array.from(g(this,e).keys())}emit(c,...u){const f=y(this,i,o).call(this,c);return f.forEach(I=>{I.apply(this,u)}),f.length>0}addListener(c,u){y(this,p,m).call(this,"newListener",c,u);const f=y(this,i,o).call(this,c).concat(u);if(g(this,e).set(c,f),g(this,r)>0&&this.listenerCount(c)>g(this,r)&&!g(this,s)){O(this,s,!0);const I=new n.MemoryLeakError(this,c,this.listenerCount(c));console.warn(I)}return this}on(c,u){return this.addListener(c,u)}once(c,u){return this.addListener(c,y(this,l,h).call(this,c,u))}prependListener(c,u){const f=y(this,i,o).call(this,c);if(f.length>0){const I=[u].concat(f);g(this,e).set(c,I)}else g(this,e).set(c,f.concat(u));return this}prependOnceListener(c,u){return this.prependListener(c,y(this,l,h).call(this,c,u))}removeListener(c,u){const f=y(this,i,o).call(this,c);return f.length>0&&(y(this,a,d).call(this,f,u),g(this,e).set(c,f),y(this,p,m).call(this,"removeListener",c,u)),this}off(c,u){return this.removeListener(c,u)}removeAllListeners(c){return c?g(this,e).delete(c):g(this,e).clear(),this}listeners(c){return Array.from(y(this,i,o).call(this,c))}listenerCount(c){return y(this,i,o).call(this,c).length}rawListeners(c){return this.listeners(c)}},b=v;e=new WeakMap,r=new WeakMap,s=new WeakMap,i=new WeakSet,o=function(c){return g(this,e).get(c)||[]},a=new WeakSet,d=function(c,u){const f=c.indexOf(u);return f>-1&&c.splice(f,1),[]},l=new WeakSet,h=function(c,u){const f=(...I)=>{this.removeListener(c,f),u.apply(this,I)};return f},p=new WeakSet,m=function(c,u,f){this.emit(c,u,f)},de(b,"defaultMaxListeners",10),t.Emitter=b}}),pe=P({"../../node_modules/.pnpm/strict-event-emitter@0.4.3/node_modules/strict-event-emitter/lib/index.js"(t){var n=t&&t.__createBinding||(Object.create?function(r,s,i,o){o===void 0&&(o=i);var a=Object.getOwnPropertyDescriptor(s,i);(!a||("get"in a?!s.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return s[i]}}),Object.defineProperty(r,o,a)}:function(r,s,i,o){o===void 0&&(o=i),r[o]=s[i]}),e=t&&t.__exportStar||function(r,s){for(var i in r)i!=="default"&&!Object.prototype.hasOwnProperty.call(s,i)&&n(s,r,i)};Object.defineProperty(t,"__esModule",{value:!0}),e(fe(),t),e(Y(),t)}}),me=j(G()),ve=/(%?)(%([sdjo]))/g;function we(t,n){switch(n){case"s":return t;case"d":case"i":return Number(t);case"j":return JSON.stringify(t);case"o":{if(typeof t=="string")return t;const e=JSON.stringify(t);return e==="{}"||e==="[]"||/^\[object .+?\]$/.test(e)?t:e}}}function w(t,...n){if(n.length===0)return t;let e=0,r=t.replace(ve,(s,i,o,a)=>{const d=n[e],l=we(d,a);return i?s:(e++,l)});return e<n.length&&(r+=` ${n.slice(e).join(" ")}`),r=r.replace(/%{2,2}/g,"%"),r}var ge=2;function ye(t){if(!t.stack)return;const n=t.stack.split(`
|
|
2
|
+
`);n.splice(1,ge),t.stack=n.join(`
|
|
3
|
+
`)}var _e=class extends Error{constructor(t,...n){super(t),this.message=t,this.name="Invariant Violation",this.message=w(t,...n),ye(this)}},S=(t,n,...e)=>{if(!t)throw new _e(n,...e)};S.as=(t,n,e,...r)=>{if(!n)throw t.prototype.name!=null?new t(w(e,r)):t(w(e,r))};var A=j(U()),Ee=window.localStorage.CSB_EMULATOR_DEBUG,Pe="\x1B[0m",be="\x1B[32;1m",Se="\x1B[31m",Le="\x1B[34m",Ie="\x1B[33;1m",Me="\x1B[35;1m",B="\x1B[36;1m",je={preview:Ie,emulator:Me,runtime:B,bridge:Le,"runtime:worker":B};function K(t){return function(e,...r){if(Ee==="true"){const s=()=>e.includes("sender")?`${be}sender`:e.includes("receiver")?`${Se}receiver`:"",i=e.replace(/\[.+\]:/,"");console.debug(`${je[t]}${t}:${s()}${Pe}:${i}`,...r)}}}var L=K("emulator"),Oe=class{constructor(t){this.target=t,this.emitter=new EventTarget,this.channel=new MessageChannel,this.receiverPort=this.channel.port1;const n=new A.DeferredPromise,e=r=>{r.data.type==="internal/ready"&&(L("[message-sender]: runtime is ready"),n.resolve())};window.addEventListener("message",e),n.then(()=>{window.removeEventListener("message",e)}),this.receiverReadyPromise=n,this.receiverPort.onmessage=r=>{const s=r.data;s.type!=null&&(L('[message-sender]: emitting "%s" event...',s.type,s.payload),this.emitter.dispatchEvent(new MessageEvent(s.type,{data:s.payload})))}}emitter;channel;receiverPort;receiverReadyPromise;async handshake(){const t=new A.DeferredPromise;await this.receiverReadyPromise,L("[message-sender]: sending handshake"),this.target.postMessage({type:"internal/handshake"},"*",[this.channel.port2]),this.on("internal/handshake/done",()=>{t.resolve(),clearTimeout(n)});const n=setTimeout(()=>{t.reject(new Error("MessageSender: Handshake timeout"))},5e3);return t}on(t,n,e){L('[message-sender]: add listener "%s"',t),this.emitter.addEventListener(t,r=>{r instanceof MessageEvent&&n(r)},e)}off(t,n,e){this.emitter.removeEventListener(t,n,e)}async send(t,...n){const e=new A.DeferredPromise,r=(0,me.default)(),s=n[0]||{};L('[message-sender]: send "%s" (%s)',t,r,s),this.receiverPort.postMessage({type:t,payload:{operationId:r,payload:s}}),L('[message-sender]: adding done listener for "%s" (%s)',t,r);const i=a=>{const{data:d}=a;if(d.operationId===r){const l=d.listenerPayload||{};L('[message-sender]: resolving "%s (%s) promise!',t,r),e.resolve({...l,operationId:d.operationId})}},o=a=>{const{data:d}=a;d.operationId===r&&(L('[message-sender]: rejecting "%s (%s) promise!',t,r),e.reject(d.error))};return this.on("internal/operation/done",i),this.on("internal/operation/failed",o),e.finally(()=>{this.emitter.removeEventListener("internal/operation/done",i),this.emitter.removeEventListener("internal/operation/failed",o)})}},N=j(U()),ke=j(G()),Ce=class{constructor(t){this.channel=t}async init(t){await this.channel.send("fs/init",{files:t})}async readFile(t,n){const e=await this.channel.send("fs/readFile",{path:t,encoding:n}).catch(r=>{throw new Error(w('Failed to read file at path "%s"',t),{cause:r})});if(!e)throw new Error("File not found");return e.data}async writeFile(t,n,e){let r,s=!1;typeof e=="object"?(r=e.encoding,s=!!e.recursive):typeof e=="string"&&(r=e),await this.channel.send("fs/writeFile",{path:t,content:n,encoding:r,recursive:s}).catch(i=>{throw new Error(w('Failed to write file at path "%s"',t),{cause:i})})}async readdir(t){const n=await this.channel.send("fs/readdir",{path:t}).catch(e=>{throw new Error(w('Failed to read directory at path "%s"',t),{cause:e})});if(!n)throw new Error("Directory not found");return n.data}async mkdir(t,n){const e=!!n?.recursive;await this.channel.send("fs/mkdir",{path:t,recursive:e}).catch(r=>{throw new Error(w('Failed to make directory at path "%s"',t),{cause:r})})}async stat(t){const n=await this.channel.send("fs/stat",{path:t}).catch(e=>{throw new Error(w('Failed to stat file at path "%s"',t),{cause:e})});if(!n)throw new Error("File not found");return n.data}async rm(t,n){const{force:e,recursive:r}=n||{};await this.channel.send("fs/rm",{path:t,force:e,recursive:r}).catch(s=>{throw new Error(w('Failed to remove file at path "%s"',t),{cause:s})})}async watch(t,n,e){const r=(0,ke.default)();return await this.channel.send("fs/watch",{watcherId:r,includes:t,excludes:n}),this.channel.on("fs/watch-event",({data:s})=>{if(s.watcherId===r&&e){const i={...s};delete i.watcherId,e(i)}}),{dispose:()=>this.channel.send("fs/unwatch",{watcherId:r})}}},q=j(pe()),Fe=class{constructor(t){this.channel=t}create(){return new xe(this.channel)}},xe=class{constructor(t){this.channel=t,this.state="running",this.stdout=new q.Emitter,this.stderr=new q.Emitter,this.stdin={write:n=>{if(!this.id)throw new Error("Failed to write to stdin, no process is currently running");return this.channel.send("shell/stdin",{data:n,workerId:this.id})}},this.forwardStdEvents()}id;state;stdout;stderr;stdin;forwardStdEvents(){this.channel.on("worker/tty",t=>{const{data:n}=t;if(n.workerId===this.id)switch(n.payload.type){case"out":{this.stdout.emit("data",n.payload.data);break}case"err":{this.stderr.emit("data",n.payload.data);break}}})}async runCommand(t,n,e={}){S(!this.id,'Failed to run "runCommand" on a ShellProcess: there is already a process running.');const r=await this.channel.send("shell/runCommand",{command:t,args:n,options:e});return S(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(t,n){switch(t){case"progress":{this.channel.on("worker/progress",({data:e})=>{n(e.status)});return}case"exit":{this.channel.on("worker/exit",({data:e})=>{e.workerId===this.id&&n(e.exitCode,e.error)});return}}}async kill(){S(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(t=>{throw new Error(w('Failed to kill shell with ID "%s"',this.id),{cause:t})}),this.id=void 0}},Ae=j(U()),De=2e4,Te=class{constructor(t){this.channel=t}async waitFor(t,n,e=De){const r=new Ae.DeferredPromise,s=setTimeout(()=>{r.reject()},e),i=await this.channel.send("preview/get/info",t).catch(a=>{r.reject(new Error(w('Failed to look up preview information for shell ID "%s" (port: %d)',t.sourceShellId,t.port)))}),o=i&&n(i);return o&&r.resolve({url:i.url,port:i.port,sourceShellId:i.sourceShellId}),this.channel.on("preview/port/ready",({data:a})=>{!o&&n(a)&&r.resolve({url:a.url,port:a.port,sourceShellId:a.sourceShellId})}),r.finally(()=>{clearTimeout(s)})}async getByShellId(t,n){return this.waitFor({sourceShellId:t},e=>e.sourceShellId===t,n).catch(e=>{throw new Error(w('Failed to get shell by ID "%s"',t),{cause:e})})}async waitForPort(t,n){return this.waitFor({port:t},e=>e.port===t,n).catch(e=>{throw new Error(w("Failed to await port %d",t),{cause:e})})}},Re="https://nodebox-runtime.codesandbox.io",C=K("emulator"),Ue=class{constructor(t){this.options=t,S(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||Re,this.isConnected=!1}channel=null;isConnected;url;fileSystemApi=null;shellApi=null;previewApi=null;async connect(){const{iframe:t,cdnUrl:n}=this.options;C("[message-sender]: Connecting to node emulator...");const e=new N.DeferredPromise;this.url||e.reject(new Error("Nodebox URL is missing. Did you forget to provide it when creating this Nodebox instance?")),S(t.contentWindow,"Failed to create a MessageChannel with the Nodebox iframe: no content window found"),this.channel=new Oe(t.contentWindow);const r=new N.DeferredPromise;return t.setAttribute("src",this.url),t.addEventListener("load",()=>{r.resolve()},{once:!0}),t.addEventListener("error",s=>{r.reject(s.error)},{once:!0}),await r,C("[message-sender]: IFrame loaded..."),await this.channel.handshake(),C("[message-sender]: Handshake completed..."),this.channel.send("connect",{cdnUrl:n}),this.channel.on("runtime/ready",()=>{e.resolve()}),e.then(()=>{C("[message-sender]: Connected to runtime..."),this.isConnected=!0})}get fs(){return S(this.isConnected,'Failed to access the File System API: consumer is not connected. Did you forget to run "connect()"?'),this.fileSystemApi?this.fileSystemApi:(this.fileSystemApi=new Ce(this.channel),this.fileSystemApi)}get shell(){return S(this.isConnected,'Failed to access the Shell API: consumer is not connected. Did you forget to run "connect()"?'),this.shellApi?this.shellApi:(this.shellApi=new Fe(this.channel),this.shellApi)}get preview(){return S(this.isConnected,'Failed to access the Preview API: consumer is not connected. Did you forget to run "connect()"?'),this.previewApi?this.previewApi:(this.previewApi=new Te(this.channel),this.previewApi)}},We="INJECT_AND_INVOKE",Be="PREVIEW_LOADED";function Ne(t,n){return _(this,void 0,void 0,function(){var e,r,s,i,o;return E(this,function(a){return e=t.contentWindow,D(e,"Failed to await preview iframe: no content window found"),r=9e4,s=20,i=0,[2,new Promise(function(d,l){var h=function(){var p=function(){clearTimeout(o),i=s,d(),t.removeEventListener("load",p)};if(i>=s){l(H("Could not able to connect to preview."));return}t.setAttribute("src",n),o=setTimeout(function(){h(),t.removeEventListener("load",p)},r),i=i+1,t.addEventListener("load",p)};t.addEventListener("error",function(){return l(new Error("Iframe error"))}),t.addEventListener("abort",function(){return l(new Error("Aborted"))}),h()})]})})}var qe=function(t,n){t.style.border="0",t.style.width=n.width||"100%",t.style.height=n.height||"100%",t.style.overflow="hidden",t.allow="cross-origin-isolated"};function He(t){var n=t.scope,e=window.history.__proto__,r=[],s=0,i=function(d){parent.postMessage({type:"urlchange",url:d,back:s>0,forward:s<r.length-1,channelId:n.channelId},"*")};function o(d,l){r.splice(s+1),r.push({url:d,state:l}),s=r.length-1}Object.assign(window.history,{go:function(d){var l=s+d;if(l>=0&&l<=r.length-1){s=l;var h=r[s],p=h.url,m=h.state;e.replaceState.call(window.history,m,"",p);var v=document.location.href;i(v),window.dispatchEvent(new PopStateEvent("popstate",{state:m}))}},back:function(){window.history.go(-1)},forward:function(){window.history.go(1)},pushState:function(d,l,h){e.replaceState.call(window.history,d,l,h),o(h,d),i(document.location.href)},replaceState:function(d,l,h){e.replaceState.call(window.history,d,l,h),r[s]={state:d,url:h},i(document.location.href)}});function a(d){var l=d.data;l.type==="urlback"?history.back():l.type==="urlforward"?history.forward():l.type==="refresh"&&document.location.reload()}window.addEventListener("message",a)}function Ve(t){var n=t.scope,e=0;function r(){if(typeof window>"u")return 0;var a=document.body,d=document.documentElement;return Math.max(a.scrollHeight,a.offsetHeight,d.offsetHeight)}function s(){var a=r();e!==a&&window.parent.postMessage({type:"resize",height:a,codesandbox:!0,channelId:n.channelId},"*"),e=a}s();var i,o=new MutationObserver(function(){i===void 0&&(s(),i=setTimeout(function(){i=void 0},300))});o.observe(document,{attributes:!0,childList:!0,subtree:!0}),setInterval(s,300)}var ze=[{code:He.toString(),id:"historyListener"},{code:"function consoleHook({ scope }) {"+re+`
|
|
4
|
+
};`,id:"consoleHook"},{code:Ve.toString(),id:"watchResize"}],Ge=function(t,n){ze.forEach(function(e){var r,s=e.code,i=e.id,o={uid:i,type:We,code:"exports.activate = ".concat(s),scope:{channelId:n}};(r=t.contentWindow)===null||r===void 0||r.postMessage(o,"*")})},Xe=(function(t){X(n,t);function n(e,r,s){s===void 0&&(s={});var i=t.call(this,e,r,k(k({},s),{bundlerURL:s.bundlerURL}))||this;return i._modulesCache=new Map,i.messageChannelId=ee(),i._initPromise=null,i.emitter=new te,i.manageIframes(e),i.emulator=new Ue({iframe:i.emulatorIframe,runtimeUrl:i.options.bundlerURL}),i.updateSandbox(r),i}return n.prototype._init=function(e){return _(this,void 0,void 0,function(){return E(this,function(r){switch(r.label){case 0:return[4,this.emulator.connect()];case 1:return r.sent(),[4,this.emulator.fs.init(e)];case 2:return r.sent(),[4,this.globalListeners()];case 3:return r.sent(),[2]}})})},n.prototype.compile=function(e){return _(this,void 0,void 0,function(){var r,s;return E(this,function(i){switch(i.label){case 0:return i.trys.push([0,5,,6]),this.status="initializing",this.dispatch({type:"start",firstLoad:!0}),this._initPromise||(this._initPromise=this._init(e)),[4,this._initPromise];case 1:return i.sent(),this.dispatch({type:"connected"}),[4,this.createShellProcessFromTask(e)];case 2:return r=i.sent().id,[4,this.createPreviewURLFromId(r)];case 3:return i.sent(),[4,this.setLocationURLIntoIFrame()];case 4:return i.sent(),this.dispatchDoneMessage(),[3,6];case 5:return s=i.sent(),this.dispatch({type:"action",action:"notification",notificationType:"error",title:W(s)}),this.dispatch({type:"done",compilatonError:!0}),[3,6];case 6:return[2]}})})},n.prototype.createShellProcessFromTask=function(e){return _(this,void 0,void 0,function(){var r,s,i=this;return E(this,function(o){switch(o.label){case 0:return r=F(e["/package.json"]),this.emulatorCommand=Z(r),this.emulatorShellProcess=this.emulator.shell.create(),[4,this.emulatorShellProcess.on("exit",function(a){i.dispatch({type:"action",action:"notification",notificationType:"error",title:H("Error: process.exit(".concat(a,") called."))})})];case 1:return o.sent(),[4,this.emulatorShellProcess.on("progress",function(a){var d,l;if(a.state==="command_running"||a.state==="starting_command"){i.dispatch({type:"shell/progress",data:k(k({},a),{command:[(d=i.emulatorCommand)===null||d===void 0?void 0:d[0],(l=i.emulatorCommand)===null||l===void 0?void 0:l[1].join(" ")].join(" ")})}),i.status="installing-dependencies";return}i.dispatch({type:"shell/progress",data:a})})];case 2:return o.sent(),this.emulatorShellProcess.stdout.on("data",function(a){i.dispatch({type:"stdout",payload:{data:a,type:"out"}})}),this.emulatorShellProcess.stderr.on("data",function(a){i.dispatch({type:"stdout",payload:{data:a,type:"err"}})}),[4,(s=this.emulatorShellProcess).runCommand.apply(s,this.emulatorCommand)];case 3:return[2,o.sent()]}})})},n.prototype.createPreviewURLFromId=function(e){var r;return _(this,void 0,void 0,function(){var s;return E(this,function(i){switch(i.label){case 0:return this.iframePreviewUrl=void 0,[4,this.emulator.preview.getByShellId(e)];case 1:return s=i.sent().url,this.iframePreviewUrl=s+((r=this.options.startRoute)!==null&&r!==void 0?r:""),[2]}})})},n.prototype.manageIframes=function(e){var r;if(typeof e=="string"){var s=document.querySelector(e);D(s,"The element '".concat(e,"' was not found")),this.iframe=document.createElement("iframe"),s?.appendChild(this.iframe)}else this.iframe=e;qe(this.iframe,this.options),D(this.iframe.parentNode,"The given iframe does not have a parent."),this.emulatorIframe=document.createElement("iframe"),this.emulatorIframe.classList.add("sp-bridge-frame"),(r=this.iframe.parentNode)===null||r===void 0||r.appendChild(this.emulatorIframe)},n.prototype.setLocationURLIntoIFrame=function(){return _(this,void 0,void 0,function(){return E(this,function(e){switch(e.label){case 0:return this.iframePreviewUrl?[4,Ne(this.iframe,this.iframePreviewUrl)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})},n.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})},n.prototype.globalListeners=function(){return _(this,void 0,void 0,function(){var e=this;return E(this,function(r){switch(r.label){case 0:return window.addEventListener("message",function(s){s.data.type===Be&&Ge(e.iframe,e.messageChannelId),s.data.type==="urlchange"&&s.data.channelId===e.messageChannelId?e.dispatch({type:"urlchange",url:s.data.url,back:s.data.back,forward:s.data.forward}):s.data.channelId===e.messageChannelId&&e.dispatch(s.data)}),[4,this.emulator.fs.watch(["*"],[".next","node_modules","build","dist","vendor",".config",".vuepress"],function(s){return _(e,void 0,void 0,function(){var i,o,a,d,l,h,p;return E(this,function(m){switch(m.label){case 0:return s?(i=s,o="newPath"in i?i.newPath:"path"in i?i.path:"",[4,this.emulator.fs.stat(o)]):[2];case 1:if(a=m.sent().type,a!=="file")return[2,null];m.label=2;case 2:switch(m.trys.push([2,10,,11]),d=i.type,d){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(i.path,"utf8")];case 4:return l=m.sent(),this.dispatch({type:"fs/change",path:i.path,content:l}),this._modulesCache.set(i.path,x(l)),[3,9];case 5:return this.dispatch({type:"fs/remove",path:i.path}),this._modulesCache.delete(i.path),[3,9];case 6:return this.dispatch({type:"fs/remove",path:i.oldPath}),this._modulesCache.delete(i.oldPath),[4,this.emulator.fs.readFile(i.newPath,"utf8")];case 7:return h=m.sent(),this.dispatch({type:"fs/change",path:i.newPath,content:h}),this._modulesCache.set(i.newPath,x(h)),[3,9];case 8:return[3,9];case 9:return[3,11];case 10:return p=m.sent(),this.dispatch({type:"action",action:"notification",notificationType:"error",title:W(p)}),[3,11];case 11:return[2]}})})})];case 1:return r.sent(),[2]}})})},n.prototype.restartShellProcess=function(){var e;return _(this,void 0,void 0,function(){return E(this,function(r){switch(r.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 r.sent(),(e=this.iframe)===null||e===void 0||e.removeAttribute("attr"),this.emulator.fs.rm("/node_modules/.vite",{recursive:!0,force:!0}),[4,this.compile(Object.fromEntries(this._modulesCache))];case 2:r.sent(),r.label=3;case 3:return[2]}})})},n.prototype.updateSandbox=function(e){var r=this,s,i=$(e.files);if(((s=this.emulatorShellProcess)===null||s===void 0?void 0:s.state)==="running"){Object.entries(i).forEach(function(o){var a=o[0],d=o[1];(!r._modulesCache.get(a)||F(d)!==F(r._modulesCache.get(a)))&&r.emulator.fs.writeFile(a,d,{recursive:!0})});return}this.dispatch({codesandbox:!0,modules:i,template:e.template,type:"compile"}),Object.entries(i).forEach(function(o){var a=o[0],d=o[1];r._modulesCache.set(a,x(d))})},n.prototype.dispatch=function(e){var r,s;return _(this,void 0,void 0,function(){var i;return E(this,function(o){switch(o.label){case 0:switch(i=e.type,i){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 o.sent(),[3,8];case 4:return(s=(r=this.iframe)===null||r===void 0?void 0:r.contentWindow)===null||s===void 0||s.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),o.label=8;case 8:return[2]}})})},n.prototype.listen=function(e){return this.emitter.listener(e)},n.prototype.destroy=function(){this.emulatorIframe.remove(),this.emitter.cleanup()},n})(Q);export{Xe as SandpackNode};
|
package/dist/client/index.html
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
/>
|
|
11
11
|
<title>Iconoma Studio</title>
|
|
12
12
|
<!--app-head-->
|
|
13
|
-
<script type="module" crossorigin src="/assets/index-
|
|
14
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
13
|
+
<script type="module" crossorigin src="/assets/index-7c_AX7XK.js"></script>
|
|
14
|
+
<link rel="stylesheet" crossorigin href="/assets/index-Bdj-eDET.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
|
17
17
|
<div id="root">
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { e as dequal } from "../entry-server.js";
|
|
2
|
+
var SandpackClient = (
|
|
3
|
+
/** @class */
|
|
4
|
+
(function() {
|
|
5
|
+
function SandpackClient2(iframeSelector, sandboxSetup, options) {
|
|
6
|
+
if (options === void 0) {
|
|
7
|
+
options = {};
|
|
8
|
+
}
|
|
9
|
+
this.status = "idle";
|
|
10
|
+
this.options = options;
|
|
11
|
+
this.sandboxSetup = sandboxSetup;
|
|
12
|
+
this.iframeSelector = iframeSelector;
|
|
13
|
+
}
|
|
14
|
+
SandpackClient2.prototype.updateOptions = function(options) {
|
|
15
|
+
if (!dequal(this.options, options)) {
|
|
16
|
+
this.options = options;
|
|
17
|
+
this.updateSandbox();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
SandpackClient2.prototype.updateSandbox = function(_sandboxSetup, _isInitializationCompile) {
|
|
21
|
+
if (_sandboxSetup === void 0) {
|
|
22
|
+
_sandboxSetup = this.sandboxSetup;
|
|
23
|
+
}
|
|
24
|
+
throw Error("Method not implemented");
|
|
25
|
+
};
|
|
26
|
+
SandpackClient2.prototype.destroy = function() {
|
|
27
|
+
throw Error("Method not implemented");
|
|
28
|
+
};
|
|
29
|
+
SandpackClient2.prototype.dispatch = function(_message) {
|
|
30
|
+
throw Error("Method not implemented");
|
|
31
|
+
};
|
|
32
|
+
SandpackClient2.prototype.listen = function(_listener) {
|
|
33
|
+
throw Error("Method not implemented");
|
|
34
|
+
};
|
|
35
|
+
return SandpackClient2;
|
|
36
|
+
})()
|
|
37
|
+
);
|
|
38
|
+
export {
|
|
39
|
+
SandpackClient as S
|
|
40
|
+
};
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { d as createError, i as invariant } from "../entry-server.js";
|
|
2
|
+
var EventEmitter = (
|
|
3
|
+
/** @class */
|
|
4
|
+
(function() {
|
|
5
|
+
function EventEmitter2() {
|
|
6
|
+
this.listeners = {};
|
|
7
|
+
this.listenersCount = 0;
|
|
8
|
+
this.channelId = Math.floor(Math.random() * 1e6);
|
|
9
|
+
this.listeners = [];
|
|
10
|
+
}
|
|
11
|
+
EventEmitter2.prototype.cleanup = function() {
|
|
12
|
+
this.listeners = {};
|
|
13
|
+
this.listenersCount = 0;
|
|
14
|
+
};
|
|
15
|
+
EventEmitter2.prototype.dispatch = function(message) {
|
|
16
|
+
Object.values(this.listeners).forEach(function(listener) {
|
|
17
|
+
return listener(message);
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
EventEmitter2.prototype.listener = function(listener) {
|
|
21
|
+
var _this = this;
|
|
22
|
+
if (typeof listener !== "function") {
|
|
23
|
+
return function() {
|
|
24
|
+
return;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
var listenerId = this.listenersCount;
|
|
28
|
+
this.listeners[listenerId] = listener;
|
|
29
|
+
this.listenersCount++;
|
|
30
|
+
return function() {
|
|
31
|
+
delete _this.listeners[listenerId];
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
return EventEmitter2;
|
|
35
|
+
})()
|
|
36
|
+
);
|
|
37
|
+
function isCommand(char) {
|
|
38
|
+
return /[a-zA-Z.]/.test(char);
|
|
39
|
+
}
|
|
40
|
+
function isAlpha(char) {
|
|
41
|
+
return /[a-zA-Z]/.test(char);
|
|
42
|
+
}
|
|
43
|
+
function isWhitespace(char) {
|
|
44
|
+
return /\s/.test(char);
|
|
45
|
+
}
|
|
46
|
+
function isOperator(char) {
|
|
47
|
+
return /[&|]/.test(char);
|
|
48
|
+
}
|
|
49
|
+
function isArgument(char) {
|
|
50
|
+
return /-/.test(char);
|
|
51
|
+
}
|
|
52
|
+
function isString(char) {
|
|
53
|
+
return /["']/.test(char);
|
|
54
|
+
}
|
|
55
|
+
function isEnvVar(char) {
|
|
56
|
+
return isAlpha(char) && char === char.toUpperCase();
|
|
57
|
+
}
|
|
58
|
+
var TokenType;
|
|
59
|
+
(function(TokenType2) {
|
|
60
|
+
TokenType2["OR"] = "OR";
|
|
61
|
+
TokenType2["AND"] = "AND";
|
|
62
|
+
TokenType2["PIPE"] = "PIPE";
|
|
63
|
+
TokenType2["Command"] = "Command";
|
|
64
|
+
TokenType2["Argument"] = "Argument";
|
|
65
|
+
TokenType2["String"] = "String";
|
|
66
|
+
TokenType2["EnvVar"] = "EnvVar";
|
|
67
|
+
})(TokenType || (TokenType = {}));
|
|
68
|
+
var operators = /* @__PURE__ */ new Map([
|
|
69
|
+
["&&", { type: TokenType.AND }],
|
|
70
|
+
["||", { type: TokenType.OR }],
|
|
71
|
+
["|", { type: TokenType.PIPE }],
|
|
72
|
+
["-", { type: TokenType.Argument }]
|
|
73
|
+
]);
|
|
74
|
+
function tokenize(input) {
|
|
75
|
+
var current = 0;
|
|
76
|
+
var tokens = [];
|
|
77
|
+
function parseCommand() {
|
|
78
|
+
var value = "";
|
|
79
|
+
while (isCommand(input[current]) && current < input.length) {
|
|
80
|
+
value += input[current];
|
|
81
|
+
current++;
|
|
82
|
+
}
|
|
83
|
+
return { type: TokenType.Command, value };
|
|
84
|
+
}
|
|
85
|
+
function parseOperator() {
|
|
86
|
+
var value = "";
|
|
87
|
+
while (isOperator(input[current]) && current < input.length) {
|
|
88
|
+
value += input[current];
|
|
89
|
+
current++;
|
|
90
|
+
}
|
|
91
|
+
return operators.get(value);
|
|
92
|
+
}
|
|
93
|
+
function parseArgument() {
|
|
94
|
+
var value = "";
|
|
95
|
+
while ((isArgument(input[current]) || isAlpha(input[current])) && current < input.length) {
|
|
96
|
+
value += input[current];
|
|
97
|
+
current++;
|
|
98
|
+
}
|
|
99
|
+
return { type: TokenType.Argument, value };
|
|
100
|
+
}
|
|
101
|
+
function parseString() {
|
|
102
|
+
var openCloseQuote = input[current];
|
|
103
|
+
var value = input[current];
|
|
104
|
+
current++;
|
|
105
|
+
while (input[current] !== openCloseQuote && current < input.length) {
|
|
106
|
+
value += input[current];
|
|
107
|
+
current++;
|
|
108
|
+
}
|
|
109
|
+
value += input[current];
|
|
110
|
+
current++;
|
|
111
|
+
return { type: TokenType.String, value };
|
|
112
|
+
}
|
|
113
|
+
function parseEnvVars() {
|
|
114
|
+
var value = {};
|
|
115
|
+
var parseSingleEnv = function() {
|
|
116
|
+
var key = "";
|
|
117
|
+
var pair = "";
|
|
118
|
+
while (input[current] !== "=" && current < input.length) {
|
|
119
|
+
key += input[current];
|
|
120
|
+
current++;
|
|
121
|
+
}
|
|
122
|
+
if (input[current] === "=") {
|
|
123
|
+
current++;
|
|
124
|
+
}
|
|
125
|
+
while (input[current] !== " " && current < input.length) {
|
|
126
|
+
pair += input[current];
|
|
127
|
+
current++;
|
|
128
|
+
}
|
|
129
|
+
value[key] = pair;
|
|
130
|
+
};
|
|
131
|
+
while (isEnvVar(input[current]) && current < input.length) {
|
|
132
|
+
parseSingleEnv();
|
|
133
|
+
current++;
|
|
134
|
+
}
|
|
135
|
+
return { type: TokenType.EnvVar, value };
|
|
136
|
+
}
|
|
137
|
+
while (current < input.length) {
|
|
138
|
+
var currentChar = input[current];
|
|
139
|
+
if (isWhitespace(currentChar)) {
|
|
140
|
+
current++;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
switch (true) {
|
|
144
|
+
case isEnvVar(currentChar):
|
|
145
|
+
tokens.push(parseEnvVars());
|
|
146
|
+
break;
|
|
147
|
+
case isCommand(currentChar):
|
|
148
|
+
tokens.push(parseCommand());
|
|
149
|
+
break;
|
|
150
|
+
case isOperator(currentChar):
|
|
151
|
+
tokens.push(parseOperator());
|
|
152
|
+
break;
|
|
153
|
+
case isArgument(currentChar):
|
|
154
|
+
tokens.push(parseArgument());
|
|
155
|
+
break;
|
|
156
|
+
case isString(currentChar):
|
|
157
|
+
tokens.push(parseString());
|
|
158
|
+
break;
|
|
159
|
+
default:
|
|
160
|
+
throw new Error("Unknown character: ".concat(currentChar));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return tokens;
|
|
164
|
+
}
|
|
165
|
+
var counter = 0;
|
|
166
|
+
function generateRandomId() {
|
|
167
|
+
var now = Date.now();
|
|
168
|
+
var randomNumber = Math.round(Math.random() * 1e4);
|
|
169
|
+
var count = counter += 1;
|
|
170
|
+
return (+"".concat(now).concat(randomNumber).concat(count)).toString(16);
|
|
171
|
+
}
|
|
172
|
+
var writeBuffer = function(content) {
|
|
173
|
+
if (typeof content === "string") {
|
|
174
|
+
return new TextEncoder().encode(content);
|
|
175
|
+
} else {
|
|
176
|
+
return content;
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
var readBuffer = function(content) {
|
|
180
|
+
if (typeof content === "string") {
|
|
181
|
+
return content;
|
|
182
|
+
} else {
|
|
183
|
+
return new TextDecoder().decode(content);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
var fromBundlerFilesToFS = function(files) {
|
|
187
|
+
return Object.entries(files).reduce(function(acc, _a) {
|
|
188
|
+
var key = _a[0], value = _a[1];
|
|
189
|
+
acc[key] = writeBuffer(value.code);
|
|
190
|
+
return acc;
|
|
191
|
+
}, {});
|
|
192
|
+
};
|
|
193
|
+
var findStartScriptPackageJson = function(packageJson) {
|
|
194
|
+
var scripts = {};
|
|
195
|
+
var possibleKeys = ["dev", "start"];
|
|
196
|
+
try {
|
|
197
|
+
scripts = JSON.parse(packageJson).scripts;
|
|
198
|
+
} catch (e) {
|
|
199
|
+
throw createError("Could not parse package.json file: " + e.message);
|
|
200
|
+
}
|
|
201
|
+
invariant(scripts, "Failed to start. Please provide a `start` or `dev` script on the package.json");
|
|
202
|
+
var _loop_1 = function(index2) {
|
|
203
|
+
if (possibleKeys[index2] in scripts) {
|
|
204
|
+
var script = possibleKeys[index2];
|
|
205
|
+
var candidate = scripts[script];
|
|
206
|
+
var env_1 = {};
|
|
207
|
+
var command_1 = "";
|
|
208
|
+
var args_1 = [];
|
|
209
|
+
tokenize(candidate).forEach(function(item) {
|
|
210
|
+
var commandNotFoundYet = command_1 === "";
|
|
211
|
+
if (item.type === TokenType.EnvVar) {
|
|
212
|
+
env_1 = item.value;
|
|
213
|
+
}
|
|
214
|
+
if (item.type === TokenType.Command && commandNotFoundYet) {
|
|
215
|
+
command_1 = item.value;
|
|
216
|
+
}
|
|
217
|
+
if (item.type === TokenType.Argument || !commandNotFoundYet && item.type === TokenType.Command) {
|
|
218
|
+
args_1.push(item.value);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
return { value: [command_1, args_1, { env: env_1 }] };
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
for (var index = 0; index < possibleKeys.length; index++) {
|
|
225
|
+
var state_1 = _loop_1(index);
|
|
226
|
+
if (typeof state_1 === "object")
|
|
227
|
+
return state_1.value;
|
|
228
|
+
}
|
|
229
|
+
throw createError("Failed to start. Please provide a `start` or `dev` script on the package.json");
|
|
230
|
+
};
|
|
231
|
+
var getMessageFromError = function(error) {
|
|
232
|
+
if (typeof error === "string")
|
|
233
|
+
return error;
|
|
234
|
+
if (typeof error === "object" && "message" in error) {
|
|
235
|
+
return error.message;
|
|
236
|
+
}
|
|
237
|
+
return createError("The server could not be reached. Make sure that the node script is running and that a port has been started.");
|
|
238
|
+
};
|
|
239
|
+
var consoleHook = `var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var e={},n={};!function(t){t.__esModule=!0,t.default=["log","debug","info","warn","error","table","clear","time","timeEnd","count","assert","command","result"]}(n);var a,o={},i={};(a=i).__esModule=!0,a.default=function(){var t=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+"-"+Date.now()};var u={},s={__esModule:!0};s.update=s.state=void 0,s.update=function(t){s.state=t};var f={},c={};!function(r){var e=t&&t.__assign||function(){return e=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var a in r=arguments[e])Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a]);return t},e.apply(this,arguments)};r.__esModule=!0,r.initialState=void 0,r.initialState={timings:{},count:{}};var n=function(){return"undefined"!=typeof performance&&performance.now?performance.now():Date.now()};r.default=function(t,a){var o,i,u;switch(void 0===t&&(t=r.initialState),a.type){case"COUNT":var s=t.count[a.name]||0;return e(e({},t),{count:e(e({},t.count),(o={},o[a.name]=s+1,o))});case"TIME_START":return e(e({},t),{timings:e(e({},t.timings),(i={},i[a.name]={start:n()},i))});case"TIME_END":var f=t.timings[a.name],c=n(),l=c-f.start;return e(e({},t),{timings:e(e({},t.timings),(u={},u[a.name]=e(e({},f),{end:c,time:l}),u))});default:return t}}}(c),function(r){var e=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};r.__esModule=!0;var n=e(c),a=s;r.default=function(t){a.update(n.default(a.state,t))}}(f);var l={__esModule:!0};l.timeEnd=l.timeStart=l.count=void 0,l.count=function(t){return{type:"COUNT",name:t}},l.timeStart=function(t){return{type:"TIME_START",name:t}},l.timeEnd=function(t){return{type:"TIME_END",name:t}};var d=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};u.__esModule=!0,u.stop=u.start=void 0;var p=s,h=d(f),m=l;u.start=function(t){h.default(m.timeStart(t))},u.stop=function(t){var r=null===p.state||void 0===p.state?void 0:p.state.timings[t];return r&&!r.end?(h.default(m.timeEnd(t)),{method:"log",data:[t+": "+p.state.timings[t].time+"ms"]}):{method:"warn",data:["Timer '"+t+"' does not exist"]}};var y={},v=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};y.__esModule=!0,y.increment=void 0;var _=s,b=v(f),g=l;y.increment=function(t){return b.default(g.count(t)),{method:"log",data:[t+": "+_.state.count[t]]}};var M={},T=t&&t.__spreadArrays||function(){for(var t=0,r=0,e=arguments.length;r<e;r++)t+=arguments[r].length;var n=Array(t),a=0;for(r=0;r<e;r++)for(var o=arguments[r],i=0,u=o.length;i<u;i++,a++)n[a]=o[i];return n};M.__esModule=!0,M.test=void 0,M.test=function(t){for(var r=[],e=1;e<arguments.length;e++)r[e-1]=arguments[e];return!t&&(0===r.length&&r.push("console.assert"),{method:"error",data:T(["Assertion failed:"],r)})},function(r){var e=t&&t.__assign||function(){return e=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var a in r=arguments[e])Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a]);return t},e.apply(this,arguments)},n=t&&t.__createBinding||(Object.create?function(t,r,e,n){void 0===n&&(n=e),Object.defineProperty(t,n,{enumerable:!0,get:function(){return r[e]}})}:function(t,r,e,n){void 0===n&&(n=e),t[n]=r[e]}),a=t&&t.__setModuleDefault||(Object.create?function(t,r){Object.defineProperty(t,"default",{enumerable:!0,value:r})}:function(t,r){t.default=r}),o=t&&t.__importStar||function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var e in t)"default"!==e&&Object.prototype.hasOwnProperty.call(t,e)&&n(r,t,e);return a(r,t),r},s=t&&t.__spreadArrays||function(){for(var t=0,r=0,e=arguments.length;r<e;r++)t+=arguments[r].length;var n=Array(t),a=0;for(r=0;r<e;r++)for(var o=arguments[r],i=0,u=o.length;i<u;i++,a++)n[a]=o[i];return n},f=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};r.__esModule=!0;var c=f(i),l=o(u),d=o(y),p=o(M);r.default=function(t,r,n){var a=n||c.default();switch(t){case"clear":return{method:t,id:a};case"count":return!!(o="string"==typeof r[0]?r[0]:"default")&&e(e({},d.increment(o)),{id:a});case"time":case"timeEnd":var o;return!!(o="string"==typeof r[0]?r[0]:"default")&&("time"===t?(l.start(o),!1):e(e({},l.stop(o)),{id:a}));case"assert":if(0!==r.length){var i=p.test.apply(p,s([r[0]],r.slice(1)));if(i)return e(e({},i),{id:a})}return!1;case"error":return{method:t,id:a,data:r.map((function(t){try{return t.stack||t}catch(r){return t}}))};default:return{method:t,id:a,data:r}}}}(o);var S={},O={};!function(t){var r;t.__esModule=!0,function(t){t[t.infinity=0]="infinity",t[t.minusInfinity=1]="minusInfinity",t[t.minusZero=2]="minusZero"}(r||(r={})),t.default={type:"Arithmetic",lookup:Number,shouldTransform:function(t,r){return"number"===t&&(r===1/0||r===-1/0||function(t){return 1/t==-1/0}(r))},toSerializable:function(t){return t===1/0?r.infinity:t===-1/0?r.minusInfinity:r.minusZero},fromSerializable:function(t){return t===r.infinity?1/0:t===r.minusInfinity?-1/0:t===r.minusZero?-0:t}}}(O);var w={};!function(t){t.__esModule=!0,t.default={type:"Function",lookup:Function,shouldTransform:function(t,r){return"function"==typeof r},toSerializable:function(t){var r="";try{r=t.toString().substring(r.indexOf("{")+1,r.lastIndexOf("}"))}catch(t){}return{name:t.name,body:r,proto:Object.getPrototypeOf(t).constructor.name}},fromSerializable:function(t){try{var r=function(){};return"string"==typeof t.name&&Object.defineProperty(r,"name",{value:t.name,writable:!1}),"string"==typeof t.body&&Object.defineProperty(r,"body",{value:t.body,writable:!1}),"string"==typeof t.proto&&(r.constructor={name:t.proto}),r}catch(r){return t}}}}(w);var A={};!function(t){var r;function e(t){for(var r={},e=0,n=t.attributes;e<n.length;e++){var a=n[e];r[a.name]=a.value}return r}t.__esModule=!0,t.default={type:"HTMLElement",shouldTransform:function(t,r){return r&&r.children&&"string"==typeof r.innerHTML&&"string"==typeof r.tagName},toSerializable:function(t){return{tagName:t.tagName.toLowerCase(),attributes:e(t),innerHTML:t.innerHTML}},fromSerializable:function(t){try{var e=(r||(r=document.implementation.createHTMLDocument("sandbox"))).createElement(t.tagName);e.innerHTML=t.innerHTML;for(var n=0,a=Object.keys(t.attributes);n<a.length;n++){var o=a[n];try{e.setAttribute(o,t.attributes[o])}catch(t){}}return e}catch(r){return t}}}}(A);var j={};!function(r){var e=t&&t.__assign||function(){return e=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var a in r=arguments[e])Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a]);return t},e.apply(this,arguments)};r.__esModule=!0,r.default={type:"Map",shouldTransform:function(t,r){return r&&r.constructor&&"Map"===r.constructor.name},toSerializable:function(t){var r={};return t.forEach((function(t,e){var n="object"==typeof e?JSON.stringify(e):e;r[n]=t})),{name:"Map",body:r,proto:Object.getPrototypeOf(t).constructor.name}},fromSerializable:function(t){var r=t.body,n=e({},r);return"string"==typeof t.proto&&(n.constructor={name:t.proto}),n}}}(j);var z={};!function(t){t.__esModule=!0;var r="@t",e=/^#*@(t|r)$/,n=(0,eval)("this"),a="function"==typeof ArrayBuffer,o="function"==typeof Map,i="function"==typeof Set,u=["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array"],s=Array.prototype.slice,f={serialize:function(t){return JSON.stringify(t)},deserialize:function(t){return JSON.parse(t)}},c=function(){function t(t,r){this.references=t,this.transforms=r,this.transformsMap=this._makeTransformsMap(),this.circularCandidates=[],this.circularCandidatesDescrs=[],this.circularRefCount=0}return t._createRefMark=function(t){var r=Object.create(null);return r["@r"]=t,r},t.prototype._createCircularCandidate=function(t,r,e){this.circularCandidates.push(t),this.circularCandidatesDescrs.push({parent:r,key:e,refIdx:-1})},t.prototype._applyTransform=function(t,e,n,a){var o=Object.create(null),i=a.toSerializable(t);return"object"==typeof i&&this._createCircularCandidate(t,e,n),o[r]=a.type,o.data=this._handleValue((function(){return i}),e,n),o},t.prototype._handleArray=function(t){for(var r=[],e=function(e){r[e]=n._handleValue((function(){return t[e]}),r,e)},n=this,a=0;a<t.length;a++)e(a);return r},t.prototype._handlePlainObject=function(t){var r,n,a=Object.create(null),o=function(r){if(Reflect.has(t,r)){var n=e.test(r)?"#"+r:r;a[n]=i._handleValue((function(){return t[r]}),a,n)}},i=this;for(var u in t)o(u);var s=null===(n=null===(r=null==t?void 0:t.__proto__)||void 0===r?void 0:r.constructor)||void 0===n?void 0:n.name;return s&&"Object"!==s&&(a.constructor={name:s}),a},t.prototype._handleObject=function(t,r,e){return this._createCircularCandidate(t,r,e),Array.isArray(t)?this._handleArray(t):this._handlePlainObject(t)},t.prototype._ensureCircularReference=function(r){var e=this.circularCandidates.indexOf(r);if(e>-1){var n=this.circularCandidatesDescrs[e];return-1===n.refIdx&&(n.refIdx=n.parent?++this.circularRefCount:0),t._createRefMark(n.refIdx)}return null},t.prototype._handleValue=function(t,r,e){try{var n=t(),a=typeof n,o="object"===a&&null!==n;if(o){var i=this._ensureCircularReference(n);if(i)return i}var u=this._findTransform(a,n);return u?this._applyTransform(n,r,e,u):o?this._handleObject(n,r,e):n}catch(t){try{return this._handleValue((function(){return t instanceof Error?t:new Error(t)}),r,e)}catch(t){return null}}},t.prototype._makeTransformsMap=function(){if(o){var t=new Map;return this.transforms.forEach((function(r){r.lookup&&t.set(r.lookup,r)})),t}},t.prototype._findTransform=function(t,r){if(o&&r&&r.constructor&&(null==(a=this.transformsMap.get(r.constructor))?void 0:a.shouldTransform(t,r)))return a;for(var e=0,n=this.transforms;e<n.length;e++){var a;if((a=n[e]).shouldTransform(t,r))return a}},t.prototype.transform=function(){for(var r=this,e=[this._handleValue((function(){return r.references}),null,null)],n=0,a=this.circularCandidatesDescrs;n<a.length;n++){var o=a[n];o.refIdx>0&&(e[o.refIdx]=o.parent[o.key],o.parent[o.key]=t._createRefMark(o.refIdx))}return e},t}(),l=function(){function t(t,r){this.activeTransformsStack=[],this.visitedRefs=Object.create(null),this.references=t,this.transformMap=r}return t.prototype._handlePlainObject=function(t){var r=Object.create(null);for(var n in"constructor"in t&&(t.constructor&&"string"==typeof t.constructor.name||(t.constructor={name:"Object"})),t)t.hasOwnProperty(n)&&(this._handleValue(t[n],t,n),e.test(n)&&(r[n.substring(1)]=t[n],delete t[n]));for(var a in r)t[a]=r[a]},t.prototype._handleTransformedObject=function(t,e,n){var a=t[r],o=this.transformMap[a];if(!o)throw new Error("Can't find transform for \\""+a+'" type.');this.activeTransformsStack.push(t),this._handleValue(t.data,t,"data"),this.activeTransformsStack.pop(),e[n]=o.fromSerializable(t.data)},t.prototype._handleCircularSelfRefDuringTransform=function(t,r,e){var n=this.references;Object.defineProperty(r,e,{val:void 0,configurable:!0,enumerable:!0,get:function(){return void 0===this.val&&(this.val=n[t]),this.val},set:function(t){this.val=t}})},t.prototype._handleCircularRef=function(t,r,e){this.activeTransformsStack.includes(this.references[t])?this._handleCircularSelfRefDuringTransform(t,r,e):(this.visitedRefs[t]||(this.visitedRefs[t]=!0,this._handleValue(this.references[t],this.references,t)),r[e]=this.references[t])},t.prototype._handleValue=function(t,e,n){if("object"==typeof t&&null!==t){var a=t["@r"];if(void 0!==a)this._handleCircularRef(a,e,n);else if(t[r])this._handleTransformedObject(t,e,n);else if(Array.isArray(t))for(var o=0;o<t.length;o++)this._handleValue(t[o],t,o);else this._handlePlainObject(t)}},t.prototype.transform=function(){return this.visitedRefs[0]=!0,this._handleValue(this.references[0],this.references,0),this.references[0]},t}(),d=[{type:"[[NaN]]",shouldTransform:function(t,r){return"number"===t&&isNaN(r)},toSerializable:function(){return""},fromSerializable:function(){return NaN}},{type:"[[undefined]]",shouldTransform:function(t){return"undefined"===t},toSerializable:function(){return""},fromSerializable:function(){}},{type:"[[Date]]",lookup:Date,shouldTransform:function(t,r){return r instanceof Date},toSerializable:function(t){return t.getTime()},fromSerializable:function(t){var r=new Date;return r.setTime(t),r}},{type:"[[RegExp]]",lookup:RegExp,shouldTransform:function(t,r){return r instanceof RegExp},toSerializable:function(t){var r={src:t.source,flags:""};return t.globalThis&&(r.flags+="g"),t.ignoreCase&&(r.flags+="i"),t.multiline&&(r.flags+="m"),r},fromSerializable:function(t){return new RegExp(t.src,t.flags)}},{type:"[[Error]]",lookup:Error,shouldTransform:function(t,r){return r instanceof Error},toSerializable:function(t){var r,e;return t.stack||null===(e=(r=Error).captureStackTrace)||void 0===e||e.call(r,t),{name:t.name,message:t.message,stack:t.stack}},fromSerializable:function(t){var r=new(n[t.name]||Error)(t.message);return r.stack=t.stack,r}},{type:"[[ArrayBuffer]]",lookup:a&&ArrayBuffer,shouldTransform:function(t,r){return a&&r instanceof ArrayBuffer},toSerializable:function(t){var r=new Int8Array(t);return s.call(r)},fromSerializable:function(t){if(a){var r=new ArrayBuffer(t.length);return new Int8Array(r).set(t),r}return t}},{type:"[[TypedArray]]",shouldTransform:function(t,r){if(a)return ArrayBuffer.isView(r)&&!(r instanceof DataView);for(var e=0,o=u;e<o.length;e++){var i=o[e];if("function"==typeof n[i]&&r instanceof n[i])return!0}return!1},toSerializable:function(t){return{ctorName:t.constructor.name,arr:s.call(t)}},fromSerializable:function(t){return"function"==typeof n[t.ctorName]?new n[t.ctorName](t.arr):t.arr}},{type:"[[Map]]",lookup:o&&Map,shouldTransform:function(t,r){return o&&r instanceof Map},toSerializable:function(t){var r=[];return t.forEach((function(t,e){r.push(e),r.push(t)})),r},fromSerializable:function(t){if(o){for(var r=new Map,e=0;e<t.length;e+=2)r.set(t[e],t[e+1]);return r}for(var n=[],a=0;a<t.length;a+=2)n.push([t[e],t[e+1]]);return n}},{type:"[[Set]]",lookup:i&&Set,shouldTransform:function(t,r){return i&&r instanceof Set},toSerializable:function(t){var r=[];return t.forEach((function(t){r.push(t)})),r},fromSerializable:function(t){if(i){for(var r=new Set,e=0;e<t.length;e++)r.add(t[e]);return r}return t}}],p=function(){function t(t){this.transforms=[],this.transformsMap=Object.create(null),this.serializer=t||f,this.addTransforms(d)}return t.prototype.addTransforms=function(t){for(var r=0,e=t=Array.isArray(t)?t:[t];r<e.length;r++){var n=e[r];if(this.transformsMap[n.type])throw new Error('Transform with type "'+n.type+'" was already added.');this.transforms.push(n),this.transformsMap[n.type]=n}return this},t.prototype.removeTransforms=function(t){for(var r=0,e=t=Array.isArray(t)?t:[t];r<e.length;r++){var n=e[r],a=this.transforms.indexOf(n);a>-1&&this.transforms.splice(a,1),delete this.transformsMap[n.type]}return this},t.prototype.encode=function(t){var r=new c(t,this.transforms).transform();return this.serializer.serialize(r)},t.prototype.decode=function(t){var r=this.serializer.deserialize(t);return new l(r,this.transformsMap).transform()},t}();t.default=p}(z);var E=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};S.__esModule=!0,S.Decode=P=S.Encode=void 0;var k=E(O),C=E(w),D=E(A),I=E(j),N=E(z),R=[D.default,C.default,k.default,I.default],x=new N.default;x.addTransforms(R);var P=S.Encode=function(t){return JSON.parse(x.encode(t))};S.Decode=function(t){return x.decode(JSON.stringify(t))},function(r){var e=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};r.__esModule=!0;var a=e(n),i=e(o),u=S;r.default=function(t,r,e){void 0===e&&(e=!0);for(var n=t,o={pointers:{},src:{npm:"https://npmjs.com/package/console-feed",github:"https://github.com/samdenty99/console-feed"}},s=function(t){var a=n[t];n[t]=function(){a.apply(this,arguments);var n=[].slice.call(arguments);setTimeout((function(){var a=i.default(t,n);if(a){var o=a;e&&(o=u.Encode(a)),r(o,a)}}))},o.pointers[t]=a},f=0,c=a.default;f<c.length;f++)s(c[f]);return n.feed=o,n}}(e),r(e)(window.console,(function(t){var r=P(t);parent.postMessage({type:"console",codesandbox:!0,log:Array.isArray(r)?r[0]:r,channelId:scope.channelId},"*")}));
|
|
240
|
+
`;
|
|
241
|
+
export {
|
|
242
|
+
EventEmitter as E,
|
|
243
|
+
fromBundlerFilesToFS as a,
|
|
244
|
+
generateRandomId as b,
|
|
245
|
+
consoleHook as c,
|
|
246
|
+
findStartScriptPackageJson as f,
|
|
247
|
+
getMessageFromError as g,
|
|
248
|
+
readBuffer as r,
|
|
249
|
+
writeBuffer as w
|
|
250
|
+
};
|