@gadgetinc/ggt 2.2.0 → 2.3.0

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.
Files changed (127) hide show
  1. package/README.md +26 -1
  2. package/dist/{add-TWLGKL2T.js → add-7MLI3TCY.js} +8 -8
  3. package/dist/add-7MLI3TCY.js.map +7 -0
  4. package/dist/agent-plugin-543K6WBH.js +11 -0
  5. package/dist/agent-plugin-543K6WBH.js.map +7 -0
  6. package/dist/chunk-2HJS3KFB.js +2 -0
  7. package/dist/{chunk-T6UHSWMT.js.map → chunk-2HJS3KFB.js.map} +2 -2
  8. package/dist/{chunk-3OM5WM7E.js → chunk-3WKH3DJL.js} +2 -2
  9. package/dist/chunk-577KP32Z.js +8 -0
  10. package/dist/chunk-577KP32Z.js.map +7 -0
  11. package/dist/{chunk-R6KJLEKY.js → chunk-6FVHOLT7.js} +2 -2
  12. package/dist/chunk-6FVHOLT7.js.map +7 -0
  13. package/dist/{chunk-HCULGPBH.js → chunk-72J7X5LR.js} +2 -2
  14. package/dist/{chunk-HCULGPBH.js.map → chunk-72J7X5LR.js.map} +2 -2
  15. package/dist/{chunk-JG2QCDK2.js → chunk-ALSXPCRD.js} +5 -5
  16. package/dist/{chunk-JG2QCDK2.js.map → chunk-ALSXPCRD.js.map} +4 -4
  17. package/dist/{chunk-SIR6HLN3.js → chunk-CNNOPE5K.js} +22 -22
  18. package/dist/chunk-CNNOPE5K.js.map +7 -0
  19. package/dist/chunk-ETKWDO4V.js +2 -0
  20. package/dist/chunk-ETKWDO4V.js.map +7 -0
  21. package/dist/{chunk-DR4CXBD6.js → chunk-F6BGQ4LG.js} +2 -2
  22. package/dist/{chunk-DR4CXBD6.js.map → chunk-F6BGQ4LG.js.map} +2 -2
  23. package/dist/{chunk-SVWK2NXG.js → chunk-FE5O5VX4.js} +2 -2
  24. package/dist/chunk-FE5O5VX4.js.map +7 -0
  25. package/dist/{chunk-F255O64V.js → chunk-GZTHIOXS.js} +2 -2
  26. package/dist/chunk-GZTHIOXS.js.map +7 -0
  27. package/dist/chunk-IQSZEOYY.js +283 -0
  28. package/dist/{chunk-442CSROP.js.map → chunk-IQSZEOYY.js.map} +4 -4
  29. package/dist/chunk-N5FFICAP.js +9 -0
  30. package/dist/chunk-N5FFICAP.js.map +7 -0
  31. package/dist/chunk-TGCJ6TMW.js +10 -0
  32. package/dist/chunk-TGCJ6TMW.js.map +7 -0
  33. package/dist/{chunk-XC4F2TLW.js → chunk-ULJYEUQG.js} +19 -19
  34. package/dist/chunk-ULJYEUQG.js.map +7 -0
  35. package/dist/{chunk-2742UPMB.js → chunk-UVVKKUYG.js} +2 -2
  36. package/dist/chunk-UVVKKUYG.js.map +7 -0
  37. package/dist/{chunk-WB6O2V5D.js → chunk-WZ2PO6H2.js} +2 -2
  38. package/dist/{chunk-OUIZQC4D.js → chunk-X4XSYLCE.js} +2 -2
  39. package/dist/{chunk-OUIZQC4D.js.map → chunk-X4XSYLCE.js.map} +2 -2
  40. package/dist/{configure-UJS7V2JX.js → configure-PYRXYNGZ.js} +2 -2
  41. package/dist/configure-PYRXYNGZ.js.map +7 -0
  42. package/dist/{debugger-QN2MCLBL.js → debugger-VKLUEWIN.js} +2 -2
  43. package/dist/debugger-VKLUEWIN.js.map +7 -0
  44. package/dist/{deploy-J74PHPQA.js → deploy-JCREEGBA.js} +3 -3
  45. package/dist/deploy-JCREEGBA.js.map +7 -0
  46. package/dist/{dev-GGUSOOYP.js → dev-Y2GLI7EH.js} +3 -3
  47. package/dist/{dev-GGUSOOYP.js.map → dev-Y2GLI7EH.js.map} +3 -3
  48. package/dist/env-5OPHX3MC.js +135 -0
  49. package/dist/env-5OPHX3MC.js.map +7 -0
  50. package/dist/esm-3JVXH7DT.js +37 -0
  51. package/dist/esm-3JVXH7DT.js.map +7 -0
  52. package/dist/{eval-L6WHUFLU.js → eval-LZPZ6PBQ.js} +3 -3
  53. package/dist/{eval-L6WHUFLU.js.map → eval-LZPZ6PBQ.js.map} +2 -2
  54. package/dist/ggt-KUAF6WUA.js +45 -0
  55. package/dist/ggt-KUAF6WUA.js.map +7 -0
  56. package/dist/{list-756D46N5.js → list-IANT7SNF.js} +2 -2
  57. package/dist/list-IANT7SNF.js.map +7 -0
  58. package/dist/login-TYRZLN5S.js +2 -0
  59. package/dist/{logout-LQABTJFD.js → logout-P75XYYZ6.js} +2 -2
  60. package/dist/logout-P75XYYZ6.js.map +7 -0
  61. package/dist/{logs-AQZB272X.js → logs-SBMD6JSR.js} +2 -2
  62. package/dist/logs-SBMD6JSR.js.map +7 -0
  63. package/dist/main.js +1 -1
  64. package/dist/{open-OMZWPQ66.js → open-JPAMII4K.js} +2 -2
  65. package/dist/open-JPAMII4K.js.map +7 -0
  66. package/dist/problems-EZRSHLZT.js +14 -0
  67. package/dist/problems-EZRSHLZT.js.map +7 -0
  68. package/dist/{pull-XYCYN7QN.js → pull-R3PMBVOT.js} +2 -2
  69. package/dist/pull-R3PMBVOT.js.map +7 -0
  70. package/dist/push-5XEEESQQ.js +2 -0
  71. package/dist/{status-PWAXNK5G.js → status-RJN5ES6S.js} +2 -2
  72. package/dist/status-RJN5ES6S.js.map +7 -0
  73. package/dist/update-X7YS3MNH.js +2 -0
  74. package/dist/{var-N4WGGJXZ.js → var-PC6KQUPF.js} +4 -4
  75. package/dist/var-PC6KQUPF.js.map +7 -0
  76. package/dist/{version-AJKSJJDC.js → version-GZJOU2CV.js} +2 -2
  77. package/dist/version-GZJOU2CV.js.map +7 -0
  78. package/dist/{whoami-KJYDSQSD.js → whoami-GKPGPZ3B.js} +2 -2
  79. package/dist/whoami-GKPGPZ3B.js.map +7 -0
  80. package/package.json +6 -6
  81. package/dist/add-TWLGKL2T.js.map +0 -7
  82. package/dist/agent-plugin-TN24O7FB.js +0 -10
  83. package/dist/agent-plugin-TN24O7FB.js.map +0 -7
  84. package/dist/chunk-2742UPMB.js.map +0 -7
  85. package/dist/chunk-442CSROP.js +0 -66
  86. package/dist/chunk-F255O64V.js.map +0 -7
  87. package/dist/chunk-JKZNSRLU.js +0 -8
  88. package/dist/chunk-JKZNSRLU.js.map +0 -7
  89. package/dist/chunk-JYE5LLIF.js +0 -9
  90. package/dist/chunk-JYE5LLIF.js.map +0 -7
  91. package/dist/chunk-MW6MXMSN.js +0 -2
  92. package/dist/chunk-MW6MXMSN.js.map +0 -7
  93. package/dist/chunk-R6KJLEKY.js.map +0 -7
  94. package/dist/chunk-SIR6HLN3.js.map +0 -7
  95. package/dist/chunk-SVWK2NXG.js.map +0 -7
  96. package/dist/chunk-T6UHSWMT.js +0 -2
  97. package/dist/chunk-XC4F2TLW.js.map +0 -7
  98. package/dist/chunk-YFUOXDPK.js +0 -10
  99. package/dist/chunk-YFUOXDPK.js.map +0 -7
  100. package/dist/chunk-ZSREFZXV.js +0 -211
  101. package/dist/chunk-ZSREFZXV.js.map +0 -7
  102. package/dist/configure-UJS7V2JX.js.map +0 -7
  103. package/dist/debugger-QN2MCLBL.js.map +0 -7
  104. package/dist/deploy-J74PHPQA.js.map +0 -7
  105. package/dist/esm-D77XRR65.js +0 -38
  106. package/dist/esm-D77XRR65.js.map +0 -7
  107. package/dist/ggt-5XNRJZSW.js +0 -44
  108. package/dist/ggt-5XNRJZSW.js.map +0 -7
  109. package/dist/list-756D46N5.js.map +0 -7
  110. package/dist/login-GMWQRH7V.js +0 -2
  111. package/dist/logout-LQABTJFD.js.map +0 -7
  112. package/dist/logs-AQZB272X.js.map +0 -7
  113. package/dist/open-OMZWPQ66.js.map +0 -7
  114. package/dist/problems-FZJKH52E.js +0 -14
  115. package/dist/problems-FZJKH52E.js.map +0 -7
  116. package/dist/pull-XYCYN7QN.js.map +0 -7
  117. package/dist/push-3QM7ZFTC.js +0 -2
  118. package/dist/status-PWAXNK5G.js.map +0 -7
  119. package/dist/update-QIQFJFRQ.js +0 -2
  120. package/dist/var-N4WGGJXZ.js.map +0 -7
  121. package/dist/version-AJKSJJDC.js.map +0 -7
  122. package/dist/whoami-KJYDSQSD.js.map +0 -7
  123. /package/dist/{chunk-3OM5WM7E.js.map → chunk-3WKH3DJL.js.map} +0 -0
  124. /package/dist/{chunk-WB6O2V5D.js.map → chunk-WZ2PO6H2.js.map} +0 -0
  125. /package/dist/{login-GMWQRH7V.js.map → login-TYRZLN5S.js.map} +0 -0
  126. /package/dist/{push-3QM7ZFTC.js.map → push-5XEEESQQ.js.map} +0 -0
  127. /package/dist/{update-QIQFJFRQ.js.map → update-X7YS3MNH.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{e as l,f}from"./chunk-442CSROP.js";import{K as w,e as i,ra as g}from"./chunk-JG2QCDK2.js";import{a as r,f as m,h as u}from"./chunk-7DYQUG5M.js";u();var o=m(w(),1);var h=i.object({pid:i.number(),startedAt:i.string()}),a=class extends f{constructor(n){super(`Another ggt dev process is already running (PID ${n.pid})`);this.details=n}static{r(this,"DevAlreadyRunningError")}isBug=l.NO;render(){return g`
1
+ import{f as l,g as f}from"./chunk-IQSZEOYY.js";import{K as w,e as i,ra as g}from"./chunk-ALSXPCRD.js";import{a as r,f as m,h as u}from"./chunk-7DYQUG5M.js";u();var o=m(w(),1);var h=i.object({pid:i.number(),startedAt:i.string()}),a=class extends f{constructor(n){super(`Another ggt dev process is already running (PID ${n.pid})`);this.details=n}static{r(this,"DevAlreadyRunningError")}isBug=l.NO;render(){return g`
2
2
  Another "ggt dev" process is already running in this directory:
3
3
 
4
4
  ${this.details.directory}
@@ -7,4 +7,4 @@ import{e as l,f}from"./chunk-442CSROP.js";import{K as w,e as i,ra as g}from"./ch
7
7
 
8
8
  Stop the other process first, or use a different directory.
9
9
  `}},c=r(t=>t.absolute(".gadget/dev-lock.json"),"devLockPath"),D=r(t=>{try{return process.kill(t,0),!0}catch{return!1}},"isProcessAlive"),y=r(async t=>{try{let e=await o.default.readJSON(c(t)),n=h.safeParse(e);return n.success?n.data:void 0}catch{return}},"readDevLock"),L=r(async t=>{let e=c(t),n={pid:process.pid,startedAt:new Date().toISOString()},d=JSON.stringify(n,null,2);await o.default.ensureDir(t.absolute(".gadget"));try{await o.default.writeFile(e,d,{flag:"wx"})}catch(p){if(p.code!=="EEXIST")throw p;let s=await y(t);if(s&&D(s.pid))throw new a({pid:s.pid,directory:t.path});await o.default.remove(e),await o.default.writeFile(e,d,{flag:"wx"})}},"acquireDevLock"),v=r(async t=>{try{await o.default.remove(c(t))}catch{}},"releaseDevLock"),S=r(async t=>{let e=await y(t);return e?D(e.pid)?{running:!0,pid:e.pid,startedAt:e.startedAt}:(await v(t),{running:!1}):{running:!1}},"getDevStatus");export{L as a,v as b,S as c};
10
- //# sourceMappingURL=chunk-2742UPMB.js.map
10
+ //# sourceMappingURL=chunk-UVVKKUYG.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/services/filesync/dev-lock.ts"],
4
+ "sourcesContent": ["import fs from \"fs-extra\";\nimport { z } from \"zod\";\n\nimport { GGTError, IsBug } from \"../output/report.js\";\nimport { sprint } from \"../output/sprint.js\";\nimport type { Directory } from \"./directory.js\";\n\n/**\n * The data stored in the dev lock file.\n */\nexport const DevLockData = z.object({\n pid: z.number(),\n startedAt: z.string(),\n});\n\nexport type DevLockData = z.infer<typeof DevLockData>;\n\n/**\n * Error thrown when another `ggt dev` process is already running in the same directory.\n */\nexport class DevAlreadyRunningError extends GGTError {\n isBug = IsBug.NO;\n\n constructor(readonly details: { pid: number; directory: string }) {\n super(`Another ggt dev process is already running (PID ${details.pid})`);\n }\n\n protected render(): string {\n return sprint`\n Another \"ggt dev\" process is already running in this directory:\n\n ${this.details.directory}\n\n The existing process has PID ${String(this.details.pid)}.\n\n Stop the other process first, or use a different directory.\n `;\n }\n}\n\n/**\n * Returns the path to the dev lock file for the given directory.\n */\nexport const devLockPath = (directory: Directory): string => {\n return directory.absolute(\".gadget/dev-lock.json\");\n};\n\n/**\n * Checks whether a process with the given PID is alive.\n */\nexport const isProcessAlive = (pid: number): boolean => {\n try {\n process.kill(pid, 0);\n return true;\n } catch {\n return false;\n }\n};\n\n/**\n * Reads and parses the dev lock file. Returns undefined if missing or malformed.\n */\nexport const readDevLock = async (directory: Directory): Promise<DevLockData | undefined> => {\n try {\n const data: unknown = await fs.readJSON(devLockPath(directory));\n const result = DevLockData.safeParse(data);\n return result.success ? result.data : undefined;\n } catch {\n return undefined;\n }\n};\n\n/**\n * Atomically acquires the dev lock for the given directory.\n *\n * Uses `wx` flag for exclusive creation to prevent race conditions.\n * If a stale lock (dead PID) is found, it is removed and re-acquired.\n *\n * @throws {DevAlreadyRunningError} if another live process holds the lock.\n */\nexport const acquireDevLock = async (directory: Directory): Promise<void> => {\n const lockPath = devLockPath(directory);\n const lockData: DevLockData = {\n pid: process.pid,\n startedAt: new Date().toISOString(),\n };\n const content = JSON.stringify(lockData, null, 2);\n\n await fs.ensureDir(directory.absolute(\".gadget\"));\n\n try {\n await fs.writeFile(lockPath, content, { flag: \"wx\" });\n } catch (error: unknown) {\n if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") {\n throw error;\n }\n\n // Lock file already exists - check if the holding process is still alive\n const existing = await readDevLock(directory);\n if (existing && isProcessAlive(existing.pid)) {\n throw new DevAlreadyRunningError({ pid: existing.pid, directory: directory.path });\n }\n\n // Stale or malformed lock - remove and retry\n await fs.remove(lockPath);\n await fs.writeFile(lockPath, content, { flag: \"wx\" });\n }\n};\n\n/**\n * Releases the dev lock for the given directory. Ignores errors.\n */\nexport const releaseDevLock = async (directory: Directory): Promise<void> => {\n try {\n await fs.remove(devLockPath(directory));\n } catch {\n // ignore errors during cleanup\n }\n};\n\n/**\n * Returns the current dev status for the given directory.\n * Cleans up stale locks as a side effect.\n */\nexport const getDevStatus = async (\n directory: Directory,\n): Promise<{ running: false } | { running: true; pid: number; startedAt: string }> => {\n const lock = await readDevLock(directory);\n if (!lock) {\n return { running: false };\n }\n\n if (!isProcessAlive(lock.pid)) {\n // Stale lock - clean it up\n await releaseDevLock(directory);\n return { running: false };\n }\n\n return { running: true, pid: lock.pid, startedAt: lock.start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AC5C,MAAMA,EAIR,IAAMC,EAAW,MAAMT,EAAYH,CAAS,EAC5C,GAAIY,GAAYX,EAAeW,EAAS,GAAG,EACzC,MAAM,IAAInB,EAAuB,CAAE,IAAKmB,EAAS,IAAK,UAAWZ,EAAU,IAAK,CAAC,EAInF,MAAM,EAAAK,QAAG,OAAOG,CAAQ,EACxB,MAAM,EAAAH,QAAG,UAAUG,EAAUE,EAAS,CAAE,KAAM,IAAK,CAAC,CACtD,CACF,EA3B8B,kBAgCjBG,EAAiBjB,EAAA,MAAOI,GAAwC,CAC3E,GAAI,CACF,MAAM,EAAAK,QAAG,OAAON,EAAYC,CAAS,CAAC,CACxC,MAAQ,CAER,CACF,EAN8B,kBAYjBc,EAAelB,EAAA,MAC1BI,GACoF,CACpF,IAAMe,EAAO,MAAMZ,EAAYH,CAAS,EACxC,OAAKe,EAIAd,EAAec,EAAK,GAAG,EAMrB,CAAE,QAAS,GAAM,IAAKA,EAAK,IAAK,UAAWA,EAAK,SAAU,GAJ/D,MAAMF,EAAeb,CAAS,EACvB,CAAE,QAAS,EAAM,GANjB,CAAE,QAAS,EAAM,CAU5B,EAf4B",
6
+ "names": ["init_cjs", "import_fs_extra", "DevLockData", "external_exports", "DevAlreadyRunningError", "GGTError", "details", "__name", "IsBug", "sprint", "devLockPath", "directory", "isProcessAlive", "pid", "readDevLock", "data", "fs", "result", "acquireDevLock", "lockPath", "lockData", "content", "error", "existing", "releaseDevLock", "getDevStatus", "lock"]
7
+ }
@@ -1,4 +1,4 @@
1
- import{na as Xt,pa as tt,qa as Zt,sa as k,ta as et}from"./chunk-JG2QCDK2.js";import{a as s,b as X,d as v,f as Z,h as g}from"./chunk-7DYQUG5M.js";var $=v((qe,rt)=>{g();var D=[],it=0,C=s((i,t)=>{it>=t&&D.push(i)},"debug");C.WARN=1;C.INFO=2;C.DEBUG=3;C.reset=()=>{D=[]};C.setDebugLevel=i=>{it=i};C.warn=i=>C(i,C.WARN);C.info=i=>C(i,C.INFO);C.debug=i=>C(i,C.DEBUG);C.debugMessages=()=>D;rt.exports=C});var Y=v((Pe,lt)=>{g();var nt=Xt();function z(i){return i?/\u001b\[((?:\d*;){0,5}\d*)m/g:/\u001b\[(?:\d*;){0,5}\d*m/g}s(z,"codeRegex");function W(i){let t=z();return(""+i).replace(t,"").split(`
1
+ import{na as Xt,pa as tt,qa as Zt,sa as k,ta as et}from"./chunk-ALSXPCRD.js";import{a as s,b as X,d as v,f as Z,h as g}from"./chunk-7DYQUG5M.js";var $=v((qe,rt)=>{g();var D=[],it=0,C=s((i,t)=>{it>=t&&D.push(i)},"debug");C.WARN=1;C.INFO=2;C.DEBUG=3;C.reset=()=>{D=[]};C.setDebugLevel=i=>{it=i};C.warn=i=>C(i,C.WARN);C.info=i=>C(i,C.INFO);C.debug=i=>C(i,C.DEBUG);C.debugMessages=()=>D;rt.exports=C});var Y=v((Pe,lt)=>{g();var nt=Xt();function z(i){return i?/\u001b\[((?:\d*;){0,5}\d*)m/g:/\u001b\[(?:\d*;){0,5}\d*m/g}s(z,"codeRegex");function W(i){let t=z();return(""+i).replace(t,"").split(`
2
2
  `).reduce(function(n,o){return nt(o)>n?nt(o):n},0)}s(W,"strlen");function _(i,t){return Array(t+1).join(i)}s(_,"repeat");function te(i,t,e,r){let n=W(i);if(t+1>=n){let o=t-n;switch(r){case"right":{i=_(e,o)+i;break}case"center":{let l=Math.ceil(o/2),d=o-l;i=_(e,d)+i+_(e,l);break}default:{i=i+_(e,o);break}}}return i}s(te,"pad");var B={};function I(i,t,e){t="\x1B["+t+"m",e="\x1B["+e+"m",B[t]={set:i,to:!0},B[e]={set:i,to:!1},B[i]={on:t,off:e}}s(I,"addToCodeCache");I("bold",1,22);I("italics",3,23);I("underline",4,24);I("inverse",7,27);I("strikethrough",9,29);function ot(i,t){let e=t[1]?parseInt(t[1].split(";")[0]):0;if(e>=30&&e<=39||e>=90&&e<=97){i.lastForegroundAdded=t[0];return}if(e>=40&&e<=49||e>=100&&e<=107){i.lastBackgroundAdded=t[0];return}if(e===0){for(let n in i)Object.prototype.hasOwnProperty.call(i,n)&&delete i[n];return}let r=B[t[0]];r&&(i[r.set]=r.to)}s(ot,"updateState");function ee(i){let t=z(!0),e=t.exec(i),r={};for(;e!==null;)ot(r,e),e=t.exec(i);return r}s(ee,"readState");function st(i,t){let e=i.lastBackgroundAdded,r=i.lastForegroundAdded;return delete i.lastBackgroundAdded,delete i.lastForegroundAdded,Object.keys(i).forEach(function(n){i[n]&&(t+=B[n].off)}),e&&e!="\x1B[49m"&&(t+="\x1B[49m"),r&&r!="\x1B[39m"&&(t+="\x1B[39m"),t}s(st,"unwindState");function ie(i,t){let e=i.lastBackgroundAdded,r=i.lastForegroundAdded;return delete i.lastBackgroundAdded,delete i.lastForegroundAdded,Object.keys(i).forEach(function(n){i[n]&&(t=B[n].on+t)}),e&&e!="\x1B[49m"&&(t=e+t),r&&r!="\x1B[39m"&&(t=r+t),t}s(ie,"rewindState");function re(i,t){if(i.length===W(i))return i.substr(0,t);for(;W(i)>t;)i=i.slice(0,-1);return i}s(re,"truncateWidth");function ne(i,t){let e=z(!0),r=i.split(z()),n=0,o=0,l="",d,m={};for(;o<t;){d=e.exec(i);let h=r[n];if(n++,o+W(h)>t&&(h=re(h,t-o)),l+=h,o+=W(h),o<t){if(!d)break;l+=d[0],ot(m,d)}}return st(m,l)}s(ne,"truncateWidthWithAnsi");function oe(i,t,e){if(e=e||"\u2026",W(i)<=t)return i;t-=W(e);let n=ne(i,t);n+=e;let o="\x1B]8;;\x07";return i.includes(o)&&!n.includes(o)&&(n+=o),n}s(oe,"truncate");function se(){return{chars:{top:"\u2500","top-mid":"\u252C","top-left":"\u250C","top-right":"\u2510",bottom:"\u2500","bottom-mid":"\u2534","bottom-left":"\u2514","bottom-right":"\u2518",left:"\u2502","left-mid":"\u251C",mid:"\u2500","mid-mid":"\u253C",right:"\u2502","right-mid":"\u2524",middle:"\u2502"},truncate:"\u2026",colWidths:[],rowHeights:[],colAligns:[],rowAligns:[],style:{"padding-left":1,"padding-right":1,head:["red"],border:["grey"],compact:!1},head:[]}}s(se,"defaultOptions");function le(i,t){i=i||{},t=t||se();let e=Object.assign({},t,i);return e.chars=Object.assign({},t.chars,i.chars),e.style=Object.assign({},t.style,i.style),e}s(le,"mergeOptions");function ue(i,t){let e=[],r=t.split(/(\s+)/g),n=[],o=0,l;for(let d=0;d<r.length;d+=2){let m=r[d],h=o+W(m);o>0&&l&&(h+=l.length),h>i?(o!==0&&e.push(n.join("")),n=[m],o=W(m)):(n.push(l||"",m),o=h),l=r[d+1]}return o&&e.push(n.join("")),e}s(ue,"wordWrap");function ae(i,t){let e=[],r="";function n(l,d){for(r.length&&d&&(r+=d),r+=l;r.length>i;)e.push(r.slice(0,i)),r=r.slice(i)}s(n,"pushLine");let o=t.split(/(\s+)/g);for(let l=0;l<o.length;l+=2)n(o[l],l&&o[l-1]);return r.length&&e.push(r),e}s(ae,"textWrap");function he(i,t,e=!0){let r=[];t=t.split(`
3
3
  `);let n=e?ue:ae;for(let o=0;o<t.length;o++)r.push.apply(r,n(i,t[o]));return r}s(he,"multiLineWordWrap");function ce(i){let t={},e=[];for(let r=0;r<i.length;r++){let n=ie(t,i[r]);t=ee(n);let o=Object.assign({},t);e.push(st(o,n))}return e}s(ce,"colorizeLines");function fe(i,t){return["\x1B]","8",";",";",i||t,"\x07",t,"\x1B]","8",";",";","\x07"].join("")}s(fe,"hyperlink");lt.exports={strlen:W,repeat:_,pad:te,truncate:oe,mergeOptions:le,wordWrap:he,colorizeLines:ce,hyperlink:fe}});var ct=v((ze,ht)=>{g();var at={};ht.exports=at;var ut={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgGray:[100,49],bgGrey:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(ut).forEach(function(i){var t=ut[i],e=at[i]=[];e.open="\x1B["+t[0]+"m",e.close="\x1B["+t[1]+"m"})});var dt=v((He,ft)=>{"use strict";g();ft.exports=function(i,t){t=t||process.argv;var e=t.indexOf("--"),r=/^-{1,2}/.test(i)?"":"--",n=t.indexOf(r+i);return n!==-1&&(e===-1?!0:n<e)}});var gt=v((Ye,pt)=>{"use strict";g();var de=X("os"),M=dt(),E=process.env,j=void 0;M("no-color")||M("no-colors")||M("color=false")?j=!1:(M("color")||M("colors")||M("color=true")||M("color=always"))&&(j=!0);"FORCE_COLOR"in E&&(j=E.FORCE_COLOR.length===0||parseInt(E.FORCE_COLOR,10)!==0);function pe(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}s(pe,"translateLevel");function ge(i){if(j===!1)return 0;if(M("color=16m")||M("color=full")||M("color=truecolor"))return 3;if(M("color=256"))return 2;if(i&&!i.isTTY&&j!==!0)return 0;var t=j?1:0;if(process.platform==="win32"){var e=de.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in E)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(function(n){return n in E})||E.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in E)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(E.TEAMCITY_VERSION)?1:0;if("TERM_PROGRAM"in E){var r=parseInt((E.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(E.TERM_PROGRAM){case"iTerm.app":return r>=3?3:2;case"Hyper":return 3;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(E.TERM)?2:/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(E.TERM)||"COLORTERM"in E?1:(E.TERM==="dumb",t)}s(ge,"supportsColor");function N(i){var t=ge(i);return pe(t)}s(N,"getSupportLevel");pt.exports={supportsColor:N,stdout:N(process.stdout),stderr:N(process.stderr)}});var mt=v((Ue,bt)=>{g();bt.exports=s(function(t,e){var r="";t=t||"Run the trap, drop the bass",t=t.split("");var n={a:["@","\u0104","\u023A","\u0245","\u0394","\u039B","\u0414"],b:["\xDF","\u0181","\u0243","\u026E","\u03B2","\u0E3F"],c:["\xA9","\u023B","\u03FE"],d:["\xD0","\u018A","\u0500","\u0501","\u0502","\u0503"],e:["\xCB","\u0115","\u018E","\u0258","\u03A3","\u03BE","\u04BC","\u0A6C"],f:["\u04FA"],g:["\u0262"],h:["\u0126","\u0195","\u04A2","\u04BA","\u04C7","\u050A"],i:["\u0F0F"],j:["\u0134"],k:["\u0138","\u04A0","\u04C3","\u051E"],l:["\u0139"],m:["\u028D","\u04CD","\u04CE","\u0520","\u0521","\u0D69"],n:["\xD1","\u014B","\u019D","\u0376","\u03A0","\u048A"],o:["\xD8","\xF5","\xF8","\u01FE","\u0298","\u047A","\u05DD","\u06DD","\u0E4F"],p:["\u01F7","\u048E"],q:["\u09CD"],r:["\xAE","\u01A6","\u0210","\u024C","\u0280","\u042F"],s:["\xA7","\u03DE","\u03DF","\u03E8"],t:["\u0141","\u0166","\u0373"],u:["\u01B1","\u054D"],v:["\u05D8"],w:["\u0428","\u0460","\u047C","\u0D70"],x:["\u04B2","\u04FE","\u04FC","\u04FD"],y:["\xA5","\u04B0","\u04CB"],z:["\u01B5","\u0240"]};return t.forEach(function(o){o=o.toLowerCase();var l=n[o]||[" "],d=Math.floor(Math.random()*l.length);typeof n[o]<"u"?r+=n[o][d]:r+=o}),r},"runTheTrap")});var wt=v((Qe,yt)=>{g();yt.exports=s(function(t,e){t=t||" he is here ";var r={up:["\u030D","\u030E","\u0304","\u0305","\u033F","\u0311","\u0306","\u0310","\u0352","\u0357","\u0351","\u0307","\u0308","\u030A","\u0342","\u0313","\u0308","\u034A","\u034B","\u034C","\u0303","\u0302","\u030C","\u0350","\u0300","\u0301","\u030B","\u030F","\u0312","\u0313","\u0314","\u033D","\u0309","\u0363","\u0364","\u0365","\u0366","\u0367","\u0368","\u0369","\u036A","\u036B","\u036C","\u036D","\u036E","\u036F","\u033E","\u035B","\u0346","\u031A"],down:["\u0316","\u0317","\u0318","\u0319","\u031C","\u031D","\u031E","\u031F","\u0320","\u0324","\u0325","\u0326","\u0329","\u032A","\u032B","\u032C","\u032D","\u032E","\u032F","\u0330","\u0331","\u0332","\u0333","\u0339","\u033A","\u033B","\u033C","\u0345","\u0347","\u0348","\u0349","\u034D","\u034E","\u0353","\u0354","\u0355","\u0356","\u0359","\u035A","\u0323"],mid:["\u0315","\u031B","\u0300","\u0301","\u0358","\u0321","\u0322","\u0327","\u0328","\u0334","\u0335","\u0336","\u035C","\u035D","\u035E","\u035F","\u0360","\u0362","\u0338","\u0337","\u0361"," \u0489"]},n=[].concat(r.up,r.down,r.mid);function o(m){var h=Math.floor(Math.random()*m);return h}s(o,"randomNumber");function l(m){var h=!1;return n.filter(function(w){h=w===m}),h}s(l,"isChar");function d(m,h){var w="",S,y;h=h||{},h.up=typeof h.up<"u"?h.up:!0,h.mid=typeof h.mid<"u"?h.mid:!0,h.down=typeof h.down<"u"?h.down:!0,h.size=typeof h.size<"u"?h.size:"maxi",m=m.split("");for(y in m)if(!l(y)){switch(w=w+m[y],S={up:0,down:0,mid:0},h.size){case"mini":S.up=o(8),S.mid=o(2),S.down=o(8);break;case"maxi":S.up=o(16)+3,S.mid=o(4)+1,S.down=o(64)+3;break;default:S.up=o(8)+1,S.mid=o(6)/2,S.down=o(8)+1;break}var a=["up","mid","down"];for(var u in a)for(var c=a[u],p=0;p<=S[c];p++)h[c]&&(w=w+r[c][o(r[c].length)])}return w}return s(d,"heComes"),d(t,e)},"zalgo")});var St=v((ti,xt)=>{g();xt.exports=function(i){return function(t,e,r){if(t===" ")return t;switch(e%3){case 0:return i.red(t);case 1:return i.white(t);case 2:return i.blue(t)}}}});var Ct=v((ii,vt)=>{g();vt.exports=function(i){return function(t,e,r){return e%2===0?t:i.inverse(t)}}});var Et=v((ni,Ot)=>{g();Ot.exports=function(i){var t=["red","yellow","green","blue","magenta"];return function(e,r,n){return e===" "?e:i[t[r++%t.length]](e)}}});var At=v((si,Rt)=>{g();Rt.exports=function(i){var t=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta","brightYellow","brightRed","brightGreen","brightBlue","brightWhite","brightCyan","brightMagenta"];return function(e,r,n){return e===" "?e:i[t[Math.round(Math.random()*(t.length-2))]](e)}}});var Bt=v((ai,kt)=>{g();var f={};kt.exports=f;f.themes={};var be=X("util"),T=f.styles=ct(),Wt=Object.defineProperties,me=new RegExp(/[\r\n]+/g);f.supportsColor=gt().supportsColor;typeof f.enabled>"u"&&(f.enabled=f.supportsColor()!==!1);f.enable=function(){f.enabled=!0};f.disable=function(){f.enabled=!1};f.stripColors=f.strip=function(i){return(""+i).replace(/\x1B\[\d+m/g,"")};var ui=f.stylize=s(function(t,e){if(!f.enabled)return t+"";var r=T[e];return!r&&e in f?f[e](t):r.open+t+r.close},"stylize"),ye=/[|\\{}()[\]^$+*?.]/g,we=s(function(i){if(typeof i!="string")throw new TypeError("Expected a string");return i.replace(ye,"\\$&")},"escapeStringRegexp");function Lt(i){var t=s(function e(){return Se.apply(e,arguments)},"builder");return t._styles=i,t.__proto__=xe,t}s(Lt,"build");var Tt=(function(){var i={};return T.grey=T.gray,Object.keys(T).forEach(function(t){T[t].closeRe=new RegExp(we(T[t].close),"g"),i[t]={get:s(function(){return Lt(this._styles.concat(t))},"get")}}),i})(),xe=Wt(s(function(){},"colors"),Tt);function Se(){var i=Array.prototype.slice.call(arguments),t=i.map(function(l){return l!=null&&l.constructor===String?l:be.inspect(l)}).join(" ");if(!f.enabled||!t)return t;for(var e=t.indexOf(`
4
4
  `)!=-1,r=this._styles,n=r.length;n--;){var o=T[r[n]];t=o.open+t.replace(o.closeRe,o.open)+o.close,e&&(t=t.replace(me,function(l){return o.close+l+o.open}))}return t}s(Se,"applyStyle");f.setTheme=function(i){if(typeof i=="string"){console.log("colors.setTheme now only accepts an object, not a string. If you are trying to set a theme from a file, it is now your (the caller's) responsibility to require the file. The old syntax looked like colors.setTheme(__dirname + '/../themes/generic-logging.js'); The new syntax looks like colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));");return}for(var t in i)(function(e){f[e]=function(r){if(typeof i[e]=="object"){var n=r;for(var o in i[e])n=f[i[e][o]](n);return n}return f[i[e]](r)}})(t)};function ve(){var i={};return Object.keys(Tt).forEach(function(t){i[t]={get:s(function(){return Lt([t])},"get")}}),i}s(ve,"init");var Ce=s(function(t,e){var r=e.split("");return r=r.map(t),r.join("")},"sequencer");f.trap=mt();f.zalgo=wt();f.maps={};f.maps.america=St()(f);f.maps.zebra=Ct()(f);f.maps.rainbow=Et()(f);f.maps.random=At()(f);for(Mt in f.maps)(function(i){f[i]=function(t){return Ce(f.maps[i],t)}})(Mt);var Mt;Wt(f,ve())});var qt=v((fi,jt)=>{g();var Oe=Bt();jt.exports=Oe});var Gt=v((pi,F)=>{g();var{info:Ee,debug:Pt}=$(),A=Y(),U=class i{static{s(this,"Cell")}constructor(t){this.setOptions(t),this.x=null,this.y=null}setOptions(t){["boolean","number","bigint","string"].indexOf(typeof t)!==-1&&(t={content:""+t}),t=t||{},this.options=t;let e=t.content;if(["boolean","number","bigint","string"].indexOf(typeof e)!==-1)this.content=String(e);else if(!e)this.content=this.options.href||"";else throw new Error("Content needs to be a primitive, got: "+typeof e);this.colSpan=t.colSpan||1,this.rowSpan=t.rowSpan||1,this.options.href&&Object.defineProperty(this,"href",{get(){return this.options.href}})}mergeTableOptions(t,e){this.cells=e;let r=this.options.chars||{},n=t.chars,o=this.chars={};Ae.forEach(function(m){V(r,n,m,o)}),this.truncate=this.options.truncate||t.truncate;let l=this.options.style=this.options.style||{},d=t.style;V(l,d,"padding-left",this),V(l,d,"padding-right",this),this.head=l.head||d.head,this.border=l.border||d.border,this.fixedWidth=t.colWidths[this.x],this.lines=this.computeLines(t),this.desiredWidth=A.strlen(this.content)+this.paddingLeft+this.paddingRight,this.desiredHeight=this.lines.length}computeLines(t){let e=t.wordWrap||t.textWrap,{wordWrap:r=e}=this.options;if(this.fixedWidth&&r){if(this.fixedWidth-=this.paddingLeft+this.paddingRight,this.colSpan){let l=1;for(;l<this.colSpan;)this.fixedWidth+=t.colWidths[this.x+l],l++}let{wrapOnWordBoundary:n=!0}=t,{wrapOnWordBoundary:o=n}=this.options;return this.wrapLines(A.wordWrap(this.fixedWidth,this.content,o))}return this.wrapLines(this.content.split(`
@@ -8,4 +8,4 @@ import{na as Xt,pa as tt,qa as Zt,sa as k,ta as et}from"./chunk-JG2QCDK2.js";imp
8
8
  `;return l==="none"&&(y=(0,Ut.dedent)(y).slice(1)),y=y.split(`
9
9
  `).map(a=>a.trimEnd()).join(`
10
10
  `),h&&(y=tt(y,h)),i&&(y=k(i)+k({content:y,ensureEmptyLineAbove:n})),r&&(y=k(y)+k({content:r,ensureEmptyLineAbove:o})),k({content:y,...w})},"sprintTable"),Mi=s(i=>{et(Be(i))},"printTable"),je={none:{"top-left":"",top:"","top-mid":"","top-right":"","left-mid":"",mid:"","mid-mid":"","right-mid":"",left:"",middle:"",right:"","bottom-left":"",bottom:"","bottom-mid":"","bottom-right":""},thin:{"top-left":"\u250C",top:"\u2500","top-mid":"\u252C","top-right":"\u2510","left-mid":"\u251C",mid:"\u2500","mid-mid":"\u253C","right-mid":"\u2524",left:"\u2502",middle:"\u2502",right:"\u2502","bottom-left":"\u2514",bottom:"\u2500","bottom-mid":"\u2534","bottom-right":"\u2518"},thick:{"top-left":"\u2554",top:"\u2550","top-mid":"\u2564","top-right":"\u2557",left:"\u2551",middle:"\u2502",right:"\u2551","left-mid":"\u255F",mid:"\u2500","mid-mid":"\u253C","right-mid":"\u2562","bottom-left":"\u255A",bottom:"\u2550","bottom-mid":"\u2567","bottom-right":"\u255D"}};export{Be as a,Mi as b};
11
- //# sourceMappingURL=chunk-WB6O2V5D.js.map
11
+ //# sourceMappingURL=chunk-WZ2PO6H2.js.map
@@ -1,4 +1,4 @@
1
- import{K}from"./chunk-JG2QCDK2.js";import{a as n,d as b,f as x,h as f}from"./chunk-7DYQUG5M.js";var F=b((It,p)=>{f();function v(e){return Array.isArray(e)?e:[e]}n(v,"makeArray");var V=void 0,w="",L=" ",I="\\",M=/^\s+$/,Y=/(?:[^\\]|^)\\$/,U=/^\\!/,q=/^\\#/,J=/\r?\n/g,Q=/^\.{0,2}\/|^\.{1,2}$/,Z=/\/$/,h="/",G="node-ignore";typeof Symbol<"u"&&(G=Symbol.for("node-ignore"));var D=G,_=n((e,t,s)=>(Object.defineProperty(e,t,{value:s}),s),"define"),tt=/([0-z])-([0-z])/g,H=n(()=>!1,"RETURN_FALSE"),et=n(e=>e.replace(tt,(t,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?t:w),"sanitizeRange"),st=n(e=>{let{length:t}=e;return e.slice(0,t-t%2)},"cleanRangeBackSlash"),rt=[[/^\uFEFF/,()=>w],[/((?:\\\\)*?)(\\?\s+)$/,(e,t,s)=>t+(s.indexOf("\\")===0?L:w)],[/(\\+?)\s/g,(e,t)=>{let{length:s}=t;return t.slice(0,s-s%2)+L}],[/[\\$.|*+(){^]/g,e=>`\\${e}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,n(function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"},"startingReplacer")],[/\\\/\\\*\\\*(?=\\\/|$)/g,(e,t,s)=>t+6<s.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(e,t,s)=>{let r=s.replace(/\\\*/g,"[^\\/]*");return t+r}],[/\\\\\\(?=[$.|*+(){^])/g,()=>I],[/\\\\/g,()=>I],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(e,t,s,r,i)=>t===I?`\\[${s}${st(r)}${i}`:i==="]"&&r.length%2===0?`[${et(s)}${r}]`:"[]"],[/(?:[^*])$/,e=>/\/$/.test(e)?`${e}$`:`${e}(?=$|\\/$)`]],it=/(^|\\\/)?\\\*$/,E="regex",R="checkRegex",T="_",nt={[E](e,t){return`${t?`${t}[^/]+`:"[^/]*"}(?=$|\\/$)`},[R](e,t){return`${t?`${t}[^/]*`:"[^/]*"}(?=$|\\/$)`}},ot=n(e=>rt.reduce((t,[s,r])=>t.replace(s,r.bind(e)),e),"makeRegexPrefix"),y=n(e=>typeof e=="string","isString"),at=n(e=>e&&y(e)&&!M.test(e)&&!Y.test(e)&&e.indexOf("#")!==0,"checkPattern"),ct=n(e=>e.split(J).filter(Boolean),"splitPattern"),N=class{static{n(this,"IgnoreRule")}constructor(t,s,r,i,o,u){this.pattern=t,this.mark=s,this.negative=o,_(this,"body",r),_(this,"ignoreCase",i),_(this,"regexPrefix",u)}get regex(){let t=T+E;return this[t]?this[t]:this._make(E,t)}get checkRegex(){let t=T+R;return this[t]?this[t]:this._make(R,t)}_make(t,s){let r=this.regexPrefix.replace(it,nt[t]),i=this.ignoreCase?new RegExp(r,"i"):new RegExp(r);return _(this,s,i)}},ut=n(({pattern:e,mark:t},s)=>{let r=!1,i=e;i.indexOf("!")===0&&(r=!0,i=i.substr(1)),i=i.replace(U,"!").replace(q,"#");let o=ot(i);return new N(e,t,i,s,r,o)},"createRule"),P=class{static{n(this,"RuleManager")}constructor(t){this._ignoreCase=t,this._rules=[]}_add(t){if(t&&t[D]){this._rules=this._rules.concat(t._rules._rules),this._added=!0;return}if(y(t)&&(t={pattern:t}),at(t.pattern)){let s=ut(t,this._ignoreCase);this._added=!0,this._rules.push(s)}}add(t){return this._added=!1,v(y(t)?ct(t):t).forEach(this._add,this),this._added}test(t,s,r){let i=!1,o=!1,u;this._rules.forEach(l=>{let{negative:c}=l;o===c&&i!==o||c&&!i&&!o&&!s||!l[r].test(t)||(i=!c,o=c,u=c?V:l)});let g={ignored:i,unignored:o};return u&&(g.rule=u),g}},lt=n((e,t)=>{throw new t(e)},"throwError"),a=n((e,t,s)=>y(e)?e?a.isNotRelative(e)?s(`path should be a \`path.relative()\`d string, but got "${t}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${t}\``,TypeError),"checkPath"),O=n(e=>Q.test(e),"isNotRelative");a.isNotRelative=O;a.convert=e=>e;var $=class{static{n(this,"Ignore")}constructor({ignorecase:t=!0,ignoreCase:s=t,allowRelativePaths:r=!1}={}){_(this,D,!0),this._rules=new P(s),this._strictPathCheck=!r,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(t){return this._rules.add(t)&&this._initCache(),this}addPattern(t){return this.add(t)}_test(t,s,r,i){let o=t&&a.convert(t);return a(o,t,this._strictPathCheck?lt:H),this._t(o,s,r,i)}checkIgnore(t){if(!Z.test(t))return this.test(t);let s=t.split(h).filter(Boolean);if(s.pop(),s.length){let r=this._t(s.join(h)+h,this._testCache,!0,s);if(r.ignored)return r}return this._rules.test(t,!1,R)}_t(t,s,r,i){if(t in s)return s[t];if(i||(i=t.split(h).filter(Boolean)),i.pop(),!i.length)return s[t]=this._rules.test(t,r,E);let o=this._t(i.join(h)+h,s,r,i);return s[t]=o.ignored?o:this._rules.test(t,r,E)}ignores(t){return this._test(t,this._ignoreCache,!1).ignored}createFilter(){return t=>!this.ignores(t)}filter(t){return v(t).filter(this.createFilter())}test(t){return this._test(t,this._testCache,!0)}},C=n(e=>new $(e),"factory"),ft=n(e=>a(e&&a.convert(e),e,H),"isPathValid"),k=n(()=>{let e=n(s=>/^\\\\\?\\/.test(s)||/["<>|\u0000-\u001F]+/u.test(s)?s:s.replace(/\\/g,"/"),"makePosix");a.convert=e;let t=/^[a-z]:\//i;a.isNotRelative=s=>t.test(s)||O(s)},"setupWindows");typeof process<"u"&&process.platform==="win32"&&k();p.exports=C;C.default=C;p.exports.isPathValid=ft;_(p.exports,Symbol.for("setupWindows"),k)});var W=b((Pt,X)=>{f();X.exports=function(e,t){if(typeof e!="string")throw new TypeError("expected path to be a string");if(e==="\\"||e==="/")return"/";var s=e.length;if(s<=1)return e;var r="";if(s>4&&e[3]==="\\"){var i=e[2];(i==="?"||i===".")&&e.slice(0,2)==="\\\\"&&(e=e.slice(2),r="//")}var o=e.split(/[/\\]+/);return t!==!1&&o[o.length-1]===""&&o.pop(),r+o.join("/")}});f();var m=x(K(),1),z=x(F(),1),S=x(W(),1);import ht from"node:assert";import{createHash as _t}from"node:crypto";import d from"node:path";import{Transform as dt}from"node:stream";import{pipeline as gt}from"node:stream/promises";var Et=[".gadget/"],mt=[".DS_Store","node_modules",".git",".shopify"],Rt=[".gadget/sync.json",".gadget/dev-lock.json",".gadget/backup","yarn-error.log"],j=class e{constructor(t){this.path=t}static{n(this,"Directory")}_ignorer;_isHashing=!1;_lastIgnoreFileLoadTime=0;static async init(t){let s=new e(t);return await s.loadIgnoreFile(),s._lastIgnoreFileLoadTime=0,s}relative(t){return d.isAbsolute(t)?d.relative(this.path,t):t}absolute(...t){let s=d.resolve(this.path,...t);return ht(s.startsWith(this.path),`expected ${s} to be within ${this.path}`),s}normalize(t,s){return d.isAbsolute(t)&&(t=this.relative(t)),t=(0,S.default)(t,!0),s&&(t+="/"),t}async loadIgnoreFile(){this._lastIgnoreFileLoadTime=Date.now(),this._ignorer=(0,z.default)(),this._ignorer.add(mt);try{let t=await m.default.readFile(this.absolute(".ignore"),"utf8");this._ignorer.add(t)}catch(t){if(B(t)||At(t))return;throw t}}ignoreFileLoadedWithin(t){return Date.now()-this._lastIgnoreFileLoadTime<t}ignores(t,s){return t=this.relative(t),t===""?!1:t.startsWith("..")||(t=(0,S.default)(t,!1),s&&!t.endsWith("/")&&(t+="/"),this._isHashing&&Rt.some(r=>t.startsWith(r)))?!0:Et.some(r=>t.startsWith(r))?!1:this._ignorer.ignores(t)}async*walk({dir:t=this.path}={}){t!==this.path&&(yield this.normalize(t,!0));for await(let s of await m.default.opendir(t)){let r=d.join(t,s.name);this.ignores(r,s.isDirectory())||(s.isDirectory()?yield*this.walk({dir:r}):s.isFile()&&(yield this.normalize(r,!1)))}}async hashes(){try{this._isHashing=!0;let t={};for await(let s of this.walk()){let r=this.absolute(s);t[s]=await pt(r)}return t}finally{this._isHashing=!1}}async hasFiles(){return!await this.isEmptyOrNonExistent()}async isEmptyOrNonExistent(){let t=!0;try{for await(let s of this.walk()){t=!1;break}}catch(s){xt(s)}return t}},yt=process.platform==="linux"||process.platform==="darwin",pt=n(async e=>{let t=_t("sha1");t.update(d.basename(e));let s=await m.default.stat(e),r;if(yt&&(r=s.mode&511),s.isDirectory())return{sha1:t.digest("hex"),permissions:r};let i=new dt({transform(o,u,g){if(!o.includes(13)){g(void 0,o);return}let l=Buffer.alloc(o.length),c=0;for(let A of o)A!==13&&(l[c++]=A);g(void 0,l.subarray(0,c))}});return await gt(m.default.createReadStream(e),i,t),{sha1:t.digest("hex"),permissions:r}},"hash");function B(e){return!!e&&typeof e=="object"&&"code"in e&&e.code==="ENOENT"}n(B,"isEnoentError");function At(e){return!!e&&typeof e=="object"&&"code"in e&&e.code==="EISDIR"}n(At,"isEisdirError");var xt=n(e=>{if(!B(e))throw e},"swallowEnoent");export{j as a,yt as b,xt as c};
1
+ import{K}from"./chunk-ALSXPCRD.js";import{a as n,d as b,f as x,h as f}from"./chunk-7DYQUG5M.js";var F=b((It,p)=>{f();function v(e){return Array.isArray(e)?e:[e]}n(v,"makeArray");var V=void 0,w="",L=" ",I="\\",M=/^\s+$/,Y=/(?:[^\\]|^)\\$/,U=/^\\!/,q=/^\\#/,J=/\r?\n/g,Q=/^\.{0,2}\/|^\.{1,2}$/,Z=/\/$/,h="/",G="node-ignore";typeof Symbol<"u"&&(G=Symbol.for("node-ignore"));var D=G,_=n((e,t,s)=>(Object.defineProperty(e,t,{value:s}),s),"define"),tt=/([0-z])-([0-z])/g,H=n(()=>!1,"RETURN_FALSE"),et=n(e=>e.replace(tt,(t,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?t:w),"sanitizeRange"),st=n(e=>{let{length:t}=e;return e.slice(0,t-t%2)},"cleanRangeBackSlash"),rt=[[/^\uFEFF/,()=>w],[/((?:\\\\)*?)(\\?\s+)$/,(e,t,s)=>t+(s.indexOf("\\")===0?L:w)],[/(\\+?)\s/g,(e,t)=>{let{length:s}=t;return t.slice(0,s-s%2)+L}],[/[\\$.|*+(){^]/g,e=>`\\${e}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,n(function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"},"startingReplacer")],[/\\\/\\\*\\\*(?=\\\/|$)/g,(e,t,s)=>t+6<s.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(e,t,s)=>{let r=s.replace(/\\\*/g,"[^\\/]*");return t+r}],[/\\\\\\(?=[$.|*+(){^])/g,()=>I],[/\\\\/g,()=>I],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(e,t,s,r,i)=>t===I?`\\[${s}${st(r)}${i}`:i==="]"&&r.length%2===0?`[${et(s)}${r}]`:"[]"],[/(?:[^*])$/,e=>/\/$/.test(e)?`${e}$`:`${e}(?=$|\\/$)`]],it=/(^|\\\/)?\\\*$/,E="regex",R="checkRegex",T="_",nt={[E](e,t){return`${t?`${t}[^/]+`:"[^/]*"}(?=$|\\/$)`},[R](e,t){return`${t?`${t}[^/]*`:"[^/]*"}(?=$|\\/$)`}},ot=n(e=>rt.reduce((t,[s,r])=>t.replace(s,r.bind(e)),e),"makeRegexPrefix"),y=n(e=>typeof e=="string","isString"),at=n(e=>e&&y(e)&&!M.test(e)&&!Y.test(e)&&e.indexOf("#")!==0,"checkPattern"),ct=n(e=>e.split(J).filter(Boolean),"splitPattern"),N=class{static{n(this,"IgnoreRule")}constructor(t,s,r,i,o,u){this.pattern=t,this.mark=s,this.negative=o,_(this,"body",r),_(this,"ignoreCase",i),_(this,"regexPrefix",u)}get regex(){let t=T+E;return this[t]?this[t]:this._make(E,t)}get checkRegex(){let t=T+R;return this[t]?this[t]:this._make(R,t)}_make(t,s){let r=this.regexPrefix.replace(it,nt[t]),i=this.ignoreCase?new RegExp(r,"i"):new RegExp(r);return _(this,s,i)}},ut=n(({pattern:e,mark:t},s)=>{let r=!1,i=e;i.indexOf("!")===0&&(r=!0,i=i.substr(1)),i=i.replace(U,"!").replace(q,"#");let o=ot(i);return new N(e,t,i,s,r,o)},"createRule"),P=class{static{n(this,"RuleManager")}constructor(t){this._ignoreCase=t,this._rules=[]}_add(t){if(t&&t[D]){this._rules=this._rules.concat(t._rules._rules),this._added=!0;return}if(y(t)&&(t={pattern:t}),at(t.pattern)){let s=ut(t,this._ignoreCase);this._added=!0,this._rules.push(s)}}add(t){return this._added=!1,v(y(t)?ct(t):t).forEach(this._add,this),this._added}test(t,s,r){let i=!1,o=!1,u;this._rules.forEach(l=>{let{negative:c}=l;o===c&&i!==o||c&&!i&&!o&&!s||!l[r].test(t)||(i=!c,o=c,u=c?V:l)});let g={ignored:i,unignored:o};return u&&(g.rule=u),g}},lt=n((e,t)=>{throw new t(e)},"throwError"),a=n((e,t,s)=>y(e)?e?a.isNotRelative(e)?s(`path should be a \`path.relative()\`d string, but got "${t}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${t}\``,TypeError),"checkPath"),O=n(e=>Q.test(e),"isNotRelative");a.isNotRelative=O;a.convert=e=>e;var $=class{static{n(this,"Ignore")}constructor({ignorecase:t=!0,ignoreCase:s=t,allowRelativePaths:r=!1}={}){_(this,D,!0),this._rules=new P(s),this._strictPathCheck=!r,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(t){return this._rules.add(t)&&this._initCache(),this}addPattern(t){return this.add(t)}_test(t,s,r,i){let o=t&&a.convert(t);return a(o,t,this._strictPathCheck?lt:H),this._t(o,s,r,i)}checkIgnore(t){if(!Z.test(t))return this.test(t);let s=t.split(h).filter(Boolean);if(s.pop(),s.length){let r=this._t(s.join(h)+h,this._testCache,!0,s);if(r.ignored)return r}return this._rules.test(t,!1,R)}_t(t,s,r,i){if(t in s)return s[t];if(i||(i=t.split(h).filter(Boolean)),i.pop(),!i.length)return s[t]=this._rules.test(t,r,E);let o=this._t(i.join(h)+h,s,r,i);return s[t]=o.ignored?o:this._rules.test(t,r,E)}ignores(t){return this._test(t,this._ignoreCache,!1).ignored}createFilter(){return t=>!this.ignores(t)}filter(t){return v(t).filter(this.createFilter())}test(t){return this._test(t,this._testCache,!0)}},C=n(e=>new $(e),"factory"),ft=n(e=>a(e&&a.convert(e),e,H),"isPathValid"),k=n(()=>{let e=n(s=>/^\\\\\?\\/.test(s)||/["<>|\u0000-\u001F]+/u.test(s)?s:s.replace(/\\/g,"/"),"makePosix");a.convert=e;let t=/^[a-z]:\//i;a.isNotRelative=s=>t.test(s)||O(s)},"setupWindows");typeof process<"u"&&process.platform==="win32"&&k();p.exports=C;C.default=C;p.exports.isPathValid=ft;_(p.exports,Symbol.for("setupWindows"),k)});var W=b((Pt,X)=>{f();X.exports=function(e,t){if(typeof e!="string")throw new TypeError("expected path to be a string");if(e==="\\"||e==="/")return"/";var s=e.length;if(s<=1)return e;var r="";if(s>4&&e[3]==="\\"){var i=e[2];(i==="?"||i===".")&&e.slice(0,2)==="\\\\"&&(e=e.slice(2),r="//")}var o=e.split(/[/\\]+/);return t!==!1&&o[o.length-1]===""&&o.pop(),r+o.join("/")}});f();var m=x(K(),1),z=x(F(),1),S=x(W(),1);import ht from"node:assert";import{createHash as _t}from"node:crypto";import d from"node:path";import{Transform as dt}from"node:stream";import{pipeline as gt}from"node:stream/promises";var Et=[".gadget/"],mt=[".DS_Store","node_modules",".git",".shopify"],Rt=[".gadget/sync.json",".gadget/dev-lock.json",".gadget/backup","yarn-error.log"],j=class e{constructor(t){this.path=t}static{n(this,"Directory")}_ignorer;_isHashing=!1;_lastIgnoreFileLoadTime=0;static async init(t){let s=new e(t);return await s.loadIgnoreFile(),s._lastIgnoreFileLoadTime=0,s}relative(t){return d.isAbsolute(t)?d.relative(this.path,t):t}absolute(...t){let s=d.resolve(this.path,...t);return ht(s.startsWith(this.path),`expected ${s} to be within ${this.path}`),s}normalize(t,s){return d.isAbsolute(t)&&(t=this.relative(t)),t=(0,S.default)(t,!0),s&&(t+="/"),t}async loadIgnoreFile(){this._lastIgnoreFileLoadTime=Date.now(),this._ignorer=(0,z.default)(),this._ignorer.add(mt);try{let t=await m.default.readFile(this.absolute(".ignore"),"utf8");this._ignorer.add(t)}catch(t){if(B(t)||At(t))return;throw t}}ignoreFileLoadedWithin(t){return Date.now()-this._lastIgnoreFileLoadTime<t}ignores(t,s){return t=this.relative(t),t===""?!1:t.startsWith("..")||(t=(0,S.default)(t,!1),s&&!t.endsWith("/")&&(t+="/"),this._isHashing&&Rt.some(r=>t.startsWith(r)))?!0:Et.some(r=>t.startsWith(r))?!1:this._ignorer.ignores(t)}async*walk({dir:t=this.path}={}){t!==this.path&&(yield this.normalize(t,!0));for await(let s of await m.default.opendir(t)){let r=d.join(t,s.name);this.ignores(r,s.isDirectory())||(s.isDirectory()?yield*this.walk({dir:r}):s.isFile()&&(yield this.normalize(r,!1)))}}async hashes(){try{this._isHashing=!0;let t={};for await(let s of this.walk()){let r=this.absolute(s);t[s]=await pt(r)}return t}finally{this._isHashing=!1}}async hasFiles(){return!await this.isEmptyOrNonExistent()}async isEmptyOrNonExistent(){let t=!0;try{for await(let s of this.walk()){t=!1;break}}catch(s){xt(s)}return t}},yt=process.platform==="linux"||process.platform==="darwin",pt=n(async e=>{let t=_t("sha1");t.update(d.basename(e));let s=await m.default.stat(e),r;if(yt&&(r=s.mode&511),s.isDirectory())return{sha1:t.digest("hex"),permissions:r};let i=new dt({transform(o,u,g){if(!o.includes(13)){g(void 0,o);return}let l=Buffer.alloc(o.length),c=0;for(let A of o)A!==13&&(l[c++]=A);g(void 0,l.subarray(0,c))}});return await gt(m.default.createReadStream(e),i,t),{sha1:t.digest("hex"),permissions:r}},"hash");function B(e){return!!e&&typeof e=="object"&&"code"in e&&e.code==="ENOENT"}n(B,"isEnoentError");function At(e){return!!e&&typeof e=="object"&&"code"in e&&e.code==="EISDIR"}n(At,"isEisdirError");var xt=n(e=>{if(!B(e))throw e},"swallowEnoent");export{j as a,yt as b,xt as c};
2
2
  /*! Bundled license information:
3
3
 
4
4
  normalize-path/index.js:
@@ -9,4 +9,4 @@ normalize-path/index.js:
9
9
  * Released under the MIT License.
10
10
  *)
11
11
  */
12
- //# sourceMappingURL=chunk-OUIZQC4D.js.map
12
+ //# sourceMappingURL=chunk-X4XSYLCE.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../node_modules/.pnpm/ignore@7.0.5/node_modules/ignore/index.js", "../node_modules/.pnpm/normalize-path@3.0.0/node_modules/normalize-path/index.js", "../src/services/filesync/directory.ts"],
4
- "sourcesContent": ["// A simple implementation of make-array\nfunction makeArray (subject) {\n return Array.isArray(subject)\n ? subject\n : [subject]\n}\n\nconst UNDEFINED = undefined\nconst EMPTY = ''\nconst SPACE = ' '\nconst ESCAPE = '\\\\'\nconst REGEX_TEST_BLANK_LINE = /^\\s+$/\nconst REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\\\]|^)\\\\$/\nconst REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\\\!/\nconst REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\\\#/\nconst REGEX_SPLITALL_CRLF = /\\r?\\n/g\n\n// Invalid:\n// - /foo,\n// - ./foo,\n// - ../foo,\n// - .\n// - ..\n// Valid:\n// - .foo\nconst REGEX_TEST_INVALID_PATH = /^\\.{0,2}\\/|^\\.{1,2}$/\n\nconst REGEX_TEST_TRAILING_SLASH = /\\/$/\n\nconst SLASH = '/'\n\n// Do not use ternary expression here, since \"istanbul ignore next\" is buggy\nlet TMP_KEY_IGNORE = 'node-ignore'\n/* istanbul ignore else */\nif (typeof Symbol !== 'undefined') {\n TMP_KEY_IGNORE = Symbol.for('node-ignore')\n}\nconst KEY_IGNORE = TMP_KEY_IGNORE\n\nconst define = (object, key, value) => {\n Object.defineProperty(object, key, {value})\n return value\n}\n\nconst REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g\n\nconst RETURN_FALSE = () => false\n\n// Sanitize the range of a regular expression\n// The cases are complicated, see test cases for details\nconst sanitizeRange = range => range.replace(\n REGEX_REGEXP_RANGE,\n (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0)\n ? match\n // Invalid range (out of order) which is ok for gitignore rules but\n // fatal for JavaScript regular expression, so eliminate it.\n : EMPTY\n)\n\n// See fixtures #59\nconst cleanRangeBackSlash = slashes => {\n const {length} = slashes\n return slashes.slice(0, length - length % 2)\n}\n\n// > If the pattern ends with a slash,\n// > it is removed for the purpose of the following description,\n// > but it would only find a match with a directory.\n// > In other words, foo/ will match a directory foo and paths underneath it,\n// > but will not match a regular file or a symbolic link foo\n// > (this is consistent with the way how pathspec works in general in Git).\n// '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'\n// -> ignore-rules will not deal with it, because it costs extra `fs.stat` call\n// you could use option `mark: true` with `glob`\n\n// '`foo/`' should not continue with the '`..`'\nconst REPLACERS = [\n\n [\n // Remove BOM\n // TODO:\n // Other similar zero-width characters?\n /^\\uFEFF/,\n () => EMPTY\n ],\n\n // > Trailing spaces are ignored unless they are quoted with backslash (\"\\\")\n [\n // (a\\ ) -> (a )\n // (a ) -> (a)\n // (a ) -> (a)\n // (a \\ ) -> (a )\n /((?:\\\\\\\\)*?)(\\\\?\\s+)$/,\n (_, m1, m2) => m1 + (\n m2.indexOf('\\\\') === 0\n ? SPACE\n : EMPTY\n )\n ],\n\n // Replace (\\ ) with ' '\n // (\\ ) -> ' '\n // (\\\\ ) -> '\\\\ '\n // (\\\\\\ ) -> '\\\\ '\n [\n /(\\\\+?)\\s/g,\n (_, m1) => {\n const {length} = m1\n return m1.slice(0, length - length % 2) + SPACE\n }\n ],\n\n // Escape metacharacters\n // which is written down by users but means special for regular expressions.\n\n // > There are 12 characters with special meanings:\n // > - the backslash \\,\n // > - the caret ^,\n // > - the dollar sign $,\n // > - the period or dot .,\n // > - the vertical bar or pipe symbol |,\n // > - the question mark ?,\n // > - the asterisk or star *,\n // > - the plus sign +,\n // > - the opening parenthesis (,\n // > - the closing parenthesis ),\n // > - and the opening square bracket [,\n // > - the opening curly brace {,\n // > These special characters are often called \"metacharacters\".\n [\n /[\\\\$.|*+(){^]/g,\n match => `\\\\${match}`\n ],\n\n [\n // > a question mark (?) matches a single character\n /(?!\\\\)\\?/g,\n () => '[^/]'\n ],\n\n // leading slash\n [\n\n // > A leading slash matches the beginning of the pathname.\n // > For example, \"/*.c\" matches \"cat-file.c\" but not \"mozilla-sha1/sha1.c\".\n // A leading slash matches the beginning of the pathname\n /^\\//,\n () => '^'\n ],\n\n // replace special metacharacter slash after the leading slash\n [\n /\\//g,\n () => '\\\\/'\n ],\n\n [\n // > A leading \"**\" followed by a slash means match in all directories.\n // > For example, \"**/foo\" matches file or directory \"foo\" anywhere,\n // > the same as pattern \"foo\".\n // > \"**/foo/bar\" matches file or directory \"bar\" anywhere that is directly\n // > under directory \"foo\".\n // Notice that the '*'s have been replaced as '\\\\*'\n /^\\^*\\\\\\*\\\\\\*\\\\\\//,\n\n // '**/foo' <-> 'foo'\n () => '^(?:.*\\\\/)?'\n ],\n\n // starting\n [\n // there will be no leading '/'\n // (which has been replaced by section \"leading slash\")\n // If starts with '**', adding a '^' to the regular expression also works\n /^(?=[^^])/,\n function startingReplacer () {\n // If has a slash `/` at the beginning or middle\n return !/\\/(?!$)/.test(this)\n // > Prior to 2.22.1\n // > If the pattern does not contain a slash /,\n // > Git treats it as a shell glob pattern\n // Actually, if there is only a trailing slash,\n // git also treats it as a shell glob pattern\n\n // After 2.22.1 (compatible but clearer)\n // > If there is a separator at the beginning or middle (or both)\n // > of the pattern, then the pattern is relative to the directory\n // > level of the particular .gitignore file itself.\n // > Otherwise the pattern may also match at any level below\n // > the .gitignore level.\n ? '(?:^|\\\\/)'\n\n // > Otherwise, Git treats the pattern as a shell glob suitable for\n // > consumption by fnmatch(3)\n : '^'\n }\n ],\n\n // two globstars\n [\n // Use lookahead assertions so that we could match more than one `'/**'`\n /\\\\\\/\\\\\\*\\\\\\*(?=\\\\\\/|$)/g,\n\n // Zero, one or several directories\n // should not use '*', or it will be replaced by the next replacer\n\n // Check if it is not the last `'/**'`\n (_, index, str) => index + 6 < str.length\n\n // case: /**/\n // > A slash followed by two consecutive asterisks then a slash matches\n // > zero or more directories.\n // > For example, \"a/**/b\" matches \"a/b\", \"a/x/b\", \"a/x/y/b\" and so on.\n // '/**/'\n ? '(?:\\\\/[^\\\\/]+)*'\n\n // case: /**\n // > A trailing `\"/**\"` matches everything inside.\n\n // #21: everything inside but it should not include the current folder\n : '\\\\/.+'\n ],\n\n // normal intermediate wildcards\n [\n // Never replace escaped '*'\n // ignore rule '\\*' will match the path '*'\n\n // 'abc.*/' -> go\n // 'abc.*' -> skip this rule,\n // coz trailing single wildcard will be handed by [trailing wildcard]\n /(^|[^\\\\]+)(\\\\\\*)+(?=.+)/g,\n\n // '*.js' matches '.js'\n // '*.js' doesn't match 'abc'\n (_, p1, p2) => {\n // 1.\n // > An asterisk \"*\" matches anything except a slash.\n // 2.\n // > Other consecutive asterisks are considered regular asterisks\n // > and will match according to the previous rules.\n const unescaped = p2.replace(/\\\\\\*/g, '[^\\\\/]*')\n return p1 + unescaped\n }\n ],\n\n [\n // unescape, revert step 3 except for back slash\n // For example, if a user escape a '\\\\*',\n // after step 3, the result will be '\\\\\\\\\\\\*'\n /\\\\\\\\\\\\(?=[$.|*+(){^])/g,\n () => ESCAPE\n ],\n\n [\n // '\\\\\\\\' -> '\\\\'\n /\\\\\\\\/g,\n () => ESCAPE\n ],\n\n [\n // > The range notation, e.g. [a-zA-Z],\n // > can be used to match one of the characters in a range.\n\n // `\\` is escaped by step 3\n /(\\\\)?\\[([^\\]/]*?)(\\\\*)($|\\])/g,\n (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE\n // '\\\\[bar]' -> '\\\\\\\\[bar\\\\]'\n ? `\\\\[${range}${cleanRangeBackSlash(endEscape)}${close}`\n : close === ']'\n ? endEscape.length % 2 === 0\n // A normal case, and it is a range notation\n // '[bar]'\n // '[bar\\\\\\\\]'\n ? `[${sanitizeRange(range)}${endEscape}]`\n // Invalid range notaton\n // '[bar\\\\]' -> '[bar\\\\\\\\]'\n : '[]'\n : '[]'\n ],\n\n // ending\n [\n // 'js' will not match 'js.'\n // 'ab' will not match 'abc'\n /(?:[^*])$/,\n\n // WTF!\n // https://git-scm.com/docs/gitignore\n // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)\n // which re-fixes #24, #38\n\n // > If there is a separator at the end of the pattern then the pattern\n // > will only match directories, otherwise the pattern can match both\n // > files and directories.\n\n // 'js*' will not match 'a.js'\n // 'js/' will not match 'a.js'\n // 'js' will match 'a.js' and 'a.js/'\n match => /\\/$/.test(match)\n // foo/ will not match 'foo'\n ? `${match}$`\n // foo matches 'foo' and 'foo/'\n : `${match}(?=$|\\\\/$)`\n ]\n]\n\nconst REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\\\\/)?\\\\\\*$/\nconst MODE_IGNORE = 'regex'\nconst MODE_CHECK_IGNORE = 'checkRegex'\nconst UNDERSCORE = '_'\n\nconst TRAILING_WILD_CARD_REPLACERS = {\n [MODE_IGNORE] (_, p1) {\n const prefix = p1\n // '\\^':\n // '/*' does not match EMPTY\n // '/*' does not match everything\n\n // '\\\\\\/':\n // 'abc/*' does not match 'abc/'\n ? `${p1}[^/]+`\n\n // 'a*' matches 'a'\n // 'a*' matches 'aa'\n : '[^/]*'\n\n return `${prefix}(?=$|\\\\/$)`\n },\n\n [MODE_CHECK_IGNORE] (_, p1) {\n // When doing `git check-ignore`\n const prefix = p1\n // '\\\\\\/':\n // 'abc/*' DOES match 'abc/' !\n ? `${p1}[^/]*`\n\n // 'a*' matches 'a'\n // 'a*' matches 'aa'\n : '[^/]*'\n\n return `${prefix}(?=$|\\\\/$)`\n }\n}\n\n// @param {pattern}\nconst makeRegexPrefix = pattern => REPLACERS.reduce(\n (prev, [matcher, replacer]) =>\n prev.replace(matcher, replacer.bind(pattern)),\n pattern\n)\n\nconst isString = subject => typeof subject === 'string'\n\n// > A blank line matches no files, so it can serve as a separator for readability.\nconst checkPattern = pattern => pattern\n && isString(pattern)\n && !REGEX_TEST_BLANK_LINE.test(pattern)\n && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern)\n\n // > A line starting with # serves as a comment.\n && pattern.indexOf('#') !== 0\n\nconst splitPattern = pattern => pattern\n.split(REGEX_SPLITALL_CRLF)\n.filter(Boolean)\n\nclass IgnoreRule {\n constructor (\n pattern,\n mark,\n body,\n ignoreCase,\n negative,\n prefix\n ) {\n this.pattern = pattern\n this.mark = mark\n this.negative = negative\n\n define(this, 'body', body)\n define(this, 'ignoreCase', ignoreCase)\n define(this, 'regexPrefix', prefix)\n }\n\n get regex () {\n const key = UNDERSCORE + MODE_IGNORE\n\n if (this[key]) {\n return this[key]\n }\n\n return this._make(MODE_IGNORE, key)\n }\n\n get checkRegex () {\n const key = UNDERSCORE + MODE_CHECK_IGNORE\n\n if (this[key]) {\n return this[key]\n }\n\n return this._make(MODE_CHECK_IGNORE, key)\n }\n\n _make (mode, key) {\n const str = this.regexPrefix.replace(\n REGEX_REPLACE_TRAILING_WILDCARD,\n\n // It does not need to bind pattern\n TRAILING_WILD_CARD_REPLACERS[mode]\n )\n\n const regex = this.ignoreCase\n ? new RegExp(str, 'i')\n : new RegExp(str)\n\n return define(this, key, regex)\n }\n}\n\nconst createRule = ({\n pattern,\n mark\n}, ignoreCase) => {\n let negative = false\n let body = pattern\n\n // > An optional prefix \"!\" which negates the pattern;\n if (body.indexOf('!') === 0) {\n negative = true\n body = body.substr(1)\n }\n\n body = body\n // > Put a backslash (\"\\\") in front of the first \"!\" for patterns that\n // > begin with a literal \"!\", for example, `\"\\!important!.txt\"`.\n .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!')\n // > Put a backslash (\"\\\") in front of the first hash for patterns that\n // > begin with a hash.\n .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#')\n\n const regexPrefix = makeRegexPrefix(body)\n\n return new IgnoreRule(\n pattern,\n mark,\n body,\n ignoreCase,\n negative,\n regexPrefix\n )\n}\n\nclass RuleManager {\n constructor (ignoreCase) {\n this._ignoreCase = ignoreCase\n this._rules = []\n }\n\n _add (pattern) {\n // #32\n if (pattern && pattern[KEY_IGNORE]) {\n this._rules = this._rules.concat(pattern._rules._rules)\n this._added = true\n return\n }\n\n if (isString(pattern)) {\n pattern = {\n pattern\n }\n }\n\n if (checkPattern(pattern.pattern)) {\n const rule = createRule(pattern, this._ignoreCase)\n this._added = true\n this._rules.push(rule)\n }\n }\n\n // @param {Array<string> | string | Ignore} pattern\n add (pattern) {\n this._added = false\n\n makeArray(\n isString(pattern)\n ? splitPattern(pattern)\n : pattern\n ).forEach(this._add, this)\n\n return this._added\n }\n\n // Test one single path without recursively checking parent directories\n //\n // - checkUnignored `boolean` whether should check if the path is unignored,\n // setting `checkUnignored` to `false` could reduce additional\n // path matching.\n // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`\n\n // @returns {TestResult} true if a file is ignored\n test (path, checkUnignored, mode) {\n let ignored = false\n let unignored = false\n let matchedRule\n\n this._rules.forEach(rule => {\n const {negative} = rule\n\n // | ignored : unignored\n // -------- | ---------------------------------------\n // negative | 0:0 | 0:1 | 1:0 | 1:1\n // -------- | ------- | ------- | ------- | --------\n // 0 | TEST | TEST | SKIP | X\n // 1 | TESTIF | SKIP | TEST | X\n\n // - SKIP: always skip\n // - TEST: always test\n // - TESTIF: only test if checkUnignored\n // - X: that never happen\n if (\n unignored === negative && ignored !== unignored\n || negative && !ignored && !unignored && !checkUnignored\n ) {\n return\n }\n\n const matched = rule[mode].test(path)\n\n if (!matched) {\n return\n }\n\n ignored = !negative\n unignored = negative\n\n matchedRule = negative\n ? UNDEFINED\n : rule\n })\n\n const ret = {\n ignored,\n unignored\n }\n\n if (matchedRule) {\n ret.rule = matchedRule\n }\n\n return ret\n }\n}\n\nconst throwError = (message, Ctor) => {\n throw new Ctor(message)\n}\n\nconst checkPath = (path, originalPath, doThrow) => {\n if (!isString(path)) {\n return doThrow(\n `path must be a string, but got \\`${originalPath}\\``,\n TypeError\n )\n }\n\n // We don't know if we should ignore EMPTY, so throw\n if (!path) {\n return doThrow(`path must not be empty`, TypeError)\n }\n\n // Check if it is a relative path\n if (checkPath.isNotRelative(path)) {\n const r = '`path.relative()`d'\n return doThrow(\n `path should be a ${r} string, but got \"${originalPath}\"`,\n RangeError\n )\n }\n\n return true\n}\n\nconst isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path)\n\ncheckPath.isNotRelative = isNotRelative\n\n// On windows, the following function will be replaced\n/* istanbul ignore next */\ncheckPath.convert = p => p\n\n\nclass Ignore {\n constructor ({\n ignorecase = true,\n ignoreCase = ignorecase,\n allowRelativePaths = false\n } = {}) {\n define(this, KEY_IGNORE, true)\n\n this._rules = new RuleManager(ignoreCase)\n this._strictPathCheck = !allowRelativePaths\n this._initCache()\n }\n\n _initCache () {\n // A cache for the result of `.ignores()`\n this._ignoreCache = Object.create(null)\n\n // A cache for the result of `.test()`\n this._testCache = Object.create(null)\n }\n\n add (pattern) {\n if (this._rules.add(pattern)) {\n // Some rules have just added to the ignore,\n // making the behavior changed,\n // so we need to re-initialize the result cache\n this._initCache()\n }\n\n return this\n }\n\n // legacy\n addPattern (pattern) {\n return this.add(pattern)\n }\n\n // @returns {TestResult}\n _test (originalPath, cache, checkUnignored, slices) {\n const path = originalPath\n // Supports nullable path\n && checkPath.convert(originalPath)\n\n checkPath(\n path,\n originalPath,\n this._strictPathCheck\n ? throwError\n : RETURN_FALSE\n )\n\n return this._t(path, cache, checkUnignored, slices)\n }\n\n checkIgnore (path) {\n // If the path doest not end with a slash, `.ignores()` is much equivalent\n // to `git check-ignore`\n if (!REGEX_TEST_TRAILING_SLASH.test(path)) {\n return this.test(path)\n }\n\n const slices = path.split(SLASH).filter(Boolean)\n slices.pop()\n\n if (slices.length) {\n const parent = this._t(\n slices.join(SLASH) + SLASH,\n this._testCache,\n true,\n slices\n )\n\n if (parent.ignored) {\n return parent\n }\n }\n\n return this._rules.test(path, false, MODE_CHECK_IGNORE)\n }\n\n _t (\n // The path to be tested\n path,\n\n // The cache for the result of a certain checking\n cache,\n\n // Whether should check if the path is unignored\n checkUnignored,\n\n // The path slices\n slices\n ) {\n if (path in cache) {\n return cache[path]\n }\n\n if (!slices) {\n // path/to/a.js\n // ['path', 'to', 'a.js']\n slices = path.split(SLASH).filter(Boolean)\n }\n\n slices.pop()\n\n // If the path has no parent directory, just test it\n if (!slices.length) {\n return cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE)\n }\n\n const parent = this._t(\n slices.join(SLASH) + SLASH,\n cache,\n checkUnignored,\n slices\n )\n\n // If the path contains a parent directory, check the parent first\n return cache[path] = parent.ignored\n // > It is not possible to re-include a file if a parent directory of\n // > that file is excluded.\n ? parent\n : this._rules.test(path, checkUnignored, MODE_IGNORE)\n }\n\n ignores (path) {\n return this._test(path, this._ignoreCache, false).ignored\n }\n\n createFilter () {\n return path => !this.ignores(path)\n }\n\n filter (paths) {\n return makeArray(paths).filter(this.createFilter())\n }\n\n // @returns {TestResult}\n test (path) {\n return this._test(path, this._testCache, true)\n }\n}\n\nconst factory = options => new Ignore(options)\n\nconst isPathValid = path =>\n checkPath(path && checkPath.convert(path), path, RETURN_FALSE)\n\n/* istanbul ignore next */\nconst setupWindows = () => {\n /* eslint no-control-regex: \"off\" */\n const makePosix = str => /^\\\\\\\\\\?\\\\/.test(str)\n || /[\"<>|\\u0000-\\u001F]+/u.test(str)\n ? str\n : str.replace(/\\\\/g, '/')\n\n checkPath.convert = makePosix\n\n // 'C:\\\\foo' <- 'C:\\\\foo' has been converted to 'C:/'\n // 'd:\\\\foo'\n const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\\//i\n checkPath.isNotRelative = path =>\n REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path)\n || isNotRelative(path)\n}\n\n\n// Windows\n// --------------------------------------------------------------\n/* istanbul ignore next */\nif (\n // Detect `process` so that it can run in browsers.\n typeof process !== 'undefined'\n && process.platform === 'win32'\n) {\n setupWindows()\n}\n\n// COMMONJS_EXPORTS ////////////////////////////////////////////////////////////\n\nmodule.exports = factory\n\n// Although it is an anti-pattern,\n// it is still widely misused by a lot of libraries in github\n// Ref: https://github.com/search?q=ignore.default%28%29&type=code\nfactory.default = factory\n\nmodule.exports.isPathValid = isPathValid\n\n// For testing purposes\ndefine(module.exports, Symbol.for('setupWindows'), setupWindows)\n", "/*!\n * normalize-path <https://github.com/jonschlinkert/normalize-path>\n *\n * Copyright (c) 2014-2018, Jon Schlinkert.\n * Released under the MIT License.\n */\n\nmodule.exports = function(path, stripTrailing) {\n if (typeof path !== 'string') {\n throw new TypeError('expected path to be a string');\n }\n\n if (path === '\\\\' || path === '/') return '/';\n\n var len = path.length;\n if (len <= 1) return path;\n\n // ensure that win32 namespaces has two leading slashes, so that the path is\n // handled properly by the win32 version of path.parse() after being normalized\n // https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces\n var prefix = '';\n if (len > 4 && path[3] === '\\\\') {\n var ch = path[2];\n if ((ch === '?' || ch === '.') && path.slice(0, 2) === '\\\\\\\\') {\n path = path.slice(2);\n prefix = '//';\n }\n }\n\n var segs = path.split(/[/\\\\]+/);\n if (stripTrailing !== false && segs[segs.length - 1] === '') {\n segs.pop();\n }\n return prefix + segs.join('/');\n};\n", "import type { Ignore } from \"ignore\";\n\n/* eslint-disable func-style */\n/**\n * DO NOT MODIFY\n *\n * Everything in this file also exists in gadget to ensure that this logic\n * is the same between the two projects.\n */\nimport fs from \"fs-extra\";\nimport ignore from \"ignore\";\nimport assert from \"node:assert\";\nimport { createHash } from \"node:crypto\";\nimport path from \"node:path\";\nimport { Transform } from \"node:stream\";\nimport { pipeline } from \"node:stream/promises\";\nimport normalizePath from \"normalize-path\";\n\n/**\n * Paths that are never ignored, regardless of the contents of the `.ignore` file.\n */\nexport const NEVER_IGNORE_PATHS = [\".gadget/\"] as const;\n\n/**\n * Paths that are always ignored, regardless of the contents of the `.ignore` file.\n */\nexport const ALWAYS_IGNORE_PATHS = [\".DS_Store\", \"node_modules\", \".git\", \".shopify\"] as const;\n\n/**\n * Paths that are ignored when hashing the directory.\n *\n * NOTE: This is the _only_ thing that is allowed to be different between gadget and ggt.\n */\nexport const HASHING_IGNORE_PATHS = [\".gadget/sync.json\", \".gadget/dev-lock.json\", \".gadget/backup\", \"yarn-error.log\"] as const;\n\n/**\n * Represents a directory that is being synced.\n */\nexport class Directory {\n /**\n * A gitignore-style file parser used to determine which files to\n * ignore while syncing.\n *\n * @see https://www.npmjs.com/package/ignore\n */\n private _ignorer!: Ignore;\n\n /**\n * Whether the directory is currently being hashed.\n */\n private _isHashing = false;\n\n /**\n * Timestamp of the last {@linkcode loadIgnoreFile} call, used to\n * deduplicate redundant reloads from duplicate FSEvents.\n */\n private _lastIgnoreFileLoadTime = 0;\n\n private constructor(\n /**\n * An absolute path to the directory that is being synced.\n */\n readonly path: string,\n ) {}\n\n /**\n * Initializes a directory to be synced.\n *\n * If the directory does not exist, it is created.\n *\n * @param dir - The directory to initialize.\n * @returns A Promise that resolves to a Directory instance.\n */\n static async init(dir: string): Promise<Directory> {\n const directory = new Directory(dir);\n await directory.loadIgnoreFile();\n // don't count the init call as a recent load \u2014 the timestamp is\n // only meaningful once the file watcher is running\n directory._lastIgnoreFileLoadTime = 0;\n return directory;\n }\n\n /**\n * Returns the relative path from this directory to the specified path.\n *\n * @param to - The path to which the relative path is calculated.\n * @returns The relative path from this directory to the specified path.\n */\n relative(to: string): string {\n if (!path.isAbsolute(to)) {\n // the filepath is already relative\n return to;\n }\n\n return path.relative(this.path, to);\n }\n\n /**\n * Returns the absolute path by resolving the given path segments\n * relative to the directory path.\n *\n * @param pathSegments - The path segments to resolve.\n * @returns The absolute path.\n */\n absolute(...pathSegments: string[]): string {\n const result = path.resolve(this.path, ...pathSegments);\n assert(result.startsWith(this.path), `expected ${result} to be within ${this.path}`);\n return result;\n }\n\n /**\n * Similar to {@linkcode relative} in that it converts an absolute\n * path into a relative one from {@linkcode path}. However, it also\n * changes any slashes to be posix/unix-like forward slashes,\n * condenses repeated slashes into a single slash, and adds a trailing\n * slash if the path is a directory.\n *\n * This is used when sending files to Gadget to ensure that the paths\n * are consistent across platforms.\n *\n * @see https://www.npmjs.com/package/normalize-path\n */\n normalize(filepath: string, isDirectory: boolean): string {\n if (path.isAbsolute(filepath)) {\n filepath = this.relative(filepath);\n }\n\n // true = trim trailing slashes\n filepath = normalizePath(filepath, true);\n\n if (isDirectory) {\n filepath += \"/\";\n }\n\n return filepath;\n }\n\n /**\n * Loads the `.ignore` file in the directory. If the file does not\n * exist, it is silently ignored.\n */\n async loadIgnoreFile(): Promise<void> {\n this._lastIgnoreFileLoadTime = Date.now();\n this._ignorer = ignore();\n this._ignorer.add(ALWAYS_IGNORE_PATHS);\n\n try {\n const content = await fs.readFile(this.absolute(\".ignore\"), \"utf8\");\n this._ignorer.add(content);\n } catch (error) {\n if (isEnoentError(error) || isEisdirError(error)) {\n // ignore missing or is-directory errors\n return;\n }\n throw error;\n }\n }\n\n /**\n * Returns true if {@linkcode loadIgnoreFile} was called within the\n * given duration. Used to skip redundant watcher-triggered reloads\n * when a remote write already loaded the ignore file.\n */\n ignoreFileLoadedWithin(duration: number): boolean {\n return Date.now() - this._lastIgnoreFileLoadTime < duration;\n }\n\n /**\n * Determines if a file should be ignored based on its filepath.\n *\n * @param filepath - The filepath of the file to check.\n * @returns True if the file should be ignored, false otherwise.\n */\n ignores(filepath: string, isDirectory: boolean): boolean {\n filepath = this.relative(filepath);\n if (filepath === \"\") {\n // don't ignore the root dir\n return false;\n }\n\n if (filepath.startsWith(\"..\")) {\n // anything above the root dir is ignored\n return true;\n }\n\n // false = don't trim trailing slashes\n filepath = normalizePath(filepath, false);\n\n if (isDirectory && !filepath.endsWith(\"/\")) {\n filepath += \"/\";\n }\n\n if (this._isHashing && HASHING_IGNORE_PATHS.some((ignored) => filepath.startsWith(ignored))) {\n // special case for hashing\n return true;\n }\n\n if (NEVER_IGNORE_PATHS.some((neverIgnored) => filepath.startsWith(neverIgnored))) {\n // special case for never ignored paths\n return false;\n }\n\n return this._ignorer.ignores(filepath);\n }\n\n /**\n * Recursively walks through the directory and yields all non-ignored\n * files and directories within it.\n *\n * @yields - The normalized path of each file and directory.\n */\n async *walk({ dir = this.path } = {}): AsyncGenerator<string> {\n // don't yield the root directory\n if (dir !== this.path) {\n yield this.normalize(dir, true);\n }\n\n for await (const entry of await fs.opendir(dir)) {\n const filepath = path.join(dir, entry.name);\n if (this.ignores(filepath, entry.isDirectory())) {\n continue;\n }\n\n if (entry.isDirectory()) {\n yield* this.walk({ dir: filepath });\n } else if (entry.isFile()) {\n yield this.normalize(filepath, false);\n }\n }\n }\n\n /**\n * Calculates the hash of each file and directory and returns an\n * object containing the hashes keyed by the normalized file path.\n *\n * @returns A Promise that resolves to an object containing the hashes\n * of each file.\n */\n async hashes(): Promise<Hashes> {\n try {\n this._isHashing = true;\n const files = {} as Hashes;\n\n for await (const normalizedPath of this.walk()) {\n const absolutePath = this.absolute(normalizedPath);\n files[normalizedPath] = await hash(absolutePath);\n }\n\n return files;\n } finally {\n this._isHashing = false;\n }\n }\n\n async hasFiles(): Promise<boolean> {\n return !(await this.isEmptyOrNonExistent());\n }\n\n async isEmptyOrNonExistent(): Promise<boolean> {\n let isEmptyOrNonExistent = true;\n try {\n for await (const _ of this.walk()) {\n isEmptyOrNonExistent = false;\n break;\n }\n } catch (error) {\n swallowEnoent(error);\n }\n return isEmptyOrNonExistent;\n }\n}\n\n/**\n * Key/value pairs where the key is the normalized path and the value is\n * the result of {@linkcode hash} for that path.\n */\nexport type Hashes = Record<string, Hash>;\n\nexport type Hash = {\n /**\n * The SHA-1 hash of the file or directory.\n *\n * If the path points to a directory, the hash is calculated based on\n * the directory's basename. If the path points to a file, the hash is\n * calculated based on the file's basename and contents.\n */\n sha1: string;\n\n /**\n * The Unix-style file permissions of the file or directory, or\n * undefined if the platform that generated this hash doesn't support\n * them.\n *\n * @example 0o644\n * @see supportsPermissions\n */\n permissions?: number;\n};\n\n/**\n * Whether the current platform supports Unix-style file permissions.\n *\n * Windows doesn't support Unix-style file permissions and all file\n * permissions retrieved via `node:fs` on Windows are translated to 666\n * or 444.\n */\nexport const supportsPermissions = process.platform === \"linux\" || process.platform === \"darwin\";\n\n/**\n * Calculates the {@linkcode Hash} of the file or directory at the\n * specified absolute path.\n *\n * @param absolutePath - The absolute path to the file or directory.\n * @returns A Promise that resolves to the {@linkcode Hash} of the file\n * or directory.\n */\nconst hash = async (absolutePath: string): Promise<Hash> => {\n const sha1 = createHash(\"sha1\");\n sha1.update(path.basename(absolutePath));\n\n const stats = await fs.stat(absolutePath);\n\n let permissions;\n if (supportsPermissions) {\n // strip everything but the permissions\n permissions = stats.mode & 0o777;\n }\n\n if (stats.isDirectory()) {\n return { sha1: sha1.digest(\"hex\"), permissions };\n }\n\n // windows uses CRLF line endings whereas unix uses LF line endings so\n // we always strip out CR bytes (0x0d) when hashing files. this does\n // make us blind to files that only differ by CR bytes, but that's a\n // tradeoff we're willing to make.\n const removeCR = new Transform({\n transform(chunk: Buffer, _encoding, callback) {\n if (!chunk.includes(0x0d)) {\n callback(undefined, chunk);\n return;\n }\n\n const filteredChunk = Buffer.alloc(chunk.length);\n let i = 0;\n for (const byte of chunk) {\n if (byte !== 0x0d) {\n filteredChunk[i++] = byte;\n }\n }\n\n callback(undefined, filteredChunk.subarray(0, i));\n },\n });\n\n await pipeline(fs.createReadStream(absolutePath), removeCR, sha1);\n\n return { sha1: sha1.digest(\"hex\"), permissions };\n};\n\nfunction isEnoentError(error: unknown): error is { code: \"ENOENT\" } {\n return !!error && typeof error === \"object\" && \"code\" in error && error.code === \"ENOENT\";\n}\n\nfunction isEisdirError(error: unknown): error is { code: \"EISDIR\" } {\n return !!error && typeof error === \"object\" && \"code\" in error && error.code === \"EISDIR\";\n}\n\n/**\n * Swallows ENOENT errors and throws any other errors.\n *\n * @param error - The error to handle.\n * @throws The original error if it is not an ENOENT error.\n */\nexport const swallowEnoent = (error: unknown): void => {\n if (isEnoentError(error)) {\n return;\n }\n throw error;\n};\n"],
5
- "mappings": "gGAAA,IAAAA,EAAAC,EAAA,CAAAC,GAAAC,IAAA,CAAAC,IACA,SAASC,EAAWC,EAAS,CAC3B,OAAO,MAAM,QAAQA,CAAO,EACxBA,EACA,CAACA,CAAO,CACd,CAJSC,EAAAF,EAAA,aAMT,IAAMG,EAAY,OACZC,EAAQ,GACRC,EAAQ,IACRC,EAAS,KACTC,EAAwB,QACxBC,EAAmC,iBACnCC,EAA4C,OAC5CC,EAAqC,OACrCC,EAAsB,SAUtBC,EAA0B,uBAE1BC,EAA4B,MAE5BC,EAAQ,IAGVC,EAAiB,cAEjB,OAAO,OAAW,MACpBA,EAAiB,OAAO,IAAI,aAAa,GAE3C,IAAMC,EAAaD,EAEbE,EAASf,EAAA,CAACgB,EAAQC,EAAKC,KAC3B,OAAO,eAAeF,EAAQC,EAAK,CAAC,MAA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CAAY,EAOjD,IAAMC,EAAW,IAAIC,GAAU,CAC7B,UAAUC,EAAeC,EAAWC,EAAU,CAC5C,GAAI,CAACF,EAAM,SAAS,EAAI,EAAG,CACzBE,EAAS,OAAWF,CAAK,EACzB,MACF,CAEA,IAAMG,EAAgB,OAAO,MAAMH,EAAM,MAAM,EAC3CI,EAAI,EACR,QAAWC,KAAQL,EACbK,IAAS,KACXF,EAAcC,GAAG,EAAIC,GAIzBH,EAAS,OAAWC,EAAc,SAAS,EAAGC,CAAC,CAAC,CAClD,CACF,CAAC,EAED,aAAME,GAAS,EAAA5B,QAAG,iBAAiBU,CAAY,EAAGU,EAAUJ,CAAI,EAEzD,CAAE,KAAMA,EAAK,OAAO,KAAK,EAAG,YAAAG,CAAY,CACjD,EA1Ca,QA4Cb,SAASjB,EAAcD,EAA6C,CAClE,MAAO,CAAC,CAACA,GAAS,OAAOA,GAAU,UAAY,SAAUA,GAASA,EAAM,OAAS,QACnF,CAFSb,EAAAc,EAAA,iBAIT,SAASC,GAAcF,EAA6C,CAClE,MAAO,CAAC,CAACA,GAAS,OAAOA,GAAU,UAAY,SAAUA,GAASA,EAAM,OAAS,QACnF,CAFSb,EAAAe,GAAA,iBAUF,IAAMW,GAAgB1B,EAACa,GAAyB,CACrD,GAAI,CAAAC,EAAcD,CAAK,EAGvB,MAAMA,CACR,EAL6B",
4
+ "sourcesContent": ["// A simple implementation of make-array\nfunction makeArray (subject) {\n return Array.isArray(subject)\n ? subject\n : [subject]\n}\n\nconst UNDEFINED = undefined\nconst EMPTY = ''\nconst SPACE = ' '\nconst ESCAPE = '\\\\'\nconst REGEX_TEST_BLANK_LINE = /^\\s+$/\nconst REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\\\]|^)\\\\$/\nconst REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\\\!/\nconst REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\\\#/\nconst REGEX_SPLITALL_CRLF = /\\r?\\n/g\n\n// Invalid:\n// - /foo,\n// - ./foo,\n// - ../foo,\n// - .\n// - ..\n// Valid:\n// - .foo\nconst REGEX_TEST_INVALID_PATH = /^\\.{0,2}\\/|^\\.{1,2}$/\n\nconst REGEX_TEST_TRAILING_SLASH = /\\/$/\n\nconst SLASH = '/'\n\n// Do not use ternary expression here, since \"istanbul ignore next\" is buggy\nlet TMP_KEY_IGNORE = 'node-ignore'\n/* istanbul ignore else */\nif (typeof Symbol !== 'undefined') {\n TMP_KEY_IGNORE = Symbol.for('node-ignore')\n}\nconst KEY_IGNORE = TMP_KEY_IGNORE\n\nconst define = (object, key, value) => {\n Object.defineProperty(object, key, {value})\n return value\n}\n\nconst REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g\n\nconst RETURN_FALSE = () => false\n\n// Sanitize the range of a regular expression\n// The cases are complicated, see test cases for details\nconst sanitizeRange = range => range.replace(\n REGEX_REGEXP_RANGE,\n (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0)\n ? match\n // Invalid range (out of order) which is ok for gitignore rules but\n // fatal for JavaScript regular expression, so eliminate it.\n : EMPTY\n)\n\n// See fixtures #59\nconst cleanRangeBackSlash = slashes => {\n const {length} = slashes\n return slashes.slice(0, length - length % 2)\n}\n\n// > If the pattern ends with a slash,\n// > it is removed for the purpose of the following description,\n// > but it would only find a match with a directory.\n// > In other words, foo/ will match a directory foo and paths underneath it,\n// > but will not match a regular file or a symbolic link foo\n// > (this is consistent with the way how pathspec works in general in Git).\n// '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'\n// -> ignore-rules will not deal with it, because it costs extra `fs.stat` call\n// you could use option `mark: true` with `glob`\n\n// '`foo/`' should not continue with the '`..`'\nconst REPLACERS = [\n\n [\n // Remove BOM\n // TODO:\n // Other similar zero-width characters?\n /^\\uFEFF/,\n () => EMPTY\n ],\n\n // > Trailing spaces are ignored unless they are quoted with backslash (\"\\\")\n [\n // (a\\ ) -> (a )\n // (a ) -> (a)\n // (a ) -> (a)\n // (a \\ ) -> (a )\n /((?:\\\\\\\\)*?)(\\\\?\\s+)$/,\n (_, m1, m2) => m1 + (\n m2.indexOf('\\\\') === 0\n ? SPACE\n : EMPTY\n )\n ],\n\n // Replace (\\ ) with ' '\n // (\\ ) -> ' '\n // (\\\\ ) -> '\\\\ '\n // (\\\\\\ ) -> '\\\\ '\n [\n /(\\\\+?)\\s/g,\n (_, m1) => {\n const {length} = m1\n return m1.slice(0, length - length % 2) + SPACE\n }\n ],\n\n // Escape metacharacters\n // which is written down by users but means special for regular expressions.\n\n // > There are 12 characters with special meanings:\n // > - the backslash \\,\n // > - the caret ^,\n // > - the dollar sign $,\n // > - the period or dot .,\n // > - the vertical bar or pipe symbol |,\n // > - the question mark ?,\n // > - the asterisk or star *,\n // > - the plus sign +,\n // > - the opening parenthesis (,\n // > - the closing parenthesis ),\n // > - and the opening square bracket [,\n // > - the opening curly brace {,\n // > These special characters are often called \"metacharacters\".\n [\n /[\\\\$.|*+(){^]/g,\n match => `\\\\${match}`\n ],\n\n [\n // > a question mark (?) matches a single character\n /(?!\\\\)\\?/g,\n () => '[^/]'\n ],\n\n // leading slash\n [\n\n // > A leading slash matches the beginning of the pathname.\n // > For example, \"/*.c\" matches \"cat-file.c\" but not \"mozilla-sha1/sha1.c\".\n // A leading slash matches the beginning of the pathname\n /^\\//,\n () => '^'\n ],\n\n // replace special metacharacter slash after the leading slash\n [\n /\\//g,\n () => '\\\\/'\n ],\n\n [\n // > A leading \"**\" followed by a slash means match in all directories.\n // > For example, \"**/foo\" matches file or directory \"foo\" anywhere,\n // > the same as pattern \"foo\".\n // > \"**/foo/bar\" matches file or directory \"bar\" anywhere that is directly\n // > under directory \"foo\".\n // Notice that the '*'s have been replaced as '\\\\*'\n /^\\^*\\\\\\*\\\\\\*\\\\\\//,\n\n // '**/foo' <-> 'foo'\n () => '^(?:.*\\\\/)?'\n ],\n\n // starting\n [\n // there will be no leading '/'\n // (which has been replaced by section \"leading slash\")\n // If starts with '**', adding a '^' to the regular expression also works\n /^(?=[^^])/,\n function startingReplacer () {\n // If has a slash `/` at the beginning or middle\n return !/\\/(?!$)/.test(this)\n // > Prior to 2.22.1\n // > If the pattern does not contain a slash /,\n // > Git treats it as a shell glob pattern\n // Actually, if there is only a trailing slash,\n // git also treats it as a shell glob pattern\n\n // After 2.22.1 (compatible but clearer)\n // > If there is a separator at the beginning or middle (or both)\n // > of the pattern, then the pattern is relative to the directory\n // > level of the particular .gitignore file itself.\n // > Otherwise the pattern may also match at any level below\n // > the .gitignore level.\n ? '(?:^|\\\\/)'\n\n // > Otherwise, Git treats the pattern as a shell glob suitable for\n // > consumption by fnmatch(3)\n : '^'\n }\n ],\n\n // two globstars\n [\n // Use lookahead assertions so that we could match more than one `'/**'`\n /\\\\\\/\\\\\\*\\\\\\*(?=\\\\\\/|$)/g,\n\n // Zero, one or several directories\n // should not use '*', or it will be replaced by the next replacer\n\n // Check if it is not the last `'/**'`\n (_, index, str) => index + 6 < str.length\n\n // case: /**/\n // > A slash followed by two consecutive asterisks then a slash matches\n // > zero or more directories.\n // > For example, \"a/**/b\" matches \"a/b\", \"a/x/b\", \"a/x/y/b\" and so on.\n // '/**/'\n ? '(?:\\\\/[^\\\\/]+)*'\n\n // case: /**\n // > A trailing `\"/**\"` matches everything inside.\n\n // #21: everything inside but it should not include the current folder\n : '\\\\/.+'\n ],\n\n // normal intermediate wildcards\n [\n // Never replace escaped '*'\n // ignore rule '\\*' will match the path '*'\n\n // 'abc.*/' -> go\n // 'abc.*' -> skip this rule,\n // coz trailing single wildcard will be handed by [trailing wildcard]\n /(^|[^\\\\]+)(\\\\\\*)+(?=.+)/g,\n\n // '*.js' matches '.js'\n // '*.js' doesn't match 'abc'\n (_, p1, p2) => {\n // 1.\n // > An asterisk \"*\" matches anything except a slash.\n // 2.\n // > Other consecutive asterisks are considered regular asterisks\n // > and will match according to the previous rules.\n const unescaped = p2.replace(/\\\\\\*/g, '[^\\\\/]*')\n return p1 + unescaped\n }\n ],\n\n [\n // unescape, revert step 3 except for back slash\n // For example, if a user escape a '\\\\*',\n // after step 3, the result will be '\\\\\\\\\\\\*'\n /\\\\\\\\\\\\(?=[$.|*+(){^])/g,\n () => ESCAPE\n ],\n\n [\n // '\\\\\\\\' -> '\\\\'\n /\\\\\\\\/g,\n () => ESCAPE\n ],\n\n [\n // > The range notation, e.g. [a-zA-Z],\n // > can be used to match one of the characters in a range.\n\n // `\\` is escaped by step 3\n /(\\\\)?\\[([^\\]/]*?)(\\\\*)($|\\])/g,\n (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE\n // '\\\\[bar]' -> '\\\\\\\\[bar\\\\]'\n ? `\\\\[${range}${cleanRangeBackSlash(endEscape)}${close}`\n : close === ']'\n ? endEscape.length % 2 === 0\n // A normal case, and it is a range notation\n // '[bar]'\n // '[bar\\\\\\\\]'\n ? `[${sanitizeRange(range)}${endEscape}]`\n // Invalid range notaton\n // '[bar\\\\]' -> '[bar\\\\\\\\]'\n : '[]'\n : '[]'\n ],\n\n // ending\n [\n // 'js' will not match 'js.'\n // 'ab' will not match 'abc'\n /(?:[^*])$/,\n\n // WTF!\n // https://git-scm.com/docs/gitignore\n // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)\n // which re-fixes #24, #38\n\n // > If there is a separator at the end of the pattern then the pattern\n // > will only match directories, otherwise the pattern can match both\n // > files and directories.\n\n // 'js*' will not match 'a.js'\n // 'js/' will not match 'a.js'\n // 'js' will match 'a.js' and 'a.js/'\n match => /\\/$/.test(match)\n // foo/ will not match 'foo'\n ? `${match}$`\n // foo matches 'foo' and 'foo/'\n : `${match}(?=$|\\\\/$)`\n ]\n]\n\nconst REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\\\\/)?\\\\\\*$/\nconst MODE_IGNORE = 'regex'\nconst MODE_CHECK_IGNORE = 'checkRegex'\nconst UNDERSCORE = '_'\n\nconst TRAILING_WILD_CARD_REPLACERS = {\n [MODE_IGNORE] (_, p1) {\n const prefix = p1\n // '\\^':\n // '/*' does not match EMPTY\n // '/*' does not match everything\n\n // '\\\\\\/':\n // 'abc/*' does not match 'abc/'\n ? `${p1}[^/]+`\n\n // 'a*' matches 'a'\n // 'a*' matches 'aa'\n : '[^/]*'\n\n return `${prefix}(?=$|\\\\/$)`\n },\n\n [MODE_CHECK_IGNORE] (_, p1) {\n // When doing `git check-ignore`\n const prefix = p1\n // '\\\\\\/':\n // 'abc/*' DOES match 'abc/' !\n ? `${p1}[^/]*`\n\n // 'a*' matches 'a'\n // 'a*' matches 'aa'\n : '[^/]*'\n\n return `${prefix}(?=$|\\\\/$)`\n }\n}\n\n// @param {pattern}\nconst makeRegexPrefix = pattern => REPLACERS.reduce(\n (prev, [matcher, replacer]) =>\n prev.replace(matcher, replacer.bind(pattern)),\n pattern\n)\n\nconst isString = subject => typeof subject === 'string'\n\n// > A blank line matches no files, so it can serve as a separator for readability.\nconst checkPattern = pattern => pattern\n && isString(pattern)\n && !REGEX_TEST_BLANK_LINE.test(pattern)\n && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern)\n\n // > A line starting with # serves as a comment.\n && pattern.indexOf('#') !== 0\n\nconst splitPattern = pattern => pattern\n.split(REGEX_SPLITALL_CRLF)\n.filter(Boolean)\n\nclass IgnoreRule {\n constructor (\n pattern,\n mark,\n body,\n ignoreCase,\n negative,\n prefix\n ) {\n this.pattern = pattern\n this.mark = mark\n this.negative = negative\n\n define(this, 'body', body)\n define(this, 'ignoreCase', ignoreCase)\n define(this, 'regexPrefix', prefix)\n }\n\n get regex () {\n const key = UNDERSCORE + MODE_IGNORE\n\n if (this[key]) {\n return this[key]\n }\n\n return this._make(MODE_IGNORE, key)\n }\n\n get checkRegex () {\n const key = UNDERSCORE + MODE_CHECK_IGNORE\n\n if (this[key]) {\n return this[key]\n }\n\n return this._make(MODE_CHECK_IGNORE, key)\n }\n\n _make (mode, key) {\n const str = this.regexPrefix.replace(\n REGEX_REPLACE_TRAILING_WILDCARD,\n\n // It does not need to bind pattern\n TRAILING_WILD_CARD_REPLACERS[mode]\n )\n\n const regex = this.ignoreCase\n ? new RegExp(str, 'i')\n : new RegExp(str)\n\n return define(this, key, regex)\n }\n}\n\nconst createRule = ({\n pattern,\n mark\n}, ignoreCase) => {\n let negative = false\n let body = pattern\n\n // > An optional prefix \"!\" which negates the pattern;\n if (body.indexOf('!') === 0) {\n negative = true\n body = body.substr(1)\n }\n\n body = body\n // > Put a backslash (\"\\\") in front of the first \"!\" for patterns that\n // > begin with a literal \"!\", for example, `\"\\!important!.txt\"`.\n .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!')\n // > Put a backslash (\"\\\") in front of the first hash for patterns that\n // > begin with a hash.\n .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#')\n\n const regexPrefix = makeRegexPrefix(body)\n\n return new IgnoreRule(\n pattern,\n mark,\n body,\n ignoreCase,\n negative,\n regexPrefix\n )\n}\n\nclass RuleManager {\n constructor (ignoreCase) {\n this._ignoreCase = ignoreCase\n this._rules = []\n }\n\n _add (pattern) {\n // #32\n if (pattern && pattern[KEY_IGNORE]) {\n this._rules = this._rules.concat(pattern._rules._rules)\n this._added = true\n return\n }\n\n if (isString(pattern)) {\n pattern = {\n pattern\n }\n }\n\n if (checkPattern(pattern.pattern)) {\n const rule = createRule(pattern, this._ignoreCase)\n this._added = true\n this._rules.push(rule)\n }\n }\n\n // @param {Array<string> | string | Ignore} pattern\n add (pattern) {\n this._added = false\n\n makeArray(\n isString(pattern)\n ? splitPattern(pattern)\n : pattern\n ).forEach(this._add, this)\n\n return this._added\n }\n\n // Test one single path without recursively checking parent directories\n //\n // - checkUnignored `boolean` whether should check if the path is unignored,\n // setting `checkUnignored` to `false` could reduce additional\n // path matching.\n // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`\n\n // @returns {TestResult} true if a file is ignored\n test (path, checkUnignored, mode) {\n let ignored = false\n let unignored = false\n let matchedRule\n\n this._rules.forEach(rule => {\n const {negative} = rule\n\n // | ignored : unignored\n // -------- | ---------------------------------------\n // negative | 0:0 | 0:1 | 1:0 | 1:1\n // -------- | ------- | ------- | ------- | --------\n // 0 | TEST | TEST | SKIP | X\n // 1 | TESTIF | SKIP | TEST | X\n\n // - SKIP: always skip\n // - TEST: always test\n // - TESTIF: only test if checkUnignored\n // - X: that never happen\n if (\n unignored === negative && ignored !== unignored\n || negative && !ignored && !unignored && !checkUnignored\n ) {\n return\n }\n\n const matched = rule[mode].test(path)\n\n if (!matched) {\n return\n }\n\n ignored = !negative\n unignored = negative\n\n matchedRule = negative\n ? UNDEFINED\n : rule\n })\n\n const ret = {\n ignored,\n unignored\n }\n\n if (matchedRule) {\n ret.rule = matchedRule\n }\n\n return ret\n }\n}\n\nconst throwError = (message, Ctor) => {\n throw new Ctor(message)\n}\n\nconst checkPath = (path, originalPath, doThrow) => {\n if (!isString(path)) {\n return doThrow(\n `path must be a string, but got \\`${originalPath}\\``,\n TypeError\n )\n }\n\n // We don't know if we should ignore EMPTY, so throw\n if (!path) {\n return doThrow(`path must not be empty`, TypeError)\n }\n\n // Check if it is a relative path\n if (checkPath.isNotRelative(path)) {\n const r = '`path.relative()`d'\n return doThrow(\n `path should be a ${r} string, but got \"${originalPath}\"`,\n RangeError\n )\n }\n\n return true\n}\n\nconst isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path)\n\ncheckPath.isNotRelative = isNotRelative\n\n// On windows, the following function will be replaced\n/* istanbul ignore next */\ncheckPath.convert = p => p\n\n\nclass Ignore {\n constructor ({\n ignorecase = true,\n ignoreCase = ignorecase,\n allowRelativePaths = false\n } = {}) {\n define(this, KEY_IGNORE, true)\n\n this._rules = new RuleManager(ignoreCase)\n this._strictPathCheck = !allowRelativePaths\n this._initCache()\n }\n\n _initCache () {\n // A cache for the result of `.ignores()`\n this._ignoreCache = Object.create(null)\n\n // A cache for the result of `.test()`\n this._testCache = Object.create(null)\n }\n\n add (pattern) {\n if (this._rules.add(pattern)) {\n // Some rules have just added to the ignore,\n // making the behavior changed,\n // so we need to re-initialize the result cache\n this._initCache()\n }\n\n return this\n }\n\n // legacy\n addPattern (pattern) {\n return this.add(pattern)\n }\n\n // @returns {TestResult}\n _test (originalPath, cache, checkUnignored, slices) {\n const path = originalPath\n // Supports nullable path\n && checkPath.convert(originalPath)\n\n checkPath(\n path,\n originalPath,\n this._strictPathCheck\n ? throwError\n : RETURN_FALSE\n )\n\n return this._t(path, cache, checkUnignored, slices)\n }\n\n checkIgnore (path) {\n // If the path doest not end with a slash, `.ignores()` is much equivalent\n // to `git check-ignore`\n if (!REGEX_TEST_TRAILING_SLASH.test(path)) {\n return this.test(path)\n }\n\n const slices = path.split(SLASH).filter(Boolean)\n slices.pop()\n\n if (slices.length) {\n const parent = this._t(\n slices.join(SLASH) + SLASH,\n this._testCache,\n true,\n slices\n )\n\n if (parent.ignored) {\n return parent\n }\n }\n\n return this._rules.test(path, false, MODE_CHECK_IGNORE)\n }\n\n _t (\n // The path to be tested\n path,\n\n // The cache for the result of a certain checking\n cache,\n\n // Whether should check if the path is unignored\n checkUnignored,\n\n // The path slices\n slices\n ) {\n if (path in cache) {\n return cache[path]\n }\n\n if (!slices) {\n // path/to/a.js\n // ['path', 'to', 'a.js']\n slices = path.split(SLASH).filter(Boolean)\n }\n\n slices.pop()\n\n // If the path has no parent directory, just test it\n if (!slices.length) {\n return cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE)\n }\n\n const parent = this._t(\n slices.join(SLASH) + SLASH,\n cache,\n checkUnignored,\n slices\n )\n\n // If the path contains a parent directory, check the parent first\n return cache[path] = parent.ignored\n // > It is not possible to re-include a file if a parent directory of\n // > that file is excluded.\n ? parent\n : this._rules.test(path, checkUnignored, MODE_IGNORE)\n }\n\n ignores (path) {\n return this._test(path, this._ignoreCache, false).ignored\n }\n\n createFilter () {\n return path => !this.ignores(path)\n }\n\n filter (paths) {\n return makeArray(paths).filter(this.createFilter())\n }\n\n // @returns {TestResult}\n test (path) {\n return this._test(path, this._testCache, true)\n }\n}\n\nconst factory = options => new Ignore(options)\n\nconst isPathValid = path =>\n checkPath(path && checkPath.convert(path), path, RETURN_FALSE)\n\n/* istanbul ignore next */\nconst setupWindows = () => {\n /* eslint no-control-regex: \"off\" */\n const makePosix = str => /^\\\\\\\\\\?\\\\/.test(str)\n || /[\"<>|\\u0000-\\u001F]+/u.test(str)\n ? str\n : str.replace(/\\\\/g, '/')\n\n checkPath.convert = makePosix\n\n // 'C:\\\\foo' <- 'C:\\\\foo' has been converted to 'C:/'\n // 'd:\\\\foo'\n const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\\//i\n checkPath.isNotRelative = path =>\n REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path)\n || isNotRelative(path)\n}\n\n\n// Windows\n// --------------------------------------------------------------\n/* istanbul ignore next */\nif (\n // Detect `process` so that it can run in browsers.\n typeof process !== 'undefined'\n && process.platform === 'win32'\n) {\n setupWindows()\n}\n\n// COMMONJS_EXPORTS ////////////////////////////////////////////////////////////\n\nmodule.exports = factory\n\n// Although it is an anti-pattern,\n// it is still widely misused by a lot of libraries in github\n// Ref: https://github.com/search?q=ignore.default%28%29&type=code\nfactory.default = factory\n\nmodule.exports.isPathValid = isPathValid\n\n// For testing purposes\ndefine(module.exports, Symbol.for('setupWindows'), setupWindows)\n", "/*!\n * normalize-path <https://github.com/jonschlinkert/normalize-path>\n *\n * Copyright (c) 2014-2018, Jon Schlinkert.\n * Released under the MIT License.\n */\n\nmodule.exports = function(path, stripTrailing) {\n if (typeof path !== 'string') {\n throw new TypeError('expected path to be a string');\n }\n\n if (path === '\\\\' || path === '/') return '/';\n\n var len = path.length;\n if (len <= 1) return path;\n\n // ensure that win32 namespaces has two leading slashes, so that the path is\n // handled properly by the win32 version of path.parse() after being normalized\n // https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces\n var prefix = '';\n if (len > 4 && path[3] === '\\\\') {\n var ch = path[2];\n if ((ch === '?' || ch === '.') && path.slice(0, 2) === '\\\\\\\\') {\n path = path.slice(2);\n prefix = '//';\n }\n }\n\n var segs = path.split(/[/\\\\]+/);\n if (stripTrailing !== false && segs[segs.length - 1] === '') {\n segs.pop();\n }\n return prefix + segs.join('/');\n};\n", "import assert from \"node:assert\";\nimport { createHash } from \"node:crypto\";\nimport path from \"node:path\";\nimport { Transform } from \"node:stream\";\nimport { pipeline } from \"node:stream/promises\";\n\n/* eslint-disable func-style */\n/**\n * DO NOT MODIFY\n *\n * Everything in this file also exists in gadget to ensure that this logic\n * is the same between the two projects.\n */\nimport fs from \"fs-extra\";\nimport type { Ignore } from \"ignore\";\nimport ignore from \"ignore\";\nimport normalizePath from \"normalize-path\";\n\n/**\n * Paths that are never ignored, regardless of the contents of the `.ignore` file.\n */\nexport const NEVER_IGNORE_PATHS = [\".gadget/\"] as const;\n\n/**\n * Paths that are always ignored, regardless of the contents of the `.ignore` file.\n */\nexport const ALWAYS_IGNORE_PATHS = [\".DS_Store\", \"node_modules\", \".git\", \".shopify\"] as const;\n\n/**\n * Paths that are ignored when hashing the directory.\n *\n * NOTE: This is the _only_ thing that is allowed to be different between gadget and ggt.\n */\nexport const HASHING_IGNORE_PATHS = [\".gadget/sync.json\", \".gadget/dev-lock.json\", \".gadget/backup\", \"yarn-error.log\"] as const;\n\n/**\n * Represents a directory that is being synced.\n */\nexport class Directory {\n /**\n * A gitignore-style file parser used to determine which files to\n * ignore while syncing.\n *\n * @see https://www.npmjs.com/package/ignore\n */\n private _ignorer!: Ignore;\n\n /**\n * Whether the directory is currently being hashed.\n */\n private _isHashing = false;\n\n /**\n * Timestamp of the last {@linkcode loadIgnoreFile} call, used to\n * deduplicate redundant reloads from duplicate FSEvents.\n */\n private _lastIgnoreFileLoadTime = 0;\n\n private constructor(\n /**\n * An absolute path to the directory that is being synced.\n */\n readonly path: string,\n ) {}\n\n /**\n * Initializes a directory to be synced.\n *\n * If the directory does not exist, it is created.\n *\n * @param dir - The directory to initialize.\n * @returns A Promise that resolves to a Directory instance.\n */\n static async init(dir: string): Promise<Directory> {\n const directory = new Directory(dir);\n await directory.loadIgnoreFile();\n // don't count the init call as a recent load \u2014 the timestamp is\n // only meaningful once the file watcher is running\n directory._lastIgnoreFileLoadTime = 0;\n return directory;\n }\n\n /**\n * Returns the relative path from this directory to the specified path.\n *\n * @param to - The path to which the relative path is calculated.\n * @returns The relative path from this directory to the specified path.\n */\n relative(to: string): string {\n if (!path.isAbsolute(to)) {\n // the filepath is already relative\n return to;\n }\n\n return path.relative(this.path, to);\n }\n\n /**\n * Returns the absolute path by resolving the given path segments\n * relative to the directory path.\n *\n * @param pathSegments - The path segments to resolve.\n * @returns The absolute path.\n */\n absolute(...pathSegments: string[]): string {\n const result = path.resolve(this.path, ...pathSegments);\n assert(result.startsWith(this.path), `expected ${result} to be within ${this.path}`);\n return result;\n }\n\n /**\n * Similar to {@linkcode relative} in that it converts an absolute\n * path into a relative one from {@linkcode path}. However, it also\n * changes any slashes to be posix/unix-like forward slashes,\n * condenses repeated slashes into a single slash, and adds a trailing\n * slash if the path is a directory.\n *\n * This is used when sending files to Gadget to ensure that the paths\n * are consistent across platforms.\n *\n * @see https://www.npmjs.com/package/normalize-path\n */\n normalize(filepath: string, isDirectory: boolean): string {\n if (path.isAbsolute(filepath)) {\n filepath = this.relative(filepath);\n }\n\n // true = trim trailing slashes\n filepath = normalizePath(filepath, true);\n\n if (isDirectory) {\n filepath += \"/\";\n }\n\n return filepath;\n }\n\n /**\n * Loads the `.ignore` file in the directory. If the file does not\n * exist, it is silently ignored.\n */\n async loadIgnoreFile(): Promise<void> {\n this._lastIgnoreFileLoadTime = Date.now();\n this._ignorer = ignore();\n this._ignorer.add(ALWAYS_IGNORE_PATHS);\n\n try {\n const content = await fs.readFile(this.absolute(\".ignore\"), \"utf8\");\n this._ignorer.add(content);\n } catch (error) {\n if (isEnoentError(error) || isEisdirError(error)) {\n // ignore missing or is-directory errors\n return;\n }\n throw error;\n }\n }\n\n /**\n * Returns true if {@linkcode loadIgnoreFile} was called within the\n * given duration. Used to skip redundant watcher-triggered reloads\n * when a remote write already loaded the ignore file.\n */\n ignoreFileLoadedWithin(duration: number): boolean {\n return Date.now() - this._lastIgnoreFileLoadTime < duration;\n }\n\n /**\n * Determines if a file should be ignored based on its filepath.\n *\n * @param filepath - The filepath of the file to check.\n * @returns True if the file should be ignored, false otherwise.\n */\n ignores(filepath: string, isDirectory: boolean): boolean {\n filepath = this.relative(filepath);\n if (filepath === \"\") {\n // don't ignore the root dir\n return false;\n }\n\n if (filepath.startsWith(\"..\")) {\n // anything above the root dir is ignored\n return true;\n }\n\n // false = don't trim trailing slashes\n filepath = normalizePath(filepath, false);\n\n if (isDirectory && !filepath.endsWith(\"/\")) {\n filepath += \"/\";\n }\n\n if (this._isHashing && HASHING_IGNORE_PATHS.some((ignored) => filepath.startsWith(ignored))) {\n // special case for hashing\n return true;\n }\n\n if (NEVER_IGNORE_PATHS.some((neverIgnored) => filepath.startsWith(neverIgnored))) {\n // special case for never ignored paths\n return false;\n }\n\n return this._ignorer.ignores(filepath);\n }\n\n /**\n * Recursively walks through the directory and yields all non-ignored\n * files and directories within it.\n *\n * @yields - The normalized path of each file and directory.\n */\n async *walk({ dir = this.path } = {}): AsyncGenerator<string> {\n // don't yield the root directory\n if (dir !== this.path) {\n yield this.normalize(dir, true);\n }\n\n for await (const entry of await fs.opendir(dir)) {\n const filepath = path.join(dir, entry.name);\n if (this.ignores(filepath, entry.isDirectory())) {\n continue;\n }\n\n if (entry.isDirectory()) {\n yield* this.walk({ dir: filepath });\n } else if (entry.isFile()) {\n yield this.normalize(filepath, false);\n }\n }\n }\n\n /**\n * Calculates the hash of each file and directory and returns an\n * object containing the hashes keyed by the normalized file path.\n *\n * @returns A Promise that resolves to an object containing the hashes\n * of each file.\n */\n async hashes(): Promise<Hashes> {\n try {\n this._isHashing = true;\n const files = {} as Hashes;\n\n for await (const normalizedPath of this.walk()) {\n const absolutePath = this.absolute(normalizedPath);\n files[normalizedPath] = await hash(absolutePath);\n }\n\n return files;\n } finally {\n this._isHashing = false;\n }\n }\n\n async hasFiles(): Promise<boolean> {\n return !(await this.isEmptyOrNonExistent());\n }\n\n async isEmptyOrNonExistent(): Promise<boolean> {\n let isEmptyOrNonExistent = true;\n try {\n for await (const _ of this.walk()) {\n isEmptyOrNonExistent = false;\n break;\n }\n } catch (error) {\n swallowEnoent(error);\n }\n return isEmptyOrNonExistent;\n }\n}\n\n/**\n * Key/value pairs where the key is the normalized path and the value is\n * the result of {@linkcode hash} for that path.\n */\nexport type Hashes = Record<string, Hash>;\n\nexport type Hash = {\n /**\n * The SHA-1 hash of the file or directory.\n *\n * If the path points to a directory, the hash is calculated based on\n * the directory's basename. If the path points to a file, the hash is\n * calculated based on the file's basename and contents.\n */\n sha1: string;\n\n /**\n * The Unix-style file permissions of the file or directory, or\n * undefined if the platform that generated this hash doesn't support\n * them.\n *\n * @example 0o644\n * @see supportsPermissions\n */\n permissions?: number;\n};\n\n/**\n * Whether the current platform supports Unix-style file permissions.\n *\n * Windows doesn't support Unix-style file permissions and all file\n * permissions retrieved via `node:fs` on Windows are translated to 666\n * or 444.\n */\nexport const supportsPermissions = process.platform === \"linux\" || process.platform === \"darwin\";\n\n/**\n * Calculates the {@linkcode Hash} of the file or directory at the\n * specified absolute path.\n *\n * @param absolutePath - The absolute path to the file or directory.\n * @returns A Promise that resolves to the {@linkcode Hash} of the file\n * or directory.\n */\nconst hash = async (absolutePath: string): Promise<Hash> => {\n const sha1 = createHash(\"sha1\");\n sha1.update(path.basename(absolutePath));\n\n const stats = await fs.stat(absolutePath);\n\n let permissions;\n if (supportsPermissions) {\n // strip everything but the permissions\n permissions = stats.mode & 0o777;\n }\n\n if (stats.isDirectory()) {\n return { sha1: sha1.digest(\"hex\"), permissions };\n }\n\n // windows uses CRLF line endings whereas unix uses LF line endings so\n // we always strip out CR bytes (0x0d) when hashing files. this does\n // make us blind to files that only differ by CR bytes, but that's a\n // tradeoff we're willing to make.\n const removeCR = new Transform({\n transform(chunk: Buffer, _encoding, callback) {\n if (!chunk.includes(0x0d)) {\n callback(undefined, chunk);\n return;\n }\n\n const filteredChunk = Buffer.alloc(chunk.length);\n let i = 0;\n for (const byte of chunk) {\n if (byte !== 0x0d) {\n filteredChunk[i++] = byte;\n }\n }\n\n callback(undefined, filteredChunk.subarray(0, i));\n },\n });\n\n await pipeline(fs.createReadStream(absolutePath), removeCR, sha1);\n\n return { sha1: sha1.digest(\"hex\"), permissions };\n};\n\nfunction isEnoentError(error: unknown): error is { code: \"ENOENT\" } {\n return !!error && typeof error === \"object\" && \"code\" in error && error.code === \"ENOENT\";\n}\n\nfunction isEisdirError(error: unknown): error is { code: \"EISDIR\" } {\n return !!error && typeof error === \"object\" && \"code\" in error && error.code === \"EISDIR\";\n}\n\n/**\n * Swallows ENOENT errors and throws any other errors.\n *\n * @param error - The error to handle.\n * @throws The original error if it is not an ENOENT error.\n */\nexport const swallowEnoent = (error: unknown): void => {\n if (isEnoentError(error)) {\n return;\n }\n throw error;\n};\n"],
5
+ "mappings": "gGAAA,IAAAA,EAAAC,EAAA,CAAAC,GAAAC,IAAA,CAAAC,IACA,SAASC,EAAWC,EAAS,CAC3B,OAAO,MAAM,QAAQA,CAAO,EACxBA,EACA,CAACA,CAAO,CACd,CAJSC,EAAAF,EAAA,aAMT,IAAMG,EAAY,OACZC,EAAQ,GACRC,EAAQ,IACRC,EAAS,KACTC,EAAwB,QACxBC,EAAmC,iBACnCC,EAA4C,OAC5CC,EAAqC,OACrCC,EAAsB,SAUtBC,EAA0B,uBAE1BC,EAA4B,MAE5BC,EAAQ,IAGVC,EAAiB,cAEjB,OAAO,OAAW,MACpBA,EAAiB,OAAO,IAAI,aAAa,GAE3C,IAAMC,EAAaD,EAEbE,EAASf,EAAA,CAACgB,EAAQC,EAAKC,KAC3B,OAAO,eAAeF,EAAQC,EAAK,CAAC,MAAAC,CAAK,CAAC,EACnCA,GAFM,UAKTC,GAAqB,mBAErBC,EAAepB,EAAA,IAAM,GAAN,gBAIfqB,GAAgBrB,EAAAsB,G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AS,EAAI,EAAG,CACzBE,EAAS,OAAWF,CAAK,EACzB,MACF,CAEA,IAAMG,EAAgB,OAAO,MAAMH,EAAM,MAAM,EAC3CI,EAAI,EACR,QAAWC,KAAQL,EACbK,IAAS,KACXF,EAAcC,GAAG,EAAIC,GAIzBH,EAAS,OAAWC,EAAc,SAAS,EAAGC,CAAC,CAAC,CAClD,CACF,CAAC,EAED,aAAME,GAAS,EAAA5B,QAAG,iBAAiBU,CAAY,EAAGU,EAAUJ,CAAI,EAEzD,CAAE,KAAMA,EAAK,OAAO,KAAK,EAAG,YAAAG,CAAY,CACjD,EA1Ca,QA4Cb,SAASjB,EAAcD,EAA6C,CAClE,MAAO,CAAC,CAACA,GAAS,OAAOA,GAAU,UAAY,SAAUA,GAASA,EAAM,OAAS,QACnF,CAFSb,EAAAc,EAAA,iBAIT,SAASC,GAAcF,EAA6C,CAClE,MAAO,CAAC,CAACA,GAAS,OAAOA,GAAU,UAAY,SAAUA,GAASA,EAAM,OAAS,QACnF,CAFSb,EAAAe,GAAA,iBAUF,IAAMW,GAAgB1B,EAACa,GAAyB,CACrD,GAAI,CAAAC,EAAcD,CAAK,EAGvB,MAAMA,CACR,EAL6B",
6
6
  "names": ["require_ignore", "__commonJSMin", "exports", "module", "init_cjs", "makeArray", "subject", "__name", "UNDEFINED", "EMPTY", "SPACE", "ESCAPE", "REGEX_TEST_BLANK_LINE", "REGEX_INVALID_TRAILING_BACKSLASH", "REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION", "REGEX_REPLACE_LEADING_EXCAPED_HASH", "REGEX_SPLITALL_CRLF", "REGEX_TEST_INVALID_PATH", "REGEX_TEST_TRAILING_SLASH", "SLASH", "TMP_KEY_IGNORE", "KEY_IGNORE", "define", "object", "key", "value", "REGEX_REGEXP_RANGE", "RETURN_FALSE", "sanitizeRange", "range", "match", "from", "to", "cleanRangeBackSlash", "slashes", "length", "REPLACERS", "_", "m1", "m2", "index", "str", "p1", "p2", "unescaped", "leadEscape", "endEscape", "close", "REGEX_REPLACE_TRAILING_WILDCARD", "MODE_IGNORE", "MODE_CHECK_IGNORE", "UNDERSCORE", "TRAILING_WILD_CARD_REPLACERS", "makeRegexPrefix", "pattern", "prev", "matcher", "replacer", "isString", "checkPattern", "splitPattern", "IgnoreRule", "mark", "body", "ignoreCase", "negative", "prefix", "mode", "regex", "createRule", "regexPrefix", "RuleManager", "rule", "path", "checkUnignored", "ignored", "unignored", "matchedRule", "ret", "throwError", "message", "Ctor", "checkPath", "originalPath", "doThrow", "isNotRelative", "p", "Ignore", "ignorecase", "allowRelativePaths", "cache", "slices", "parent", "paths", "factory", "options", "isPathValid", "setupWindows", "makePosix", "REGEX_TEST_WINDOWS_PATH_ABSOLUTE", "require_normalize_path", "__commonJSMin", "exports", "module", "init_cjs", "path", "stripTrailing", "len", "prefix", "ch", "segs", "init_cjs", "import_fs_extra", "import_ignore", "import_normalize_path", "assert", "createHash", "path", "Transform", "pipeline", "NEVER_IGNORE_PATHS", "ALWAYS_IGNORE_PATHS", "HASHING_IGNORE_PATHS", "Directory", "_Directory", "path", "__name", "dir", "directory", "to", "pathSegments", "result", "assert", "filepath", "isDirectory", "normalizePath", "ignore", "content", "fs", "error", "isEnoentError", "isEisdirError", "duration", "ignored", "neverIgnored", "entry", "files", "normalizedPath", "absolutePath", "hash", "isEmptyOrNonExistent", "_", "swallowEnoent", "supportsPermissions", "sha1", "createHash", "stats", "permissions", "removeCR", "Transform", "chunk", "_encoding", "callback", "filteredChunk", "i", "byte", "pipeline"]
7
7
  }
@@ -1,4 +1,4 @@
1
- import{a as i,b as s,c as g}from"./chunk-SVWK2NXG.js";import{b as n}from"./chunk-WB6O2V5D.js";import"./chunk-DR4CXBD6.js";import"./chunk-HCULGPBH.js";import"./chunk-OUIZQC4D.js";import{ra as a,ta as r}from"./chunk-JG2QCDK2.js";import{a as o,h as t}from"./chunk-7DYQUG5M.js";t();var c=o(e=>{n({json:e,headers:["Option","Configured Value"],rows:[["telemetry",String(e.telemetry)],["json",String(e.json)]],borders:"thick"})},"printDefaultsConfig"),m=o(e=>a`
1
+ import{a as i,b as s,c as g}from"./chunk-FE5O5VX4.js";import{b as n}from"./chunk-WZ2PO6H2.js";import"./chunk-F6BGQ4LG.js";import"./chunk-72J7X5LR.js";import"./chunk-X4XSYLCE.js";import{ra as a,ta as r}from"./chunk-ALSXPCRD.js";import{a as o,h as t}from"./chunk-7DYQUG5M.js";t();var c=o(e=>{n({json:e,headers:["Option","Configured Value"],rows:[["telemetry",String(e.telemetry)],["json",String(e.json)]],borders:"thick"})},"printDefaultsConfig"),m=o(e=>a`
2
2
  Make changes to the configured defaults. This allows you to set an option on every ggt command by default without
3
3
  needing to set a flag on every command.
4
4
 
@@ -9,4 +9,4 @@ import{a as i,b as s,c as g}from"./chunk-SVWK2NXG.js";import{b as n}from"./chunk
9
9
 
10
10
  ggt configure clear
11
11
  `,"usage"),h=o(async(e,f)=>{switch(f._[0]){case"show":c(await s(e,!1));break;case"change":await i(e);break;case"clear":await g(e);break;default:r(m(e));return}},"run");export{h as run,m as usage};
12
- //# sourceMappingURL=configure-UJS7V2JX.js.map
12
+ //# sourceMappingURL=configure-PYRXYNGZ.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/commands/configure.ts"],
4
+ "sourcesContent": ["import type { Run, Usage } from \"../services/command/command.js\";\nimport { clearDefaultsConfig, type DefaultsConfigData, loadDefaultsConfig, promptDefaultsConfig } from \"../services/config/defaults.js\";\nimport { println } from \"../services/output/print.js\";\nimport { sprint } from \"../services/output/sprint.js\";\nimport { printTable } from \"../services/output/table.js\";\n\nconst printDefaultsConfig = (defaults: DefaultsConfigData): void => {\n printTable({\n json: defaults,\n headers: [\"Option\", \"Configured Value\"],\n rows: [\n [\"telemetry\", String(defaults.telemetry)],\n [\"json\", String(defaults.json)],\n ],\n borders: \"thick\",\n });\n};\n\nexport const usage: Usage = (_ctx) => {\n return sprint`\n Make changes to the configured defaults. This allows you to set an option on every ggt command by default without\n needing to set a flag on every command.\n\n {gray Usage}\n ggt configure show\n \n ggt configure change\n \n ggt configure clear\n `;\n};\n\nexport const run: Run = async (ctx, args): Promise<void> => {\n switch (args._[0]) {\n case \"show\":\n printDefaultsConfig(await loadDefaultsConfig(ctx, false));\n break;\n case \"change\":\n await promptDefaultsConfig(ctx);\n break;\n case \"clear\":\n await clearDefaultsConfig(ctx);\n break;\n default:\n println(usage(ctx));\n return;\n }\n};\n"],
5
+ "mappings": "kRAAAA,IAMA,IAAMC,EAAsBC,EAACC,GAAuC,CAClEC,EAAW,CACT,KAAMD,EACN,QAAS,CAAC,SAAU,kBAAkB,EACtC,KAAM,CACJ,CAAC,YAAa,OAAOA,EAAS,SAAS,CAAC,EACxC,CAAC,OAAQ,OAAOA,EAAS,IAAI,CAAC,CAChC,EACA,QAAS,OACX,CAAC,CACH,EAV4B,uBAYfE,EAAeH,EAACI,GACpBC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IADmB,SAcfC,EAAWN,EAAA,MAAOO,EAAKC,IAAwB,CAC1D,OAAQA,EAAK,EAAE,CAAC,EAAG,CACjB,IAAK,OACHT,EAAoB,MAAMU,EAAmBF,EAAK,EAAK,CAAC,EACxD,MACF,IAAK,SACH,MAAMG,EAAqBH,CAAG,EAC9B,MACF,IAAK,QACH,MAAMI,EAAoBJ,CAAG,EAC7B,MACF,QACEK,EAAQT,EAAMI,CAAG,CAAC,EAClB,MACJ,CACF,EAfwB",
6
+ "names": ["init_cjs", "printDefaultsConfig", "__name", "defaults", "printTable", "usage", "_ctx", "sprint", "run", "ctx", "args", "loadDefaultsConfig", "promptDefaultsConfig", "clearDefaultsConfig", "println"]
7
+ }
@@ -1,4 +1,4 @@
1
- import{b as H}from"./chunk-JKZNSRLU.js";import{n as U,o as T,r as E}from"./chunk-XC4F2TLW.js";import"./chunk-T6UHSWMT.js";import"./chunk-DR4CXBD6.js";import"./chunk-ZYDMXS5R.js";import{I as A,M,c as $,q as D,r as p,s as W}from"./chunk-442CSROP.js";import"./chunk-F255O64V.js";import{c as h}from"./chunk-HCULGPBH.js";import"./chunk-OUIZQC4D.js";import{b as u,ha as P,ra as f,ta as d}from"./chunk-JG2QCDK2.js";import"./chunk-GFQYFEEH.js";import{a as c,h as I}from"./chunk-7DYQUG5M.js";I();import{randomUUID as V}from"node:crypto";import{existsSync as l,mkdirSync as N,readFileSync as b,writeFileSync as J}from"node:fs";import{createServer as q}from"node:http";import y from"node:path";import B,{nextTick as G}from"node:process";var L="Starting ggt debugger",j="ggt debugger running on",ue={...U,...A,"--port":{type:Number,alias:["-p"]},"--configure":{type:String}},m=["vscode","cursor"],he=c(r=>f`
1
+ import{b as H}from"./chunk-577KP32Z.js";import{p as U,q as T,u as E}from"./chunk-ULJYEUQG.js";import"./chunk-2HJS3KFB.js";import"./chunk-F6BGQ4LG.js";import"./chunk-ZYDMXS5R.js";import{$ as A,K as D,L as p,M as W,d as $,da as M}from"./chunk-IQSZEOYY.js";import"./chunk-GZTHIOXS.js";import{c as h}from"./chunk-72J7X5LR.js";import"./chunk-X4XSYLCE.js";import{b as u,ha as P,ra as f,ta as d}from"./chunk-ALSXPCRD.js";import"./chunk-GFQYFEEH.js";import{a as c,h as I}from"./chunk-7DYQUG5M.js";I();import{randomUUID as V}from"node:crypto";import{existsSync as l,mkdirSync as N,readFileSync as b,writeFileSync as J}from"node:fs";import{createServer as q}from"node:http";import y from"node:path";import B,{nextTick as G}from"node:process";var L="Starting ggt debugger",j="ggt debugger running on",ue={...U,...A,"--port":{type:Number,alias:["-p"]},"--configure":{type:String}},m=["vscode","cursor"],he=c(r=>f`
2
2
  Start a Chrome DevTools Protocol proxy server that connects to the Gadget debugger.
3
3
  This allows you to debug your Gadget app using VS Code, Chrome DevTools, or any other
4
4
  CDP-compatible debugger client.
@@ -38,4 +38,4 @@ Connection: close\r
38
38
  `),e.destroy()}_acceptUpgrade(e,t,n){!this._wsServer||!this._sessionManager||this._wsServer.handleUpgrade(e,t,n,o=>{this._ctx.log.info("client websocket upgraded, establishing remote connection"),this._handleClientConnection(o)})}async _handleClientConnection(e){if(!this._sessionManager)return;let t=new x(this._ctx,e,this._sessionManager);try{let n=await this._establishRemoteConnection();t.connectToRemote(n),this._sessionManager.setActiveConnection(e)}catch(n){this._ctx.log.error("error establishing remote debugger connection",{error:n}),t.closeWithError("Failed to establish remote debugger connection")}}async _establishRemoteConnection(){let e=await M({context:{ctx:this._ctx},method:"POST",url:`https://${this._subdomain}.${P.domains.app}/edit/api/debugger/start-session`,headers:{...this._authHeaders,"x-gadget-debugger-session-id":this._sessionId},responseType:"json",resolveBodyOnly:!0});return this._ctx.log.debug("debugger session created",{session:e}),await new w(this._ctx,{wsUrl:e.wsUrl,sessionId:this._sessionId,authHeaders:this._authHeaders}).connect()}async _listen(){this._httpServer&&await new Promise((e,t)=>{let n=this._httpServer;if(!n){t(new Error("HTTP server is not initialized"));return}n.listen(this._port,"127.0.0.1",()=>{this._ctx.log.info("debugger proxy server listening",{port:this._port}),e()}),n.on("error",t)})}},C=class{static{c(this,"DebuggerSessionManager")}_ctx;_activeConnection;_isConnecting=!1;constructor(e){this._ctx=e}get hasActiveConnection(){return!!this._activeConnection&&this._activeConnection.readyState===p.default.OPEN}get isConnecting(){return this._isConnecting}setActiveConnection(e){this._activeConnection=e,this._isConnecting=!1}clearActiveConnection(){this._activeConnection=void 0}clearStaleConnection(){this._activeConnection&&(this._ctx.log.debug("clearing stale connection reference"),this._activeConnection=void 0)}startConnecting(){this._isConnecting=!0}stopConnecting(){this._isConnecting=!1}},x=class{static{c(this,"ClientConnection")}_ctx;_clientWs;_sessionManager;_messageQueue=[];_remoteWs;_remoteReady=!1;constructor(e,t,n){this._ctx=e,this._clientWs=t,this._sessionManager=n,this._setupClientHandlers()}connectToRemote(e){this._remoteWs=e,this._setupRemoteHandlers(),this._flushMessageQueue()}closeWithError(e){this._sessionManager.stopConnecting(),this._clientWs.close(1011,e)}_setupClientHandlers(){this._clientWs.on("message",(e,t)=>{this._handleClientMessage(e,t)}),this._clientWs.on("error",e=>{this._ctx.log.error("client websocket error",{error:e.message,stack:e.stack}),this._remoteWs?.close()}),this._clientWs.on("close",()=>{this._ctx.log.info("client websocket closed"),this._sessionManager.clearActiveConnection(),this._remoteWs?.close()})}_handleClientMessage(e,t){let n=t?"<binary data>":String(e);this._ctx.log.trace("received message from client",{message:n}),this._remoteReady&&this._remoteWs?this._remoteWs.send(e,{binary:t}):this._messageQueue.push({data:e,isBinary:t})}_setupRemoteHandlers(){this._remoteWs&&(this._remoteWs.on("message",(e,t)=>{let n=t?"<binary data>":String(e);this._ctx.log.trace("received message from remote debugger",{message:n}),this._clientWs.send(e,{binary:t})}),this._remoteWs.on("error",e=>{this._ctx.log.error("remote debugger error",{error:e.message,stack:e.stack}),this._clientWs.close(1011,"Remote debugger connection error, please reconnect")}),this._remoteWs.on("close",()=>{this._ctx.log.info("remote debugger connection closed"),this._clientWs.close(1011,"Remote debugger connection closed by server, please reconnect")}),this._remoteReady=!0)}_flushMessageQueue(){if(this._remoteWs){this._ctx.log.debug("remote debugger connected, flushing message queue",{queueLength:this._messageQueue.length});for(let{data:e,isBinary:t}of this._messageQueue)this._remoteWs.send(e,{binary:t});this._messageQueue.length=0}}},w=class{static{c(this,"RemoteDebuggerConnection")}_ctx;_wsUrl;_sessionId;_authHeaders;constructor(e,t){this._ctx=e,this._wsUrl=t.wsUrl,this._sessionId=t.sessionId,this._authHeaders=t.authHeaders}async connect(){let e,t,n=!1,o=new Promise((s,a)=>{e=s,t=a}),i=new p.default(this._wsUrl,{headers:{...this._authHeaders,"x-gadget-debugger-session-id":this._sessionId}});return i.on("open",()=>{this._ctx.log.debug("connected to remote debugger"),!n&&(n=!0,e())}),i.on("error",s=>{this._ctx.log.error("remote debugger error",{error:s.message,stack:s.stack}),n||t(s)}),i.readyState===p.default.OPEN&&G(()=>{e()}),await o,i}},v=class{static{c(this,"DebuggerConfigurator")}_vscodeDir;constructor(e){this._vscodeDir=y.join(e,".vscode")}get launchJsonPath(){return y.join(this._vscodeDir,"launch.json")}get tasksJsonPath(){return y.join(this._vscodeDir,"tasks.json")}hasLaunchConfiguration(){if(!l(this.launchJsonPath))return!1;try{return(JSON.parse(b(this.launchJsonPath,"utf-8")).configurations??[]).some(n=>n.name==="Gadget debugger")}catch{return!1}}configure(e){l(this._vscodeDir)||N(this._vscodeDir,{recursive:!0}),this._configureLaunch(e),this._configureTasks()}_configureLaunch(e){let t={type:"node",request:"attach",name:"Gadget debugger",address:"127.0.0.1",port:e,localRoot:"${workspaceFolder}",remoteRoot:"/gadget/app",preLaunchTask:"ggt debugger",restart:!0,timeout:6e4},n;if(l(this.launchJsonPath)){let o=b(this.launchJsonPath,"utf-8"),i=JSON.parse(o),s=i.configurations??[],a=s.findIndex(k=>k.name==="Gadget debugger");a>=0?s[a]=t:s.push(t),n={version:i.version,configurations:s}}else n={version:"0.2.0",configurations:[t]};J(this.launchJsonPath,JSON.stringify(n,void 0,2)+`
39
39
  `,"utf-8")}_configureTasks(){let e={label:"ggt debugger",type:"shell",command:"ggt debugger",isBackground:!0,problemMatcher:{pattern:{regexp:"^$"},background:{activeOnStart:!0,beginsPattern:L,endsPattern:j}}},t;if(l(this.tasksJsonPath)){let n=b(this.tasksJsonPath,"utf-8"),o=JSON.parse(n),i=o.tasks??[],s=i.findIndex(a=>a.label==="ggt debugger");s>=0?i[s]=e:i.push(e),t={version:o.version,tasks:i}}else t={version:"2.0.0",tasks:[e]};J(this.tasksJsonPath,JSON.stringify(t,void 0,2)+`
40
40
  `,"utf-8")}};export{ue as args,pe as run,he as usage};
41
- //# sourceMappingURL=debugger-QN2MCLBL.js.map
41
+ //# sourceMappingURL=debugger-VKLUEWIN.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/commands/debugger.ts"],
4
+ "sourcesContent": ["import { randomUUID } from \"node:crypto\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport type { Server as HttpServer, IncomingMessage, ServerResponse } from \"node:http\";\nimport { createServer } from \"node:http\";\nimport path from \"node:path\";\nimport process, { nextTick } from \"node:process\";\nimport type { Duplex } from \"node:stream\";\n\nimport chalk from \"chalk\";\nimport { WebSocket, WebSocketServer, type RawData } from \"ws\";\n\nimport { AppIdentity, AppIdentityArgs } from \"../services/command/app-identity.js\";\nimport type { ArgsDefinition } from \"../services/command/arg.js\";\nimport type { Run, Usage } from \"../services/command/command.js\";\nimport type { Context } from \"../services/command/context.js\";\nimport { config } from \"../services/config/config.js\";\nimport { loadSyncJsonDirectory } from \"../services/filesync/sync-json.js\";\nimport { loadAuthHeaders } from \"../services/http/auth.js\";\nimport { http } from \"../services/http/http.js\";\nimport { LoggingArgs } from \"../services/output/log/structured.js\";\nimport { println } from \"../services/output/print.js\";\nimport { reportErrorAndExit } from \"../services/output/report.js\";\nimport { spin } from \"../services/output/spinner.js\";\nimport { sprint } from \"../services/output/sprint.js\";\nimport { symbol } from \"../services/output/symbols.js\";\n\nexport type DebuggerArgs = typeof args;\n\nconst StartingMessage = \"Starting ggt debugger\";\nconst RunningMessage = \"ggt debugger running on\";\n\nexport const args = {\n ...AppIdentityArgs,\n ...LoggingArgs,\n \"--port\": {\n type: Number,\n alias: [\"-p\"],\n },\n \"--configure\": {\n type: String,\n },\n} satisfies ArgsDefinition;\n\nconst SupportedEditors = [\"vscode\", \"cursor\"] as const;\n\nexport const usage: Usage = (_ctx) => {\n return sprint`\n Start a Chrome DevTools Protocol proxy server that connects to the Gadget debugger.\n This allows you to debug your Gadget app using VS Code, Chrome DevTools, or any other\n CDP-compatible debugger client.\n\n {gray Usage}\n $ ggt debugger [DIRECTORY] [options]\n\n DIRECTORY: The directory containing your Gadget app (default: current directory)\n\n {gray Options}\n -a, --app <app_name> Selects the app to debug. Defaults to the app synced to the current directory, if there is one.\n -e, --env <env_name> Selects the environment to debug. Defaults to the environment synced to the current directory, if there is one.\n -p, --port <port> Local port for the inspector proxy (default: 9229)\n --configure <editor> Configure debugger for ${SupportedEditors.join(\", \")}\n\n {gray Examples}\n start debugger proxy for current environment\n {cyanBright $ ggt debugger}\n\n use a custom port\n {cyanBright $ ggt debugger --port 9230}\n\n debug a specific app and environment\n {cyanBright $ ggt debugger --app myApp --env development}\n\n configure VS Code debugger\n {cyanBright $ ggt debugger --configure vscode}\n `;\n};\n\ntype DebuggerSessionResponse = {\n wsUrl: string;\n lease: {\n sessionId: string;\n startedAt: string;\n expiresAt: string;\n };\n};\n\nexport const run: Run<DebuggerArgs> = async (ctx, args) => {\n const directory = await loadSyncJsonDirectory(args._[0] || process.cwd());\n const appIdentity = await AppIdentity.load(ctx, { command: \"debugger\", args, directory });\n\n // Handle --configure option\n if (args[\"--configure\"]) {\n const editor = args[\"--configure\"].toLowerCase();\n if (!SupportedEditors.includes(editor as (typeof SupportedEditors)[number])) {\n throw new Error(`Invalid editor \"${args[\"--configure\"]}\". Supported editors: ${SupportedEditors.join(\", \")}`);\n }\n\n const configurator = new DebuggerConfigurator(directory.path);\n const port = args[\"--port\"] ?? 9229;\n configurator.configure(port);\n\n println({\n ensureEmptyLineAbove: true,\n content: chalk.green(`${symbol.tick} Configured ${editor} debugger`),\n });\n println({\n content: sprint`\n Added configuration to:\n \u2022 ${configurator.launchJsonPath}\n \u2022 ${configurator.tasksJsonPath}\n\n You can now start debugging by running the \"Gadget debugger\" launch configuration.\n `,\n });\n return;\n }\n\n const spinner = spin(`${StartingMessage} for ${appIdentity.environment.name} environment`);\n ctx.log.info(\"debugger command started\");\n\n ctx.log.trace(\"sync json loaded\", {\n app: appIdentity.environment.application.slug,\n environment: appIdentity.environment.name,\n });\n\n const authHeaders = loadAuthHeaders(ctx);\n const port = args[\"--port\"] ?? 9229;\n const sessionId = randomUUID();\n\n // Check if VS Code launch configuration exists\n const configurator = new DebuggerConfigurator(directory.path);\n if (!configurator.hasLaunchConfiguration()) {\n ctx.log.warn(\"vscode/cursor debugger configuration not found\");\n println({\n ensureEmptyLineAbove: true,\n content: chalk.yellow(\n `\u26A0 Gadget debugger not configured. Run \"${chalk.bold(`ggt debugger --configure ${SupportedEditors[0]}`)}\" to set up.`,\n ),\n });\n }\n\n const proxy = new DebuggerProxy(ctx, {\n appIdentity,\n authHeaders,\n sessionId,\n port,\n });\n\n try {\n await proxy.start();\n\n spinner.succeed();\n println({ ensureEmptyLineAbove: true, content: chalk.green(`${symbol.tick} ${RunningMessage} ws://localhost:${port}/${sessionId}`) });\n println({ content: chalk.gray(\"Press Ctrl+C to stop\") });\n\n await new Promise<void>((resolve) => {\n ctx.onAbort(() => {\n ctx.log.info(\"abort signal received\");\n resolve();\n });\n });\n\n proxy.stop();\n println({ ensureEmptyLineAbove: true, content: `${symbol.tick} Proxy server stopped` });\n } catch (error) {\n ctx.log.error(\"debugger command failed\", { error });\n await reportErrorAndExit(ctx, error);\n }\n};\n\ntype DebuggerProxyOptions = {\n appIdentity: AppIdentity;\n authHeaders: Record<string, string>;\n sessionId: string;\n port: number;\n};\n\n/**\n * Manages the local debugger proxy server that connects CDP clients to the remote Gadget debugger.\n */\nclass DebuggerProxy {\n private readonly _ctx: Context;\n private readonly _appIdentity: AppIdentity;\n private readonly _authHeaders: Record<string, string>;\n private readonly _sessionId: string;\n private readonly _port: number;\n private readonly _subdomain: string;\n\n private _httpServer?: HttpServer;\n private _wsServer?: WebSocketServer;\n private _sessionManager?: DebuggerSessionManager;\n\n constructor(ctx: Context, options: DebuggerProxyOptions) {\n this._ctx = ctx;\n this._appIdentity = options.appIdentity;\n this._authHeaders = options.authHeaders;\n this._sessionId = options.sessionId;\n this._port = options.port;\n this._subdomain = this._buildSubdomain();\n }\n\n async start(): Promise<void> {\n this._sessionManager = new DebuggerSessionManager(this._ctx);\n this._httpServer = this._createHttpServer();\n this._wsServer = new WebSocketServer({ noServer: true });\n\n this._httpServer.on(\"upgrade\", (request, socket, head) => {\n this._handleUpgrade(request, socket, head);\n });\n\n await this._listen();\n }\n\n stop(): void {\n this._ctx.log.debug(\"shutting down proxy server\");\n this._wsServer?.close();\n this._httpServer?.close();\n this._ctx.log.info(\"proxy server stopped\");\n }\n\n private _buildSubdomain(): string {\n const { application, name, type } = this._appIdentity.environment;\n return type === \"production\" ? application.slug : `${application.slug}--${name}`;\n }\n\n private _createHttpServer(): HttpServer {\n return createServer((req, res) => {\n const url = new URL(req.url ?? \"/\", `http://${req.headers.host}`);\n this._ctx.log.trace(\"debugger proxy http request received\", {\n method: req.method,\n rUrl: req.url,\n urlPathname: url.pathname,\n url: url.toString(),\n });\n\n try {\n if (url.pathname === \"/json/version\") {\n this._handleVersionRequest(res);\n } else if (url.pathname === \"/json/list\") {\n this._handleListRequest(res);\n } else {\n this._handleNotFound(res, url);\n }\n } catch (error) {\n this._handleError(res, error);\n }\n });\n }\n\n private _handleVersionRequest(res: ServerResponse): void {\n const versionPayload = {\n \"Protocol-Version\": \"1.1\",\n Browser: `node.js/${this._appIdentity.environment.nodeVersion}`,\n };\n this._ctx.log.trace(\"debugger proxy http version request payload\", { payload: versionPayload });\n res.setHeader(\"Content-Type\", \"application/json\");\n res.end(JSON.stringify(versionPayload));\n }\n\n private _handleListRequest(res: ServerResponse): void {\n const listPayload = [\n {\n id: this._sessionId,\n type: \"node\",\n title: \"ggt debugger\",\n description: `authenticated CDP proxy to current sandbox process for ${this._appIdentity.environment.application.slug}@${this._appIdentity.environment.name}`,\n faviconUrl: \"https://assets.gadget.dev/assets/environment/dev/favicon-32.png\",\n webSocketDebuggerUrl: `ws://127.0.0.1:${this._port}/${this._sessionId}`,\n },\n ];\n this._ctx.log.trace(\"debugger proxy http list request payload\", { payload: listPayload });\n res.setHeader(\"Content-Type\", \"application/json\");\n res.end(JSON.stringify(listPayload));\n }\n\n private _handleNotFound(res: ServerResponse, url: URL): void {\n this._ctx.log.warn(\"debugger proxy http request not found\", { url: url.toString() });\n res.statusCode = 404;\n res.end(\"Not Found\");\n }\n\n private _handleError(res: ServerResponse, error: unknown): void {\n this._ctx.log.error(\"error handling debugger proxy http request\", { error });\n res.statusCode = 500;\n res.end(\"Internal Server Error\");\n }\n\n private _handleUpgrade(request: IncomingMessage, socket: Duplex, head: Buffer): void {\n if (!this._sessionManager || !this._wsServer) {\n socket.destroy();\n return;\n }\n\n const url = new URL(request.url ?? \"/\", `http://${request.headers.host}`);\n this._ctx.log.trace(\"debugger proxy websocket upgrade request received\", {\n url: request.url,\n isConnecting: this._sessionManager.isConnecting,\n hasActiveConnection: this._sessionManager.hasActiveConnection,\n });\n\n if (url.pathname !== `/${this._sessionId}`) {\n socket.destroy();\n return;\n }\n\n if (this._sessionManager.hasActiveConnection || this._sessionManager.isConnecting) {\n this._ctx.log.debug(\"rejecting upgrade request\", {\n hasActiveConnection: this._sessionManager.hasActiveConnection,\n isConnecting: this._sessionManager.isConnecting,\n });\n this._rejectUpgrade(socket);\n return;\n }\n\n this._sessionManager.clearStaleConnection();\n this._acceptUpgrade(request, socket, head);\n }\n\n private _rejectUpgrade(socket: Duplex): void {\n const status = 409;\n const text = \"Another debugger session is already running for this environment\";\n socket.write(`HTTP/1.1 ${status} ${text}\\r\\nConnection: close\\r\\n\\r\\n`);\n socket.destroy();\n }\n\n private _acceptUpgrade(request: IncomingMessage, socket: Duplex, head: Buffer): void {\n if (!this._wsServer || !this._sessionManager) {\n return;\n }\n\n this._wsServer.handleUpgrade(request, socket, head, (clientWs) => {\n this._ctx.log.info(\"client websocket upgraded, establishing remote connection\");\n void this._handleClientConnection(clientWs);\n });\n }\n\n private async _handleClientConnection(clientWs: WebSocket): Promise<void> {\n if (!this._sessionManager) {\n return;\n }\n\n const connection = new ClientConnection(this._ctx, clientWs, this._sessionManager);\n\n try {\n const remoteWs = await this._establishRemoteConnection();\n connection.connectToRemote(remoteWs);\n this._sessionManager.setActiveConnection(clientWs);\n } catch (error) {\n this._ctx.log.error(\"error establishing remote debugger connection\", { error });\n connection.closeWithError(\"Failed to establish remote debugger connection\");\n }\n }\n\n private async _establishRemoteConnection(): Promise<WebSocket> {\n const session = await http<DebuggerSessionResponse>({\n context: { ctx: this._ctx },\n method: \"POST\",\n url: `https://${this._subdomain}.${config.domains.app}/edit/api/debugger/start-session`,\n headers: { ...this._authHeaders, \"x-gadget-debugger-session-id\": this._sessionId },\n responseType: \"json\",\n resolveBodyOnly: true,\n });\n\n this._ctx.log.debug(\"debugger session created\", { session });\n\n const remoteConnection = new RemoteDebuggerConnection(this._ctx, {\n wsUrl: session.wsUrl,\n sessionId: this._sessionId,\n authHeaders: this._authHeaders,\n });\n\n return await remoteConnection.connect();\n }\n\n private async _listen(): Promise<void> {\n if (!this._httpServer) {\n return;\n }\n\n await new Promise<void>((resolve, reject) => {\n const server = this._httpServer;\n if (!server) {\n reject(new Error(\"HTTP server is not initialized\"));\n return;\n }\n server.listen(this._port, \"127.0.0.1\", () => {\n this._ctx.log.info(\"debugger proxy server listening\", { port: this._port });\n resolve();\n });\n server.on(\"error\", reject);\n });\n }\n}\n\n/**\n * Manages the state of active debugger sessions and connections.\n */\nclass DebuggerSessionManager {\n private readonly _ctx: Context;\n private _activeConnection?: WebSocket;\n private _isConnecting = false;\n\n constructor(ctx: Context) {\n this._ctx = ctx;\n }\n\n get hasActiveConnection(): boolean {\n return !!this._activeConnection && this._activeConnection.readyState === WebSocket.OPEN;\n }\n\n get isConnecting(): boolean {\n return this._isConnecting;\n }\n\n setActiveConnection(ws: WebSocket): void {\n this._activeConnection = ws;\n this._isConnecting = false;\n }\n\n clearActiveConnection(): void {\n this._activeConnection = undefined;\n }\n\n clearStaleConnection(): void {\n if (this._activeConnection) {\n this._ctx.log.debug(\"clearing stale connection reference\");\n this._activeConnection = undefined;\n }\n }\n\n startConnecting(): void {\n this._isConnecting = true;\n }\n\n stopConnecting(): void {\n this._isConnecting = false;\n }\n}\n\n/**\n * Manages a client connection from a CDP debugger (VS Code, Chrome DevTools, etc).\n */\nclass ClientConnection {\n private readonly _ctx: Context;\n private readonly _clientWs: WebSocket;\n private readonly _sessionManager: DebuggerSessionManager;\n private readonly _messageQueue: { data: RawData; isBinary: boolean }[] = [];\n private _remoteWs?: WebSocket;\n private _remoteReady = false;\n\n constructor(ctx: Context, clientWs: WebSocket, sessionManager: DebuggerSessionManager) {\n this._ctx = ctx;\n this._clientWs = clientWs;\n this._sessionManager = sessionManager;\n this._setupClientHandlers();\n }\n\n connectToRemote(remoteWs: WebSocket): void {\n this._remoteWs = remoteWs;\n this._setupRemoteHandlers();\n this._flushMessageQueue();\n }\n\n closeWithError(reason: string): void {\n this._sessionManager.stopConnecting();\n this._clientWs.close(1011, reason);\n }\n\n private _setupClientHandlers(): void {\n this._clientWs.on(\"message\", (data: RawData, isBinary: boolean) => {\n this._handleClientMessage(data, isBinary);\n });\n\n this._clientWs.on(\"error\", (error: Error) => {\n this._ctx.log.error(\"client websocket error\", { error: error.message, stack: error.stack });\n this._remoteWs?.close();\n });\n\n this._clientWs.on(\"close\", () => {\n this._ctx.log.info(\"client websocket closed\");\n this._sessionManager.clearActiveConnection();\n this._remoteWs?.close();\n });\n }\n\n private _handleClientMessage(data: RawData, isBinary: boolean): void {\n // oxlint-disable-next-line no-base-to-string\n const messageString = isBinary ? \"<binary data>\" : String(data);\n this._ctx.log.trace(\"received message from client\", { message: messageString });\n\n if (this._remoteReady && this._remoteWs) {\n this._remoteWs.send(data, { binary: isBinary });\n } else {\n this._messageQueue.push({ data, isBinary });\n }\n }\n\n private _setupRemoteHandlers(): void {\n if (!this._remoteWs) {\n return;\n }\n\n this._remoteWs.on(\"message\", (data: RawData, isBinary: boolean) => {\n // oxlint-disable-next-line no-base-to-string\n const messageString = isBinary ? \"<binary data>\" : String(data);\n this._ctx.log.trace(\"received message from remote debugger\", { message: messageString });\n this._clientWs.send(data, { binary: isBinary });\n });\n\n this._remoteWs.on(\"error\", (error: Error) => {\n this._ctx.log.error(\"remote debugger error\", { error: error.message, stack: error.stack });\n this._clientWs.close(1011, \"Remote debugger connection error, please reconnect\");\n });\n\n this._remoteWs.on(\"close\", () => {\n this._ctx.log.info(\"remote debugger connection closed\");\n this._clientWs.close(1011, \"Remote debugger connection closed by server, please reconnect\");\n });\n\n this._remoteReady = true;\n }\n\n private _flushMessageQueue(): void {\n if (!this._remoteWs) {\n return;\n }\n\n this._ctx.log.debug(\"remote debugger connected, flushing message queue\", {\n queueLength: this._messageQueue.length,\n });\n\n for (const { data, isBinary } of this._messageQueue) {\n this._remoteWs.send(data, { binary: isBinary });\n }\n this._messageQueue.length = 0;\n }\n}\n\ntype RemoteDebuggerConnectionOptions = {\n wsUrl: string;\n sessionId: string;\n authHeaders: Record<string, string>;\n};\n\n/**\n * Manages a connection to the remote Gadget debugger WebSocket.\n */\nclass RemoteDebuggerConnection {\n private readonly _ctx: Context;\n private readonly _wsUrl: string;\n private readonly _sessionId: string;\n private readonly _authHeaders: Record<string, string>;\n\n constructor(ctx: Context, options: RemoteDebuggerConnectionOptions) {\n this._ctx = ctx;\n this._wsUrl = options.wsUrl;\n this._sessionId = options.sessionId;\n this._authHeaders = options.authHeaders;\n }\n\n async connect(): Promise<WebSocket> {\n let resolveConnection: () => void;\n let rejectConnection: (error: Error) => void;\n let connected = false;\n\n const connectionPromise = new Promise<void>((resolve, reject) => {\n resolveConnection = resolve;\n rejectConnection = reject;\n });\n\n const ws = new WebSocket(this._wsUrl, {\n headers: { ...this._authHeaders, \"x-gadget-debugger-session-id\": this._sessionId },\n });\n\n ws.on(\"open\", () => {\n this._ctx.log.debug(\"connected to remote debugger\");\n if (connected) {\n return;\n }\n connected = true;\n resolveConnection();\n });\n\n ws.on(\"error\", (error: Error) => {\n this._ctx.log.error(\"remote debugger error\", { error: error.message, stack: error.stack });\n if (!connected) {\n rejectConnection(error);\n }\n });\n\n if (ws.readyState === WebSocket.OPEN) {\n nextTick(() => {\n resolveConnection();\n });\n }\n\n await connectionPromise;\n\n return ws;\n }\n}\n\ntype VSCodeLaunchConfiguration = {\n type: string;\n request: string;\n name: string;\n address: string;\n port: number;\n localRoot: string;\n remoteRoot: string;\n preLaunchTask: string;\n restart: boolean;\n timeout: number;\n};\n\ntype VSCodeTask = {\n label: string;\n type: string;\n command: string;\n isBackground: boolean;\n problemMatcher: {\n pattern: { regexp: string };\n background: {\n activeOnStart: boolean;\n beginsPattern: string;\n endsPattern: string;\n };\n };\n};\n\n/**\n * Handles VS Code/Cursor debugger configuration setup.\n */\nclass DebuggerConfigurator {\n private readonly _vscodeDir: string;\n\n constructor(directory: string) {\n this._vscodeDir = path.join(directory, \".vscode\");\n }\n\n get launchJsonPath(): string {\n return path.join(this._vscodeDir, \"launch.json\");\n }\n\n get tasksJsonPath(): string {\n return path.join(this._vscodeDir, \"tasks.json\");\n }\n\n hasLaunchConfiguration(): boolean {\n if (!existsSync(this.launchJsonPath)) {\n return false;\n }\n\n try {\n const launchJson = JSON.parse(readFileSync(this.launchJsonPath, \"utf-8\")) as {\n configurations?: VSCodeLaunchConfiguration[];\n };\n const configurations = launchJson.configurations ?? [];\n return configurations.some((config) => config.name === \"Gadget debugger\");\n } catch {\n return false;\n }\n }\n\n configure(port: number): void {\n // Ensure .vscode directory exists\n if (!existsSync(this._vscodeDir)) {\n mkdirSync(this._vscodeDir, { recursive: true });\n }\n\n this._configureLaunch(port);\n this._configureTasks();\n }\n\n private _configureLaunch(port: number): void {\n const launchConfig: VSCodeLaunchConfiguration = {\n type: \"node\",\n request: \"attach\",\n name: \"Gadget debugger\",\n address: \"127.0.0.1\",\n port,\n localRoot: \"${workspaceFolder}\",\n remoteRoot: \"/gadget/app\",\n preLaunchTask: \"ggt debugger\",\n restart: true,\n timeout: 60000,\n };\n\n let launchJson: { version?: string; configurations: VSCodeLaunchConfiguration[] };\n\n if (existsSync(this.launchJsonPath)) {\n // Read existing launch.json\n const content = readFileSync(this.launchJsonPath, \"utf-8\");\n const parsed = JSON.parse(content) as { version?: string; configurations?: VSCodeLaunchConfiguration[] };\n\n // Ensure configurations array exists\n const configurations = parsed.configurations ?? [];\n\n // Check if configuration already exists\n const existingIndex = configurations.findIndex((config) => config.name === \"Gadget debugger\");\n\n if (existingIndex >= 0) {\n // Update existing configuration\n configurations[existingIndex] = launchConfig;\n } else {\n // Add new configuration\n configurations.push(launchConfig);\n }\n\n launchJson = {\n version: parsed.version,\n configurations,\n };\n } else {\n // Create new launch.json\n launchJson = {\n version: \"0.2.0\",\n configurations: [launchConfig],\n };\n }\n\n writeFileSync(this.launchJsonPath, JSON.stringify(launchJson, undefined, 2) + \"\\n\", \"utf-8\");\n }\n\n private _configureTasks(): void {\n const task: VSCodeTask = {\n label: \"ggt debugger\",\n type: \"shell\",\n command: \"ggt debugger\",\n isBackground: true,\n problemMatcher: {\n pattern: { regexp: \"^$\" },\n background: {\n activeOnStart: true,\n beginsPattern: StartingMessage,\n endsPattern: RunningMessage,\n },\n },\n };\n\n let tasksJson: { version?: string; tasks: VSCodeTask[] };\n\n if (existsSync(this.tasksJsonPath)) {\n // Read existing tasks.json\n const content = readFileSync(this.tasksJsonPath, \"utf-8\");\n const parsed = JSON.parse(content) as { version?: string; tasks?: VSCodeTask[] };\n\n // Ensure tasks array exists\n const tasks = parsed.tasks ?? [];\n\n // Check if task already exists\n const existingIndex = tasks.findIndex((t) => t.label === \"ggt debugger\");\n\n if (existingIndex >= 0) {\n // Update existing task\n tasks[existingIndex] = task;\n } else {\n // Add new task\n tasks.push(task);\n }\n\n tasksJson = {\n version: parsed.version,\n tasks,\n };\n } else {\n // Create new tasks.json\n tasksJson = {\n version: \"2.0.0\",\n tasks: [task],\n };\n }\n\n writeFileSync(this.tasksJsonPath, JSON.stringify(tasksJson, undefined, 2) + \"\\n\", \"utf-8\");\n }\n}\n"],
5
+ "mappings": "yeAAAA,IAAA,OAAS,cAAAC,MAAkB,cAC3B,OAAS,cAAAC,EAAY,aAAAC,EAAW,gBAAAC,EAAc,iBAAAC,MAAqB,UAEnE,OAAS,gBAAAC,MAAoB,YAC7B,OAAOC,MAAU,YACjB,OAAOC,GAAW,YAAAC,MAAgB,eAuBlC,IAAMC,EAAkB,wBAClBC,EAAiB,0BAEVC,GAAO,CAClB,GAAGC,EACH,GAAGC,EACH,SAA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"names": ["init_cjs", "randomUUID", "existsSync", "mkdirSync", "readFileSync", "writeFileSync", "createServer", "path", "process", "nextTick", "StartingMessage", "RunningMessage", "args", "AppIdentityArgs", "LoggingArgs", "SupportedEditors", "usage", "__name", "_ctx", "sprint", "run", "ctx", "directory", "loadSyncJsonDirectory", "process", "appIdentity", "AppIdentity", "editor", "configurator", "DebuggerConfigurator", "port", "println", "source_default", "symbol", "spinner", "spin", "authHeaders", "loadAuthHeaders", "sessionId", "randomUUID", "proxy", "DebuggerProxy", "resolve", "error", "reportErrorAndExit", "options", "DebuggerSessionManager", "WebSocketServer", "request", "socket", "head", "application", "name", "type", "createServer", "req", "res", "url", "versionPayload", "listPayload", "clientWs", "connection", "ClientConnection", "remoteWs", "session", "http", "config", "RemoteDebuggerConnection", "reject", "server", "WebSocket", "ws", "sessionManager", "reason", "data", "isBinary", "messageString", "resolveConnection", "rejectConnection", "connected", "connectionPromise", "nextTick", "path", "existsSync", "readFileSync", "mkdirSync", "launchConfig", "launchJson", "content", "parsed", "configurations", "existingIndex", "writeFileSync", "task", "tasksJson", "tasks", "t"]
7
+ }