@struktoai/mirage-browser 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aliyun-YEWHEWCL.js +8 -0
- package/dist/backblaze-LWE2HEDK.js +8 -0
- package/dist/box-GTWWIB6F.js +8 -0
- package/dist/ceph-ATSCSVGU.js +8 -0
- package/dist/{chunk-YGRKFONX.js → chunk-23NO22WD.js} +1 -2
- package/dist/{chunk-YGRKFONX.js.map → chunk-23NO22WD.js.map} +1 -1
- package/dist/{chunk-OSMEXGRN.js → chunk-2R7SPBTM.js} +10 -12
- package/dist/chunk-2R7SPBTM.js.map +1 -0
- package/dist/{chunk-SOF74I3T.js → chunk-37WKCB2E.js} +7 -5
- package/dist/chunk-37WKCB2E.js.map +1 -0
- package/dist/{chunk-NLBT6TBM.js → chunk-3FZ3GHZO.js} +6 -4
- package/dist/chunk-3FZ3GHZO.js.map +1 -0
- package/dist/{chunk-KV2DM5H6.js → chunk-4YUYQTRN.js} +616 -398
- package/dist/chunk-4YUYQTRN.js.map +1 -0
- package/dist/{chunk-KNJKYCTA.js → chunk-5ZNWDS5I.js} +9 -11
- package/dist/chunk-5ZNWDS5I.js.map +1 -0
- package/dist/{chunk-PV53AX35.js → chunk-6BXVYCIC.js} +9 -11
- package/dist/chunk-6BXVYCIC.js.map +1 -0
- package/dist/{chunk-BJHHL4UT.js → chunk-6ETIHSTA.js} +9 -10
- package/dist/chunk-6ETIHSTA.js.map +1 -0
- package/dist/{chunk-XBOJZZRT.js → chunk-AAJQ6AQT.js} +10 -12
- package/dist/chunk-AAJQ6AQT.js.map +1 -0
- package/dist/{chunk-DHZMC42C.js → chunk-AUKVYHNZ.js} +6 -4
- package/dist/chunk-AUKVYHNZ.js.map +1 -0
- package/dist/{chunk-DA5EW34P.js → chunk-AUXZEXCG.js} +11 -11
- package/dist/chunk-AUXZEXCG.js.map +1 -0
- package/dist/{chunk-2AEAISO2.js → chunk-CQERQTAZ.js} +16 -13
- package/dist/chunk-CQERQTAZ.js.map +1 -0
- package/dist/{chunk-RQ273N5K.js → chunk-DC6VA36O.js} +8 -15
- package/dist/chunk-DC6VA36O.js.map +1 -0
- package/dist/{chunk-HYUESAQS.js → chunk-DGP3N4WM.js} +1 -2
- package/dist/{chunk-HYUESAQS.js.map → chunk-DGP3N4WM.js.map} +1 -1
- package/dist/{chunk-ROHDW6KT.js → chunk-DKPDXQML.js} +6 -4
- package/dist/chunk-DKPDXQML.js.map +1 -0
- package/dist/{chunk-2H4KUUFP.js → chunk-DQK6H5LW.js} +1 -2
- package/dist/{chunk-2H4KUUFP.js.map → chunk-DQK6H5LW.js.map} +1 -1
- package/dist/{chunk-KTE5PB2D.js → chunk-E77ESWWV.js} +12 -12
- package/dist/chunk-E77ESWWV.js.map +1 -0
- package/dist/{chunk-F5QWZ7GM.js → chunk-EDS5Q5B7.js} +6 -4
- package/dist/chunk-EDS5Q5B7.js.map +1 -0
- package/dist/{chunk-K2S42IR4.js → chunk-EHTYPBGX.js} +6 -4
- package/dist/chunk-EHTYPBGX.js.map +1 -0
- package/dist/{chunk-DVXOMWD4.js → chunk-GENFT46X.js} +6 -4
- package/dist/chunk-GENFT46X.js.map +1 -0
- package/dist/{chunk-J54OBIJA.js → chunk-GQVJTQXU.js} +6 -2
- package/dist/chunk-GQVJTQXU.js.map +1 -0
- package/dist/{chunk-J7PLA5S3.js → chunk-GZFNGV55.js} +6 -4
- package/dist/chunk-GZFNGV55.js.map +1 -0
- package/dist/{chunk-DFHFILVF.js → chunk-HPID7BWJ.js} +10 -12
- package/dist/chunk-HPID7BWJ.js.map +1 -0
- package/dist/{chunk-57QQAM7V.js → chunk-HTQ4GBKM.js} +6 -4
- package/dist/chunk-HTQ4GBKM.js.map +1 -0
- package/dist/{chunk-NWZNQ3RC.js → chunk-JV4T5HNB.js} +6 -4
- package/dist/chunk-JV4T5HNB.js.map +1 -0
- package/dist/{chunk-BIIG7ZAQ.js → chunk-KL2VFYUV.js} +7 -5
- package/dist/chunk-KL2VFYUV.js.map +1 -0
- package/dist/{chunk-54NTYJEO.js → chunk-LPDLPRPS.js} +1 -3
- package/dist/{chunk-54NTYJEO.js.map → chunk-LPDLPRPS.js.map} +1 -1
- package/dist/{chunk-CGZGX2GO.js → chunk-LW56WZDS.js} +10 -12
- package/dist/chunk-LW56WZDS.js.map +1 -0
- package/dist/{chunk-QLLRQNOJ.js → chunk-MB4TUUJQ.js} +6 -4
- package/dist/chunk-MB4TUUJQ.js.map +1 -0
- package/dist/{chunk-O5ONB7QT.js → chunk-MQMUOJZ2.js} +8 -4
- package/dist/chunk-MQMUOJZ2.js.map +1 -0
- package/dist/{chunk-4NLXLDMV.js → chunk-N5VRBFRT.js} +10 -12
- package/dist/chunk-N5VRBFRT.js.map +1 -0
- package/dist/{chunk-LSURHXZH.js → chunk-NVGB3B7J.js} +6 -4
- package/dist/chunk-NVGB3B7J.js.map +1 -0
- package/dist/{chunk-HXQ7HDA6.js → chunk-NYTRDAWX.js} +16 -13
- package/dist/chunk-NYTRDAWX.js.map +1 -0
- package/dist/{chunk-CNDGXKMU.js → chunk-PCC6EZIE.js} +6 -4
- package/dist/chunk-PCC6EZIE.js.map +1 -0
- package/dist/{chunk-TQ6VRUEI.js → chunk-PDZSZ5CB.js} +9 -11
- package/dist/chunk-PDZSZ5CB.js.map +1 -0
- package/dist/{chunk-XYKNXGPR.js → chunk-POJ3IQMQ.js} +13 -13
- package/dist/chunk-POJ3IQMQ.js.map +1 -0
- package/dist/{chunk-X2CCEHOR.js → chunk-PSEXJ5S5.js} +12 -11
- package/dist/chunk-PSEXJ5S5.js.map +1 -0
- package/dist/{chunk-NMZBJOFW.js → chunk-QXJP6TWI.js} +5 -4
- package/dist/chunk-QXJP6TWI.js.map +1 -0
- package/dist/{chunk-6YP3B7UK.js → chunk-TCFD6YJ5.js} +6 -4
- package/dist/chunk-TCFD6YJ5.js.map +1 -0
- package/dist/{chunk-G26SGOFR.js → chunk-VASFK7V6.js} +6 -4
- package/dist/chunk-VASFK7V6.js.map +1 -0
- package/dist/{chunk-JSAQMYPK.js → chunk-ZLHC2CZ6.js} +1 -2
- package/dist/{chunk-JSAQMYPK.js.map → chunk-ZLHC2CZ6.js.map} +1 -1
- package/dist/config-22T7HJBJ.js +9 -0
- package/dist/config-A56HUM6C.js +9 -0
- package/dist/config-DIWQZBOK.js +9 -0
- package/dist/config-HGJ2MGAC.js +9 -0
- package/dist/{config-ET26F632.js → config-MHBKYS53.js} +2 -4
- package/dist/config-PAHALM2T.js +9 -0
- package/dist/config-PWZXYJOI.js +9 -0
- package/dist/{config-NV5WXP64.js → config-UU27ALAA.js} +2 -4
- package/dist/digitalocean-SQA6MJJQ.js +8 -0
- package/dist/discord-ASNFJP6A.js +7 -0
- package/dist/dropbox-VV2WZE6I.js +8 -0
- package/dist/gcs-2W6DDWM7.js +8 -0
- package/dist/gdocs-QPM7VXXE.js +8 -0
- package/dist/gdrive-KT6R7EVB.js +8 -0
- package/dist/github-3IFZGW6I.js +7 -0
- package/dist/github_ci-CKKF2Y4S.js +8 -0
- package/dist/gmail-HLZIMKQU.js +8 -0
- package/dist/gsheets-HF4YPIEF.js +8 -0
- package/dist/gslides-EV2JJH7I.js +8 -0
- package/dist/index.d.ts +28 -16
- package/dist/index.js +82 -82
- package/dist/langfuse-74ZCR6QL.js +7 -0
- package/dist/linear-XABGTU6E.js +7 -0
- package/dist/minio-JPNSX2NP.js +8 -0
- package/dist/mongodb-YZP643ZU.js +7 -0
- package/dist/notion-YJOTGH7J.js +7 -0
- package/dist/oci-R4VYQKGJ.js +8 -0
- package/dist/opfs-4RWMJBCI.js +7 -0
- package/dist/postgres-HPOMN2AR.js +7 -0
- package/dist/qingstor-ZWWK2ZGV.js +8 -0
- package/dist/r2-PZAN2YFG.js +8 -0
- package/dist/{s3-GI7SDKGR.js → s3-CSFY3PLT.js} +2 -2
- package/dist/scaleway-BFROPDBB.js +8 -0
- package/dist/seaweedfs-X6THZT26.js +8 -0
- package/dist/slack-O7BTJ4YR.js +7 -0
- package/dist/supabase-PHN3MIXW.js +8 -0
- package/dist/tencent-JGCJEKHV.js +8 -0
- package/dist/trello-QUDOP3M2.js +7 -0
- package/dist/wasabi-5VMNAFOC.js +8 -0
- package/package.json +2 -3
- package/dist/aliyun-GMNRT7BJ.js +0 -8
- package/dist/backblaze-O6CLR73B.js +0 -8
- package/dist/box-GXWDWZRN.js +0 -8
- package/dist/ceph-SM7MXDAY.js +0 -8
- package/dist/chunk-2AEAISO2.js.map +0 -1
- package/dist/chunk-4NLXLDMV.js.map +0 -1
- package/dist/chunk-57QQAM7V.js.map +0 -1
- package/dist/chunk-6YP3B7UK.js.map +0 -1
- package/dist/chunk-BIIG7ZAQ.js.map +0 -1
- package/dist/chunk-BJHHL4UT.js.map +0 -1
- package/dist/chunk-CGZGX2GO.js.map +0 -1
- package/dist/chunk-CNDGXKMU.js.map +0 -1
- package/dist/chunk-DA5EW34P.js.map +0 -1
- package/dist/chunk-DFHFILVF.js.map +0 -1
- package/dist/chunk-DHZMC42C.js.map +0 -1
- package/dist/chunk-DVXOMWD4.js.map +0 -1
- package/dist/chunk-F5QWZ7GM.js.map +0 -1
- package/dist/chunk-G26SGOFR.js.map +0 -1
- package/dist/chunk-HXQ7HDA6.js.map +0 -1
- package/dist/chunk-J54OBIJA.js.map +0 -1
- package/dist/chunk-J7PLA5S3.js.map +0 -1
- package/dist/chunk-K2S42IR4.js.map +0 -1
- package/dist/chunk-KNJKYCTA.js.map +0 -1
- package/dist/chunk-KTE5PB2D.js.map +0 -1
- package/dist/chunk-KV2DM5H6.js.map +0 -1
- package/dist/chunk-LSURHXZH.js.map +0 -1
- package/dist/chunk-NLBT6TBM.js.map +0 -1
- package/dist/chunk-NMZBJOFW.js.map +0 -1
- package/dist/chunk-NWZNQ3RC.js.map +0 -1
- package/dist/chunk-O5ONB7QT.js.map +0 -1
- package/dist/chunk-OSMEXGRN.js.map +0 -1
- package/dist/chunk-PV53AX35.js.map +0 -1
- package/dist/chunk-QLLRQNOJ.js.map +0 -1
- package/dist/chunk-ROHDW6KT.js.map +0 -1
- package/dist/chunk-RQ273N5K.js.map +0 -1
- package/dist/chunk-SOF74I3T.js.map +0 -1
- package/dist/chunk-TQ6VRUEI.js.map +0 -1
- package/dist/chunk-X2CCEHOR.js.map +0 -1
- package/dist/chunk-XBOJZZRT.js.map +0 -1
- package/dist/chunk-XYKNXGPR.js.map +0 -1
- package/dist/config-7IZCGWKX.js +0 -11
- package/dist/config-AT74FARJ.js +0 -11
- package/dist/config-C2AYHACT.js +0 -11
- package/dist/config-GHJOYNM6.js +0 -11
- package/dist/config-L55UXIF4.js +0 -11
- package/dist/config-V7BLK5WP.js +0 -11
- package/dist/digitalocean-XFH2V2A3.js +0 -8
- package/dist/discord-OQMSHM3L.js +0 -7
- package/dist/dropbox-IAOKM7G5.js +0 -8
- package/dist/gcs-JYZB6CVP.js +0 -8
- package/dist/gdocs-PHKQGLZL.js +0 -8
- package/dist/gdrive-4JQLGOOP.js +0 -8
- package/dist/github-DU7Z4RSU.js +0 -7
- package/dist/github_ci-XSAJDNXC.js +0 -8
- package/dist/gmail-DEQP2M7T.js +0 -8
- package/dist/gsheets-KCIHSMOK.js +0 -8
- package/dist/gslides-2KBUKKM5.js +0 -8
- package/dist/langfuse-FNCMKFSL.js +0 -7
- package/dist/linear-XTFO4WKD.js +0 -7
- package/dist/minio-NGPBAJY3.js +0 -8
- package/dist/mongodb-PGOX6QSY.js +0 -7
- package/dist/notion-HYYNQ7KI.js +0 -7
- package/dist/oci-EGDBSMLM.js +0 -8
- package/dist/opfs-5WGXB5OG.js +0 -7
- package/dist/postgres-5HYED4AC.js +0 -7
- package/dist/qingstor-2T4Y6MEG.js +0 -8
- package/dist/r2-3B45S2KV.js +0 -8
- package/dist/scaleway-ICCXVAY6.js +0 -8
- package/dist/seaweedfs-MF77EC33.js +0 -8
- package/dist/slack-6LGQERIU.js +0 -7
- package/dist/supabase-XTOVMHXU.js +0 -8
- package/dist/tencent-FXFKSOTN.js +0 -8
- package/dist/trello-DZK4NEVY.js +0 -7
- package/dist/wasabi-KVE2B6RB.js +0 -8
- /package/dist/{aliyun-GMNRT7BJ.js.map → aliyun-YEWHEWCL.js.map} +0 -0
- /package/dist/{backblaze-O6CLR73B.js.map → backblaze-LWE2HEDK.js.map} +0 -0
- /package/dist/{box-GXWDWZRN.js.map → box-GTWWIB6F.js.map} +0 -0
- /package/dist/{ceph-SM7MXDAY.js.map → ceph-ATSCSVGU.js.map} +0 -0
- /package/dist/{config-7IZCGWKX.js.map → config-22T7HJBJ.js.map} +0 -0
- /package/dist/{config-AT74FARJ.js.map → config-A56HUM6C.js.map} +0 -0
- /package/dist/{config-C2AYHACT.js.map → config-DIWQZBOK.js.map} +0 -0
- /package/dist/{config-ET26F632.js.map → config-HGJ2MGAC.js.map} +0 -0
- /package/dist/{config-GHJOYNM6.js.map → config-MHBKYS53.js.map} +0 -0
- /package/dist/{config-L55UXIF4.js.map → config-PAHALM2T.js.map} +0 -0
- /package/dist/{config-NV5WXP64.js.map → config-PWZXYJOI.js.map} +0 -0
- /package/dist/{config-V7BLK5WP.js.map → config-UU27ALAA.js.map} +0 -0
- /package/dist/{digitalocean-XFH2V2A3.js.map → digitalocean-SQA6MJJQ.js.map} +0 -0
- /package/dist/{discord-OQMSHM3L.js.map → discord-ASNFJP6A.js.map} +0 -0
- /package/dist/{dropbox-IAOKM7G5.js.map → dropbox-VV2WZE6I.js.map} +0 -0
- /package/dist/{gcs-JYZB6CVP.js.map → gcs-2W6DDWM7.js.map} +0 -0
- /package/dist/{gdocs-PHKQGLZL.js.map → gdocs-QPM7VXXE.js.map} +0 -0
- /package/dist/{gdrive-4JQLGOOP.js.map → gdrive-KT6R7EVB.js.map} +0 -0
- /package/dist/{github-DU7Z4RSU.js.map → github-3IFZGW6I.js.map} +0 -0
- /package/dist/{github_ci-XSAJDNXC.js.map → github_ci-CKKF2Y4S.js.map} +0 -0
- /package/dist/{gmail-DEQP2M7T.js.map → gmail-HLZIMKQU.js.map} +0 -0
- /package/dist/{gsheets-KCIHSMOK.js.map → gsheets-HF4YPIEF.js.map} +0 -0
- /package/dist/{gslides-2KBUKKM5.js.map → gslides-EV2JJH7I.js.map} +0 -0
- /package/dist/{langfuse-FNCMKFSL.js.map → langfuse-74ZCR6QL.js.map} +0 -0
- /package/dist/{linear-XTFO4WKD.js.map → linear-XABGTU6E.js.map} +0 -0
- /package/dist/{minio-NGPBAJY3.js.map → minio-JPNSX2NP.js.map} +0 -0
- /package/dist/{mongodb-PGOX6QSY.js.map → mongodb-YZP643ZU.js.map} +0 -0
- /package/dist/{notion-HYYNQ7KI.js.map → notion-YJOTGH7J.js.map} +0 -0
- /package/dist/{oci-EGDBSMLM.js.map → oci-R4VYQKGJ.js.map} +0 -0
- /package/dist/{opfs-5WGXB5OG.js.map → opfs-4RWMJBCI.js.map} +0 -0
- /package/dist/{postgres-5HYED4AC.js.map → postgres-HPOMN2AR.js.map} +0 -0
- /package/dist/{qingstor-2T4Y6MEG.js.map → qingstor-ZWWK2ZGV.js.map} +0 -0
- /package/dist/{r2-3B45S2KV.js.map → r2-PZAN2YFG.js.map} +0 -0
- /package/dist/{s3-GI7SDKGR.js.map → s3-CSFY3PLT.js.map} +0 -0
- /package/dist/{scaleway-ICCXVAY6.js.map → scaleway-BFROPDBB.js.map} +0 -0
- /package/dist/{seaweedfs-MF77EC33.js.map → seaweedfs-X6THZT26.js.map} +0 -0
- /package/dist/{slack-6LGQERIU.js.map → slack-O7BTJ4YR.js.map} +0 -0
- /package/dist/{supabase-XTOVMHXU.js.map → supabase-PHN3MIXW.js.map} +0 -0
- /package/dist/{tencent-FXFKSOTN.js.map → tencent-JGCJEKHV.js.map} +0 -0
- /package/dist/{trello-DZK4NEVY.js.map → trello-QUDOP3M2.js.map} +0 -0
- /package/dist/{wasabi-KVE2B6RB.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
|
|
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 {
|
|
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.
|
|
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.
|
|
153
|
+
const virtual = p.mountPath;
|
|
118
154
|
const segs = splitSegments(virtual);
|
|
119
155
|
const last = segs.at(-1);
|
|
120
156
|
if (last === void 0) {
|
|
@@ -177,15 +213,16 @@ import { ResourceName as ResourceName3, awkGeneric, command, specOf } from "@str
|
|
|
177
213
|
|
|
178
214
|
// src/core/opfs/stream.ts
|
|
179
215
|
import { recordStream, ResourceName as ResourceName2 } from "@struktoai/mirage-core";
|
|
180
|
-
import { enoent as enoent3 } from "@struktoai/mirage-core";
|
|
216
|
+
import { eisdir as eisdir2, enoent as enoent3 } from "@struktoai/mirage-core";
|
|
181
217
|
async function* stream(accessor, path) {
|
|
182
218
|
const root = accessor.rootHandle;
|
|
183
|
-
const virtual = path.
|
|
219
|
+
const virtual = path.mountPath;
|
|
184
220
|
let handle;
|
|
185
221
|
try {
|
|
186
222
|
handle = await resolveFileHandle(root, virtual, { create: false });
|
|
187
223
|
} catch (err) {
|
|
188
224
|
if (isNotFound(err)) throw enoent3(path);
|
|
225
|
+
if (err instanceof DOMException && err.name === "TypeMismatchError") throw eisdir2(path);
|
|
189
226
|
throw err;
|
|
190
227
|
}
|
|
191
228
|
const file = await handle.getFile();
|
|
@@ -226,14 +263,7 @@ var OPFS_BASENAME = command3({
|
|
|
226
263
|
});
|
|
227
264
|
|
|
228
265
|
// src/commands/builtin/opfs/cat/cat.ts
|
|
229
|
-
import {
|
|
230
|
-
ResourceName as ResourceName6,
|
|
231
|
-
catGeneric,
|
|
232
|
-
catProvisionGeneric,
|
|
233
|
-
command as command4,
|
|
234
|
-
concatAggregate,
|
|
235
|
-
specOf as specOf4
|
|
236
|
-
} from "@struktoai/mirage-core";
|
|
266
|
+
import { ResourceName as ResourceName6, catGeneric, command as command4, concatAggregate, specOf as specOf4 } from "@struktoai/mirage-core";
|
|
237
267
|
var OPFS_CAT = command4({
|
|
238
268
|
name: "cat",
|
|
239
269
|
resource: ResourceName6.OPFS,
|
|
@@ -245,7 +275,6 @@ var OPFS_CAT = command4({
|
|
|
245
275
|
(p) => stat(accessor, p),
|
|
246
276
|
(p) => stream(accessor, p)
|
|
247
277
|
),
|
|
248
|
-
provision: (accessor, paths, _texts, _opts) => catProvisionGeneric(paths, (p) => stat(accessor, p)),
|
|
249
278
|
aggregate: concatAggregate
|
|
250
279
|
});
|
|
251
280
|
|
|
@@ -290,14 +319,14 @@ async function copy(accessor, src, dst) {
|
|
|
290
319
|
const root = accessor.rootHandle;
|
|
291
320
|
let srcHandle;
|
|
292
321
|
try {
|
|
293
|
-
srcHandle = await resolveFileHandle(root, src.
|
|
322
|
+
srcHandle = await resolveFileHandle(root, src.mountPath, { create: false });
|
|
294
323
|
} catch (err) {
|
|
295
|
-
if (isNotFound(err)) throw new Error(`file not found: ${src.
|
|
324
|
+
if (isNotFound(err)) throw new Error(`file not found: ${src.mountPath}`);
|
|
296
325
|
throw err;
|
|
297
326
|
}
|
|
298
327
|
const file = await srcHandle.getFile();
|
|
299
328
|
const data = new Uint8Array(await file.arrayBuffer());
|
|
300
|
-
const dstHandle = await resolveFileHandle(root, dst.
|
|
329
|
+
const dstHandle = await resolveFileHandle(root, dst.mountPath, { create: true });
|
|
301
330
|
const writable = await dstHandle.createWritable();
|
|
302
331
|
await writable.write(toWritableChunk(data));
|
|
303
332
|
await writable.close();
|
|
@@ -351,6 +380,10 @@ async function walk(ctx, dir, current, depth) {
|
|
|
351
380
|
)) {
|
|
352
381
|
accept = false;
|
|
353
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
|
+
}
|
|
354
387
|
if (accept && kind === "f" && (opts.minSize !== null || opts.maxSize !== null || opts.mtimeMin !== null || opts.mtimeMax !== null)) {
|
|
355
388
|
try {
|
|
356
389
|
const fh = await dir.getFileHandle(entryName, { create: false });
|
|
@@ -382,8 +415,8 @@ async function walk(ctx, dir, current, depth) {
|
|
|
382
415
|
}
|
|
383
416
|
async function find(accessor, p, options = {}) {
|
|
384
417
|
const root = accessor.rootHandle;
|
|
385
|
-
const virtual = norm(p.
|
|
386
|
-
const startName = startBasename(p.
|
|
418
|
+
const virtual = norm(p.mountPath);
|
|
419
|
+
const startName = startBasename(p.virtual);
|
|
387
420
|
const results = [];
|
|
388
421
|
const tree = options.tree ?? buildTree({
|
|
389
422
|
name: options.name,
|
|
@@ -417,7 +450,9 @@ async function find(accessor, p, options = {}) {
|
|
|
417
450
|
exists: true,
|
|
418
451
|
tree,
|
|
419
452
|
maxDepth: options.maxDepth,
|
|
420
|
-
minDepth: options.minDepth
|
|
453
|
+
minDepth: options.minDepth,
|
|
454
|
+
minSize: options.minSize,
|
|
455
|
+
maxSize: options.maxSize
|
|
421
456
|
});
|
|
422
457
|
}
|
|
423
458
|
await walk({ options, tree, results }, dir, virtual, 0);
|
|
@@ -436,9 +471,11 @@ function cpCommand(accessor, paths, _texts, opts) {
|
|
|
436
471
|
const recursive = opts.flags.r === true || opts.flags.R === true || opts.flags.a === true;
|
|
437
472
|
return cpGeneric(
|
|
438
473
|
paths,
|
|
439
|
-
(src, target) => copy(accessor, src, target),
|
|
440
|
-
(src, options) => find(accessor, src, options),
|
|
441
474
|
(p) => stat(accessor, p),
|
|
475
|
+
{
|
|
476
|
+
copy: (src, target) => copy(accessor, src, target),
|
|
477
|
+
find: (src, options) => find(accessor, src, options)
|
|
478
|
+
},
|
|
442
479
|
recursive,
|
|
443
480
|
opts.flags.n === true,
|
|
444
481
|
opts.flags.v === true,
|
|
@@ -461,7 +498,7 @@ import { record as record2, ResourceName as ResourceName11 } from "@struktoai/mi
|
|
|
461
498
|
async function writeBytes(accessor, p, data) {
|
|
462
499
|
const root = accessor.rootHandle;
|
|
463
500
|
const start = performance.now();
|
|
464
|
-
const virtual = p.
|
|
501
|
+
const virtual = p.mountPath;
|
|
465
502
|
const handle = await resolveFileHandle(root, virtual, { create: true });
|
|
466
503
|
const writable = await handle.createWritable();
|
|
467
504
|
await writable.write(toWritableChunk(data));
|
|
@@ -495,33 +532,6 @@ var OPFS_CUT = command10({
|
|
|
495
532
|
|
|
496
533
|
// src/commands/builtin/opfs/diff.ts
|
|
497
534
|
import { ResourceName as ResourceName14, command as command11, diffGeneric, specOf as specOf11 } from "@struktoai/mirage-core";
|
|
498
|
-
|
|
499
|
-
// src/core/opfs/readdir.ts
|
|
500
|
-
import { enotdir } from "@struktoai/mirage-core";
|
|
501
|
-
async function readdir(accessor, path) {
|
|
502
|
-
const root = accessor.rootHandle;
|
|
503
|
-
const virtual = path.pattern !== null ? path.directory : path.stripPrefix;
|
|
504
|
-
let dir;
|
|
505
|
-
try {
|
|
506
|
-
dir = await resolveDirHandle(root, virtual, { create: false });
|
|
507
|
-
} catch (err) {
|
|
508
|
-
if (isNotFound(err)) throw enotdir(path);
|
|
509
|
-
if (err instanceof DOMException && err.name === "TypeMismatchError") {
|
|
510
|
-
throw enotdir(path);
|
|
511
|
-
}
|
|
512
|
-
throw err;
|
|
513
|
-
}
|
|
514
|
-
const names = [];
|
|
515
|
-
for await (const [name] of iterEntries(dir)) {
|
|
516
|
-
names.push(name);
|
|
517
|
-
}
|
|
518
|
-
const base = norm(virtual);
|
|
519
|
-
const dirPrefix = base === "/" ? "/" : `${base}/`;
|
|
520
|
-
const mountPrefix = path.prefix;
|
|
521
|
-
return names.map((n) => `${mountPrefix}${dirPrefix}${n}`).sort();
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
// src/commands/builtin/opfs/diff.ts
|
|
525
535
|
var OPFS_DIFF = command11({
|
|
526
536
|
name: "diff",
|
|
527
537
|
resource: ResourceName14.OPFS,
|
|
@@ -618,11 +628,11 @@ async function sizeOfPath(root, virtual) {
|
|
|
618
628
|
}
|
|
619
629
|
}
|
|
620
630
|
async function du(accessor, p) {
|
|
621
|
-
return sizeOfPath(accessor.rootHandle, p.
|
|
631
|
+
return sizeOfPath(accessor.rootHandle, p.mountPath);
|
|
622
632
|
}
|
|
623
633
|
async function duAll(accessor, p) {
|
|
624
634
|
const root = accessor.rootHandle;
|
|
625
|
-
const virtual = norm(p.
|
|
635
|
+
const virtual = norm(p.mountPath);
|
|
626
636
|
const entries = [];
|
|
627
637
|
try {
|
|
628
638
|
const [parentDir, name] = await resolveParentDirHandle(root, virtual, { create: false });
|
|
@@ -751,7 +761,7 @@ import { ResourceName as ResourceName23, command as command20, specOf as specOf2
|
|
|
751
761
|
// src/core/opfs/unlink.ts
|
|
752
762
|
async function unlink(accessor, path) {
|
|
753
763
|
const root = accessor.rootHandle;
|
|
754
|
-
const virtual = path.
|
|
764
|
+
const virtual = path.mountPath;
|
|
755
765
|
let parentDir;
|
|
756
766
|
let name;
|
|
757
767
|
try {
|
|
@@ -802,14 +812,7 @@ var OPFS_GZIP = command21({
|
|
|
802
812
|
});
|
|
803
813
|
|
|
804
814
|
// src/commands/builtin/opfs/head/head.ts
|
|
805
|
-
import {
|
|
806
|
-
ResourceName as ResourceName25,
|
|
807
|
-
command as command22,
|
|
808
|
-
headGeneric,
|
|
809
|
-
headProvisionGeneric,
|
|
810
|
-
headerAggregate,
|
|
811
|
-
specOf as specOf22
|
|
812
|
-
} from "@struktoai/mirage-core";
|
|
815
|
+
import { ResourceName as ResourceName25, command as command22, headGeneric, headerAggregate, specOf as specOf22 } from "@struktoai/mirage-core";
|
|
813
816
|
var OPFS_HEAD = command22({
|
|
814
817
|
name: "head",
|
|
815
818
|
resource: ResourceName25.OPFS,
|
|
@@ -821,7 +824,6 @@ var OPFS_HEAD = command22({
|
|
|
821
824
|
(p) => stat(accessor, p),
|
|
822
825
|
(p) => stream(accessor, p)
|
|
823
826
|
),
|
|
824
|
-
provision: (accessor, paths, texts, opts) => headProvisionGeneric(paths, texts, opts, (p) => stat(accessor, p)),
|
|
825
827
|
aggregate: headerAggregate
|
|
826
828
|
});
|
|
827
829
|
|
|
@@ -850,19 +852,12 @@ var OPFS_JOIN = command24({
|
|
|
850
852
|
});
|
|
851
853
|
|
|
852
854
|
// src/commands/builtin/opfs/jq.ts
|
|
853
|
-
import {
|
|
854
|
-
ResourceName as ResourceName28,
|
|
855
|
-
command as command25,
|
|
856
|
-
jqGeneric,
|
|
857
|
-
jqProvisionGeneric,
|
|
858
|
-
specOf as specOf25
|
|
859
|
-
} from "@struktoai/mirage-core";
|
|
855
|
+
import { ResourceName as ResourceName28, command as command25, jqGeneric, specOf as specOf25 } from "@struktoai/mirage-core";
|
|
860
856
|
var OPFS_JQ = command25({
|
|
861
857
|
name: "jq",
|
|
862
858
|
resource: ResourceName28.OPFS,
|
|
863
859
|
spec: specOf25("jq"),
|
|
864
|
-
fn: (accessor, paths, texts, opts) => jqGeneric(paths, texts, opts, (p) => stream(accessor, p))
|
|
865
|
-
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))
|
|
866
861
|
});
|
|
867
862
|
|
|
868
863
|
// src/commands/builtin/opfs/ln.ts
|
|
@@ -877,7 +872,7 @@ import {
|
|
|
877
872
|
// src/core/opfs/exists.ts
|
|
878
873
|
async function exists(accessor, path) {
|
|
879
874
|
const root = accessor.rootHandle;
|
|
880
|
-
const virtual = path.
|
|
875
|
+
const virtual = path.mountPath;
|
|
881
876
|
if (virtual === "/" || virtual === "") return true;
|
|
882
877
|
try {
|
|
883
878
|
const [parentDir, name] = await resolveParentDirHandle(root, virtual, { create: false });
|
|
@@ -930,9 +925,9 @@ async function lnCommand(accessor, paths, texts, opts) {
|
|
|
930
925
|
}
|
|
931
926
|
const data = await materialize(stream(accessor, source));
|
|
932
927
|
await writeBytes(accessor, dest, data);
|
|
933
|
-
const out = opts.flags.v === true ? ENC.encode(`'${source.
|
|
928
|
+
const out = opts.flags.v === true ? ENC.encode(`'${source.virtual}' -> '${dest.virtual}'
|
|
934
929
|
`) : null;
|
|
935
|
-
return [out, new IOResult2({ writes: { [dest.
|
|
930
|
+
return [out, new IOResult2({ writes: { [dest.mountPath]: data } })];
|
|
936
931
|
}
|
|
937
932
|
var OPFS_LN = command26({
|
|
938
933
|
name: "ln",
|
|
@@ -957,12 +952,11 @@ var OPFS_LS = command28({
|
|
|
957
952
|
name: "ls",
|
|
958
953
|
resource: ResourceName31.OPFS,
|
|
959
954
|
spec: specOf28("ls"),
|
|
960
|
-
fn: (accessor, paths, _texts, opts) =>
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
(p) => readdir(accessor, p),
|
|
964
|
-
|
|
965
|
-
)
|
|
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
|
+
}
|
|
966
960
|
});
|
|
967
961
|
|
|
968
962
|
// src/commands/builtin/opfs/md5.ts
|
|
@@ -974,22 +968,35 @@ var OPFS_MD5 = command29({
|
|
|
974
968
|
fn: (accessor, paths, _texts, opts) => md5Generic(paths, opts, (p) => stream(accessor, p))
|
|
975
969
|
});
|
|
976
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
|
+
|
|
977
980
|
// src/commands/builtin/opfs/mkdir.ts
|
|
978
981
|
import {
|
|
979
982
|
IOResult as IOResult3,
|
|
980
|
-
ResourceName as
|
|
981
|
-
command as
|
|
982
|
-
|
|
983
|
+
ResourceName as ResourceName34,
|
|
984
|
+
command as command31,
|
|
985
|
+
formatRecords,
|
|
986
|
+
specOf as specOf31
|
|
983
987
|
} from "@struktoai/mirage-core";
|
|
984
988
|
|
|
985
989
|
// src/core/opfs/mkdir.ts
|
|
990
|
+
import { invalidateAfterWrite, invalidateAncestors } from "@struktoai/mirage-core";
|
|
986
991
|
async function mkdir(accessor, path, parents = false) {
|
|
987
992
|
const root = accessor.rootHandle;
|
|
988
|
-
const virtual = path.
|
|
993
|
+
const virtual = path.mountPath;
|
|
989
994
|
const segs = splitSegments(virtual);
|
|
990
995
|
if (segs.length === 0) return;
|
|
991
996
|
if (parents) {
|
|
992
997
|
await resolveDirHandle(root, virtual, { create: true });
|
|
998
|
+
await invalidateAfterWrite(path);
|
|
999
|
+
await invalidateAncestors(path);
|
|
993
1000
|
return;
|
|
994
1001
|
}
|
|
995
1002
|
let parentDir;
|
|
@@ -1020,6 +1027,7 @@ async function mkdir(accessor, path, parents = false) {
|
|
|
1020
1027
|
// src/commands/builtin/opfs/mkdir.ts
|
|
1021
1028
|
async function mkdirCommand(accessor, paths, texts, opts) {
|
|
1022
1029
|
const parents = opts.flags.p === true;
|
|
1030
|
+
const verbose = opts.flags.v === true;
|
|
1023
1031
|
if (paths.length === 0) {
|
|
1024
1032
|
return [
|
|
1025
1033
|
null,
|
|
@@ -1029,25 +1037,28 @@ async function mkdirCommand(accessor, paths, texts, opts) {
|
|
|
1029
1037
|
})
|
|
1030
1038
|
];
|
|
1031
1039
|
}
|
|
1040
|
+
const lines = [];
|
|
1032
1041
|
for (const p of paths) {
|
|
1033
1042
|
await mkdir(accessor, p, parents);
|
|
1043
|
+
if (verbose) lines.push(`mkdir: created directory '${p.virtual.replace(/\/+$/, "") || "/"}'`);
|
|
1034
1044
|
}
|
|
1035
|
-
|
|
1045
|
+
const output = verbose && lines.length > 0 ? formatRecords(lines) : null;
|
|
1046
|
+
return [output, new IOResult3()];
|
|
1036
1047
|
}
|
|
1037
|
-
var OPFS_MKDIR =
|
|
1048
|
+
var OPFS_MKDIR = command31({
|
|
1038
1049
|
name: "mkdir",
|
|
1039
|
-
resource:
|
|
1040
|
-
spec:
|
|
1050
|
+
resource: ResourceName34.OPFS,
|
|
1051
|
+
spec: specOf31("mkdir"),
|
|
1041
1052
|
fn: mkdirCommand,
|
|
1042
1053
|
write: true
|
|
1043
1054
|
});
|
|
1044
1055
|
|
|
1045
1056
|
// src/commands/builtin/opfs/mktemp.ts
|
|
1046
|
-
import { ResourceName as
|
|
1047
|
-
var OPFS_MKTEMP =
|
|
1057
|
+
import { ResourceName as ResourceName35, command as command32, mktempGeneric, specOf as specOf32 } from "@struktoai/mirage-core";
|
|
1058
|
+
var OPFS_MKTEMP = command32({
|
|
1048
1059
|
name: "mktemp",
|
|
1049
|
-
resource:
|
|
1050
|
-
spec:
|
|
1060
|
+
resource: ResourceName35.OPFS,
|
|
1061
|
+
spec: specOf32("mktemp"),
|
|
1051
1062
|
fn: (accessor, _paths, texts, opts) => mktempGeneric(
|
|
1052
1063
|
texts,
|
|
1053
1064
|
opts,
|
|
@@ -1060,10 +1071,10 @@ var OPFS_MKTEMP = command31({
|
|
|
1060
1071
|
// src/commands/builtin/opfs/mv.ts
|
|
1061
1072
|
import {
|
|
1062
1073
|
IOResult as IOResult4,
|
|
1063
|
-
ResourceName as
|
|
1064
|
-
command as
|
|
1074
|
+
ResourceName as ResourceName36,
|
|
1075
|
+
command as command33,
|
|
1065
1076
|
mvGeneric,
|
|
1066
|
-
specOf as
|
|
1077
|
+
specOf as specOf33
|
|
1067
1078
|
} from "@struktoai/mirage-core";
|
|
1068
1079
|
|
|
1069
1080
|
// src/core/opfs/rename.ts
|
|
@@ -1086,8 +1097,8 @@ async function copyDirRecursive(root, srcPath, dstPath) {
|
|
|
1086
1097
|
}
|
|
1087
1098
|
async function rename(accessor, src, dst) {
|
|
1088
1099
|
const root = accessor.rootHandle;
|
|
1089
|
-
const srcPath = src.
|
|
1090
|
-
const dstPath = dst.
|
|
1100
|
+
const srcPath = src.mountPath;
|
|
1101
|
+
const dstPath = dst.mountPath;
|
|
1091
1102
|
let srcParent;
|
|
1092
1103
|
let srcName;
|
|
1093
1104
|
try {
|
|
@@ -1139,45 +1150,45 @@ function mvCommand(accessor, paths, _texts, opts) {
|
|
|
1139
1150
|
}
|
|
1140
1151
|
return mvGeneric(
|
|
1141
1152
|
paths,
|
|
1142
|
-
(src, target) => rename(accessor, src, target),
|
|
1143
1153
|
(p) => stat(accessor, p),
|
|
1154
|
+
{ rename: (src, target) => rename(accessor, src, target) },
|
|
1144
1155
|
opts.flags.n === true,
|
|
1145
1156
|
opts.flags.v === true,
|
|
1146
1157
|
opts.index ?? void 0
|
|
1147
1158
|
);
|
|
1148
1159
|
}
|
|
1149
|
-
var OPFS_MV =
|
|
1160
|
+
var OPFS_MV = command33({
|
|
1150
1161
|
name: "mv",
|
|
1151
|
-
resource:
|
|
1152
|
-
spec:
|
|
1162
|
+
resource: ResourceName36.OPFS,
|
|
1163
|
+
spec: specOf33("mv"),
|
|
1153
1164
|
fn: mvCommand,
|
|
1154
1165
|
write: true
|
|
1155
1166
|
});
|
|
1156
1167
|
|
|
1157
1168
|
// src/commands/builtin/opfs/nl.ts
|
|
1158
|
-
import { ResourceName as
|
|
1159
|
-
var OPFS_NL =
|
|
1169
|
+
import { ResourceName as ResourceName37, command as command34, specOf as specOf34, nlGeneric } from "@struktoai/mirage-core";
|
|
1170
|
+
var OPFS_NL = command34({
|
|
1160
1171
|
name: "nl",
|
|
1161
|
-
resource:
|
|
1162
|
-
spec:
|
|
1172
|
+
resource: ResourceName37.OPFS,
|
|
1173
|
+
spec: specOf34("nl"),
|
|
1163
1174
|
fn: (accessor, paths, _texts, opts) => nlGeneric(paths, opts, (p) => stream(accessor, p))
|
|
1164
1175
|
});
|
|
1165
1176
|
|
|
1166
1177
|
// src/commands/builtin/opfs/paste.ts
|
|
1167
|
-
import { ResourceName as
|
|
1168
|
-
var OPFS_PASTE =
|
|
1178
|
+
import { ResourceName as ResourceName38, command as command35, specOf as specOf35, pasteGeneric } from "@struktoai/mirage-core";
|
|
1179
|
+
var OPFS_PASTE = command35({
|
|
1169
1180
|
name: "paste",
|
|
1170
|
-
resource:
|
|
1171
|
-
spec:
|
|
1181
|
+
resource: ResourceName38.OPFS,
|
|
1182
|
+
spec: specOf35("paste"),
|
|
1172
1183
|
fn: (accessor, paths, _texts, opts) => pasteGeneric(paths, opts, (p) => stream(accessor, p))
|
|
1173
1184
|
});
|
|
1174
1185
|
|
|
1175
1186
|
// src/commands/builtin/opfs/patch.ts
|
|
1176
|
-
import { ResourceName as
|
|
1177
|
-
var OPFS_PATCH =
|
|
1187
|
+
import { ResourceName as ResourceName39, command as command36, specOf as specOf36, patchGeneric } from "@struktoai/mirage-core";
|
|
1188
|
+
var OPFS_PATCH = command36({
|
|
1178
1189
|
name: "patch",
|
|
1179
|
-
resource:
|
|
1180
|
-
spec:
|
|
1190
|
+
resource: ResourceName39.OPFS,
|
|
1191
|
+
spec: specOf36("patch"),
|
|
1181
1192
|
fn: (accessor, paths, _texts, opts) => patchGeneric(
|
|
1182
1193
|
paths,
|
|
1183
1194
|
opts,
|
|
@@ -1189,42 +1200,42 @@ var OPFS_PATCH = command35({
|
|
|
1189
1200
|
|
|
1190
1201
|
// src/commands/builtin/opfs/readlink.ts
|
|
1191
1202
|
import {
|
|
1192
|
-
ResourceName as
|
|
1193
|
-
command as
|
|
1203
|
+
ResourceName as ResourceName40,
|
|
1204
|
+
command as command37,
|
|
1194
1205
|
readlinkGeneric,
|
|
1195
|
-
specOf as
|
|
1206
|
+
specOf as specOf37
|
|
1196
1207
|
} from "@struktoai/mirage-core";
|
|
1197
|
-
var OPFS_READLINK =
|
|
1208
|
+
var OPFS_READLINK = command37({
|
|
1198
1209
|
name: "readlink",
|
|
1199
|
-
resource:
|
|
1200
|
-
spec:
|
|
1210
|
+
resource: ResourceName40.OPFS,
|
|
1211
|
+
spec: specOf37("readlink"),
|
|
1201
1212
|
fn: (_accessor, paths, texts, opts) => readlinkGeneric(paths, texts, opts)
|
|
1202
1213
|
});
|
|
1203
1214
|
|
|
1204
1215
|
// src/commands/builtin/opfs/realpath.ts
|
|
1205
|
-
import { ResourceName as
|
|
1206
|
-
var OPFS_REALPATH =
|
|
1216
|
+
import { ResourceName as ResourceName41, command as command38, realpathGeneric, specOf as specOf38 } from "@struktoai/mirage-core";
|
|
1217
|
+
var OPFS_REALPATH = command38({
|
|
1207
1218
|
name: "realpath",
|
|
1208
|
-
resource:
|
|
1209
|
-
spec:
|
|
1219
|
+
resource: ResourceName41.OPFS,
|
|
1220
|
+
spec: specOf38("realpath"),
|
|
1210
1221
|
fn: (accessor, paths, texts, opts) => realpathGeneric(paths, texts, opts, (p) => stat(accessor, p))
|
|
1211
1222
|
});
|
|
1212
1223
|
|
|
1213
1224
|
// src/commands/builtin/opfs/rev.ts
|
|
1214
|
-
import { ResourceName as
|
|
1215
|
-
var OPFS_REV =
|
|
1225
|
+
import { ResourceName as ResourceName42, command as command39, specOf as specOf39, revGeneric } from "@struktoai/mirage-core";
|
|
1226
|
+
var OPFS_REV = command39({
|
|
1216
1227
|
name: "rev",
|
|
1217
|
-
resource:
|
|
1218
|
-
spec:
|
|
1228
|
+
resource: ResourceName42.OPFS,
|
|
1229
|
+
spec: specOf39("rev"),
|
|
1219
1230
|
fn: (accessor, paths, _texts, opts) => revGeneric(paths, opts, (p) => stream(accessor, p))
|
|
1220
1231
|
});
|
|
1221
1232
|
|
|
1222
1233
|
// src/commands/builtin/opfs/rg.ts
|
|
1223
|
-
import { ResourceName as
|
|
1224
|
-
var OPFS_RG =
|
|
1234
|
+
import { ResourceName as ResourceName43, command as command40, rgGeneric, specOf as specOf40 } from "@struktoai/mirage-core";
|
|
1235
|
+
var OPFS_RG = command40({
|
|
1225
1236
|
name: "rg",
|
|
1226
|
-
resource:
|
|
1227
|
-
spec:
|
|
1237
|
+
resource: ResourceName43.OPFS,
|
|
1238
|
+
spec: specOf40("rg"),
|
|
1228
1239
|
fn: (accessor, paths, texts, opts) => rgGeneric(
|
|
1229
1240
|
paths,
|
|
1230
1241
|
texts,
|
|
@@ -1239,15 +1250,18 @@ var OPFS_RG = command39({
|
|
|
1239
1250
|
import {
|
|
1240
1251
|
FileType as FileType2,
|
|
1241
1252
|
IOResult as IOResult5,
|
|
1242
|
-
ResourceName as
|
|
1243
|
-
command as
|
|
1244
|
-
|
|
1253
|
+
ResourceName as ResourceName44,
|
|
1254
|
+
command as command41,
|
|
1255
|
+
cpWalk,
|
|
1256
|
+
formatRecords as formatRecords2,
|
|
1257
|
+
removalLines,
|
|
1258
|
+
specOf as specOf41
|
|
1245
1259
|
} from "@struktoai/mirage-core";
|
|
1246
1260
|
|
|
1247
1261
|
// src/core/opfs/rmdir.ts
|
|
1248
1262
|
async function rmdir(accessor, path) {
|
|
1249
1263
|
const root = accessor.rootHandle;
|
|
1250
|
-
const virtual = path.
|
|
1264
|
+
const virtual = path.mountPath;
|
|
1251
1265
|
let parentDir;
|
|
1252
1266
|
let name;
|
|
1253
1267
|
try {
|
|
@@ -1269,7 +1283,7 @@ async function rmdir(accessor, path) {
|
|
|
1269
1283
|
// src/core/opfs/rm.ts
|
|
1270
1284
|
async function rmR(accessor, path) {
|
|
1271
1285
|
const root = accessor.rootHandle;
|
|
1272
|
-
const virtual = path.
|
|
1286
|
+
const virtual = path.mountPath;
|
|
1273
1287
|
let parentDir;
|
|
1274
1288
|
let name;
|
|
1275
1289
|
try {
|
|
@@ -1300,75 +1314,244 @@ async function rmCommand(accessor, paths, texts, opts) {
|
|
|
1300
1314
|
];
|
|
1301
1315
|
}
|
|
1302
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 = {};
|
|
1303
1323
|
for (const p of paths) {
|
|
1304
1324
|
let isDir = false;
|
|
1305
1325
|
try {
|
|
1306
1326
|
const st = await stat(accessor, p);
|
|
1307
1327
|
isDir = st.type === FileType2.DIRECTORY;
|
|
1308
1328
|
} catch {
|
|
1309
|
-
|
|
1329
|
+
if (force) continue;
|
|
1330
|
+
errors.push(`rm: cannot remove '${p.virtual}': No such file or directory`);
|
|
1331
|
+
continue;
|
|
1310
1332
|
}
|
|
1333
|
+
let entryLines = [];
|
|
1311
1334
|
if (isDir) {
|
|
1312
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
|
+
}
|
|
1313
1345
|
await rmR(accessor, p);
|
|
1314
|
-
} 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
|
+
}
|
|
1315
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;
|
|
1316
1356
|
}
|
|
1317
1357
|
} else {
|
|
1318
1358
|
await unlink(accessor, p);
|
|
1359
|
+
entryLines = [`removed '${p.virtual.replace(/\/+$/, "") || "/"}'`];
|
|
1319
1360
|
}
|
|
1320
|
-
|
|
1321
|
-
|
|
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
|
+
];
|
|
1322
1374
|
}
|
|
1323
|
-
var OPFS_RM =
|
|
1375
|
+
var OPFS_RM = command41({
|
|
1324
1376
|
name: "rm",
|
|
1325
|
-
resource:
|
|
1326
|
-
spec:
|
|
1377
|
+
resource: ResourceName44.OPFS,
|
|
1378
|
+
spec: specOf41("rm"),
|
|
1327
1379
|
fn: rmCommand,
|
|
1328
1380
|
write: true
|
|
1329
1381
|
});
|
|
1330
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
|
+
|
|
1331
1446
|
// src/commands/builtin/opfs/sed.ts
|
|
1332
|
-
import {
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
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({
|
|
1472
|
+
name: "sed",
|
|
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))
|
|
1337
1497
|
});
|
|
1338
1498
|
|
|
1339
1499
|
// src/commands/builtin/opfs/sha256sum.ts
|
|
1340
|
-
import { ResourceName as
|
|
1341
|
-
var OPFS_SHA256SUM =
|
|
1500
|
+
import { ResourceName as ResourceName48, command as command45, sha256sumGeneric, specOf as specOf45 } from "@struktoai/mirage-core";
|
|
1501
|
+
var OPFS_SHA256SUM = command45({
|
|
1342
1502
|
name: "sha256sum",
|
|
1343
|
-
resource:
|
|
1344
|
-
spec:
|
|
1503
|
+
resource: ResourceName48.OPFS,
|
|
1504
|
+
spec: specOf45("sha256sum"),
|
|
1345
1505
|
fn: (accessor, paths, _texts, opts) => sha256sumGeneric(paths, opts, (p) => stream(accessor, p))
|
|
1346
1506
|
});
|
|
1347
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
|
+
|
|
1348
1526
|
// src/commands/builtin/opfs/shuf.ts
|
|
1349
|
-
import { ResourceName as
|
|
1350
|
-
var OPFS_SHUF =
|
|
1527
|
+
import { ResourceName as ResourceName51, command as command48, specOf as specOf48, shufGeneric } from "@struktoai/mirage-core";
|
|
1528
|
+
var OPFS_SHUF = command48({
|
|
1351
1529
|
name: "shuf",
|
|
1352
|
-
resource:
|
|
1353
|
-
spec:
|
|
1530
|
+
resource: ResourceName51.OPFS,
|
|
1531
|
+
spec: specOf48("shuf"),
|
|
1354
1532
|
fn: (accessor, paths, texts, opts) => shufGeneric(paths, texts, opts, (p) => stream(accessor, p))
|
|
1355
1533
|
});
|
|
1356
1534
|
|
|
1357
1535
|
// src/commands/builtin/opfs/sort.ts
|
|
1358
|
-
import { ResourceName as
|
|
1359
|
-
var OPFS_SORT =
|
|
1536
|
+
import { ResourceName as ResourceName52, command as command49, specOf as specOf49, sortGeneric } from "@struktoai/mirage-core";
|
|
1537
|
+
var OPFS_SORT = command49({
|
|
1360
1538
|
name: "sort",
|
|
1361
|
-
resource:
|
|
1362
|
-
spec:
|
|
1363
|
-
fn: (accessor, paths, _texts, opts) => sortGeneric(
|
|
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
|
+
)
|
|
1364
1547
|
});
|
|
1365
1548
|
|
|
1366
1549
|
// src/commands/builtin/opfs/split.ts
|
|
1367
|
-
import { ResourceName as
|
|
1368
|
-
var OPFS_SPLIT =
|
|
1550
|
+
import { ResourceName as ResourceName53, command as command50, specOf as specOf50, splitGeneric } from "@struktoai/mirage-core";
|
|
1551
|
+
var OPFS_SPLIT = command50({
|
|
1369
1552
|
name: "split",
|
|
1370
|
-
resource:
|
|
1371
|
-
spec:
|
|
1553
|
+
resource: ResourceName53.OPFS,
|
|
1554
|
+
spec: specOf50("split"),
|
|
1372
1555
|
fn: (accessor, paths, _texts, opts) => splitGeneric(
|
|
1373
1556
|
paths,
|
|
1374
1557
|
opts,
|
|
@@ -1379,55 +1562,48 @@ var OPFS_SPLIT = command44({
|
|
|
1379
1562
|
});
|
|
1380
1563
|
|
|
1381
1564
|
// src/commands/builtin/opfs/stat/stat.ts
|
|
1382
|
-
import {
|
|
1383
|
-
|
|
1384
|
-
command as command45,
|
|
1385
|
-
specOf as specOf45,
|
|
1386
|
-
statGeneric,
|
|
1387
|
-
statProvisionGeneric
|
|
1388
|
-
} from "@struktoai/mirage-core";
|
|
1389
|
-
var OPFS_STAT = command45({
|
|
1565
|
+
import { ResourceName as ResourceName54, command as command51, specOf as specOf51, statGeneric } from "@struktoai/mirage-core";
|
|
1566
|
+
var OPFS_STAT = command51({
|
|
1390
1567
|
name: "stat",
|
|
1391
|
-
resource:
|
|
1392
|
-
spec:
|
|
1393
|
-
fn: (accessor, paths, _texts, opts) => statGeneric(paths, opts, (p) => stat(accessor, p))
|
|
1394
|
-
provision: statProvisionGeneric
|
|
1568
|
+
resource: ResourceName54.OPFS,
|
|
1569
|
+
spec: specOf51("stat"),
|
|
1570
|
+
fn: (accessor, paths, _texts, opts) => statGeneric(paths, opts, (p) => stat(accessor, p))
|
|
1395
1571
|
});
|
|
1396
1572
|
|
|
1397
1573
|
// src/commands/builtin/opfs/strings.ts
|
|
1398
|
-
import { ResourceName as
|
|
1399
|
-
var OPFS_STRINGS =
|
|
1574
|
+
import { ResourceName as ResourceName55, command as command52, specOf as specOf52, stringsGeneric } from "@struktoai/mirage-core";
|
|
1575
|
+
var OPFS_STRINGS = command52({
|
|
1400
1576
|
name: "strings",
|
|
1401
|
-
resource:
|
|
1402
|
-
spec:
|
|
1577
|
+
resource: ResourceName55.OPFS,
|
|
1578
|
+
spec: specOf52("strings"),
|
|
1403
1579
|
fn: (accessor, paths, _texts, opts) => stringsGeneric(paths, opts, (p) => stream(accessor, p))
|
|
1404
1580
|
});
|
|
1405
1581
|
|
|
1406
1582
|
// src/commands/builtin/opfs/tac.ts
|
|
1407
|
-
import { ResourceName as
|
|
1408
|
-
var OPFS_TAC =
|
|
1583
|
+
import { ResourceName as ResourceName56, command as command53, specOf as specOf53, tacGeneric } from "@struktoai/mirage-core";
|
|
1584
|
+
var OPFS_TAC = command53({
|
|
1409
1585
|
name: "tac",
|
|
1410
|
-
resource:
|
|
1411
|
-
spec:
|
|
1586
|
+
resource: ResourceName56.OPFS,
|
|
1587
|
+
spec: specOf53("tac"),
|
|
1412
1588
|
fn: (accessor, paths, _texts, opts) => tacGeneric(paths, opts, (p) => stream(accessor, p))
|
|
1413
1589
|
});
|
|
1414
1590
|
|
|
1415
1591
|
// src/commands/builtin/opfs/tail/tail.ts
|
|
1416
|
-
import { ResourceName as
|
|
1417
|
-
var OPFS_TAIL =
|
|
1592
|
+
import { ResourceName as ResourceName57, command as command54, headerAggregate as headerAggregate2, specOf as specOf54, tailGeneric } from "@struktoai/mirage-core";
|
|
1593
|
+
var OPFS_TAIL = command54({
|
|
1418
1594
|
name: "tail",
|
|
1419
|
-
resource:
|
|
1420
|
-
spec:
|
|
1595
|
+
resource: ResourceName57.OPFS,
|
|
1596
|
+
spec: specOf54("tail"),
|
|
1421
1597
|
fn: (accessor, paths, texts, opts) => tailGeneric(paths, texts, opts, (p) => stream(accessor, p)),
|
|
1422
1598
|
aggregate: headerAggregate2
|
|
1423
1599
|
});
|
|
1424
1600
|
|
|
1425
1601
|
// src/commands/builtin/opfs/tar.ts
|
|
1426
|
-
import { ResourceName as
|
|
1427
|
-
var OPFS_TAR =
|
|
1602
|
+
import { ResourceName as ResourceName58, command as command55, specOf as specOf55, tarGeneric } from "@struktoai/mirage-core";
|
|
1603
|
+
var OPFS_TAR = command55({
|
|
1428
1604
|
name: "tar",
|
|
1429
|
-
resource:
|
|
1430
|
-
spec:
|
|
1605
|
+
resource: ResourceName58.OPFS,
|
|
1606
|
+
spec: specOf55("tar"),
|
|
1431
1607
|
fn: (accessor, paths, _texts, opts) => tarGeneric(
|
|
1432
1608
|
paths,
|
|
1433
1609
|
opts,
|
|
@@ -1439,11 +1615,11 @@ var OPFS_TAR = command49({
|
|
|
1439
1615
|
});
|
|
1440
1616
|
|
|
1441
1617
|
// src/commands/builtin/opfs/tee.ts
|
|
1442
|
-
import { ResourceName as
|
|
1443
|
-
var OPFS_TEE =
|
|
1618
|
+
import { ResourceName as ResourceName59, command as command56, specOf as specOf56, teeGeneric } from "@struktoai/mirage-core";
|
|
1619
|
+
var OPFS_TEE = command56({
|
|
1444
1620
|
name: "tee",
|
|
1445
|
-
resource:
|
|
1446
|
-
spec:
|
|
1621
|
+
resource: ResourceName59.OPFS,
|
|
1622
|
+
spec: specOf56("tee"),
|
|
1447
1623
|
fn: (accessor, paths, texts, opts) => teeGeneric(
|
|
1448
1624
|
paths,
|
|
1449
1625
|
texts,
|
|
@@ -1456,15 +1632,15 @@ var OPFS_TEE = command50({
|
|
|
1456
1632
|
|
|
1457
1633
|
// src/commands/builtin/opfs/touch.ts
|
|
1458
1634
|
import {
|
|
1459
|
-
IOResult as
|
|
1460
|
-
ResourceName as
|
|
1461
|
-
command as
|
|
1462
|
-
specOf as
|
|
1635
|
+
IOResult as IOResult7,
|
|
1636
|
+
ResourceName as ResourceName60,
|
|
1637
|
+
command as command57,
|
|
1638
|
+
specOf as specOf57
|
|
1463
1639
|
} from "@struktoai/mirage-core";
|
|
1464
1640
|
var ENC2 = new TextEncoder();
|
|
1465
1641
|
async function touchCommand(accessor, paths, texts, opts) {
|
|
1466
1642
|
if (paths.length === 0) {
|
|
1467
|
-
return [null, new
|
|
1643
|
+
return [null, new IOResult7({ exitCode: 1, stderr: ENC2.encode("touch: missing operand\n") })];
|
|
1468
1644
|
}
|
|
1469
1645
|
const createOnly = opts.flags.c === true;
|
|
1470
1646
|
for (const p of paths) {
|
|
@@ -1473,31 +1649,31 @@ async function touchCommand(accessor, paths, texts, opts) {
|
|
|
1473
1649
|
await writeBytes(accessor, p, new Uint8Array(0));
|
|
1474
1650
|
}
|
|
1475
1651
|
}
|
|
1476
|
-
return [null, new
|
|
1652
|
+
return [null, new IOResult7()];
|
|
1477
1653
|
}
|
|
1478
|
-
var OPFS_TOUCH =
|
|
1654
|
+
var OPFS_TOUCH = command57({
|
|
1479
1655
|
name: "touch",
|
|
1480
|
-
resource:
|
|
1481
|
-
spec:
|
|
1656
|
+
resource: ResourceName60.OPFS,
|
|
1657
|
+
spec: specOf57("touch"),
|
|
1482
1658
|
fn: touchCommand,
|
|
1483
1659
|
write: true
|
|
1484
1660
|
});
|
|
1485
1661
|
|
|
1486
1662
|
// src/commands/builtin/opfs/tr.ts
|
|
1487
|
-
import { ResourceName as
|
|
1488
|
-
var OPFS_TR =
|
|
1663
|
+
import { ResourceName as ResourceName61, command as command58, specOf as specOf58, trGeneric } from "@struktoai/mirage-core";
|
|
1664
|
+
var OPFS_TR = command58({
|
|
1489
1665
|
name: "tr",
|
|
1490
|
-
resource:
|
|
1491
|
-
spec:
|
|
1666
|
+
resource: ResourceName61.OPFS,
|
|
1667
|
+
spec: specOf58("tr"),
|
|
1492
1668
|
fn: (accessor, paths, texts, opts) => trGeneric(paths, texts, opts, (p) => stream(accessor, p))
|
|
1493
1669
|
});
|
|
1494
1670
|
|
|
1495
1671
|
// src/commands/builtin/opfs/tree.ts
|
|
1496
|
-
import { ResourceName as
|
|
1497
|
-
var OPFS_TREE =
|
|
1672
|
+
import { ResourceName as ResourceName62, command as command59, specOf as specOf59, treeGeneric } from "@struktoai/mirage-core";
|
|
1673
|
+
var OPFS_TREE = command59({
|
|
1498
1674
|
name: "tree",
|
|
1499
|
-
resource:
|
|
1500
|
-
spec:
|
|
1675
|
+
resource: ResourceName62.OPFS,
|
|
1676
|
+
spec: specOf59("tree"),
|
|
1501
1677
|
fn: (accessor, paths, _texts, opts) => treeGeneric(
|
|
1502
1678
|
paths,
|
|
1503
1679
|
opts,
|
|
@@ -1507,38 +1683,111 @@ var OPFS_TREE = command53({
|
|
|
1507
1683
|
});
|
|
1508
1684
|
|
|
1509
1685
|
// src/commands/builtin/opfs/tsort.ts
|
|
1510
|
-
import { ResourceName as
|
|
1511
|
-
var OPFS_TSORT =
|
|
1686
|
+
import { ResourceName as ResourceName63, command as command60, specOf as specOf60, tsortGeneric } from "@struktoai/mirage-core";
|
|
1687
|
+
var OPFS_TSORT = command60({
|
|
1512
1688
|
name: "tsort",
|
|
1513
|
-
resource:
|
|
1514
|
-
spec:
|
|
1689
|
+
resource: ResourceName63.OPFS,
|
|
1690
|
+
spec: specOf60("tsort"),
|
|
1515
1691
|
fn: (accessor, paths, _texts, opts) => tsortGeneric(paths, opts, (p) => stream(accessor, p))
|
|
1516
1692
|
});
|
|
1517
1693
|
|
|
1518
1694
|
// src/commands/builtin/opfs/unexpand.ts
|
|
1519
|
-
import { ResourceName as
|
|
1520
|
-
var OPFS_UNEXPAND =
|
|
1695
|
+
import { ResourceName as ResourceName64, command as command61, specOf as specOf61, unexpandGeneric } from "@struktoai/mirage-core";
|
|
1696
|
+
var OPFS_UNEXPAND = command61({
|
|
1521
1697
|
name: "unexpand",
|
|
1522
|
-
resource:
|
|
1523
|
-
spec:
|
|
1698
|
+
resource: ResourceName64.OPFS,
|
|
1699
|
+
spec: specOf61("unexpand"),
|
|
1524
1700
|
fn: (accessor, paths, _texts, opts) => unexpandGeneric(paths, opts, (p) => stream(accessor, p))
|
|
1525
1701
|
});
|
|
1526
1702
|
|
|
1527
1703
|
// src/commands/builtin/opfs/uniq.ts
|
|
1528
|
-
import { ResourceName as
|
|
1529
|
-
var OPFS_UNIQ =
|
|
1704
|
+
import { ResourceName as ResourceName65, command as command62, specOf as specOf62, uniqGeneric } from "@struktoai/mirage-core";
|
|
1705
|
+
var OPFS_UNIQ = command62({
|
|
1530
1706
|
name: "uniq",
|
|
1531
|
-
resource:
|
|
1532
|
-
spec:
|
|
1533
|
-
fn: (accessor, paths, _texts, opts) => uniqGeneric(
|
|
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
|
|
1534
1783
|
});
|
|
1535
1784
|
|
|
1536
1785
|
// src/commands/builtin/opfs/unzip.ts
|
|
1537
|
-
import { ResourceName as
|
|
1538
|
-
var OPFS_UNZIP =
|
|
1786
|
+
import { ResourceName as ResourceName67, command as command64, specOf as specOf64, unzipGeneric } from "@struktoai/mirage-core";
|
|
1787
|
+
var OPFS_UNZIP = command64({
|
|
1539
1788
|
name: "unzip",
|
|
1540
|
-
resource:
|
|
1541
|
-
spec:
|
|
1789
|
+
resource: ResourceName67.OPFS,
|
|
1790
|
+
spec: specOf64("unzip"),
|
|
1542
1791
|
fn: (accessor, paths, _texts, opts) => unzipGeneric(
|
|
1543
1792
|
paths,
|
|
1544
1793
|
opts,
|
|
@@ -1550,48 +1799,48 @@ var OPFS_UNZIP = command57({
|
|
|
1550
1799
|
});
|
|
1551
1800
|
|
|
1552
1801
|
// src/commands/builtin/opfs/wc/wc.ts
|
|
1553
|
-
import { ResourceName as
|
|
1554
|
-
var OPFS_WC =
|
|
1802
|
+
import { ResourceName as ResourceName68, command as command65, specOf as specOf65, wcAggregate, wcGeneric } from "@struktoai/mirage-core";
|
|
1803
|
+
var OPFS_WC = command65({
|
|
1555
1804
|
name: "wc",
|
|
1556
|
-
resource:
|
|
1557
|
-
spec:
|
|
1805
|
+
resource: ResourceName68.OPFS,
|
|
1806
|
+
spec: specOf65("wc"),
|
|
1558
1807
|
fn: (accessor, paths, texts, opts) => wcGeneric(paths, texts, opts, (p) => stream(accessor, p)),
|
|
1559
1808
|
aggregate: wcAggregate
|
|
1560
1809
|
});
|
|
1561
1810
|
|
|
1562
1811
|
// src/commands/builtin/opfs/xxd.ts
|
|
1563
|
-
import { ResourceName as
|
|
1564
|
-
var OPFS_XXD =
|
|
1812
|
+
import { ResourceName as ResourceName69, command as command66, specOf as specOf66, xxdGeneric } from "@struktoai/mirage-core";
|
|
1813
|
+
var OPFS_XXD = command66({
|
|
1565
1814
|
name: "xxd",
|
|
1566
|
-
resource:
|
|
1567
|
-
spec:
|
|
1815
|
+
resource: ResourceName69.OPFS,
|
|
1816
|
+
spec: specOf66("xxd"),
|
|
1568
1817
|
fn: (accessor, paths, _texts, opts) => xxdGeneric(paths, opts, (p) => stream(accessor, p))
|
|
1569
1818
|
});
|
|
1570
1819
|
|
|
1571
1820
|
// src/commands/builtin/opfs/zcat.ts
|
|
1572
|
-
import { ResourceName as
|
|
1573
|
-
var OPFS_ZCAT =
|
|
1821
|
+
import { ResourceName as ResourceName70, command as command67, specOf as specOf67, zcatGeneric } from "@struktoai/mirage-core";
|
|
1822
|
+
var OPFS_ZCAT = command67({
|
|
1574
1823
|
name: "zcat",
|
|
1575
|
-
resource:
|
|
1576
|
-
spec:
|
|
1824
|
+
resource: ResourceName70.OPFS,
|
|
1825
|
+
spec: specOf67("zcat"),
|
|
1577
1826
|
fn: (accessor, paths, _texts, opts) => zcatGeneric(paths, opts, (p) => stream(accessor, p))
|
|
1578
1827
|
});
|
|
1579
1828
|
|
|
1580
1829
|
// src/commands/builtin/opfs/zgrep.ts
|
|
1581
|
-
import { ResourceName as
|
|
1582
|
-
var OPFS_ZGREP =
|
|
1830
|
+
import { ResourceName as ResourceName71, command as command68, specOf as specOf68, zgrepGeneric } from "@struktoai/mirage-core";
|
|
1831
|
+
var OPFS_ZGREP = command68({
|
|
1583
1832
|
name: "zgrep",
|
|
1584
|
-
resource:
|
|
1585
|
-
spec:
|
|
1833
|
+
resource: ResourceName71.OPFS,
|
|
1834
|
+
spec: specOf68("zgrep"),
|
|
1586
1835
|
fn: (accessor, paths, texts, opts) => zgrepGeneric(paths, texts, opts, (p) => stream(accessor, p))
|
|
1587
1836
|
});
|
|
1588
1837
|
|
|
1589
1838
|
// src/commands/builtin/opfs/zip_cmd.ts
|
|
1590
|
-
import { ResourceName as
|
|
1591
|
-
var OPFS_ZIP =
|
|
1839
|
+
import { ResourceName as ResourceName72, command as command69, specOf as specOf69, zipGeneric } from "@struktoai/mirage-core";
|
|
1840
|
+
var OPFS_ZIP = command69({
|
|
1592
1841
|
name: "zip",
|
|
1593
|
-
resource:
|
|
1594
|
-
spec:
|
|
1842
|
+
resource: ResourceName72.OPFS,
|
|
1843
|
+
spec: specOf69("zip"),
|
|
1595
1844
|
fn: (accessor, paths, _texts, opts) => zipGeneric(
|
|
1596
1845
|
paths,
|
|
1597
1846
|
opts,
|
|
@@ -1602,83 +1851,95 @@ var OPFS_ZIP = command62({
|
|
|
1602
1851
|
});
|
|
1603
1852
|
|
|
1604
1853
|
// src/commands/builtin/opfs/index.ts
|
|
1605
|
-
var
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
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
|
+
);
|
|
1675
1936
|
|
|
1676
1937
|
// src/core/opfs/append.ts
|
|
1677
|
-
import { record as record3, ResourceName as
|
|
1938
|
+
import { record as record3, ResourceName as ResourceName74 } from "@struktoai/mirage-core";
|
|
1678
1939
|
async function appendBytes(accessor, p, data) {
|
|
1679
1940
|
const root = accessor.rootHandle;
|
|
1680
1941
|
const start = performance.now();
|
|
1681
|
-
const virtual = p.
|
|
1942
|
+
const virtual = p.mountPath;
|
|
1682
1943
|
const handle = await resolveFileHandle(root, virtual, { create: true });
|
|
1683
1944
|
const existing = await handle.getFile();
|
|
1684
1945
|
const existingBytes = new Uint8Array(await existing.arrayBuffer());
|
|
@@ -1688,57 +1949,13 @@ async function appendBytes(accessor, p, data) {
|
|
|
1688
1949
|
const writable = await handle.createWritable();
|
|
1689
1950
|
await writable.write(toWritableChunk(merged));
|
|
1690
1951
|
await writable.close();
|
|
1691
|
-
record3("append", virtual,
|
|
1692
|
-
}
|
|
1693
|
-
|
|
1694
|
-
// src/core/opfs/glob.ts
|
|
1695
|
-
import { PathSpec } from "@struktoai/mirage-core";
|
|
1696
|
-
|
|
1697
|
-
// src/core/opfs/constants.ts
|
|
1698
|
-
var SCOPE_ERROR = 5e4;
|
|
1699
|
-
|
|
1700
|
-
// src/core/opfs/glob.ts
|
|
1701
|
-
import { fnmatch } from "@struktoai/mirage-core";
|
|
1702
|
-
import { gnuBasename as gnuBasename2 } from "@struktoai/mirage-core";
|
|
1703
|
-
async function resolveGlob(accessor, paths) {
|
|
1704
|
-
const result = [];
|
|
1705
|
-
for (const p of paths) {
|
|
1706
|
-
if (p.resolved) {
|
|
1707
|
-
result.push(p);
|
|
1708
|
-
} else if (p.pattern !== null) {
|
|
1709
|
-
const dirSpec = new PathSpec({
|
|
1710
|
-
original: p.directory,
|
|
1711
|
-
directory: p.directory,
|
|
1712
|
-
resolved: true,
|
|
1713
|
-
prefix: p.prefix
|
|
1714
|
-
});
|
|
1715
|
-
const entries = await readdir(accessor, dirSpec);
|
|
1716
|
-
const matched = [];
|
|
1717
|
-
for (const e of entries) {
|
|
1718
|
-
if (fnmatch(gnuBasename2(e), p.pattern)) {
|
|
1719
|
-
matched.push(
|
|
1720
|
-
new PathSpec({
|
|
1721
|
-
original: e,
|
|
1722
|
-
directory: p.directory,
|
|
1723
|
-
resolved: true,
|
|
1724
|
-
prefix: p.prefix
|
|
1725
|
-
})
|
|
1726
|
-
);
|
|
1727
|
-
}
|
|
1728
|
-
}
|
|
1729
|
-
if (matched.length > SCOPE_ERROR) matched.length = SCOPE_ERROR;
|
|
1730
|
-
result.push(...matched);
|
|
1731
|
-
} else {
|
|
1732
|
-
result.push(p);
|
|
1733
|
-
}
|
|
1734
|
-
}
|
|
1735
|
-
return result;
|
|
1952
|
+
record3("append", virtual, ResourceName74.OPFS, data.byteLength, start);
|
|
1736
1953
|
}
|
|
1737
1954
|
|
|
1738
1955
|
// src/core/opfs/truncate.ts
|
|
1739
1956
|
async function truncate(accessor, path, length) {
|
|
1740
1957
|
const root = accessor.rootHandle;
|
|
1741
|
-
const virtual = path.
|
|
1958
|
+
const virtual = path.mountPath;
|
|
1742
1959
|
let handle;
|
|
1743
1960
|
let existing;
|
|
1744
1961
|
try {
|
|
@@ -1761,10 +1978,10 @@ async function truncate(accessor, path, length) {
|
|
|
1761
1978
|
}
|
|
1762
1979
|
|
|
1763
1980
|
// src/ops/opfs/append.ts
|
|
1764
|
-
import { ResourceName as
|
|
1981
|
+
import { ResourceName as ResourceName75 } from "@struktoai/mirage-core";
|
|
1765
1982
|
var appendOp = {
|
|
1766
1983
|
name: "append",
|
|
1767
|
-
resource:
|
|
1984
|
+
resource: ResourceName75.OPFS,
|
|
1768
1985
|
filetype: null,
|
|
1769
1986
|
write: true,
|
|
1770
1987
|
fn: (accessor, path, args) => {
|
|
@@ -1777,7 +1994,7 @@ var appendOp = {
|
|
|
1777
1994
|
};
|
|
1778
1995
|
|
|
1779
1996
|
// src/ops/opfs/create.ts
|
|
1780
|
-
import { ResourceName as
|
|
1997
|
+
import { ResourceName as ResourceName76 } from "@struktoai/mirage-core";
|
|
1781
1998
|
|
|
1782
1999
|
// src/core/opfs/create.ts
|
|
1783
2000
|
function create(accessor, path) {
|
|
@@ -1787,52 +2004,52 @@ function create(accessor, path) {
|
|
|
1787
2004
|
// src/ops/opfs/create.ts
|
|
1788
2005
|
var createOp = {
|
|
1789
2006
|
name: "create",
|
|
1790
|
-
resource:
|
|
2007
|
+
resource: ResourceName76.OPFS,
|
|
1791
2008
|
filetype: null,
|
|
1792
2009
|
write: true,
|
|
1793
2010
|
fn: (accessor, path) => create(accessor, path)
|
|
1794
2011
|
};
|
|
1795
2012
|
|
|
1796
2013
|
// src/ops/opfs/mkdir.ts
|
|
1797
|
-
import { ResourceName as
|
|
2014
|
+
import { ResourceName as ResourceName77 } from "@struktoai/mirage-core";
|
|
1798
2015
|
var mkdirOp = {
|
|
1799
2016
|
name: "mkdir",
|
|
1800
|
-
resource:
|
|
2017
|
+
resource: ResourceName77.OPFS,
|
|
1801
2018
|
filetype: null,
|
|
1802
2019
|
write: true,
|
|
1803
2020
|
fn: (accessor, path) => mkdir(accessor, path, true)
|
|
1804
2021
|
};
|
|
1805
2022
|
|
|
1806
2023
|
// src/ops/opfs/read.ts
|
|
1807
|
-
import { ResourceName as
|
|
2024
|
+
import { ResourceName as ResourceName78 } from "@struktoai/mirage-core";
|
|
1808
2025
|
var readOp = {
|
|
1809
2026
|
name: "read",
|
|
1810
|
-
resource:
|
|
2027
|
+
resource: ResourceName78.OPFS,
|
|
1811
2028
|
filetype: null,
|
|
1812
2029
|
write: false,
|
|
1813
2030
|
fn: (accessor, path) => read(accessor, path)
|
|
1814
2031
|
};
|
|
1815
2032
|
|
|
1816
2033
|
// src/ops/opfs/readdir.ts
|
|
1817
|
-
import { ResourceName as
|
|
2034
|
+
import { ResourceName as ResourceName79 } from "@struktoai/mirage-core";
|
|
1818
2035
|
var readdirOp = {
|
|
1819
2036
|
name: "readdir",
|
|
1820
|
-
resource:
|
|
2037
|
+
resource: ResourceName79.OPFS,
|
|
1821
2038
|
filetype: null,
|
|
1822
2039
|
write: false,
|
|
1823
2040
|
fn: (accessor, path) => readdir(accessor, path)
|
|
1824
2041
|
};
|
|
1825
2042
|
|
|
1826
2043
|
// src/ops/opfs/rename.ts
|
|
1827
|
-
import { ResourceName as
|
|
2044
|
+
import { ResourceName as ResourceName80 } from "@struktoai/mirage-core";
|
|
1828
2045
|
var renameOp = {
|
|
1829
2046
|
name: "rename",
|
|
1830
|
-
resource:
|
|
2047
|
+
resource: ResourceName80.OPFS,
|
|
1831
2048
|
filetype: null,
|
|
1832
2049
|
write: true,
|
|
1833
2050
|
fn: (accessor, path, args) => {
|
|
1834
2051
|
const dst = args[0];
|
|
1835
|
-
if (dst === void 0 || dst === null || typeof dst !== "object" || !("
|
|
2052
|
+
if (dst === void 0 || dst === null || typeof dst !== "object" || !("virtual" in dst)) {
|
|
1836
2053
|
throw new TypeError("rename op requires a PathSpec destination as the first arg");
|
|
1837
2054
|
}
|
|
1838
2055
|
return rename(accessor, path, dst);
|
|
@@ -1840,30 +2057,30 @@ var renameOp = {
|
|
|
1840
2057
|
};
|
|
1841
2058
|
|
|
1842
2059
|
// src/ops/opfs/rmdir.ts
|
|
1843
|
-
import { ResourceName as
|
|
2060
|
+
import { ResourceName as ResourceName81 } from "@struktoai/mirage-core";
|
|
1844
2061
|
var rmdirOp = {
|
|
1845
2062
|
name: "rmdir",
|
|
1846
|
-
resource:
|
|
2063
|
+
resource: ResourceName81.OPFS,
|
|
1847
2064
|
filetype: null,
|
|
1848
2065
|
write: true,
|
|
1849
2066
|
fn: (accessor, path) => rmdir(accessor, path)
|
|
1850
2067
|
};
|
|
1851
2068
|
|
|
1852
2069
|
// src/ops/opfs/stat.ts
|
|
1853
|
-
import { ResourceName as
|
|
2070
|
+
import { ResourceName as ResourceName82 } from "@struktoai/mirage-core";
|
|
1854
2071
|
var statOp = {
|
|
1855
2072
|
name: "stat",
|
|
1856
|
-
resource:
|
|
2073
|
+
resource: ResourceName82.OPFS,
|
|
1857
2074
|
filetype: null,
|
|
1858
2075
|
write: false,
|
|
1859
2076
|
fn: (accessor, path) => stat(accessor, path)
|
|
1860
2077
|
};
|
|
1861
2078
|
|
|
1862
2079
|
// src/ops/opfs/truncate.ts
|
|
1863
|
-
import { ResourceName as
|
|
2080
|
+
import { ResourceName as ResourceName83 } from "@struktoai/mirage-core";
|
|
1864
2081
|
var truncateOp = {
|
|
1865
2082
|
name: "truncate",
|
|
1866
|
-
resource:
|
|
2083
|
+
resource: ResourceName83.OPFS,
|
|
1867
2084
|
filetype: null,
|
|
1868
2085
|
write: true,
|
|
1869
2086
|
fn: (accessor, path, args) => {
|
|
@@ -1876,20 +2093,20 @@ var truncateOp = {
|
|
|
1876
2093
|
};
|
|
1877
2094
|
|
|
1878
2095
|
// src/ops/opfs/unlink.ts
|
|
1879
|
-
import { ResourceName as
|
|
2096
|
+
import { ResourceName as ResourceName84 } from "@struktoai/mirage-core";
|
|
1880
2097
|
var unlinkOp = {
|
|
1881
2098
|
name: "unlink",
|
|
1882
|
-
resource:
|
|
2099
|
+
resource: ResourceName84.OPFS,
|
|
1883
2100
|
filetype: null,
|
|
1884
2101
|
write: true,
|
|
1885
2102
|
fn: (accessor, path) => unlink(accessor, path)
|
|
1886
2103
|
};
|
|
1887
2104
|
|
|
1888
2105
|
// src/ops/opfs/write.ts
|
|
1889
|
-
import { ResourceName as
|
|
2106
|
+
import { ResourceName as ResourceName85 } from "@struktoai/mirage-core";
|
|
1890
2107
|
var writeOp = {
|
|
1891
2108
|
name: "write",
|
|
1892
|
-
resource:
|
|
2109
|
+
resource: ResourceName85.OPFS,
|
|
1893
2110
|
filetype: null,
|
|
1894
2111
|
write: true,
|
|
1895
2112
|
fn: (accessor, path, args) => {
|
|
@@ -1922,6 +2139,7 @@ var OPFS_PROMPT = `{prefix}
|
|
|
1922
2139
|
Standard commands: ls, cat, head, tail, grep, wc, find, tree, mkdir, touch, cp, mv, rm, tee.`;
|
|
1923
2140
|
|
|
1924
2141
|
// src/resource/opfs/opfs.ts
|
|
2142
|
+
var globCore = makeResolveGlob2(readdir, SCOPE_ERROR);
|
|
1925
2143
|
async function walkFiles(dir, currentPath, files) {
|
|
1926
2144
|
for await (const [name, handle] of iterEntries(dir)) {
|
|
1927
2145
|
const childPath = currentPath === "" ? name : `${currentPath}/${name}`;
|
|
@@ -1953,7 +2171,7 @@ async function splitAndCreate(root, relativePath) {
|
|
|
1953
2171
|
return handle;
|
|
1954
2172
|
}
|
|
1955
2173
|
var OPFSResource = class {
|
|
1956
|
-
kind =
|
|
2174
|
+
kind = ResourceName86.OPFS;
|
|
1957
2175
|
prompt = OPFS_PROMPT;
|
|
1958
2176
|
rootName;
|
|
1959
2177
|
accessor;
|
|
@@ -2068,7 +2286,7 @@ var OPFSResource = class {
|
|
|
2068
2286
|
}
|
|
2069
2287
|
async glob(paths) {
|
|
2070
2288
|
await this.ensureOpen();
|
|
2071
|
-
return
|
|
2289
|
+
return globCore(this.accessor, paths);
|
|
2072
2290
|
}
|
|
2073
2291
|
async getState() {
|
|
2074
2292
|
const handle = await this.ensureOpen();
|
|
@@ -2113,4 +2331,4 @@ export {
|
|
|
2113
2331
|
OPFS_PROMPT,
|
|
2114
2332
|
OPFSResource
|
|
2115
2333
|
};
|
|
2116
|
-
//# sourceMappingURL=chunk-
|
|
2334
|
+
//# sourceMappingURL=chunk-4YUYQTRN.js.map
|