@struktoai/mirage-browser 0.0.3-alpha.0 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (243) hide show
  1. package/README.md +1 -1
  2. package/dist/aliyun-YEWHEWCL.js +8 -0
  3. package/dist/backblaze-LWE2HEDK.js +8 -0
  4. package/dist/box-GTWWIB6F.js +8 -0
  5. package/dist/ceph-ATSCSVGU.js +8 -0
  6. package/dist/{chunk-YGRKFONX.js → chunk-23NO22WD.js} +1 -2
  7. package/dist/{chunk-YGRKFONX.js.map → chunk-23NO22WD.js.map} +1 -1
  8. package/dist/{chunk-TPFH5V4D.js → chunk-2R7SPBTM.js} +11 -13
  9. package/dist/chunk-2R7SPBTM.js.map +1 -0
  10. package/dist/{chunk-UZWJ462U.js → chunk-37WKCB2E.js} +8 -6
  11. package/dist/chunk-37WKCB2E.js.map +1 -0
  12. package/dist/{chunk-GHKX2BA3.js → chunk-3FZ3GHZO.js} +6 -4
  13. package/dist/chunk-3FZ3GHZO.js.map +1 -0
  14. package/dist/{chunk-SJB2KXDM.js → chunk-4YUYQTRN.js} +649 -424
  15. package/dist/chunk-4YUYQTRN.js.map +1 -0
  16. package/dist/{chunk-JCS5EG5A.js → chunk-5ZNWDS5I.js} +10 -12
  17. package/dist/chunk-5ZNWDS5I.js.map +1 -0
  18. package/dist/{chunk-N43C6XFP.js → chunk-6BXVYCIC.js} +10 -12
  19. package/dist/chunk-6BXVYCIC.js.map +1 -0
  20. package/dist/{chunk-INLL7LRM.js → chunk-6ETIHSTA.js} +10 -11
  21. package/dist/chunk-6ETIHSTA.js.map +1 -0
  22. package/dist/{chunk-RZRXEXHM.js → chunk-AAJQ6AQT.js} +11 -13
  23. package/dist/chunk-AAJQ6AQT.js.map +1 -0
  24. package/dist/{chunk-CAKSQ2LV.js → chunk-AUKVYHNZ.js} +6 -4
  25. package/dist/chunk-AUKVYHNZ.js.map +1 -0
  26. package/dist/{chunk-HGSTRD7H.js → chunk-AUXZEXCG.js} +12 -12
  27. package/dist/chunk-AUXZEXCG.js.map +1 -0
  28. package/dist/{chunk-SBAUYZJB.js → chunk-CQERQTAZ.js} +17 -14
  29. package/dist/chunk-CQERQTAZ.js.map +1 -0
  30. package/dist/{chunk-XFREXNA2.js → chunk-DC6VA36O.js} +9 -16
  31. package/dist/chunk-DC6VA36O.js.map +1 -0
  32. package/dist/{chunk-HYUESAQS.js → chunk-DGP3N4WM.js} +1 -2
  33. package/dist/{chunk-HYUESAQS.js.map → chunk-DGP3N4WM.js.map} +1 -1
  34. package/dist/{chunk-WEJGUCCL.js → chunk-DKPDXQML.js} +6 -4
  35. package/dist/chunk-DKPDXQML.js.map +1 -0
  36. package/dist/{chunk-2H4KUUFP.js → chunk-DQK6H5LW.js} +1 -2
  37. package/dist/{chunk-2H4KUUFP.js.map → chunk-DQK6H5LW.js.map} +1 -1
  38. package/dist/{chunk-T43CZ3IZ.js → chunk-E77ESWWV.js} +13 -13
  39. package/dist/chunk-E77ESWWV.js.map +1 -0
  40. package/dist/{chunk-WZ53HLH6.js → chunk-EDS5Q5B7.js} +6 -4
  41. package/dist/chunk-EDS5Q5B7.js.map +1 -0
  42. package/dist/{chunk-32VC36P4.js → chunk-EHTYPBGX.js} +6 -4
  43. package/dist/chunk-EHTYPBGX.js.map +1 -0
  44. package/dist/{chunk-72GY5B23.js → chunk-GENFT46X.js} +6 -4
  45. package/dist/chunk-GENFT46X.js.map +1 -0
  46. package/dist/{chunk-J54OBIJA.js → chunk-GQVJTQXU.js} +6 -2
  47. package/dist/chunk-GQVJTQXU.js.map +1 -0
  48. package/dist/{chunk-RJ5FBBL6.js → chunk-GZFNGV55.js} +6 -4
  49. package/dist/chunk-GZFNGV55.js.map +1 -0
  50. package/dist/{chunk-RD7ED27I.js → chunk-HPID7BWJ.js} +11 -13
  51. package/dist/chunk-HPID7BWJ.js.map +1 -0
  52. package/dist/{chunk-D3JDGGKO.js → chunk-HTQ4GBKM.js} +6 -4
  53. package/dist/chunk-HTQ4GBKM.js.map +1 -0
  54. package/dist/{chunk-RJ4RR3BR.js → chunk-JV4T5HNB.js} +6 -4
  55. package/dist/chunk-JV4T5HNB.js.map +1 -0
  56. package/dist/{chunk-EH2BN4JC.js → chunk-KL2VFYUV.js} +8 -6
  57. package/dist/chunk-KL2VFYUV.js.map +1 -0
  58. package/dist/{chunk-54NTYJEO.js → chunk-LPDLPRPS.js} +1 -3
  59. package/dist/{chunk-54NTYJEO.js.map → chunk-LPDLPRPS.js.map} +1 -1
  60. package/dist/{chunk-JVTKE6DB.js → chunk-LW56WZDS.js} +11 -13
  61. package/dist/chunk-LW56WZDS.js.map +1 -0
  62. package/dist/{chunk-63GZEZW4.js → chunk-MB4TUUJQ.js} +6 -4
  63. package/dist/chunk-MB4TUUJQ.js.map +1 -0
  64. package/dist/{chunk-O5ONB7QT.js → chunk-MQMUOJZ2.js} +8 -4
  65. package/dist/chunk-MQMUOJZ2.js.map +1 -0
  66. package/dist/{chunk-6K57U6CM.js → chunk-N5VRBFRT.js} +11 -13
  67. package/dist/chunk-N5VRBFRT.js.map +1 -0
  68. package/dist/{chunk-EUKHGXCE.js → chunk-NVGB3B7J.js} +6 -4
  69. package/dist/chunk-NVGB3B7J.js.map +1 -0
  70. package/dist/{chunk-D6HF462C.js → chunk-NYTRDAWX.js} +17 -14
  71. package/dist/chunk-NYTRDAWX.js.map +1 -0
  72. package/dist/{chunk-MO5DGX42.js → chunk-PCC6EZIE.js} +6 -4
  73. package/dist/chunk-PCC6EZIE.js.map +1 -0
  74. package/dist/{chunk-BUXWUKN7.js → chunk-PDZSZ5CB.js} +10 -12
  75. package/dist/chunk-PDZSZ5CB.js.map +1 -0
  76. package/dist/{chunk-4YJMDF2S.js → chunk-POJ3IQMQ.js} +14 -14
  77. package/dist/chunk-POJ3IQMQ.js.map +1 -0
  78. package/dist/{chunk-ATLYBQSC.js → chunk-PSEXJ5S5.js} +13 -12
  79. package/dist/chunk-PSEXJ5S5.js.map +1 -0
  80. package/dist/{chunk-NMZBJOFW.js → chunk-QXJP6TWI.js} +5 -4
  81. package/dist/chunk-QXJP6TWI.js.map +1 -0
  82. package/dist/{chunk-YEDSFMWK.js → chunk-TCFD6YJ5.js} +6 -4
  83. package/dist/chunk-TCFD6YJ5.js.map +1 -0
  84. package/dist/{chunk-CO4FMKOF.js → chunk-VASFK7V6.js} +6 -4
  85. package/dist/chunk-VASFK7V6.js.map +1 -0
  86. package/dist/{chunk-JSAQMYPK.js → chunk-ZLHC2CZ6.js} +1 -2
  87. package/dist/{chunk-JSAQMYPK.js.map → chunk-ZLHC2CZ6.js.map} +1 -1
  88. package/dist/config-22T7HJBJ.js +9 -0
  89. package/dist/config-A56HUM6C.js +9 -0
  90. package/dist/config-DIWQZBOK.js +9 -0
  91. package/dist/config-HGJ2MGAC.js +9 -0
  92. package/dist/{config-ET26F632.js → config-MHBKYS53.js} +2 -4
  93. package/dist/config-PAHALM2T.js +9 -0
  94. package/dist/config-PWZXYJOI.js +9 -0
  95. package/dist/{config-NV5WXP64.js → config-UU27ALAA.js} +2 -4
  96. package/dist/digitalocean-SQA6MJJQ.js +8 -0
  97. package/dist/discord-ASNFJP6A.js +7 -0
  98. package/dist/dropbox-VV2WZE6I.js +8 -0
  99. package/dist/gcs-2W6DDWM7.js +8 -0
  100. package/dist/gdocs-QPM7VXXE.js +8 -0
  101. package/dist/gdrive-KT6R7EVB.js +8 -0
  102. package/dist/github-3IFZGW6I.js +7 -0
  103. package/dist/github_ci-CKKF2Y4S.js +8 -0
  104. package/dist/gmail-HLZIMKQU.js +8 -0
  105. package/dist/gsheets-HF4YPIEF.js +8 -0
  106. package/dist/gslides-EV2JJH7I.js +8 -0
  107. package/dist/index.d.ts +46 -34
  108. package/dist/index.js +87 -83
  109. package/dist/index.js.map +1 -1
  110. package/dist/langfuse-74ZCR6QL.js +7 -0
  111. package/dist/linear-XABGTU6E.js +7 -0
  112. package/dist/minio-JPNSX2NP.js +8 -0
  113. package/dist/mongodb-YZP643ZU.js +7 -0
  114. package/dist/notion-YJOTGH7J.js +7 -0
  115. package/dist/oci-R4VYQKGJ.js +8 -0
  116. package/dist/opfs-4RWMJBCI.js +7 -0
  117. package/dist/postgres-HPOMN2AR.js +7 -0
  118. package/dist/qingstor-ZWWK2ZGV.js +8 -0
  119. package/dist/r2-PZAN2YFG.js +8 -0
  120. package/dist/{s3-GD2WKLWR.js → s3-CSFY3PLT.js} +2 -2
  121. package/dist/scaleway-BFROPDBB.js +8 -0
  122. package/dist/seaweedfs-X6THZT26.js +8 -0
  123. package/dist/slack-O7BTJ4YR.js +7 -0
  124. package/dist/supabase-PHN3MIXW.js +8 -0
  125. package/dist/tencent-JGCJEKHV.js +8 -0
  126. package/dist/trello-QUDOP3M2.js +7 -0
  127. package/dist/wasabi-5VMNAFOC.js +8 -0
  128. package/package.json +2 -3
  129. package/dist/aliyun-F2ORS3KZ.js +0 -8
  130. package/dist/backblaze-HOVWPSV7.js +0 -8
  131. package/dist/box-VJSE5N7P.js +0 -8
  132. package/dist/ceph-CQKQ4NWW.js +0 -8
  133. package/dist/chunk-32VC36P4.js.map +0 -1
  134. package/dist/chunk-4YJMDF2S.js.map +0 -1
  135. package/dist/chunk-63GZEZW4.js.map +0 -1
  136. package/dist/chunk-6K57U6CM.js.map +0 -1
  137. package/dist/chunk-72GY5B23.js.map +0 -1
  138. package/dist/chunk-ATLYBQSC.js.map +0 -1
  139. package/dist/chunk-BUXWUKN7.js.map +0 -1
  140. package/dist/chunk-CAKSQ2LV.js.map +0 -1
  141. package/dist/chunk-CO4FMKOF.js.map +0 -1
  142. package/dist/chunk-D3JDGGKO.js.map +0 -1
  143. package/dist/chunk-D6HF462C.js.map +0 -1
  144. package/dist/chunk-EH2BN4JC.js.map +0 -1
  145. package/dist/chunk-EUKHGXCE.js.map +0 -1
  146. package/dist/chunk-GHKX2BA3.js.map +0 -1
  147. package/dist/chunk-HGSTRD7H.js.map +0 -1
  148. package/dist/chunk-INLL7LRM.js.map +0 -1
  149. package/dist/chunk-J54OBIJA.js.map +0 -1
  150. package/dist/chunk-JCS5EG5A.js.map +0 -1
  151. package/dist/chunk-JVTKE6DB.js.map +0 -1
  152. package/dist/chunk-MO5DGX42.js.map +0 -1
  153. package/dist/chunk-N43C6XFP.js.map +0 -1
  154. package/dist/chunk-NMZBJOFW.js.map +0 -1
  155. package/dist/chunk-O5ONB7QT.js.map +0 -1
  156. package/dist/chunk-RD7ED27I.js.map +0 -1
  157. package/dist/chunk-RJ4RR3BR.js.map +0 -1
  158. package/dist/chunk-RJ5FBBL6.js.map +0 -1
  159. package/dist/chunk-RZRXEXHM.js.map +0 -1
  160. package/dist/chunk-SBAUYZJB.js.map +0 -1
  161. package/dist/chunk-SJB2KXDM.js.map +0 -1
  162. package/dist/chunk-T43CZ3IZ.js.map +0 -1
  163. package/dist/chunk-TPFH5V4D.js.map +0 -1
  164. package/dist/chunk-UZWJ462U.js.map +0 -1
  165. package/dist/chunk-WEJGUCCL.js.map +0 -1
  166. package/dist/chunk-WZ53HLH6.js.map +0 -1
  167. package/dist/chunk-XFREXNA2.js.map +0 -1
  168. package/dist/chunk-YEDSFMWK.js.map +0 -1
  169. package/dist/config-7IZCGWKX.js +0 -11
  170. package/dist/config-AT74FARJ.js +0 -11
  171. package/dist/config-C2AYHACT.js +0 -11
  172. package/dist/config-GHJOYNM6.js +0 -11
  173. package/dist/config-L55UXIF4.js +0 -11
  174. package/dist/config-V7BLK5WP.js +0 -11
  175. package/dist/digitalocean-KC7VIWZK.js +0 -8
  176. package/dist/discord-W3DSEXKN.js +0 -7
  177. package/dist/dropbox-GI273OVA.js +0 -8
  178. package/dist/gcs-WRQTU27E.js +0 -8
  179. package/dist/gdocs-EI2EFVKG.js +0 -8
  180. package/dist/gdrive-62HD67IP.js +0 -8
  181. package/dist/github-SWLYD3LS.js +0 -7
  182. package/dist/github_ci-7P7VGBKM.js +0 -8
  183. package/dist/gmail-B7HXHZ7D.js +0 -8
  184. package/dist/gsheets-OTBW2JWG.js +0 -8
  185. package/dist/gslides-MXSR4HRY.js +0 -8
  186. package/dist/langfuse-FWKU6E3F.js +0 -7
  187. package/dist/linear-SHVG3XVT.js +0 -7
  188. package/dist/minio-246KOHBJ.js +0 -8
  189. package/dist/mongodb-2ITJUDCF.js +0 -7
  190. package/dist/notion-BOBBSJSG.js +0 -7
  191. package/dist/oci-T7VREPQW.js +0 -8
  192. package/dist/opfs-3XNAXR5B.js +0 -7
  193. package/dist/postgres-CK4HWZSL.js +0 -7
  194. package/dist/qingstor-WIC27LS3.js +0 -8
  195. package/dist/r2-EAX6KHEI.js +0 -8
  196. package/dist/scaleway-OVFRZBKW.js +0 -8
  197. package/dist/seaweedfs-EOJVO432.js +0 -8
  198. package/dist/slack-RNXMU5OC.js +0 -7
  199. package/dist/supabase-VSUNLIJ6.js +0 -8
  200. package/dist/tencent-YYM5WUVU.js +0 -8
  201. package/dist/trello-MNR3VPTT.js +0 -7
  202. package/dist/wasabi-K5ANTZ2C.js +0 -8
  203. /package/dist/{aliyun-F2ORS3KZ.js.map → aliyun-YEWHEWCL.js.map} +0 -0
  204. /package/dist/{backblaze-HOVWPSV7.js.map → backblaze-LWE2HEDK.js.map} +0 -0
  205. /package/dist/{box-VJSE5N7P.js.map → box-GTWWIB6F.js.map} +0 -0
  206. /package/dist/{ceph-CQKQ4NWW.js.map → ceph-ATSCSVGU.js.map} +0 -0
  207. /package/dist/{config-7IZCGWKX.js.map → config-22T7HJBJ.js.map} +0 -0
  208. /package/dist/{config-AT74FARJ.js.map → config-A56HUM6C.js.map} +0 -0
  209. /package/dist/{config-C2AYHACT.js.map → config-DIWQZBOK.js.map} +0 -0
  210. /package/dist/{config-ET26F632.js.map → config-HGJ2MGAC.js.map} +0 -0
  211. /package/dist/{config-GHJOYNM6.js.map → config-MHBKYS53.js.map} +0 -0
  212. /package/dist/{config-L55UXIF4.js.map → config-PAHALM2T.js.map} +0 -0
  213. /package/dist/{config-NV5WXP64.js.map → config-PWZXYJOI.js.map} +0 -0
  214. /package/dist/{config-V7BLK5WP.js.map → config-UU27ALAA.js.map} +0 -0
  215. /package/dist/{digitalocean-KC7VIWZK.js.map → digitalocean-SQA6MJJQ.js.map} +0 -0
  216. /package/dist/{discord-W3DSEXKN.js.map → discord-ASNFJP6A.js.map} +0 -0
  217. /package/dist/{dropbox-GI273OVA.js.map → dropbox-VV2WZE6I.js.map} +0 -0
  218. /package/dist/{gcs-WRQTU27E.js.map → gcs-2W6DDWM7.js.map} +0 -0
  219. /package/dist/{gdocs-EI2EFVKG.js.map → gdocs-QPM7VXXE.js.map} +0 -0
  220. /package/dist/{gdrive-62HD67IP.js.map → gdrive-KT6R7EVB.js.map} +0 -0
  221. /package/dist/{github-SWLYD3LS.js.map → github-3IFZGW6I.js.map} +0 -0
  222. /package/dist/{github_ci-7P7VGBKM.js.map → github_ci-CKKF2Y4S.js.map} +0 -0
  223. /package/dist/{gmail-B7HXHZ7D.js.map → gmail-HLZIMKQU.js.map} +0 -0
  224. /package/dist/{gsheets-OTBW2JWG.js.map → gsheets-HF4YPIEF.js.map} +0 -0
  225. /package/dist/{gslides-MXSR4HRY.js.map → gslides-EV2JJH7I.js.map} +0 -0
  226. /package/dist/{langfuse-FWKU6E3F.js.map → langfuse-74ZCR6QL.js.map} +0 -0
  227. /package/dist/{linear-SHVG3XVT.js.map → linear-XABGTU6E.js.map} +0 -0
  228. /package/dist/{minio-246KOHBJ.js.map → minio-JPNSX2NP.js.map} +0 -0
  229. /package/dist/{mongodb-2ITJUDCF.js.map → mongodb-YZP643ZU.js.map} +0 -0
  230. /package/dist/{notion-BOBBSJSG.js.map → notion-YJOTGH7J.js.map} +0 -0
  231. /package/dist/{oci-T7VREPQW.js.map → oci-R4VYQKGJ.js.map} +0 -0
  232. /package/dist/{opfs-3XNAXR5B.js.map → opfs-4RWMJBCI.js.map} +0 -0
  233. /package/dist/{postgres-CK4HWZSL.js.map → postgres-HPOMN2AR.js.map} +0 -0
  234. /package/dist/{qingstor-WIC27LS3.js.map → qingstor-ZWWK2ZGV.js.map} +0 -0
  235. /package/dist/{r2-EAX6KHEI.js.map → r2-PZAN2YFG.js.map} +0 -0
  236. /package/dist/{s3-GD2WKLWR.js.map → s3-CSFY3PLT.js.map} +0 -0
  237. /package/dist/{scaleway-OVFRZBKW.js.map → scaleway-BFROPDBB.js.map} +0 -0
  238. /package/dist/{seaweedfs-EOJVO432.js.map → seaweedfs-X6THZT26.js.map} +0 -0
  239. /package/dist/{slack-RNXMU5OC.js.map → slack-O7BTJ4YR.js.map} +0 -0
  240. /package/dist/{supabase-VSUNLIJ6.js.map → supabase-PHN3MIXW.js.map} +0 -0
  241. /package/dist/{tencent-YYM5WUVU.js.map → tencent-JGCJEKHV.js.map} +0 -0
  242. /package/dist/{trello-MNR3VPTT.js.map → trello-QUDOP3M2.js.map} +0 -0
  243. /package/dist/{wasabi-K5ANTZ2C.js.map → wasabi-5VMNAFOC.js.map} +0 -0
@@ -1,7 +1,8 @@
1
1
  // src/resource/opfs/opfs.ts
2
2
  import {
3
- ResourceName as ResourceName80,
4
- lstripSlash
3
+ ResourceName as ResourceName86,
4
+ lstripSlash,
5
+ makeResolveGlob as makeResolveGlob2
5
6
  } from "@struktoai/mirage-core";
6
7
 
7
8
  // src/accessor/opfs.ts
@@ -18,11 +19,19 @@ var OPFSAccessor = class extends Accessor {
18
19
  };
19
20
 
20
21
  // src/commands/builtin/opfs/index.ts
21
- import { makeFiletypeCommands, ResourceName as ResourceName67 } from "@struktoai/mirage-core";
22
+ import {
23
+ makeFiletypeCommands,
24
+ makeResolveGlob,
25
+ ResourceName as ResourceName73,
26
+ withDefaultProvisions
27
+ } from "@struktoai/mirage-core";
28
+
29
+ // src/core/opfs/constants.ts
30
+ var SCOPE_ERROR = 5e4;
22
31
 
23
32
  // src/core/opfs/read.ts
24
33
  import { record, ResourceName } from "@struktoai/mirage-core";
25
- import { enoent } from "@struktoai/mirage-core";
34
+ import { eisdir, enoent } from "@struktoai/mirage-core";
26
35
 
27
36
  // src/core/opfs/utils.ts
28
37
  import { norm, parent, gnuBasename } from "@struktoai/mirage-core";
@@ -95,12 +104,13 @@ async function* iterEntries(dir) {
95
104
  async function read(accessor, path) {
96
105
  const root = accessor.rootHandle;
97
106
  const start = performance.now();
98
- const virtual = path.stripPrefix;
107
+ const virtual = path.mountPath;
99
108
  let handle;
100
109
  try {
101
110
  handle = await resolveFileHandle(root, virtual, { create: false });
102
111
  } catch (err) {
103
112
  if (isNotFound(err)) throw enoent(path);
113
+ if (err instanceof DOMException && err.name === "TypeMismatchError") throw eisdir(path);
104
114
  throw err;
105
115
  }
106
116
  const file = await handle.getFile();
@@ -109,12 +119,38 @@ async function read(accessor, path) {
109
119
  return bytes;
110
120
  }
111
121
 
122
+ // src/core/opfs/readdir.ts
123
+ import { mountPrefixOf } from "@struktoai/mirage-core";
124
+ import { enotdir } from "@struktoai/mirage-core";
125
+ async function readdir(accessor, path) {
126
+ const root = accessor.rootHandle;
127
+ const virtual = path.pattern !== null ? path.directory : path.mountPath;
128
+ let dir;
129
+ try {
130
+ dir = await resolveDirHandle(root, virtual, { create: false });
131
+ } catch (err) {
132
+ if (isNotFound(err)) throw enotdir(path);
133
+ if (err instanceof DOMException && err.name === "TypeMismatchError") {
134
+ throw enotdir(path);
135
+ }
136
+ throw err;
137
+ }
138
+ const names = [];
139
+ for await (const [name] of iterEntries(dir)) {
140
+ names.push(name);
141
+ }
142
+ const base = norm(virtual);
143
+ const dirPrefix = base === "/" ? "/" : `${base}/`;
144
+ const mountPrefix = mountPrefixOf(path.virtual, path.resourcePath);
145
+ return names.map((n) => `${mountPrefix}${dirPrefix}${n}`).sort();
146
+ }
147
+
112
148
  // src/core/opfs/stat.ts
113
149
  import { FileStat, FileType, guessType } from "@struktoai/mirage-core";
114
150
  import { enoent as enoent2 } from "@struktoai/mirage-core";
115
151
  async function stat(accessor, p) {
116
152
  const root = accessor.rootHandle;
117
- const virtual = p.stripPrefix;
153
+ const virtual = p.mountPath;
118
154
  const segs = splitSegments(virtual);
119
155
  const last = segs.at(-1);
120
156
  if (last === void 0) {
@@ -151,18 +187,25 @@ async function stat(accessor, p) {
151
187
  throw err;
152
188
  }
153
189
  }
190
+ let dirHandle;
154
191
  try {
155
- await resolveDirHandle(root, virtual, { create: false });
156
- return new FileStat({
157
- name,
158
- size: null,
159
- modified: null,
160
- type: FileType.DIRECTORY
161
- });
192
+ dirHandle = await resolveDirHandle(root, virtual, { create: false });
162
193
  } catch (err) {
163
194
  if (isNotFound(err)) throw enoent2(p);
164
195
  throw err;
165
196
  }
197
+ let latest = 0;
198
+ for await (const [, handle] of iterEntries(dirHandle)) {
199
+ if (handle.kind !== "file") continue;
200
+ const file = await handle.getFile();
201
+ if (file.lastModified > latest) latest = file.lastModified;
202
+ }
203
+ return new FileStat({
204
+ name,
205
+ size: null,
206
+ modified: latest > 0 ? new Date(latest).toISOString() : null,
207
+ type: FileType.DIRECTORY
208
+ });
166
209
  }
167
210
 
168
211
  // src/commands/builtin/opfs/awk.ts
@@ -170,15 +213,16 @@ import { ResourceName as ResourceName3, awkGeneric, command, specOf } from "@str
170
213
 
171
214
  // src/core/opfs/stream.ts
172
215
  import { recordStream, ResourceName as ResourceName2 } from "@struktoai/mirage-core";
173
- import { enoent as enoent3 } from "@struktoai/mirage-core";
216
+ import { eisdir as eisdir2, enoent as enoent3 } from "@struktoai/mirage-core";
174
217
  async function* stream(accessor, path) {
175
218
  const root = accessor.rootHandle;
176
- const virtual = path.stripPrefix;
219
+ const virtual = path.mountPath;
177
220
  let handle;
178
221
  try {
179
222
  handle = await resolveFileHandle(root, virtual, { create: false });
180
223
  } catch (err) {
181
224
  if (isNotFound(err)) throw enoent3(path);
225
+ if (err instanceof DOMException && err.name === "TypeMismatchError") throw eisdir2(path);
182
226
  throw err;
183
227
  }
184
228
  const file = await handle.getFile();
@@ -219,14 +263,7 @@ var OPFS_BASENAME = command3({
219
263
  });
220
264
 
221
265
  // src/commands/builtin/opfs/cat/cat.ts
222
- import {
223
- ResourceName as ResourceName6,
224
- catGeneric,
225
- catProvisionGeneric,
226
- command as command4,
227
- concatAggregate,
228
- specOf as specOf4
229
- } from "@struktoai/mirage-core";
266
+ import { ResourceName as ResourceName6, catGeneric, command as command4, concatAggregate, specOf as specOf4 } from "@struktoai/mirage-core";
230
267
  var OPFS_CAT = command4({
231
268
  name: "cat",
232
269
  resource: ResourceName6.OPFS,
@@ -238,7 +275,6 @@ var OPFS_CAT = command4({
238
275
  (p) => stat(accessor, p),
239
276
  (p) => stream(accessor, p)
240
277
  ),
241
- provision: (accessor, paths, _texts, _opts) => catProvisionGeneric(paths, (p) => stat(accessor, p)),
242
278
  aggregate: concatAggregate
243
279
  });
244
280
 
@@ -283,21 +319,26 @@ async function copy(accessor, src, dst) {
283
319
  const root = accessor.rootHandle;
284
320
  let srcHandle;
285
321
  try {
286
- srcHandle = await resolveFileHandle(root, src.stripPrefix, { create: false });
322
+ srcHandle = await resolveFileHandle(root, src.mountPath, { create: false });
287
323
  } catch (err) {
288
- if (isNotFound(err)) throw new Error(`file not found: ${src.stripPrefix}`);
324
+ if (isNotFound(err)) throw new Error(`file not found: ${src.mountPath}`);
289
325
  throw err;
290
326
  }
291
327
  const file = await srcHandle.getFile();
292
328
  const data = new Uint8Array(await file.arrayBuffer());
293
- const dstHandle = await resolveFileHandle(root, dst.stripPrefix, { create: true });
329
+ const dstHandle = await resolveFileHandle(root, dst.mountPath, { create: true });
294
330
  const writable = await dstHandle.createWritable();
295
331
  await writable.write(toWritableChunk(data));
296
332
  await writable.close();
297
333
  }
298
334
 
299
335
  // src/core/opfs/find.ts
300
- import { buildTree, keep } from "@struktoai/mirage-core";
336
+ import {
337
+ buildTree,
338
+ emitStartPath,
339
+ keep,
340
+ startBasename
341
+ } from "@struktoai/mirage-core";
301
342
  async function walk(ctx, dir, current, depth) {
302
343
  const opts = ctx.options;
303
344
  if (opts.maxDepth !== null && opts.maxDepth !== void 0 && depth > opts.maxDepth) return;
@@ -339,6 +380,10 @@ async function walk(ctx, dir, current, depth) {
339
380
  )) {
340
381
  accept = false;
341
382
  }
383
+ if (accept && kind !== "f" && (opts.minSize != null || opts.maxSize != null)) {
384
+ if (opts.minSize != null && opts.minSize > 0) accept = false;
385
+ if (opts.maxSize != null && opts.maxSize < 0) accept = false;
386
+ }
342
387
  if (accept && kind === "f" && (opts.minSize !== null || opts.maxSize !== null || opts.mtimeMin !== null || opts.mtimeMax !== null)) {
343
388
  try {
344
389
  const fh = await dir.getFileHandle(entryName, { create: false });
@@ -370,7 +415,8 @@ async function walk(ctx, dir, current, depth) {
370
415
  }
371
416
  async function find(accessor, p, options = {}) {
372
417
  const root = accessor.rootHandle;
373
- const virtual = norm(p.stripPrefix);
418
+ const virtual = norm(p.mountPath);
419
+ const startName = startBasename(p.virtual);
374
420
  const results = [];
375
421
  const tree = options.tree ?? buildTree({
376
422
  name: options.name,
@@ -388,7 +434,7 @@ async function find(accessor, p, options = {}) {
388
434
  if (isNotFound(err)) return results;
389
435
  throw err;
390
436
  }
391
- if (virtual !== "/" && (options.maxDepth == null || options.maxDepth >= 0)) {
437
+ if (options.maxDepth == null || options.maxDepth >= 0) {
392
438
  let rootEmpty = null;
393
439
  if (options.empty === true) {
394
440
  rootEmpty = true;
@@ -398,19 +444,16 @@ async function find(accessor, p, options = {}) {
398
444
  break;
399
445
  }
400
446
  }
401
- if (keep(
402
- {
403
- key: virtual,
404
- name: virtual.slice(virtual.lastIndexOf("/") + 1),
405
- kind: "d",
406
- depth: 0,
407
- isEmpty: rootEmpty
408
- },
447
+ emitStartPath(results, virtual, startName, {
448
+ kind: "d",
449
+ isEmpty: rootEmpty,
450
+ exists: true,
409
451
  tree,
410
- options.minDepth
411
- )) {
412
- results.push(virtual);
413
- }
452
+ maxDepth: options.maxDepth,
453
+ minDepth: options.minDepth,
454
+ minSize: options.minSize,
455
+ maxSize: options.maxSize
456
+ });
414
457
  }
415
458
  await walk({ options, tree, results }, dir, virtual, 0);
416
459
  results.sort();
@@ -428,9 +471,11 @@ function cpCommand(accessor, paths, _texts, opts) {
428
471
  const recursive = opts.flags.r === true || opts.flags.R === true || opts.flags.a === true;
429
472
  return cpGeneric(
430
473
  paths,
431
- (src, target) => copy(accessor, src, target),
432
- (src, options) => find(accessor, src, options),
433
474
  (p) => stat(accessor, p),
475
+ {
476
+ copy: (src, target) => copy(accessor, src, target),
477
+ find: (src, options) => find(accessor, src, options)
478
+ },
434
479
  recursive,
435
480
  opts.flags.n === true,
436
481
  opts.flags.v === true,
@@ -453,7 +498,7 @@ import { record as record2, ResourceName as ResourceName11 } from "@struktoai/mi
453
498
  async function writeBytes(accessor, p, data) {
454
499
  const root = accessor.rootHandle;
455
500
  const start = performance.now();
456
- const virtual = p.stripPrefix;
501
+ const virtual = p.mountPath;
457
502
  const handle = await resolveFileHandle(root, virtual, { create: true });
458
503
  const writable = await handle.createWritable();
459
504
  await writable.write(toWritableChunk(data));
@@ -491,7 +536,13 @@ var OPFS_DIFF = command11({
491
536
  name: "diff",
492
537
  resource: ResourceName14.OPFS,
493
538
  spec: specOf11("diff"),
494
- fn: (accessor, paths, _texts, opts) => diffGeneric(paths, opts, (p) => stream(accessor, p))
539
+ fn: (accessor, paths, _texts, opts) => diffGeneric(
540
+ paths,
541
+ opts,
542
+ (p) => stream(accessor, p),
543
+ (p) => readdir(accessor, p),
544
+ (p) => stat(accessor, p)
545
+ )
495
546
  });
496
547
 
497
548
  // src/commands/builtin/opfs/dirname.ts
@@ -577,11 +628,11 @@ async function sizeOfPath(root, virtual) {
577
628
  }
578
629
  }
579
630
  async function du(accessor, p) {
580
- return sizeOfPath(accessor.rootHandle, p.stripPrefix);
631
+ return sizeOfPath(accessor.rootHandle, p.mountPath);
581
632
  }
582
633
  async function duAll(accessor, p) {
583
634
  const root = accessor.rootHandle;
584
- const virtual = norm(p.stripPrefix);
635
+ const virtual = norm(p.mountPath);
585
636
  const entries = [];
586
637
  try {
587
638
  const [parentDir, name] = await resolveParentDirHandle(root, virtual, { create: false });
@@ -688,33 +739,6 @@ var OPFS_FOLD = command18({
688
739
 
689
740
  // src/commands/builtin/opfs/grep/grep.ts
690
741
  import { ResourceName as ResourceName22, command as command19, grepGeneric, prefixAggregate, specOf as specOf19 } from "@struktoai/mirage-core";
691
-
692
- // src/core/opfs/readdir.ts
693
- import { enotdir } from "@struktoai/mirage-core";
694
- async function readdir(accessor, path) {
695
- const root = accessor.rootHandle;
696
- const virtual = path.pattern !== null ? path.directory : path.stripPrefix;
697
- let dir;
698
- try {
699
- dir = await resolveDirHandle(root, virtual, { create: false });
700
- } catch (err) {
701
- if (isNotFound(err)) throw enotdir(path);
702
- if (err instanceof DOMException && err.name === "TypeMismatchError") {
703
- throw enotdir(path);
704
- }
705
- throw err;
706
- }
707
- const names = [];
708
- for await (const [name] of iterEntries(dir)) {
709
- names.push(name);
710
- }
711
- const base = norm(virtual);
712
- const dirPrefix = base === "/" ? "/" : `${base}/`;
713
- const mountPrefix = path.prefix;
714
- return names.map((n) => `${mountPrefix}${dirPrefix}${n}`).sort();
715
- }
716
-
717
- // src/commands/builtin/opfs/grep/grep.ts
718
742
  var OPFS_GREP = command19({
719
743
  name: "grep",
720
744
  resource: ResourceName22.OPFS,
@@ -737,7 +761,7 @@ import { ResourceName as ResourceName23, command as command20, specOf as specOf2
737
761
  // src/core/opfs/unlink.ts
738
762
  async function unlink(accessor, path) {
739
763
  const root = accessor.rootHandle;
740
- const virtual = path.stripPrefix;
764
+ const virtual = path.mountPath;
741
765
  let parentDir;
742
766
  let name;
743
767
  try {
@@ -788,14 +812,7 @@ var OPFS_GZIP = command21({
788
812
  });
789
813
 
790
814
  // src/commands/builtin/opfs/head/head.ts
791
- import {
792
- ResourceName as ResourceName25,
793
- command as command22,
794
- headGeneric,
795
- headProvisionGeneric,
796
- headerAggregate,
797
- specOf as specOf22
798
- } from "@struktoai/mirage-core";
815
+ import { ResourceName as ResourceName25, command as command22, headGeneric, headerAggregate, specOf as specOf22 } from "@struktoai/mirage-core";
799
816
  var OPFS_HEAD = command22({
800
817
  name: "head",
801
818
  resource: ResourceName25.OPFS,
@@ -807,7 +824,6 @@ var OPFS_HEAD = command22({
807
824
  (p) => stat(accessor, p),
808
825
  (p) => stream(accessor, p)
809
826
  ),
810
- provision: (accessor, paths, texts, opts) => headProvisionGeneric(paths, texts, opts, (p) => stat(accessor, p)),
811
827
  aggregate: headerAggregate
812
828
  });
813
829
 
@@ -836,19 +852,12 @@ var OPFS_JOIN = command24({
836
852
  });
837
853
 
838
854
  // src/commands/builtin/opfs/jq.ts
839
- import {
840
- ResourceName as ResourceName28,
841
- command as command25,
842
- jqGeneric,
843
- jqProvisionGeneric,
844
- specOf as specOf25
845
- } from "@struktoai/mirage-core";
855
+ import { ResourceName as ResourceName28, command as command25, jqGeneric, specOf as specOf25 } from "@struktoai/mirage-core";
846
856
  var OPFS_JQ = command25({
847
857
  name: "jq",
848
858
  resource: ResourceName28.OPFS,
849
859
  spec: specOf25("jq"),
850
- fn: (accessor, paths, texts, opts) => jqGeneric(paths, texts, opts, (p) => stream(accessor, p)),
851
- provision: (accessor, paths, texts, _opts) => jqProvisionGeneric(paths, texts, (p) => stat(accessor, p))
860
+ fn: (accessor, paths, texts, opts) => jqGeneric(paths, texts, opts, (p) => stream(accessor, p))
852
861
  });
853
862
 
854
863
  // src/commands/builtin/opfs/ln.ts
@@ -863,7 +872,7 @@ import {
863
872
  // src/core/opfs/exists.ts
864
873
  async function exists(accessor, path) {
865
874
  const root = accessor.rootHandle;
866
- const virtual = path.stripPrefix;
875
+ const virtual = path.mountPath;
867
876
  if (virtual === "/" || virtual === "") return true;
868
877
  try {
869
878
  const [parentDir, name] = await resolveParentDirHandle(root, virtual, { create: false });
@@ -916,9 +925,9 @@ async function lnCommand(accessor, paths, texts, opts) {
916
925
  }
917
926
  const data = await materialize(stream(accessor, source));
918
927
  await writeBytes(accessor, dest, data);
919
- const out = opts.flags.v === true ? ENC.encode(`'${source.original}' -> '${dest.original}'
928
+ const out = opts.flags.v === true ? ENC.encode(`'${source.virtual}' -> '${dest.virtual}'
920
929
  `) : null;
921
- return [out, new IOResult2({ writes: { [dest.stripPrefix]: data } })];
930
+ return [out, new IOResult2({ writes: { [dest.mountPath]: data } })];
922
931
  }
923
932
  var OPFS_LN = command26({
924
933
  name: "ln",
@@ -943,12 +952,11 @@ var OPFS_LS = command28({
943
952
  name: "ls",
944
953
  resource: ResourceName31.OPFS,
945
954
  spec: specOf28("ls"),
946
- fn: (accessor, paths, _texts, opts) => lsGeneric(
947
- paths,
948
- opts,
949
- (p) => readdir(accessor, p),
950
- (p) => stat(accessor, p)
951
- )
955
+ fn: (accessor, paths, _texts, opts) => {
956
+ const overlay = opts.statOverlay;
957
+ const stat2 = overlay !== void 0 ? async (p) => overlay(p.virtual, await stat(accessor, p)) : (p) => stat(accessor, p);
958
+ return lsGeneric(paths, opts, (p) => readdir(accessor, p), stat2);
959
+ }
952
960
  });
953
961
 
954
962
  // src/commands/builtin/opfs/md5.ts
@@ -960,22 +968,35 @@ var OPFS_MD5 = command29({
960
968
  fn: (accessor, paths, _texts, opts) => md5Generic(paths, opts, (p) => stream(accessor, p))
961
969
  });
962
970
 
971
+ // src/commands/builtin/opfs/md5sum.ts
972
+ import { ResourceName as ResourceName33, command as command30, md5sumGeneric, specOf as specOf30 } from "@struktoai/mirage-core";
973
+ var OPFS_MD5SUM = command30({
974
+ name: "md5sum",
975
+ resource: ResourceName33.OPFS,
976
+ spec: specOf30("md5sum"),
977
+ fn: (accessor, paths, _texts, opts) => md5sumGeneric(paths, opts, (p) => stream(accessor, p))
978
+ });
979
+
963
980
  // src/commands/builtin/opfs/mkdir.ts
964
981
  import {
965
982
  IOResult as IOResult3,
966
- ResourceName as ResourceName33,
967
- command as command30,
968
- specOf as specOf30
983
+ ResourceName as ResourceName34,
984
+ command as command31,
985
+ formatRecords,
986
+ specOf as specOf31
969
987
  } from "@struktoai/mirage-core";
970
988
 
971
989
  // src/core/opfs/mkdir.ts
990
+ import { invalidateAfterWrite, invalidateAncestors } from "@struktoai/mirage-core";
972
991
  async function mkdir(accessor, path, parents = false) {
973
992
  const root = accessor.rootHandle;
974
- const virtual = path.stripPrefix;
993
+ const virtual = path.mountPath;
975
994
  const segs = splitSegments(virtual);
976
995
  if (segs.length === 0) return;
977
996
  if (parents) {
978
997
  await resolveDirHandle(root, virtual, { create: true });
998
+ await invalidateAfterWrite(path);
999
+ await invalidateAncestors(path);
979
1000
  return;
980
1001
  }
981
1002
  let parentDir;
@@ -1006,6 +1027,7 @@ async function mkdir(accessor, path, parents = false) {
1006
1027
  // src/commands/builtin/opfs/mkdir.ts
1007
1028
  async function mkdirCommand(accessor, paths, texts, opts) {
1008
1029
  const parents = opts.flags.p === true;
1030
+ const verbose = opts.flags.v === true;
1009
1031
  if (paths.length === 0) {
1010
1032
  return [
1011
1033
  null,
@@ -1015,25 +1037,28 @@ async function mkdirCommand(accessor, paths, texts, opts) {
1015
1037
  })
1016
1038
  ];
1017
1039
  }
1040
+ const lines = [];
1018
1041
  for (const p of paths) {
1019
1042
  await mkdir(accessor, p, parents);
1043
+ if (verbose) lines.push(`mkdir: created directory '${p.virtual.replace(/\/+$/, "") || "/"}'`);
1020
1044
  }
1021
- return [null, new IOResult3()];
1045
+ const output = verbose && lines.length > 0 ? formatRecords(lines) : null;
1046
+ return [output, new IOResult3()];
1022
1047
  }
1023
- var OPFS_MKDIR = command30({
1048
+ var OPFS_MKDIR = command31({
1024
1049
  name: "mkdir",
1025
- resource: ResourceName33.OPFS,
1026
- spec: specOf30("mkdir"),
1050
+ resource: ResourceName34.OPFS,
1051
+ spec: specOf31("mkdir"),
1027
1052
  fn: mkdirCommand,
1028
1053
  write: true
1029
1054
  });
1030
1055
 
1031
1056
  // src/commands/builtin/opfs/mktemp.ts
1032
- import { ResourceName as ResourceName34, command as command31, mktempGeneric, specOf as specOf31 } from "@struktoai/mirage-core";
1033
- var OPFS_MKTEMP = command31({
1057
+ import { ResourceName as ResourceName35, command as command32, mktempGeneric, specOf as specOf32 } from "@struktoai/mirage-core";
1058
+ var OPFS_MKTEMP = command32({
1034
1059
  name: "mktemp",
1035
- resource: ResourceName34.OPFS,
1036
- spec: specOf31("mktemp"),
1060
+ resource: ResourceName35.OPFS,
1061
+ spec: specOf32("mktemp"),
1037
1062
  fn: (accessor, _paths, texts, opts) => mktempGeneric(
1038
1063
  texts,
1039
1064
  opts,
@@ -1046,10 +1071,10 @@ var OPFS_MKTEMP = command31({
1046
1071
  // src/commands/builtin/opfs/mv.ts
1047
1072
  import {
1048
1073
  IOResult as IOResult4,
1049
- ResourceName as ResourceName35,
1050
- command as command32,
1074
+ ResourceName as ResourceName36,
1075
+ command as command33,
1051
1076
  mvGeneric,
1052
- specOf as specOf32
1077
+ specOf as specOf33
1053
1078
  } from "@struktoai/mirage-core";
1054
1079
 
1055
1080
  // src/core/opfs/rename.ts
@@ -1072,8 +1097,8 @@ async function copyDirRecursive(root, srcPath, dstPath) {
1072
1097
  }
1073
1098
  async function rename(accessor, src, dst) {
1074
1099
  const root = accessor.rootHandle;
1075
- const srcPath = src.stripPrefix;
1076
- const dstPath = dst.stripPrefix;
1100
+ const srcPath = src.mountPath;
1101
+ const dstPath = dst.mountPath;
1077
1102
  let srcParent;
1078
1103
  let srcName;
1079
1104
  try {
@@ -1125,45 +1150,45 @@ function mvCommand(accessor, paths, _texts, opts) {
1125
1150
  }
1126
1151
  return mvGeneric(
1127
1152
  paths,
1128
- (src, target) => rename(accessor, src, target),
1129
1153
  (p) => stat(accessor, p),
1154
+ { rename: (src, target) => rename(accessor, src, target) },
1130
1155
  opts.flags.n === true,
1131
1156
  opts.flags.v === true,
1132
1157
  opts.index ?? void 0
1133
1158
  );
1134
1159
  }
1135
- var OPFS_MV = command32({
1160
+ var OPFS_MV = command33({
1136
1161
  name: "mv",
1137
- resource: ResourceName35.OPFS,
1138
- spec: specOf32("mv"),
1162
+ resource: ResourceName36.OPFS,
1163
+ spec: specOf33("mv"),
1139
1164
  fn: mvCommand,
1140
1165
  write: true
1141
1166
  });
1142
1167
 
1143
1168
  // src/commands/builtin/opfs/nl.ts
1144
- import { ResourceName as ResourceName36, command as command33, specOf as specOf33, nlGeneric } from "@struktoai/mirage-core";
1145
- var OPFS_NL = command33({
1169
+ import { ResourceName as ResourceName37, command as command34, specOf as specOf34, nlGeneric } from "@struktoai/mirage-core";
1170
+ var OPFS_NL = command34({
1146
1171
  name: "nl",
1147
- resource: ResourceName36.OPFS,
1148
- spec: specOf33("nl"),
1172
+ resource: ResourceName37.OPFS,
1173
+ spec: specOf34("nl"),
1149
1174
  fn: (accessor, paths, _texts, opts) => nlGeneric(paths, opts, (p) => stream(accessor, p))
1150
1175
  });
1151
1176
 
1152
1177
  // src/commands/builtin/opfs/paste.ts
1153
- import { ResourceName as ResourceName37, command as command34, specOf as specOf34, pasteGeneric } from "@struktoai/mirage-core";
1154
- var OPFS_PASTE = command34({
1178
+ import { ResourceName as ResourceName38, command as command35, specOf as specOf35, pasteGeneric } from "@struktoai/mirage-core";
1179
+ var OPFS_PASTE = command35({
1155
1180
  name: "paste",
1156
- resource: ResourceName37.OPFS,
1157
- spec: specOf34("paste"),
1181
+ resource: ResourceName38.OPFS,
1182
+ spec: specOf35("paste"),
1158
1183
  fn: (accessor, paths, _texts, opts) => pasteGeneric(paths, opts, (p) => stream(accessor, p))
1159
1184
  });
1160
1185
 
1161
1186
  // src/commands/builtin/opfs/patch.ts
1162
- import { ResourceName as ResourceName38, command as command35, specOf as specOf35, patchGeneric } from "@struktoai/mirage-core";
1163
- var OPFS_PATCH = command35({
1187
+ import { ResourceName as ResourceName39, command as command36, specOf as specOf36, patchGeneric } from "@struktoai/mirage-core";
1188
+ var OPFS_PATCH = command36({
1164
1189
  name: "patch",
1165
- resource: ResourceName38.OPFS,
1166
- spec: specOf35("patch"),
1190
+ resource: ResourceName39.OPFS,
1191
+ spec: specOf36("patch"),
1167
1192
  fn: (accessor, paths, _texts, opts) => patchGeneric(
1168
1193
  paths,
1169
1194
  opts,
@@ -1175,42 +1200,42 @@ var OPFS_PATCH = command35({
1175
1200
 
1176
1201
  // src/commands/builtin/opfs/readlink.ts
1177
1202
  import {
1178
- ResourceName as ResourceName39,
1179
- command as command36,
1203
+ ResourceName as ResourceName40,
1204
+ command as command37,
1180
1205
  readlinkGeneric,
1181
- specOf as specOf36
1206
+ specOf as specOf37
1182
1207
  } from "@struktoai/mirage-core";
1183
- var OPFS_READLINK = command36({
1208
+ var OPFS_READLINK = command37({
1184
1209
  name: "readlink",
1185
- resource: ResourceName39.OPFS,
1186
- spec: specOf36("readlink"),
1210
+ resource: ResourceName40.OPFS,
1211
+ spec: specOf37("readlink"),
1187
1212
  fn: (_accessor, paths, texts, opts) => readlinkGeneric(paths, texts, opts)
1188
1213
  });
1189
1214
 
1190
1215
  // src/commands/builtin/opfs/realpath.ts
1191
- import { ResourceName as ResourceName40, command as command37, realpathGeneric, specOf as specOf37 } from "@struktoai/mirage-core";
1192
- var OPFS_REALPATH = command37({
1216
+ import { ResourceName as ResourceName41, command as command38, realpathGeneric, specOf as specOf38 } from "@struktoai/mirage-core";
1217
+ var OPFS_REALPATH = command38({
1193
1218
  name: "realpath",
1194
- resource: ResourceName40.OPFS,
1195
- spec: specOf37("realpath"),
1219
+ resource: ResourceName41.OPFS,
1220
+ spec: specOf38("realpath"),
1196
1221
  fn: (accessor, paths, texts, opts) => realpathGeneric(paths, texts, opts, (p) => stat(accessor, p))
1197
1222
  });
1198
1223
 
1199
1224
  // src/commands/builtin/opfs/rev.ts
1200
- import { ResourceName as ResourceName41, command as command38, specOf as specOf38, revGeneric } from "@struktoai/mirage-core";
1201
- var OPFS_REV = command38({
1225
+ import { ResourceName as ResourceName42, command as command39, specOf as specOf39, revGeneric } from "@struktoai/mirage-core";
1226
+ var OPFS_REV = command39({
1202
1227
  name: "rev",
1203
- resource: ResourceName41.OPFS,
1204
- spec: specOf38("rev"),
1228
+ resource: ResourceName42.OPFS,
1229
+ spec: specOf39("rev"),
1205
1230
  fn: (accessor, paths, _texts, opts) => revGeneric(paths, opts, (p) => stream(accessor, p))
1206
1231
  });
1207
1232
 
1208
1233
  // src/commands/builtin/opfs/rg.ts
1209
- import { ResourceName as ResourceName42, command as command39, rgGeneric, specOf as specOf39 } from "@struktoai/mirage-core";
1210
- var OPFS_RG = command39({
1234
+ import { ResourceName as ResourceName43, command as command40, rgGeneric, specOf as specOf40 } from "@struktoai/mirage-core";
1235
+ var OPFS_RG = command40({
1211
1236
  name: "rg",
1212
- resource: ResourceName42.OPFS,
1213
- spec: specOf39("rg"),
1237
+ resource: ResourceName43.OPFS,
1238
+ spec: specOf40("rg"),
1214
1239
  fn: (accessor, paths, texts, opts) => rgGeneric(
1215
1240
  paths,
1216
1241
  texts,
@@ -1225,15 +1250,18 @@ var OPFS_RG = command39({
1225
1250
  import {
1226
1251
  FileType as FileType2,
1227
1252
  IOResult as IOResult5,
1228
- ResourceName as ResourceName43,
1229
- command as command40,
1230
- specOf as specOf40
1253
+ ResourceName as ResourceName44,
1254
+ command as command41,
1255
+ cpWalk,
1256
+ formatRecords as formatRecords2,
1257
+ removalLines,
1258
+ specOf as specOf41
1231
1259
  } from "@struktoai/mirage-core";
1232
1260
 
1233
1261
  // src/core/opfs/rmdir.ts
1234
1262
  async function rmdir(accessor, path) {
1235
1263
  const root = accessor.rootHandle;
1236
- const virtual = path.stripPrefix;
1264
+ const virtual = path.mountPath;
1237
1265
  let parentDir;
1238
1266
  let name;
1239
1267
  try {
@@ -1255,7 +1283,7 @@ async function rmdir(accessor, path) {
1255
1283
  // src/core/opfs/rm.ts
1256
1284
  async function rmR(accessor, path) {
1257
1285
  const root = accessor.rootHandle;
1258
- const virtual = path.stripPrefix;
1286
+ const virtual = path.mountPath;
1259
1287
  let parentDir;
1260
1288
  let name;
1261
1289
  try {
@@ -1286,82 +1314,244 @@ async function rmCommand(accessor, paths, texts, opts) {
1286
1314
  ];
1287
1315
  }
1288
1316
  const recursive = opts.flags.r === true || opts.flags.R === true;
1317
+ const dirFlag = opts.flags.d === true;
1318
+ const force = opts.flags.f === true;
1319
+ const verbose = opts.flags.v === true;
1320
+ const errors = [];
1321
+ const verboseParts = [];
1322
+ const writes = {};
1289
1323
  for (const p of paths) {
1290
1324
  let isDir = false;
1291
1325
  try {
1292
1326
  const st = await stat(accessor, p);
1293
1327
  isDir = st.type === FileType2.DIRECTORY;
1294
1328
  } catch {
1295
- isDir = false;
1329
+ if (force) continue;
1330
+ errors.push(`rm: cannot remove '${p.virtual}': No such file or directory`);
1331
+ continue;
1296
1332
  }
1333
+ let entryLines = [];
1297
1334
  if (isDir) {
1298
1335
  if (recursive) {
1336
+ if (verbose) {
1337
+ entryLines = removalLines(
1338
+ await cpWalk(
1339
+ (dir) => readdir(accessor, dir),
1340
+ (spec) => stat(accessor, spec),
1341
+ p
1342
+ )
1343
+ );
1344
+ }
1299
1345
  await rmR(accessor, p);
1300
- } else {
1346
+ } else if (dirFlag) {
1347
+ if ((await readdir(accessor, p)).length > 0) {
1348
+ errors.push(`rm: cannot remove '${p.virtual}': Directory not empty`);
1349
+ continue;
1350
+ }
1301
1351
  await rmdir(accessor, p);
1352
+ entryLines = [`removed directory '${p.virtual.replace(/\/+$/, "") || "/"}'`];
1353
+ } else {
1354
+ errors.push(`rm: cannot remove '${p.virtual}': Is a directory`);
1355
+ continue;
1302
1356
  }
1303
1357
  } else {
1304
1358
  await unlink(accessor, p);
1359
+ entryLines = [`removed '${p.virtual.replace(/\/+$/, "") || "/"}'`];
1305
1360
  }
1306
- }
1307
- return [null, new IOResult5()];
1361
+ writes[p.mountPath] = new Uint8Array();
1362
+ if (verbose) verboseParts.push(...entryLines);
1363
+ }
1364
+ const output = verbose && verboseParts.length > 0 ? formatRecords2(verboseParts) : null;
1365
+ const stderr = errors.length > 0 ? new TextEncoder().encode(errors.join("\n") + "\n") : void 0;
1366
+ return [
1367
+ output,
1368
+ new IOResult5({
1369
+ writes,
1370
+ exitCode: errors.length > 0 ? 1 : 0,
1371
+ ...stderr !== void 0 ? { stderr } : {}
1372
+ })
1373
+ ];
1308
1374
  }
1309
- var OPFS_RM = command40({
1375
+ var OPFS_RM = command41({
1310
1376
  name: "rm",
1311
- resource: ResourceName43.OPFS,
1312
- spec: specOf40("rm"),
1377
+ resource: ResourceName44.OPFS,
1378
+ spec: specOf41("rm"),
1313
1379
  fn: rmCommand,
1314
1380
  write: true
1315
1381
  });
1316
1382
 
1383
+ // src/commands/builtin/opfs/rmdir.ts
1384
+ import {
1385
+ FileType as FileType3,
1386
+ IOResult as IOResult6,
1387
+ ResourceName as ResourceName45,
1388
+ command as command42,
1389
+ formatRecords as formatRecords3,
1390
+ specOf as specOf42
1391
+ } from "@struktoai/mirage-core";
1392
+ async function rmdirCommand(accessor, paths, _texts, opts) {
1393
+ const enc = new TextEncoder();
1394
+ if (paths.length === 0) {
1395
+ return [
1396
+ null,
1397
+ new IOResult6({
1398
+ exitCode: 1,
1399
+ stderr: enc.encode("rmdir: missing operand\nTry 'rmdir --help' for more information.\n")
1400
+ })
1401
+ ];
1402
+ }
1403
+ const verbose = opts.flags.v === true;
1404
+ const errors = [];
1405
+ const verboseParts = [];
1406
+ const writes = {};
1407
+ for (const p of paths) {
1408
+ let isDir = false;
1409
+ try {
1410
+ isDir = (await stat(accessor, p)).type === FileType3.DIRECTORY;
1411
+ } catch {
1412
+ errors.push(`rmdir: failed to remove '${p.virtual}': No such file or directory`);
1413
+ continue;
1414
+ }
1415
+ if (!isDir) {
1416
+ errors.push(`rmdir: failed to remove '${p.virtual}': Not a directory`);
1417
+ continue;
1418
+ }
1419
+ if ((await readdir(accessor, p)).length > 0) {
1420
+ errors.push(`rmdir: failed to remove '${p.virtual}': Directory not empty`);
1421
+ continue;
1422
+ }
1423
+ await rmdir(accessor, p);
1424
+ writes[p.mountPath] = new Uint8Array();
1425
+ if (verbose) verboseParts.push(`rmdir: removing directory, '${p.virtual}'`);
1426
+ }
1427
+ const output = verbose && verboseParts.length > 0 ? formatRecords3(verboseParts) : null;
1428
+ const stderr = errors.length > 0 ? enc.encode(errors.join("\n") + "\n") : void 0;
1429
+ return [
1430
+ output,
1431
+ new IOResult6({
1432
+ writes,
1433
+ exitCode: errors.length > 0 ? 1 : 0,
1434
+ ...stderr !== void 0 ? { stderr } : {}
1435
+ })
1436
+ ];
1437
+ }
1438
+ var OPFS_RMDIR = command42({
1439
+ name: "rmdir",
1440
+ resource: ResourceName45.OPFS,
1441
+ spec: specOf42("rmdir"),
1442
+ fn: rmdirCommand,
1443
+ write: true
1444
+ });
1445
+
1317
1446
  // src/commands/builtin/opfs/sed.ts
1318
- import { ResourceName as ResourceName44, command as command41, specOf as specOf41, sedGeneric } from "@struktoai/mirage-core";
1319
- var OPFS_SED = command41({
1447
+ import {
1448
+ PathSpec,
1449
+ ResourceName as ResourceName46,
1450
+ command as command43,
1451
+ makeSedProvision,
1452
+ mountKey,
1453
+ resolvePath,
1454
+ rstripSlash,
1455
+ sedGeneric,
1456
+ specOf as specOf43
1457
+ } from "@struktoai/mirage-core";
1458
+ function positionalAsPaths(texts, opts) {
1459
+ const prefix = opts.mountPrefix !== void 0 ? rstripSlash(opts.mountPrefix) : "";
1460
+ return texts.map((t) => {
1461
+ const resolved = resolvePath(t, opts.cwd);
1462
+ const slash = resolved.lastIndexOf("/");
1463
+ return new PathSpec({
1464
+ virtual: resolved,
1465
+ directory: slash >= 0 ? resolved.slice(0, slash + 1) : "/",
1466
+ resolved: true,
1467
+ resourcePath: mountKey(resolved, prefix)
1468
+ });
1469
+ });
1470
+ }
1471
+ var OPFS_SED = command43({
1320
1472
  name: "sed",
1321
- resource: ResourceName44.OPFS,
1322
- spec: specOf41("sed"),
1323
- fn: (accessor, paths, texts, opts) => sedGeneric(
1324
- paths,
1325
- texts,
1326
- opts,
1327
- (p) => stream(accessor, p),
1328
- (p, d) => writeBytes(accessor, p, d)
1329
- )
1473
+ resource: ResourceName46.OPFS,
1474
+ spec: specOf43("sed"),
1475
+ provision: makeSedProvision((a, p) => stat(a, p)),
1476
+ fn: async (accessor, paths, texts, opts) => {
1477
+ const usingE = opts.flags.e !== void 0 && opts.flags.e !== false;
1478
+ const usingF = opts.flags.f !== void 0 && opts.flags.f !== false;
1479
+ const operands = usingE || usingF ? [...positionalAsPaths(texts, opts), ...paths] : paths;
1480
+ return sedGeneric(
1481
+ operands,
1482
+ texts,
1483
+ opts,
1484
+ (p) => stream(accessor, p),
1485
+ (p, d) => writeBytes(accessor, p, d)
1486
+ );
1487
+ }
1488
+ });
1489
+
1490
+ // src/commands/builtin/opfs/sha1sum.ts
1491
+ import { ResourceName as ResourceName47, command as command44, sha1sumGeneric, specOf as specOf44 } from "@struktoai/mirage-core";
1492
+ var OPFS_SHA1SUM = command44({
1493
+ name: "sha1sum",
1494
+ resource: ResourceName47.OPFS,
1495
+ spec: specOf44("sha1sum"),
1496
+ fn: (accessor, paths, _texts, opts) => sha1sumGeneric(paths, opts, (p) => stream(accessor, p))
1330
1497
  });
1331
1498
 
1332
1499
  // src/commands/builtin/opfs/sha256sum.ts
1333
- import { ResourceName as ResourceName45, command as command42, sha256sumGeneric, specOf as specOf42 } from "@struktoai/mirage-core";
1334
- var OPFS_SHA256SUM = command42({
1500
+ import { ResourceName as ResourceName48, command as command45, sha256sumGeneric, specOf as specOf45 } from "@struktoai/mirage-core";
1501
+ var OPFS_SHA256SUM = command45({
1335
1502
  name: "sha256sum",
1336
- resource: ResourceName45.OPFS,
1337
- spec: specOf42("sha256sum"),
1503
+ resource: ResourceName48.OPFS,
1504
+ spec: specOf45("sha256sum"),
1338
1505
  fn: (accessor, paths, _texts, opts) => sha256sumGeneric(paths, opts, (p) => stream(accessor, p))
1339
1506
  });
1340
1507
 
1508
+ // src/commands/builtin/opfs/sha384sum.ts
1509
+ import { ResourceName as ResourceName49, command as command46, sha384sumGeneric, specOf as specOf46 } from "@struktoai/mirage-core";
1510
+ var OPFS_SHA384SUM = command46({
1511
+ name: "sha384sum",
1512
+ resource: ResourceName49.OPFS,
1513
+ spec: specOf46("sha384sum"),
1514
+ fn: (accessor, paths, _texts, opts) => sha384sumGeneric(paths, opts, (p) => stream(accessor, p))
1515
+ });
1516
+
1517
+ // src/commands/builtin/opfs/sha512sum.ts
1518
+ import { ResourceName as ResourceName50, command as command47, sha512sumGeneric, specOf as specOf47 } from "@struktoai/mirage-core";
1519
+ var OPFS_SHA512SUM = command47({
1520
+ name: "sha512sum",
1521
+ resource: ResourceName50.OPFS,
1522
+ spec: specOf47("sha512sum"),
1523
+ fn: (accessor, paths, _texts, opts) => sha512sumGeneric(paths, opts, (p) => stream(accessor, p))
1524
+ });
1525
+
1341
1526
  // src/commands/builtin/opfs/shuf.ts
1342
- import { ResourceName as ResourceName46, command as command43, specOf as specOf43, shufGeneric } from "@struktoai/mirage-core";
1343
- var OPFS_SHUF = command43({
1527
+ import { ResourceName as ResourceName51, command as command48, specOf as specOf48, shufGeneric } from "@struktoai/mirage-core";
1528
+ var OPFS_SHUF = command48({
1344
1529
  name: "shuf",
1345
- resource: ResourceName46.OPFS,
1346
- spec: specOf43("shuf"),
1530
+ resource: ResourceName51.OPFS,
1531
+ spec: specOf48("shuf"),
1347
1532
  fn: (accessor, paths, texts, opts) => shufGeneric(paths, texts, opts, (p) => stream(accessor, p))
1348
1533
  });
1349
1534
 
1350
1535
  // src/commands/builtin/opfs/sort.ts
1351
- import { ResourceName as ResourceName47, command as command44, specOf as specOf44, sortGeneric } from "@struktoai/mirage-core";
1352
- var OPFS_SORT = command44({
1536
+ import { ResourceName as ResourceName52, command as command49, specOf as specOf49, sortGeneric } from "@struktoai/mirage-core";
1537
+ var OPFS_SORT = command49({
1353
1538
  name: "sort",
1354
- resource: ResourceName47.OPFS,
1355
- spec: specOf44("sort"),
1356
- fn: (accessor, paths, _texts, opts) => sortGeneric(paths, opts, (p) => stream(accessor, p))
1539
+ resource: ResourceName52.OPFS,
1540
+ spec: specOf49("sort"),
1541
+ fn: (accessor, paths, _texts, opts) => sortGeneric(
1542
+ paths,
1543
+ opts,
1544
+ (p) => stream(accessor, p),
1545
+ (p, data) => writeBytes(accessor, p, data)
1546
+ )
1357
1547
  });
1358
1548
 
1359
1549
  // src/commands/builtin/opfs/split.ts
1360
- import { ResourceName as ResourceName48, command as command45, specOf as specOf45, splitGeneric } from "@struktoai/mirage-core";
1361
- var OPFS_SPLIT = command45({
1550
+ import { ResourceName as ResourceName53, command as command50, specOf as specOf50, splitGeneric } from "@struktoai/mirage-core";
1551
+ var OPFS_SPLIT = command50({
1362
1552
  name: "split",
1363
- resource: ResourceName48.OPFS,
1364
- spec: specOf45("split"),
1553
+ resource: ResourceName53.OPFS,
1554
+ spec: specOf50("split"),
1365
1555
  fn: (accessor, paths, _texts, opts) => splitGeneric(
1366
1556
  paths,
1367
1557
  opts,
@@ -1372,55 +1562,48 @@ var OPFS_SPLIT = command45({
1372
1562
  });
1373
1563
 
1374
1564
  // src/commands/builtin/opfs/stat/stat.ts
1375
- import {
1376
- ResourceName as ResourceName49,
1377
- command as command46,
1378
- specOf as specOf46,
1379
- statGeneric,
1380
- statProvisionGeneric
1381
- } from "@struktoai/mirage-core";
1382
- var OPFS_STAT = command46({
1565
+ import { ResourceName as ResourceName54, command as command51, specOf as specOf51, statGeneric } from "@struktoai/mirage-core";
1566
+ var OPFS_STAT = command51({
1383
1567
  name: "stat",
1384
- resource: ResourceName49.OPFS,
1385
- spec: specOf46("stat"),
1386
- fn: (accessor, paths, _texts, opts) => statGeneric(paths, opts, (p) => stat(accessor, p)),
1387
- provision: statProvisionGeneric
1568
+ resource: ResourceName54.OPFS,
1569
+ spec: specOf51("stat"),
1570
+ fn: (accessor, paths, _texts, opts) => statGeneric(paths, opts, (p) => stat(accessor, p))
1388
1571
  });
1389
1572
 
1390
1573
  // src/commands/builtin/opfs/strings.ts
1391
- import { ResourceName as ResourceName50, command as command47, specOf as specOf47, stringsGeneric } from "@struktoai/mirage-core";
1392
- var OPFS_STRINGS = command47({
1574
+ import { ResourceName as ResourceName55, command as command52, specOf as specOf52, stringsGeneric } from "@struktoai/mirage-core";
1575
+ var OPFS_STRINGS = command52({
1393
1576
  name: "strings",
1394
- resource: ResourceName50.OPFS,
1395
- spec: specOf47("strings"),
1577
+ resource: ResourceName55.OPFS,
1578
+ spec: specOf52("strings"),
1396
1579
  fn: (accessor, paths, _texts, opts) => stringsGeneric(paths, opts, (p) => stream(accessor, p))
1397
1580
  });
1398
1581
 
1399
1582
  // src/commands/builtin/opfs/tac.ts
1400
- import { ResourceName as ResourceName51, command as command48, specOf as specOf48, tacGeneric } from "@struktoai/mirage-core";
1401
- var OPFS_TAC = command48({
1583
+ import { ResourceName as ResourceName56, command as command53, specOf as specOf53, tacGeneric } from "@struktoai/mirage-core";
1584
+ var OPFS_TAC = command53({
1402
1585
  name: "tac",
1403
- resource: ResourceName51.OPFS,
1404
- spec: specOf48("tac"),
1586
+ resource: ResourceName56.OPFS,
1587
+ spec: specOf53("tac"),
1405
1588
  fn: (accessor, paths, _texts, opts) => tacGeneric(paths, opts, (p) => stream(accessor, p))
1406
1589
  });
1407
1590
 
1408
1591
  // src/commands/builtin/opfs/tail/tail.ts
1409
- import { ResourceName as ResourceName52, command as command49, headerAggregate as headerAggregate2, specOf as specOf49, tailGeneric } from "@struktoai/mirage-core";
1410
- var OPFS_TAIL = command49({
1592
+ import { ResourceName as ResourceName57, command as command54, headerAggregate as headerAggregate2, specOf as specOf54, tailGeneric } from "@struktoai/mirage-core";
1593
+ var OPFS_TAIL = command54({
1411
1594
  name: "tail",
1412
- resource: ResourceName52.OPFS,
1413
- spec: specOf49("tail"),
1595
+ resource: ResourceName57.OPFS,
1596
+ spec: specOf54("tail"),
1414
1597
  fn: (accessor, paths, texts, opts) => tailGeneric(paths, texts, opts, (p) => stream(accessor, p)),
1415
1598
  aggregate: headerAggregate2
1416
1599
  });
1417
1600
 
1418
1601
  // src/commands/builtin/opfs/tar.ts
1419
- import { ResourceName as ResourceName53, command as command50, specOf as specOf50, tarGeneric } from "@struktoai/mirage-core";
1420
- var OPFS_TAR = command50({
1602
+ import { ResourceName as ResourceName58, command as command55, specOf as specOf55, tarGeneric } from "@struktoai/mirage-core";
1603
+ var OPFS_TAR = command55({
1421
1604
  name: "tar",
1422
- resource: ResourceName53.OPFS,
1423
- spec: specOf50("tar"),
1605
+ resource: ResourceName58.OPFS,
1606
+ spec: specOf55("tar"),
1424
1607
  fn: (accessor, paths, _texts, opts) => tarGeneric(
1425
1608
  paths,
1426
1609
  opts,
@@ -1432,11 +1615,11 @@ var OPFS_TAR = command50({
1432
1615
  });
1433
1616
 
1434
1617
  // src/commands/builtin/opfs/tee.ts
1435
- import { ResourceName as ResourceName54, command as command51, specOf as specOf51, teeGeneric } from "@struktoai/mirage-core";
1436
- var OPFS_TEE = command51({
1618
+ import { ResourceName as ResourceName59, command as command56, specOf as specOf56, teeGeneric } from "@struktoai/mirage-core";
1619
+ var OPFS_TEE = command56({
1437
1620
  name: "tee",
1438
- resource: ResourceName54.OPFS,
1439
- spec: specOf51("tee"),
1621
+ resource: ResourceName59.OPFS,
1622
+ spec: specOf56("tee"),
1440
1623
  fn: (accessor, paths, texts, opts) => teeGeneric(
1441
1624
  paths,
1442
1625
  texts,
@@ -1449,15 +1632,15 @@ var OPFS_TEE = command51({
1449
1632
 
1450
1633
  // src/commands/builtin/opfs/touch.ts
1451
1634
  import {
1452
- IOResult as IOResult6,
1453
- ResourceName as ResourceName55,
1454
- command as command52,
1455
- specOf as specOf52
1635
+ IOResult as IOResult7,
1636
+ ResourceName as ResourceName60,
1637
+ command as command57,
1638
+ specOf as specOf57
1456
1639
  } from "@struktoai/mirage-core";
1457
1640
  var ENC2 = new TextEncoder();
1458
1641
  async function touchCommand(accessor, paths, texts, opts) {
1459
1642
  if (paths.length === 0) {
1460
- return [null, new IOResult6({ exitCode: 1, stderr: ENC2.encode("touch: missing operand\n") })];
1643
+ return [null, new IOResult7({ exitCode: 1, stderr: ENC2.encode("touch: missing operand\n") })];
1461
1644
  }
1462
1645
  const createOnly = opts.flags.c === true;
1463
1646
  for (const p of paths) {
@@ -1466,31 +1649,31 @@ async function touchCommand(accessor, paths, texts, opts) {
1466
1649
  await writeBytes(accessor, p, new Uint8Array(0));
1467
1650
  }
1468
1651
  }
1469
- return [null, new IOResult6()];
1652
+ return [null, new IOResult7()];
1470
1653
  }
1471
- var OPFS_TOUCH = command52({
1654
+ var OPFS_TOUCH = command57({
1472
1655
  name: "touch",
1473
- resource: ResourceName55.OPFS,
1474
- spec: specOf52("touch"),
1656
+ resource: ResourceName60.OPFS,
1657
+ spec: specOf57("touch"),
1475
1658
  fn: touchCommand,
1476
1659
  write: true
1477
1660
  });
1478
1661
 
1479
1662
  // src/commands/builtin/opfs/tr.ts
1480
- import { ResourceName as ResourceName56, command as command53, specOf as specOf53, trGeneric } from "@struktoai/mirage-core";
1481
- var OPFS_TR = command53({
1663
+ import { ResourceName as ResourceName61, command as command58, specOf as specOf58, trGeneric } from "@struktoai/mirage-core";
1664
+ var OPFS_TR = command58({
1482
1665
  name: "tr",
1483
- resource: ResourceName56.OPFS,
1484
- spec: specOf53("tr"),
1666
+ resource: ResourceName61.OPFS,
1667
+ spec: specOf58("tr"),
1485
1668
  fn: (accessor, paths, texts, opts) => trGeneric(paths, texts, opts, (p) => stream(accessor, p))
1486
1669
  });
1487
1670
 
1488
1671
  // src/commands/builtin/opfs/tree.ts
1489
- import { ResourceName as ResourceName57, command as command54, specOf as specOf54, treeGeneric } from "@struktoai/mirage-core";
1490
- var OPFS_TREE = command54({
1672
+ import { ResourceName as ResourceName62, command as command59, specOf as specOf59, treeGeneric } from "@struktoai/mirage-core";
1673
+ var OPFS_TREE = command59({
1491
1674
  name: "tree",
1492
- resource: ResourceName57.OPFS,
1493
- spec: specOf54("tree"),
1675
+ resource: ResourceName62.OPFS,
1676
+ spec: specOf59("tree"),
1494
1677
  fn: (accessor, paths, _texts, opts) => treeGeneric(
1495
1678
  paths,
1496
1679
  opts,
@@ -1500,38 +1683,111 @@ var OPFS_TREE = command54({
1500
1683
  });
1501
1684
 
1502
1685
  // src/commands/builtin/opfs/tsort.ts
1503
- import { ResourceName as ResourceName58, command as command55, specOf as specOf55, tsortGeneric } from "@struktoai/mirage-core";
1504
- var OPFS_TSORT = command55({
1686
+ import { ResourceName as ResourceName63, command as command60, specOf as specOf60, tsortGeneric } from "@struktoai/mirage-core";
1687
+ var OPFS_TSORT = command60({
1505
1688
  name: "tsort",
1506
- resource: ResourceName58.OPFS,
1507
- spec: specOf55("tsort"),
1689
+ resource: ResourceName63.OPFS,
1690
+ spec: specOf60("tsort"),
1508
1691
  fn: (accessor, paths, _texts, opts) => tsortGeneric(paths, opts, (p) => stream(accessor, p))
1509
1692
  });
1510
1693
 
1511
1694
  // src/commands/builtin/opfs/unexpand.ts
1512
- import { ResourceName as ResourceName59, command as command56, specOf as specOf56, unexpandGeneric } from "@struktoai/mirage-core";
1513
- var OPFS_UNEXPAND = command56({
1695
+ import { ResourceName as ResourceName64, command as command61, specOf as specOf61, unexpandGeneric } from "@struktoai/mirage-core";
1696
+ var OPFS_UNEXPAND = command61({
1514
1697
  name: "unexpand",
1515
- resource: ResourceName59.OPFS,
1516
- spec: specOf56("unexpand"),
1698
+ resource: ResourceName64.OPFS,
1699
+ spec: specOf61("unexpand"),
1517
1700
  fn: (accessor, paths, _texts, opts) => unexpandGeneric(paths, opts, (p) => stream(accessor, p))
1518
1701
  });
1519
1702
 
1520
1703
  // src/commands/builtin/opfs/uniq.ts
1521
- import { ResourceName as ResourceName60, command as command57, specOf as specOf57, uniqGeneric } from "@struktoai/mirage-core";
1522
- var OPFS_UNIQ = command57({
1704
+ import { ResourceName as ResourceName65, command as command62, specOf as specOf62, uniqGeneric } from "@struktoai/mirage-core";
1705
+ var OPFS_UNIQ = command62({
1523
1706
  name: "uniq",
1524
- resource: ResourceName60.OPFS,
1525
- spec: specOf57("uniq"),
1526
- fn: (accessor, paths, _texts, opts) => uniqGeneric(paths, opts, (p) => stream(accessor, p))
1707
+ resource: ResourceName65.OPFS,
1708
+ spec: specOf62("uniq"),
1709
+ fn: (accessor, paths, _texts, opts) => uniqGeneric(
1710
+ paths,
1711
+ opts,
1712
+ (p) => stream(accessor, p),
1713
+ (p, data) => writeBytes(accessor, p, data)
1714
+ )
1715
+ });
1716
+
1717
+ // src/commands/builtin/opfs/unlink.ts
1718
+ import {
1719
+ FileType as FileType4,
1720
+ IOResult as IOResult8,
1721
+ ResourceName as ResourceName66,
1722
+ command as command63,
1723
+ specOf as specOf63
1724
+ } from "@struktoai/mirage-core";
1725
+ async function unlinkCommand(accessor, paths, _texts, _opts) {
1726
+ const enc = new TextEncoder();
1727
+ if (paths.length === 0) {
1728
+ return [
1729
+ null,
1730
+ new IOResult8({
1731
+ exitCode: 1,
1732
+ stderr: enc.encode("unlink: missing operand\nTry 'unlink --help' for more information.\n")
1733
+ })
1734
+ ];
1735
+ }
1736
+ if (paths.length > 1) {
1737
+ const extra = paths[1];
1738
+ const raw = extra === void 0 ? "" : extra.rawPath;
1739
+ return [
1740
+ null,
1741
+ new IOResult8({
1742
+ exitCode: 1,
1743
+ stderr: enc.encode(
1744
+ `unlink: extra operand '${raw}'
1745
+ Try 'unlink --help' for more information.
1746
+ `
1747
+ )
1748
+ })
1749
+ ];
1750
+ }
1751
+ const p = paths[0];
1752
+ if (p === void 0) return [null, new IOResult8()];
1753
+ try {
1754
+ if ((await stat(accessor, p)).type === FileType4.DIRECTORY) {
1755
+ return [
1756
+ null,
1757
+ new IOResult8({
1758
+ exitCode: 1,
1759
+ stderr: enc.encode(`unlink: cannot unlink '${p.virtual}': Is a directory
1760
+ `)
1761
+ })
1762
+ ];
1763
+ }
1764
+ } catch {
1765
+ return [
1766
+ null,
1767
+ new IOResult8({
1768
+ exitCode: 1,
1769
+ stderr: enc.encode(`unlink: cannot unlink '${p.virtual}': No such file or directory
1770
+ `)
1771
+ })
1772
+ ];
1773
+ }
1774
+ await unlink(accessor, p);
1775
+ return [null, new IOResult8({ writes: { [p.mountPath]: new Uint8Array() } })];
1776
+ }
1777
+ var OPFS_UNLINK = command63({
1778
+ name: "unlink",
1779
+ resource: ResourceName66.OPFS,
1780
+ spec: specOf63("unlink"),
1781
+ fn: unlinkCommand,
1782
+ write: true
1527
1783
  });
1528
1784
 
1529
1785
  // src/commands/builtin/opfs/unzip.ts
1530
- import { ResourceName as ResourceName61, command as command58, specOf as specOf58, unzipGeneric } from "@struktoai/mirage-core";
1531
- var OPFS_UNZIP = command58({
1786
+ import { ResourceName as ResourceName67, command as command64, specOf as specOf64, unzipGeneric } from "@struktoai/mirage-core";
1787
+ var OPFS_UNZIP = command64({
1532
1788
  name: "unzip",
1533
- resource: ResourceName61.OPFS,
1534
- spec: specOf58("unzip"),
1789
+ resource: ResourceName67.OPFS,
1790
+ spec: specOf64("unzip"),
1535
1791
  fn: (accessor, paths, _texts, opts) => unzipGeneric(
1536
1792
  paths,
1537
1793
  opts,
@@ -1543,48 +1799,48 @@ var OPFS_UNZIP = command58({
1543
1799
  });
1544
1800
 
1545
1801
  // src/commands/builtin/opfs/wc/wc.ts
1546
- import { ResourceName as ResourceName62, command as command59, specOf as specOf59, wcAggregate, wcGeneric } from "@struktoai/mirage-core";
1547
- var OPFS_WC = command59({
1802
+ import { ResourceName as ResourceName68, command as command65, specOf as specOf65, wcAggregate, wcGeneric } from "@struktoai/mirage-core";
1803
+ var OPFS_WC = command65({
1548
1804
  name: "wc",
1549
- resource: ResourceName62.OPFS,
1550
- spec: specOf59("wc"),
1805
+ resource: ResourceName68.OPFS,
1806
+ spec: specOf65("wc"),
1551
1807
  fn: (accessor, paths, texts, opts) => wcGeneric(paths, texts, opts, (p) => stream(accessor, p)),
1552
1808
  aggregate: wcAggregate
1553
1809
  });
1554
1810
 
1555
1811
  // src/commands/builtin/opfs/xxd.ts
1556
- import { ResourceName as ResourceName63, command as command60, specOf as specOf60, xxdGeneric } from "@struktoai/mirage-core";
1557
- var OPFS_XXD = command60({
1812
+ import { ResourceName as ResourceName69, command as command66, specOf as specOf66, xxdGeneric } from "@struktoai/mirage-core";
1813
+ var OPFS_XXD = command66({
1558
1814
  name: "xxd",
1559
- resource: ResourceName63.OPFS,
1560
- spec: specOf60("xxd"),
1815
+ resource: ResourceName69.OPFS,
1816
+ spec: specOf66("xxd"),
1561
1817
  fn: (accessor, paths, _texts, opts) => xxdGeneric(paths, opts, (p) => stream(accessor, p))
1562
1818
  });
1563
1819
 
1564
1820
  // src/commands/builtin/opfs/zcat.ts
1565
- import { ResourceName as ResourceName64, command as command61, specOf as specOf61, zcatGeneric } from "@struktoai/mirage-core";
1566
- var OPFS_ZCAT = command61({
1821
+ import { ResourceName as ResourceName70, command as command67, specOf as specOf67, zcatGeneric } from "@struktoai/mirage-core";
1822
+ var OPFS_ZCAT = command67({
1567
1823
  name: "zcat",
1568
- resource: ResourceName64.OPFS,
1569
- spec: specOf61("zcat"),
1824
+ resource: ResourceName70.OPFS,
1825
+ spec: specOf67("zcat"),
1570
1826
  fn: (accessor, paths, _texts, opts) => zcatGeneric(paths, opts, (p) => stream(accessor, p))
1571
1827
  });
1572
1828
 
1573
1829
  // src/commands/builtin/opfs/zgrep.ts
1574
- import { ResourceName as ResourceName65, command as command62, specOf as specOf62, zgrepGeneric } from "@struktoai/mirage-core";
1575
- var OPFS_ZGREP = command62({
1830
+ import { ResourceName as ResourceName71, command as command68, specOf as specOf68, zgrepGeneric } from "@struktoai/mirage-core";
1831
+ var OPFS_ZGREP = command68({
1576
1832
  name: "zgrep",
1577
- resource: ResourceName65.OPFS,
1578
- spec: specOf62("zgrep"),
1833
+ resource: ResourceName71.OPFS,
1834
+ spec: specOf68("zgrep"),
1579
1835
  fn: (accessor, paths, texts, opts) => zgrepGeneric(paths, texts, opts, (p) => stream(accessor, p))
1580
1836
  });
1581
1837
 
1582
1838
  // src/commands/builtin/opfs/zip_cmd.ts
1583
- import { ResourceName as ResourceName66, command as command63, specOf as specOf63, zipGeneric } from "@struktoai/mirage-core";
1584
- var OPFS_ZIP = command63({
1839
+ import { ResourceName as ResourceName72, command as command69, specOf as specOf69, zipGeneric } from "@struktoai/mirage-core";
1840
+ var OPFS_ZIP = command69({
1585
1841
  name: "zip",
1586
- resource: ResourceName66.OPFS,
1587
- spec: specOf63("zip"),
1842
+ resource: ResourceName72.OPFS,
1843
+ spec: specOf69("zip"),
1588
1844
  fn: (accessor, paths, _texts, opts) => zipGeneric(
1589
1845
  paths,
1590
1846
  opts,
@@ -1595,83 +1851,95 @@ var OPFS_ZIP = command63({
1595
1851
  });
1596
1852
 
1597
1853
  // src/commands/builtin/opfs/index.ts
1598
- var OPFS_COMMANDS = [
1599
- ...makeFiletypeCommands({
1600
- resource: ResourceName67.OPFS,
1601
- readBytes: read,
1602
- statEntry: stat
1603
- }),
1604
- ...OPFS_AWK,
1605
- ...OPFS_BASE64,
1606
- ...OPFS_BASENAME,
1607
- ...OPFS_CAT,
1608
- ...OPFS_CMP,
1609
- ...OPFS_COLUMN,
1610
- ...OPFS_COMM,
1611
- ...OPFS_CP,
1612
- ...OPFS_CSPLIT,
1613
- ...OPFS_CUT,
1614
- ...OPFS_DIFF,
1615
- ...OPFS_DIRNAME,
1616
- ...OPFS_DU,
1617
- ...OPFS_EXPAND,
1618
- ...OPFS_FILE,
1619
- ...OPFS_FIND,
1620
- ...OPFS_FMT,
1621
- ...OPFS_FOLD,
1622
- ...OPFS_GREP,
1623
- ...OPFS_GUNZIP,
1624
- ...OPFS_GZIP,
1625
- ...OPFS_HEAD,
1626
- ...OPFS_ICONV,
1627
- ...OPFS_JOIN,
1628
- ...OPFS_JQ,
1629
- ...OPFS_LN,
1630
- ...OPFS_LOOK,
1631
- ...OPFS_LS,
1632
- ...OPFS_MD5,
1633
- ...OPFS_MKDIR,
1634
- ...OPFS_MKTEMP,
1635
- ...OPFS_MV,
1636
- ...OPFS_NL,
1637
- ...OPFS_PASTE,
1638
- ...OPFS_PATCH,
1639
- ...OPFS_READLINK,
1640
- ...OPFS_REALPATH,
1641
- ...OPFS_REV,
1642
- ...OPFS_RG,
1643
- ...OPFS_RM,
1644
- ...OPFS_SED,
1645
- ...OPFS_SHA256SUM,
1646
- ...OPFS_SHUF,
1647
- ...OPFS_SORT,
1648
- ...OPFS_SPLIT,
1649
- ...OPFS_STAT,
1650
- ...OPFS_STRINGS,
1651
- ...OPFS_TAC,
1652
- ...OPFS_TAIL,
1653
- ...OPFS_TAR,
1654
- ...OPFS_TEE,
1655
- ...OPFS_TOUCH,
1656
- ...OPFS_TR,
1657
- ...OPFS_TREE,
1658
- ...OPFS_TSORT,
1659
- ...OPFS_UNEXPAND,
1660
- ...OPFS_UNIQ,
1661
- ...OPFS_UNZIP,
1662
- ...OPFS_WC,
1663
- ...OPFS_XXD,
1664
- ...OPFS_ZCAT,
1665
- ...OPFS_ZGREP,
1666
- ...OPFS_ZIP
1667
- ];
1854
+ var opfsResolveGlob = makeResolveGlob(readdir, SCOPE_ERROR);
1855
+ var OPFS_COMMANDS = withDefaultProvisions(
1856
+ [
1857
+ ...makeFiletypeCommands({
1858
+ resource: ResourceName73.OPFS,
1859
+ readBytes: read,
1860
+ statEntry: stat
1861
+ }),
1862
+ ...OPFS_AWK,
1863
+ ...OPFS_BASE64,
1864
+ ...OPFS_BASENAME,
1865
+ ...OPFS_CAT,
1866
+ ...OPFS_CMP,
1867
+ ...OPFS_COLUMN,
1868
+ ...OPFS_COMM,
1869
+ ...OPFS_CP,
1870
+ ...OPFS_CSPLIT,
1871
+ ...OPFS_CUT,
1872
+ ...OPFS_DIFF,
1873
+ ...OPFS_DIRNAME,
1874
+ ...OPFS_DU,
1875
+ ...OPFS_EXPAND,
1876
+ ...OPFS_FILE,
1877
+ ...OPFS_FIND,
1878
+ ...OPFS_FMT,
1879
+ ...OPFS_FOLD,
1880
+ ...OPFS_GREP,
1881
+ ...OPFS_GUNZIP,
1882
+ ...OPFS_GZIP,
1883
+ ...OPFS_HEAD,
1884
+ ...OPFS_ICONV,
1885
+ ...OPFS_JOIN,
1886
+ ...OPFS_JQ,
1887
+ ...OPFS_LN,
1888
+ ...OPFS_LOOK,
1889
+ ...OPFS_LS,
1890
+ ...OPFS_MD5,
1891
+ ...OPFS_MD5SUM,
1892
+ ...OPFS_MKDIR,
1893
+ ...OPFS_MKTEMP,
1894
+ ...OPFS_MV,
1895
+ ...OPFS_NL,
1896
+ ...OPFS_PASTE,
1897
+ ...OPFS_PATCH,
1898
+ ...OPFS_READLINK,
1899
+ ...OPFS_REALPATH,
1900
+ ...OPFS_REV,
1901
+ ...OPFS_RG,
1902
+ ...OPFS_RM,
1903
+ ...OPFS_RMDIR,
1904
+ ...OPFS_SED,
1905
+ ...OPFS_SHA1SUM,
1906
+ ...OPFS_SHA256SUM,
1907
+ ...OPFS_SHA384SUM,
1908
+ ...OPFS_SHA512SUM,
1909
+ ...OPFS_SHUF,
1910
+ ...OPFS_SORT,
1911
+ ...OPFS_SPLIT,
1912
+ ...OPFS_STAT,
1913
+ ...OPFS_STRINGS,
1914
+ ...OPFS_TAC,
1915
+ ...OPFS_TAIL,
1916
+ ...OPFS_TAR,
1917
+ ...OPFS_TEE,
1918
+ ...OPFS_TOUCH,
1919
+ ...OPFS_TR,
1920
+ ...OPFS_TREE,
1921
+ ...OPFS_TSORT,
1922
+ ...OPFS_UNEXPAND,
1923
+ ...OPFS_UNIQ,
1924
+ ...OPFS_UNLINK,
1925
+ ...OPFS_UNZIP,
1926
+ ...OPFS_WC,
1927
+ ...OPFS_XXD,
1928
+ ...OPFS_ZCAT,
1929
+ ...OPFS_ZGREP,
1930
+ ...OPFS_ZIP
1931
+ ],
1932
+ stat,
1933
+ opfsResolveGlob,
1934
+ readdir
1935
+ );
1668
1936
 
1669
1937
  // src/core/opfs/append.ts
1670
- import { record as record3, ResourceName as ResourceName68 } from "@struktoai/mirage-core";
1938
+ import { record as record3, ResourceName as ResourceName74 } from "@struktoai/mirage-core";
1671
1939
  async function appendBytes(accessor, p, data) {
1672
1940
  const root = accessor.rootHandle;
1673
1941
  const start = performance.now();
1674
- const virtual = p.stripPrefix;
1942
+ const virtual = p.mountPath;
1675
1943
  const handle = await resolveFileHandle(root, virtual, { create: true });
1676
1944
  const existing = await handle.getFile();
1677
1945
  const existingBytes = new Uint8Array(await existing.arrayBuffer());
@@ -1681,57 +1949,13 @@ async function appendBytes(accessor, p, data) {
1681
1949
  const writable = await handle.createWritable();
1682
1950
  await writable.write(toWritableChunk(merged));
1683
1951
  await writable.close();
1684
- record3("append", virtual, ResourceName68.OPFS, data.byteLength, start);
1685
- }
1686
-
1687
- // src/core/opfs/glob.ts
1688
- import { PathSpec } from "@struktoai/mirage-core";
1689
-
1690
- // src/core/opfs/constants.ts
1691
- var SCOPE_ERROR = 5e4;
1692
-
1693
- // src/core/opfs/glob.ts
1694
- import { fnmatch } from "@struktoai/mirage-core";
1695
- import { gnuBasename as gnuBasename2 } from "@struktoai/mirage-core";
1696
- async function resolveGlob(accessor, paths) {
1697
- const result = [];
1698
- for (const p of paths) {
1699
- if (p.resolved) {
1700
- result.push(p);
1701
- } else if (p.pattern !== null) {
1702
- const dirSpec = new PathSpec({
1703
- original: p.directory,
1704
- directory: p.directory,
1705
- resolved: true,
1706
- prefix: p.prefix
1707
- });
1708
- const entries = await readdir(accessor, dirSpec);
1709
- const matched = [];
1710
- for (const e of entries) {
1711
- if (fnmatch(gnuBasename2(e), p.pattern)) {
1712
- matched.push(
1713
- new PathSpec({
1714
- original: e,
1715
- directory: p.directory,
1716
- resolved: true,
1717
- prefix: p.prefix
1718
- })
1719
- );
1720
- }
1721
- }
1722
- if (matched.length > SCOPE_ERROR) matched.length = SCOPE_ERROR;
1723
- result.push(...matched);
1724
- } else {
1725
- result.push(p);
1726
- }
1727
- }
1728
- return result;
1952
+ record3("append", virtual, ResourceName74.OPFS, data.byteLength, start);
1729
1953
  }
1730
1954
 
1731
1955
  // src/core/opfs/truncate.ts
1732
1956
  async function truncate(accessor, path, length) {
1733
1957
  const root = accessor.rootHandle;
1734
- const virtual = path.stripPrefix;
1958
+ const virtual = path.mountPath;
1735
1959
  let handle;
1736
1960
  let existing;
1737
1961
  try {
@@ -1754,10 +1978,10 @@ async function truncate(accessor, path, length) {
1754
1978
  }
1755
1979
 
1756
1980
  // src/ops/opfs/append.ts
1757
- import { ResourceName as ResourceName69 } from "@struktoai/mirage-core";
1981
+ import { ResourceName as ResourceName75 } from "@struktoai/mirage-core";
1758
1982
  var appendOp = {
1759
1983
  name: "append",
1760
- resource: ResourceName69.OPFS,
1984
+ resource: ResourceName75.OPFS,
1761
1985
  filetype: null,
1762
1986
  write: true,
1763
1987
  fn: (accessor, path, args) => {
@@ -1770,7 +1994,7 @@ var appendOp = {
1770
1994
  };
1771
1995
 
1772
1996
  // src/ops/opfs/create.ts
1773
- import { ResourceName as ResourceName70 } from "@struktoai/mirage-core";
1997
+ import { ResourceName as ResourceName76 } from "@struktoai/mirage-core";
1774
1998
 
1775
1999
  // src/core/opfs/create.ts
1776
2000
  function create(accessor, path) {
@@ -1780,52 +2004,52 @@ function create(accessor, path) {
1780
2004
  // src/ops/opfs/create.ts
1781
2005
  var createOp = {
1782
2006
  name: "create",
1783
- resource: ResourceName70.OPFS,
2007
+ resource: ResourceName76.OPFS,
1784
2008
  filetype: null,
1785
2009
  write: true,
1786
2010
  fn: (accessor, path) => create(accessor, path)
1787
2011
  };
1788
2012
 
1789
2013
  // src/ops/opfs/mkdir.ts
1790
- import { ResourceName as ResourceName71 } from "@struktoai/mirage-core";
2014
+ import { ResourceName as ResourceName77 } from "@struktoai/mirage-core";
1791
2015
  var mkdirOp = {
1792
2016
  name: "mkdir",
1793
- resource: ResourceName71.OPFS,
2017
+ resource: ResourceName77.OPFS,
1794
2018
  filetype: null,
1795
2019
  write: true,
1796
2020
  fn: (accessor, path) => mkdir(accessor, path, true)
1797
2021
  };
1798
2022
 
1799
2023
  // src/ops/opfs/read.ts
1800
- import { ResourceName as ResourceName72 } from "@struktoai/mirage-core";
2024
+ import { ResourceName as ResourceName78 } from "@struktoai/mirage-core";
1801
2025
  var readOp = {
1802
2026
  name: "read",
1803
- resource: ResourceName72.OPFS,
2027
+ resource: ResourceName78.OPFS,
1804
2028
  filetype: null,
1805
2029
  write: false,
1806
2030
  fn: (accessor, path) => read(accessor, path)
1807
2031
  };
1808
2032
 
1809
2033
  // src/ops/opfs/readdir.ts
1810
- import { ResourceName as ResourceName73 } from "@struktoai/mirage-core";
2034
+ import { ResourceName as ResourceName79 } from "@struktoai/mirage-core";
1811
2035
  var readdirOp = {
1812
2036
  name: "readdir",
1813
- resource: ResourceName73.OPFS,
2037
+ resource: ResourceName79.OPFS,
1814
2038
  filetype: null,
1815
2039
  write: false,
1816
2040
  fn: (accessor, path) => readdir(accessor, path)
1817
2041
  };
1818
2042
 
1819
2043
  // src/ops/opfs/rename.ts
1820
- import { ResourceName as ResourceName74 } from "@struktoai/mirage-core";
2044
+ import { ResourceName as ResourceName80 } from "@struktoai/mirage-core";
1821
2045
  var renameOp = {
1822
2046
  name: "rename",
1823
- resource: ResourceName74.OPFS,
2047
+ resource: ResourceName80.OPFS,
1824
2048
  filetype: null,
1825
2049
  write: true,
1826
2050
  fn: (accessor, path, args) => {
1827
2051
  const dst = args[0];
1828
- if (dst === void 0 || dst === null || typeof dst !== "object" || !("original" in dst)) {
2052
+ if (dst === void 0 || dst === null || typeof dst !== "object" || !("virtual" in dst)) {
1829
2053
  throw new TypeError("rename op requires a PathSpec destination as the first arg");
1830
2054
  }
1831
2055
  return rename(accessor, path, dst);
@@ -1833,30 +2057,30 @@ var renameOp = {
1833
2057
  };
1834
2058
 
1835
2059
  // src/ops/opfs/rmdir.ts
1836
- import { ResourceName as ResourceName75 } from "@struktoai/mirage-core";
2060
+ import { ResourceName as ResourceName81 } from "@struktoai/mirage-core";
1837
2061
  var rmdirOp = {
1838
2062
  name: "rmdir",
1839
- resource: ResourceName75.OPFS,
2063
+ resource: ResourceName81.OPFS,
1840
2064
  filetype: null,
1841
2065
  write: true,
1842
2066
  fn: (accessor, path) => rmdir(accessor, path)
1843
2067
  };
1844
2068
 
1845
2069
  // src/ops/opfs/stat.ts
1846
- import { ResourceName as ResourceName76 } from "@struktoai/mirage-core";
2070
+ import { ResourceName as ResourceName82 } from "@struktoai/mirage-core";
1847
2071
  var statOp = {
1848
2072
  name: "stat",
1849
- resource: ResourceName76.OPFS,
2073
+ resource: ResourceName82.OPFS,
1850
2074
  filetype: null,
1851
2075
  write: false,
1852
2076
  fn: (accessor, path) => stat(accessor, path)
1853
2077
  };
1854
2078
 
1855
2079
  // src/ops/opfs/truncate.ts
1856
- import { ResourceName as ResourceName77 } from "@struktoai/mirage-core";
2080
+ import { ResourceName as ResourceName83 } from "@struktoai/mirage-core";
1857
2081
  var truncateOp = {
1858
2082
  name: "truncate",
1859
- resource: ResourceName77.OPFS,
2083
+ resource: ResourceName83.OPFS,
1860
2084
  filetype: null,
1861
2085
  write: true,
1862
2086
  fn: (accessor, path, args) => {
@@ -1869,20 +2093,20 @@ var truncateOp = {
1869
2093
  };
1870
2094
 
1871
2095
  // src/ops/opfs/unlink.ts
1872
- import { ResourceName as ResourceName78 } from "@struktoai/mirage-core";
2096
+ import { ResourceName as ResourceName84 } from "@struktoai/mirage-core";
1873
2097
  var unlinkOp = {
1874
2098
  name: "unlink",
1875
- resource: ResourceName78.OPFS,
2099
+ resource: ResourceName84.OPFS,
1876
2100
  filetype: null,
1877
2101
  write: true,
1878
2102
  fn: (accessor, path) => unlink(accessor, path)
1879
2103
  };
1880
2104
 
1881
2105
  // src/ops/opfs/write.ts
1882
- import { ResourceName as ResourceName79 } from "@struktoai/mirage-core";
2106
+ import { ResourceName as ResourceName85 } from "@struktoai/mirage-core";
1883
2107
  var writeOp = {
1884
2108
  name: "write",
1885
- resource: ResourceName79.OPFS,
2109
+ resource: ResourceName85.OPFS,
1886
2110
  filetype: null,
1887
2111
  write: true,
1888
2112
  fn: (accessor, path, args) => {
@@ -1915,6 +2139,7 @@ var OPFS_PROMPT = `{prefix}
1915
2139
  Standard commands: ls, cat, head, tail, grep, wc, find, tree, mkdir, touch, cp, mv, rm, tee.`;
1916
2140
 
1917
2141
  // src/resource/opfs/opfs.ts
2142
+ var globCore = makeResolveGlob2(readdir, SCOPE_ERROR);
1918
2143
  async function walkFiles(dir, currentPath, files) {
1919
2144
  for await (const [name, handle] of iterEntries(dir)) {
1920
2145
  const childPath = currentPath === "" ? name : `${currentPath}/${name}`;
@@ -1946,7 +2171,7 @@ async function splitAndCreate(root, relativePath) {
1946
2171
  return handle;
1947
2172
  }
1948
2173
  var OPFSResource = class {
1949
- kind = ResourceName80.OPFS;
2174
+ kind = ResourceName86.OPFS;
1950
2175
  prompt = OPFS_PROMPT;
1951
2176
  rootName;
1952
2177
  accessor;
@@ -2061,7 +2286,7 @@ var OPFSResource = class {
2061
2286
  }
2062
2287
  async glob(paths) {
2063
2288
  await this.ensureOpen();
2064
- return resolveGlob(this.accessor, paths);
2289
+ return globCore(this.accessor, paths);
2065
2290
  }
2066
2291
  async getState() {
2067
2292
  const handle = await this.ensureOpen();
@@ -2106,4 +2331,4 @@ export {
2106
2331
  OPFS_PROMPT,
2107
2332
  OPFSResource
2108
2333
  };
2109
- //# sourceMappingURL=chunk-SJB2KXDM.js.map
2334
+ //# sourceMappingURL=chunk-4YUYQTRN.js.map