@bendyline/docblocks 2.6.1 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/THIRD_PARTY_NOTICES.txt +33 -33
  2. package/dist/capabilities-CdQAc745.d.ts +1233 -0
  3. package/dist/catalog-BQK05tne.d.ts +122 -0
  4. package/dist/chunk-245W57QP.js +31 -0
  5. package/dist/{chunk-2WDJ27EH.js → chunk-46AGYHDY.js} +8 -0
  6. package/dist/{chunk-4437YWLE.js → chunk-6UPO2GE6.js} +4 -2
  7. package/dist/{chunk-UMWCTEXW.js → chunk-7SN7YQL4.js} +211 -40
  8. package/dist/{chunk-OQCPBOQA.js → chunk-DAPFSEKY.js} +35 -0
  9. package/dist/{chunk-M62ZGJ5I.js → chunk-HABG2JM3.js} +0 -17
  10. package/dist/{chunk-YM7O3PWO.js → chunk-HKOOHM67.js} +20 -12
  11. package/dist/chunk-IDYE73TU.js +77 -0
  12. package/dist/{chunk-KLQKU74Q.js → chunk-IGB2VSRE.js} +124 -330
  13. package/dist/{chunk-BVY7GGNV.js → chunk-L6PRMR7T.js} +137 -95
  14. package/dist/chunk-LPIJ6HKL.js +19 -0
  15. package/dist/{chunk-SJBB5OD7.js → chunk-QS5WTLUZ.js} +10 -8
  16. package/dist/chunk-R2JX5N3F.js +382 -0
  17. package/dist/{chunk-ZO7G53QP.js → chunk-UDEWLHQI.js} +4 -2
  18. package/dist/chunk-UK7R3RC7.js +514 -0
  19. package/dist/chunk-XTNWCNSK.js +464 -0
  20. package/dist/chunk-YHSFRPBS.js +42 -0
  21. package/dist/chunk-YNUQG4GF.js +1173 -0
  22. package/dist/document/index.d.ts +31 -1
  23. package/dist/document/index.js +7 -6
  24. package/dist/filesystem/electron.d.ts +8 -34
  25. package/dist/filesystem/electron.js +7 -4
  26. package/dist/filesystem/host.d.ts +28 -0
  27. package/dist/filesystem/host.js +103 -0
  28. package/dist/filesystem/index.d.ts +52 -6
  29. package/dist/filesystem/index.js +36 -15
  30. package/dist/filesystem/indexeddb.d.ts +8 -1
  31. package/dist/filesystem/indexeddb.js +7 -6
  32. package/dist/filesystem/memory.d.ts +2 -1
  33. package/dist/filesystem/memory.js +3 -2
  34. package/dist/filesystem/native.d.ts +2 -1
  35. package/dist/filesystem/native.js +3 -2
  36. package/dist/filesystem-v2-C8AdSXUN.d.ts +74 -0
  37. package/dist/host/index.d.ts +127 -5
  38. package/dist/host/index.js +100 -4
  39. package/dist/host/mobile.d.ts +389 -0
  40. package/dist/host/mobile.js +315 -0
  41. package/dist/host-provider-v2-CyLTRKJF.d.ts +51 -0
  42. package/dist/index.d.ts +8 -5
  43. package/dist/index.js +153 -34
  44. package/dist/mcp/index.d.ts +2 -2
  45. package/dist/mcp/zod.d.ts +23 -1
  46. package/dist/mcp/zod.js +1 -0
  47. package/dist/settings-HrrCikVX.d.ts +170 -0
  48. package/dist/types-BvDnr3YU.d.ts +88 -0
  49. package/dist/{types-Oy9U5FST.d.ts → types-d0yvHUJz.d.ts} +6 -0
  50. package/dist/{types-Bb3yccTH.d.ts → v2-BVnZZyd4.d.ts} +1 -86
  51. package/dist/vscode/index.d.ts +43 -1
  52. package/dist/vscode/index.js +67 -1
  53. package/dist/workspace/index.d.ts +10 -6
  54. package/dist/workspace/index.js +4 -2
  55. package/dist/workspace-index/index.d.ts +240 -0
  56. package/dist/workspace-index/index.js +1287 -0
  57. package/dist/workspace-settings/index.d.ts +301 -0
  58. package/dist/workspace-settings/index.js +820 -0
  59. package/package.json +22 -2
  60. package/dist/chunk-6XHOOBYF.js +0 -36
  61. package/dist/chunk-QI6YKTQV.js +0 -110
  62. package/dist/types-DBYraXxE.d.ts +0 -557
@@ -0,0 +1,389 @@
1
+ import { m as FileSystemProviderCapabilities } from '../v2-BVnZZyd4.js';
2
+ import { z } from 'zod';
3
+ import { D as DocBlocksHostFsV2API } from '../filesystem-v2-C8AdSXUN.js';
4
+ import '../workspace-path-CWVrcuPL.js';
5
+
6
+ /** Capabilities cross the native boundary and must describe the actual backend. */
7
+ declare function parseFileSystemCapabilities(value: unknown): FileSystemProviderCapabilities;
8
+
9
+ declare const MOBILE_STORAGE_LIMITS: Readonly<{
10
+ fileBytes: number;
11
+ chunkBytes: number;
12
+ totalBytes: number;
13
+ entries: 10000;
14
+ transfers: 4;
15
+ }>;
16
+ declare const mobileRequests: {
17
+ open: z.ZodObject<{
18
+ providerId: z.ZodString;
19
+ label: z.ZodString;
20
+ instanceId: z.ZodString;
21
+ op: z.ZodLiteral<"open">;
22
+ }, "strict", z.ZodTypeAny, {
23
+ op: "open";
24
+ providerId: string;
25
+ label: string;
26
+ instanceId: string;
27
+ }, {
28
+ op: "open";
29
+ providerId: string;
30
+ label: string;
31
+ instanceId: string;
32
+ }>;
33
+ stat: z.ZodObject<{
34
+ path: z.ZodEffects<z.ZodString, string, string>;
35
+ instanceId: z.ZodString;
36
+ op: z.ZodLiteral<"stat">;
37
+ }, "strict", z.ZodTypeAny, {
38
+ path: string;
39
+ op: "stat";
40
+ instanceId: string;
41
+ }, {
42
+ path: string;
43
+ op: "stat";
44
+ instanceId: string;
45
+ }>;
46
+ list: z.ZodObject<{
47
+ path: z.ZodEffects<z.ZodString, string, string>;
48
+ instanceId: z.ZodString;
49
+ op: z.ZodLiteral<"list">;
50
+ }, "strict", z.ZodTypeAny, {
51
+ path: string;
52
+ op: "list";
53
+ instanceId: string;
54
+ }, {
55
+ path: string;
56
+ op: "list";
57
+ instanceId: string;
58
+ }>;
59
+ readBegin: z.ZodObject<{
60
+ path: z.ZodEffects<z.ZodString, string, string>;
61
+ instanceId: z.ZodString;
62
+ op: z.ZodLiteral<"readBegin">;
63
+ }, "strict", z.ZodTypeAny, {
64
+ path: string;
65
+ op: "readBegin";
66
+ instanceId: string;
67
+ }, {
68
+ path: string;
69
+ op: "readBegin";
70
+ instanceId: string;
71
+ }>;
72
+ readChunk: z.ZodObject<{
73
+ offset: z.ZodNumber;
74
+ transferId: z.ZodString;
75
+ instanceId: z.ZodString;
76
+ op: z.ZodLiteral<"readChunk">;
77
+ }, "strict", z.ZodTypeAny, {
78
+ op: "readChunk";
79
+ instanceId: string;
80
+ offset: number;
81
+ transferId: string;
82
+ }, {
83
+ op: "readChunk";
84
+ instanceId: string;
85
+ offset: number;
86
+ transferId: string;
87
+ }>;
88
+ writeBegin: z.ZodObject<{
89
+ byteLength: z.ZodNumber;
90
+ options: z.ZodObject<{
91
+ mode: z.ZodOptional<z.ZodEnum<["upsert", "create", "replace"]>>;
92
+ createParents: z.ZodOptional<z.ZodBoolean>;
93
+ expectedVersion: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>;
94
+ }, "strict", z.ZodTypeAny, {
95
+ mode?: "upsert" | "create" | "replace" | undefined;
96
+ createParents?: boolean | undefined;
97
+ expectedVersion?: string | null | undefined;
98
+ }, {
99
+ mode?: "upsert" | "create" | "replace" | undefined;
100
+ createParents?: boolean | undefined;
101
+ expectedVersion?: string | null | undefined;
102
+ }>;
103
+ path: z.ZodEffects<z.ZodString, string, string>;
104
+ instanceId: z.ZodString;
105
+ op: z.ZodLiteral<"writeBegin">;
106
+ }, "strict", z.ZodTypeAny, {
107
+ path: string;
108
+ options: {
109
+ mode?: "upsert" | "create" | "replace" | undefined;
110
+ createParents?: boolean | undefined;
111
+ expectedVersion?: string | null | undefined;
112
+ };
113
+ op: "writeBegin";
114
+ instanceId: string;
115
+ byteLength: number;
116
+ }, {
117
+ path: string;
118
+ options: {
119
+ mode?: "upsert" | "create" | "replace" | undefined;
120
+ createParents?: boolean | undefined;
121
+ expectedVersion?: string | null | undefined;
122
+ };
123
+ op: "writeBegin";
124
+ instanceId: string;
125
+ byteLength: number;
126
+ }>;
127
+ writeChunk: z.ZodObject<{
128
+ offset: z.ZodNumber;
129
+ data: z.ZodString;
130
+ transferId: z.ZodString;
131
+ instanceId: z.ZodString;
132
+ op: z.ZodLiteral<"writeChunk">;
133
+ }, "strict", z.ZodTypeAny, {
134
+ op: "writeChunk";
135
+ instanceId: string;
136
+ offset: number;
137
+ transferId: string;
138
+ data: string;
139
+ }, {
140
+ op: "writeChunk";
141
+ instanceId: string;
142
+ offset: number;
143
+ transferId: string;
144
+ data: string;
145
+ }>;
146
+ writeFinish: z.ZodObject<{
147
+ transferId: z.ZodString;
148
+ instanceId: z.ZodString;
149
+ op: z.ZodLiteral<"writeFinish">;
150
+ }, "strict", z.ZodTypeAny, {
151
+ op: "writeFinish";
152
+ instanceId: string;
153
+ transferId: string;
154
+ }, {
155
+ op: "writeFinish";
156
+ instanceId: string;
157
+ transferId: string;
158
+ }>;
159
+ closeTransfer: z.ZodObject<{
160
+ transferId: z.ZodString;
161
+ instanceId: z.ZodString;
162
+ op: z.ZodLiteral<"closeTransfer">;
163
+ }, "strict", z.ZodTypeAny, {
164
+ op: "closeTransfer";
165
+ instanceId: string;
166
+ transferId: string;
167
+ }, {
168
+ op: "closeTransfer";
169
+ instanceId: string;
170
+ transferId: string;
171
+ }>;
172
+ mkdir: z.ZodObject<{
173
+ options: z.ZodObject<{
174
+ mode: z.ZodOptional<z.ZodEnum<["ensure", "create"]>>;
175
+ createParents: z.ZodOptional<z.ZodBoolean>;
176
+ }, "strict", z.ZodTypeAny, {
177
+ mode?: "create" | "ensure" | undefined;
178
+ createParents?: boolean | undefined;
179
+ }, {
180
+ mode?: "create" | "ensure" | undefined;
181
+ createParents?: boolean | undefined;
182
+ }>;
183
+ path: z.ZodEffects<z.ZodString, string, string>;
184
+ instanceId: z.ZodString;
185
+ op: z.ZodLiteral<"mkdir">;
186
+ }, "strict", z.ZodTypeAny, {
187
+ path: string;
188
+ options: {
189
+ mode?: "create" | "ensure" | undefined;
190
+ createParents?: boolean | undefined;
191
+ };
192
+ op: "mkdir";
193
+ instanceId: string;
194
+ }, {
195
+ path: string;
196
+ options: {
197
+ mode?: "create" | "ensure" | undefined;
198
+ createParents?: boolean | undefined;
199
+ };
200
+ op: "mkdir";
201
+ instanceId: string;
202
+ }>;
203
+ remove: z.ZodObject<{
204
+ options: z.ZodObject<{
205
+ recursive: z.ZodOptional<z.ZodBoolean>;
206
+ missing: z.ZodOptional<z.ZodEnum<["ignore", "error"]>>;
207
+ expectedVersion: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
208
+ }, "strict", z.ZodTypeAny, {
209
+ expectedVersion?: string | undefined;
210
+ recursive?: boolean | undefined;
211
+ missing?: "ignore" | "error" | undefined;
212
+ }, {
213
+ expectedVersion?: string | undefined;
214
+ recursive?: boolean | undefined;
215
+ missing?: "ignore" | "error" | undefined;
216
+ }>;
217
+ path: z.ZodEffects<z.ZodString, string, string>;
218
+ instanceId: z.ZodString;
219
+ op: z.ZodLiteral<"remove">;
220
+ }, "strict", z.ZodTypeAny, {
221
+ path: string;
222
+ options: {
223
+ expectedVersion?: string | undefined;
224
+ recursive?: boolean | undefined;
225
+ missing?: "ignore" | "error" | undefined;
226
+ };
227
+ op: "remove";
228
+ instanceId: string;
229
+ }, {
230
+ path: string;
231
+ options: {
232
+ expectedVersion?: string | undefined;
233
+ recursive?: boolean | undefined;
234
+ missing?: "ignore" | "error" | undefined;
235
+ };
236
+ op: "remove";
237
+ instanceId: string;
238
+ }>;
239
+ move: z.ZodObject<{
240
+ oldPath: z.ZodEffects<z.ZodString, string, string>;
241
+ newPath: z.ZodEffects<z.ZodString, string, string>;
242
+ options: z.ZodObject<{
243
+ createParents: z.ZodOptional<z.ZodBoolean>;
244
+ expectedVersion: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
245
+ }, "strict", z.ZodTypeAny, {
246
+ createParents?: boolean | undefined;
247
+ expectedVersion?: string | undefined;
248
+ }, {
249
+ createParents?: boolean | undefined;
250
+ expectedVersion?: string | undefined;
251
+ }>;
252
+ instanceId: z.ZodString;
253
+ op: z.ZodLiteral<"move">;
254
+ }, "strict", z.ZodTypeAny, {
255
+ options: {
256
+ createParents?: boolean | undefined;
257
+ expectedVersion?: string | undefined;
258
+ };
259
+ op: "move";
260
+ instanceId: string;
261
+ oldPath: string;
262
+ newPath: string;
263
+ }, {
264
+ options: {
265
+ createParents?: boolean | undefined;
266
+ expectedVersion?: string | undefined;
267
+ };
268
+ op: "move";
269
+ instanceId: string;
270
+ oldPath: string;
271
+ newPath: string;
272
+ }>;
273
+ snapshot: z.ZodObject<{
274
+ instanceId: z.ZodString;
275
+ op: z.ZodLiteral<"snapshot">;
276
+ }, "strict", z.ZodTypeAny, {
277
+ op: "snapshot";
278
+ instanceId: string;
279
+ }, {
280
+ op: "snapshot";
281
+ instanceId: string;
282
+ }>;
283
+ dispose: z.ZodObject<{
284
+ instanceId: z.ZodString;
285
+ op: z.ZodLiteral<"dispose">;
286
+ }, "strict", z.ZodTypeAny, {
287
+ op: "dispose";
288
+ instanceId: string;
289
+ }, {
290
+ op: "dispose";
291
+ instanceId: string;
292
+ }>;
293
+ };
294
+ type MobileFsRequest = {
295
+ [K in keyof typeof mobileRequests]: z.infer<(typeof mobileRequests)[K]>;
296
+ }[keyof typeof mobileRequests];
297
+ type MobileNativeSend = (request: MobileFsRequest) => Promise<unknown>;
298
+ declare function parseMobileResult<T>(input: unknown, parse: (value: unknown) => T): T;
299
+ declare function encodeMobileBytes(data: ArrayBuffer | Uint8Array): string;
300
+ /** JSON-safe transport shared by Capacitor and the real-native conformance runner. */
301
+ declare function createMobileFileSystemBridge(send: MobileNativeSend, capabilities: ReturnType<typeof parseFileSystemCapabilities>): DocBlocksHostFsV2API;
302
+ declare function parseMobileBootstrap(value: unknown): {
303
+ env: {
304
+ surface: "capacitor";
305
+ surfaceLabel: "iOS" | "Android";
306
+ platform: "ios" | "android";
307
+ appVersion: string;
308
+ isDev: boolean;
309
+ };
310
+ workspaces: {
311
+ name: string;
312
+ id: string;
313
+ rootPath: string;
314
+ }[];
315
+ folderPicker: boolean;
316
+ capabilities: FileSystemProviderCapabilities;
317
+ };
318
+ declare const mobileExportRequests: {
319
+ begin: z.ZodObject<{
320
+ op: z.ZodLiteral<"begin">;
321
+ filename: z.ZodEffects<z.ZodString, string, string>;
322
+ byteLength: z.ZodNumber;
323
+ }, "strict", z.ZodTypeAny, {
324
+ op: "begin";
325
+ byteLength: number;
326
+ filename: string;
327
+ }, {
328
+ op: "begin";
329
+ byteLength: number;
330
+ filename: string;
331
+ }>;
332
+ append: z.ZodObject<{
333
+ op: z.ZodLiteral<"append">;
334
+ transferId: z.ZodString;
335
+ offset: z.ZodNumber;
336
+ data: z.ZodString;
337
+ }, "strict", z.ZodTypeAny, {
338
+ op: "append";
339
+ offset: number;
340
+ transferId: string;
341
+ data: string;
342
+ }, {
343
+ op: "append";
344
+ offset: number;
345
+ transferId: string;
346
+ data: string;
347
+ }>;
348
+ finish: z.ZodObject<{
349
+ op: z.ZodLiteral<"finish">;
350
+ transferId: z.ZodString;
351
+ action: z.ZodEnum<["save", "share"]>;
352
+ }, "strict", z.ZodTypeAny, {
353
+ op: "finish";
354
+ transferId: string;
355
+ action: "save" | "share";
356
+ }, {
357
+ op: "finish";
358
+ transferId: string;
359
+ action: "save" | "share";
360
+ }>;
361
+ cancel: z.ZodObject<{
362
+ op: z.ZodLiteral<"cancel">;
363
+ transferId: z.ZodString;
364
+ }, "strict", z.ZodTypeAny, {
365
+ op: "cancel";
366
+ transferId: string;
367
+ }, {
368
+ op: "cancel";
369
+ transferId: string;
370
+ }>;
371
+ };
372
+ type MobileExportRequest = {
373
+ [K in keyof typeof mobileExportRequests]: z.infer<(typeof mobileExportRequests)[K]>;
374
+ }[keyof typeof mobileExportRequests];
375
+ declare function parseMobileExportRequest(input: MobileExportRequest): MobileExportRequest;
376
+ declare function parseMobileExportToken(input: unknown): string;
377
+ declare function parseMobileExportOutcome(input: unknown): 'saved' | 'shared' | 'presented' | 'cancelled';
378
+ declare function parseMobileOpenRequests(input: unknown): {
379
+ path: string;
380
+ kind: "workspace-file";
381
+ workspaceId: string;
382
+ }[];
383
+ declare function parseMobilePickedFolder(input: unknown): {
384
+ name: string;
385
+ id: string;
386
+ rootPath: string;
387
+ } | null;
388
+
389
+ export { MOBILE_STORAGE_LIMITS, type MobileExportRequest, type MobileFsRequest, type MobileNativeSend, createMobileFileSystemBridge, encodeMobileBytes, parseMobileBootstrap, parseMobileExportOutcome, parseMobileExportRequest, parseMobileExportToken, parseMobileOpenRequests, parseMobilePickedFolder, parseMobileResult };
@@ -0,0 +1,315 @@
1
+ import {
2
+ parseFileSystemCapabilities
3
+ } from "../chunk-245W57QP.js";
4
+ import {
5
+ parseFileSystemVersion
6
+ } from "../chunk-LPIJ6HKL.js";
7
+ import {
8
+ FsError,
9
+ deserializeFsError,
10
+ isSerializedFsError,
11
+ parseWorkspacePath
12
+ } from "../chunk-AYWKIZLD.js";
13
+
14
+ // src/host/mobile-wire.ts
15
+ import { z } from "zod";
16
+ var MOBILE_STORAGE_LIMITS = Object.freeze({
17
+ fileBytes: 16 * 1024 * 1024,
18
+ chunkBytes: 256 * 1024,
19
+ totalBytes: 32 * 1024 * 1024,
20
+ entries: 1e4,
21
+ transfers: 4
22
+ });
23
+ var id = z.string().min(1).max(256).regex(/^[a-zA-Z0-9_-]+$/);
24
+ var path = z.string().max(4096).refine((value) => parseWorkspacePath(value) === value, "Native paths must be canonical.");
25
+ var version = z.string().min(1).max(1024).refine((value) => !value.includes("\0"));
26
+ var integer = z.number().int().nonnegative();
27
+ var entryFields = {
28
+ path: path.transform(parseWorkspacePath),
29
+ name: z.string().max(4096),
30
+ version: version.transform(parseFileSystemVersion),
31
+ lastModified: z.string().datetime()
32
+ };
33
+ var file = z.object({
34
+ ...entryFields,
35
+ kind: z.literal("file"),
36
+ size: integer.max(MOBILE_STORAGE_LIMITS.fileBytes)
37
+ }).strict();
38
+ var directory = z.object({ ...entryFields, kind: z.literal("directory"), size: z.null() }).strict();
39
+ var entry = z.union([file, directory]);
40
+ var base64 = z.string().max(Math.ceil(MOBILE_STORAGE_LIMITS.fileBytes / 3) * 4).regex(/^[A-Za-z0-9+/]*={0,2}$/);
41
+ var writeOptions = z.object({
42
+ mode: z.enum(["upsert", "create", "replace"]).optional(),
43
+ createParents: z.boolean().optional(),
44
+ expectedVersion: version.nullable().optional()
45
+ }).strict();
46
+ var mkdirOptions = z.object({ mode: z.enum(["ensure", "create"]).optional(), createParents: z.boolean().optional() }).strict();
47
+ var removeOptions = z.object({
48
+ recursive: z.boolean().optional(),
49
+ missing: z.enum(["ignore", "error"]).optional(),
50
+ expectedVersion: version.optional()
51
+ }).strict();
52
+ var moveOptions = z.object({ createParents: z.boolean().optional(), expectedVersion: version.optional() }).strict();
53
+ var instance = { instanceId: id };
54
+ var location = { ...instance, path };
55
+ var transfer = { ...instance, transferId: id };
56
+ var mobileRequests = {
57
+ open: z.object({ op: z.literal("open"), ...instance, providerId: id, label: z.string().max(1024) }).strict(),
58
+ stat: z.object({ op: z.literal("stat"), ...location }).strict(),
59
+ list: z.object({ op: z.literal("list"), ...location }).strict(),
60
+ readBegin: z.object({ op: z.literal("readBegin"), ...location }).strict(),
61
+ readChunk: z.object({
62
+ op: z.literal("readChunk"),
63
+ ...transfer,
64
+ offset: integer.max(MOBILE_STORAGE_LIMITS.fileBytes)
65
+ }).strict(),
66
+ writeBegin: z.object({
67
+ op: z.literal("writeBegin"),
68
+ ...location,
69
+ byteLength: integer.max(MOBILE_STORAGE_LIMITS.fileBytes),
70
+ options: writeOptions
71
+ }).strict(),
72
+ writeChunk: z.object({
73
+ op: z.literal("writeChunk"),
74
+ ...transfer,
75
+ offset: integer.max(MOBILE_STORAGE_LIMITS.fileBytes),
76
+ data: base64.max(Math.ceil(MOBILE_STORAGE_LIMITS.chunkBytes / 3) * 4)
77
+ }).strict(),
78
+ writeFinish: z.object({ op: z.literal("writeFinish"), ...transfer }).strict(),
79
+ closeTransfer: z.object({ op: z.literal("closeTransfer"), ...transfer }).strict(),
80
+ mkdir: z.object({ op: z.literal("mkdir"), ...location, options: mkdirOptions }).strict(),
81
+ remove: z.object({ op: z.literal("remove"), ...location, options: removeOptions }).strict(),
82
+ move: z.object({
83
+ op: z.literal("move"),
84
+ ...instance,
85
+ oldPath: path,
86
+ newPath: path,
87
+ options: moveOptions
88
+ }).strict(),
89
+ snapshot: z.object({ op: z.literal("snapshot"), ...instance }).strict(),
90
+ dispose: z.object({ op: z.literal("dispose"), ...instance }).strict()
91
+ };
92
+ var envelope = z.union([
93
+ z.object({ ok: z.literal(true), value: z.unknown() }).strict(),
94
+ z.object({ ok: z.literal(false), error: z.unknown() }).strict()
95
+ ]);
96
+ function parseMobileResult(input, parse) {
97
+ const result = envelope.parse(input);
98
+ if (!result.ok) {
99
+ if (!isSerializedFsError(result.error) || Object.keys(result.error).length !== 7)
100
+ throw new TypeError("Invalid native filesystem error.");
101
+ throw deserializeFsError(result.error);
102
+ }
103
+ return parse(result.value);
104
+ }
105
+ function encodeMobileBytes(data) {
106
+ const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
107
+ if (bytes.length > MOBILE_STORAGE_LIMITS.chunkBytes)
108
+ throw new RangeError("Mobile chunk exceeds its budget.");
109
+ let binary = "";
110
+ for (let offset = 0; offset < bytes.length; offset += 8192)
111
+ binary += String.fromCharCode(...bytes.subarray(offset, offset + 8192));
112
+ return btoa(binary);
113
+ }
114
+ function decodeBytes(input) {
115
+ const value = base64.parse(input);
116
+ const binary = atob(value);
117
+ if (value.length % 4 !== 0 || btoa(binary) !== value)
118
+ throw new TypeError("Invalid native Base64 payload.");
119
+ return Uint8Array.from(binary, (character) => character.charCodeAt(0)).buffer;
120
+ }
121
+ var readTransfer = z.object({ transferId: id, entry: file }).strict().nullable();
122
+ var snapshot = z.object({
123
+ version: version.transform(parseFileSystemVersion),
124
+ entries: z.array(z.union([directory, file.extend({ data: base64 }).strict()])).max(MOBILE_STORAGE_LIMITS.entries)
125
+ }).strict();
126
+ function createMobileFileSystemBridge(send, capabilities) {
127
+ async function call(request, parse) {
128
+ const validated = mobileRequests[request.op].parse(request);
129
+ try {
130
+ return { ok: true, value: parseMobileResult(await send(validated), parse) };
131
+ } catch (error) {
132
+ if (error instanceof FsError) return { ok: false, error: error.toJSON() };
133
+ throw error;
134
+ }
135
+ }
136
+ const nullResult = (value) => z.null().parse(value);
137
+ const unwrap = (result) => {
138
+ if (!result.ok) throw deserializeFsError(result.error);
139
+ return result.value;
140
+ };
141
+ const bridge = {
142
+ capabilitiesFor: () => capabilities,
143
+ transferLimits: MOBILE_STORAGE_LIMITS,
144
+ open: (request) => call({ op: "open", ...request }, parseFileSystemCapabilities),
145
+ stat: (instanceId, path2) => call({ op: "stat", instanceId, path: path2 }, (value) => entry.nullable().parse(value)),
146
+ readDirectory: (instanceId, path2) => call(
147
+ { op: "list", instanceId, path: path2 },
148
+ (value) => z.array(entry).max(MOBILE_STORAGE_LIMITS.entries).parse(value)
149
+ ),
150
+ beginRead: (instanceId, path2) => call({ op: "readBegin", instanceId, path: path2 }, (value) => readTransfer.parse(value)),
151
+ readChunk: (instanceId, transferId, offset) => call({ op: "readChunk", instanceId, transferId, offset }, (value) => {
152
+ const bytes = decodeBytes(value);
153
+ if (bytes.byteLength > MOBILE_STORAGE_LIMITS.chunkBytes)
154
+ throw new TypeError("Oversized native read chunk.");
155
+ return bytes;
156
+ }),
157
+ beginWrite: (instanceId, path2, byteLength, options = {}) => call({ op: "writeBegin", instanceId, path: path2, byteLength, options }, (value) => id.parse(value)),
158
+ writeChunk: (instanceId, transferId, offset, data) => call(
159
+ { op: "writeChunk", instanceId, transferId, offset, data: encodeMobileBytes(data) },
160
+ nullResult
161
+ ),
162
+ finishWrite: (instanceId, transferId) => call({ op: "writeFinish", instanceId, transferId }, (value) => file.parse(value)),
163
+ closeTransfer: (instanceId, transferId) => call({ op: "closeTransfer", instanceId, transferId }, nullResult),
164
+ async readFile(instanceId, path2) {
165
+ let transferId;
166
+ try {
167
+ const transfer2 = unwrap(await bridge.beginRead(instanceId, path2));
168
+ if (!transfer2) return { ok: true, value: null };
169
+ transferId = transfer2.transferId;
170
+ const bytes = new Uint8Array(transfer2.entry.size);
171
+ for (let offset = 0; offset < bytes.length; ) {
172
+ const chunk = new Uint8Array(
173
+ unwrap(await bridge.readChunk(instanceId, transferId, offset))
174
+ );
175
+ if (!chunk.length || offset + chunk.length > bytes.length)
176
+ throw new TypeError("Invalid native read length.");
177
+ bytes.set(chunk, offset);
178
+ offset += chunk.length;
179
+ }
180
+ return { ok: true, value: { entry: transfer2.entry, data: bytes.buffer } };
181
+ } catch (error) {
182
+ if (error instanceof FsError) return { ok: false, error: error.toJSON() };
183
+ throw error;
184
+ } finally {
185
+ if (transferId) unwrap(await bridge.closeTransfer(instanceId, transferId));
186
+ }
187
+ },
188
+ async writeFile(instanceId, path2, data, options = {}) {
189
+ let transferId;
190
+ try {
191
+ const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
192
+ transferId = unwrap(await bridge.beginWrite(instanceId, path2, bytes.length, options));
193
+ for (let offset = 0; offset < bytes.length; offset += MOBILE_STORAGE_LIMITS.chunkBytes)
194
+ unwrap(
195
+ await bridge.writeChunk(
196
+ instanceId,
197
+ transferId,
198
+ offset,
199
+ bytes.subarray(offset, offset + MOBILE_STORAGE_LIMITS.chunkBytes)
200
+ )
201
+ );
202
+ return await bridge.finishWrite(instanceId, transferId);
203
+ } catch (error) {
204
+ if (error instanceof FsError) return { ok: false, error: error.toJSON() };
205
+ throw error;
206
+ } finally {
207
+ if (transferId) unwrap(await bridge.closeTransfer(instanceId, transferId));
208
+ }
209
+ },
210
+ createDirectory: (instanceId, path2, options = {}) => call({ op: "mkdir", instanceId, path: path2, options }, (value) => directory.parse(value)),
211
+ remove: (instanceId, path2, options = {}) => call(
212
+ { op: "remove", instanceId, path: path2, options },
213
+ (value) => z.object({ removed: z.boolean(), version: version.transform(parseFileSystemVersion) }).strict().parse(value)
214
+ ),
215
+ move: (instanceId, oldPath, newPath, options = {}) => call({ op: "move", instanceId, oldPath, newPath, options }, (value) => entry.parse(value)),
216
+ snapshot: (instanceId) => call({ op: "snapshot", instanceId }, (value) => {
217
+ const parsed = snapshot.parse(value);
218
+ let total = 0;
219
+ return {
220
+ version: parsed.version,
221
+ entries: parsed.entries.map((item) => {
222
+ if (item.kind === "directory") return item;
223
+ const data = decodeBytes(item.data);
224
+ total += data.byteLength;
225
+ if (total > MOBILE_STORAGE_LIMITS.totalBytes || data.byteLength !== item.size)
226
+ throw new TypeError("Invalid native snapshot size.");
227
+ return { ...item, data };
228
+ })
229
+ };
230
+ }),
231
+ dispose: (instanceId) => call({ op: "dispose", instanceId }, nullResult),
232
+ watchSubscribe: async () => ({
233
+ ok: false,
234
+ error: new FsError("not-supported", "Native workspace watching is unavailable.", {
235
+ operation: "watch"
236
+ }).toJSON()
237
+ }),
238
+ watchUnsubscribe: async () => ({ ok: true, value: null }),
239
+ onWatchMessage: () => () => {
240
+ }
241
+ };
242
+ return bridge;
243
+ }
244
+ var workspace = z.object({ id, name: z.string().min(1).max(1024), rootPath: z.string().min(1).max(4096) }).strict();
245
+ function parseMobileBootstrap(value) {
246
+ return z.object({
247
+ env: z.object({
248
+ surface: z.literal("capacitor"),
249
+ surfaceLabel: z.enum(["iOS", "Android"]),
250
+ platform: z.enum(["ios", "android"]),
251
+ appVersion: z.string().min(1).max(256),
252
+ isDev: z.boolean()
253
+ }).strict(),
254
+ workspaces: z.array(workspace).min(1).max(64),
255
+ folderPicker: z.boolean(),
256
+ capabilities: z.unknown().transform(parseFileSystemCapabilities)
257
+ }).strict().parse(value);
258
+ }
259
+ var exportFilename = z.string().min(1).max(255).refine(
260
+ (name) => name !== "." && name !== ".." && !/[\\/:]/.test(name) && [...name].every(
261
+ (character) => character.charCodeAt(0) >= 32 && character.charCodeAt(0) !== 127
262
+ )
263
+ );
264
+ var mobileExportRequests = {
265
+ begin: z.object({
266
+ op: z.literal("begin"),
267
+ filename: exportFilename,
268
+ byteLength: integer.max(MOBILE_STORAGE_LIMITS.fileBytes)
269
+ }).strict(),
270
+ append: z.object({
271
+ op: z.literal("append"),
272
+ transferId: id,
273
+ offset: integer.max(MOBILE_STORAGE_LIMITS.fileBytes),
274
+ data: base64.max(Math.ceil(MOBILE_STORAGE_LIMITS.chunkBytes / 3) * 4)
275
+ }).strict(),
276
+ finish: z.object({ op: z.literal("finish"), transferId: id, action: z.enum(["save", "share"]) }).strict(),
277
+ cancel: z.object({ op: z.literal("cancel"), transferId: id }).strict()
278
+ };
279
+ function parseMobileExportRequest(input) {
280
+ return mobileExportRequests[input.op].parse(input);
281
+ }
282
+ function parseMobileExportToken(input) {
283
+ return z.object({ transferId: id }).strict().parse(input).transferId;
284
+ }
285
+ function parseMobileExportOutcome(input) {
286
+ return z.object({ outcome: z.enum(["saved", "shared", "presented", "cancelled"]) }).strict().parse(input).outcome;
287
+ }
288
+ function parseMobileOpenRequests(input) {
289
+ return z.object({
290
+ requests: z.array(
291
+ z.object({
292
+ kind: z.literal("workspace-file"),
293
+ workspaceId: id,
294
+ path: z.string().min(1).max(4097).refine(
295
+ (value) => value.startsWith("/") && parseWorkspacePath(value) === value.slice(1)
296
+ )
297
+ }).strict()
298
+ ).max(8)
299
+ }).strict().parse(input).requests;
300
+ }
301
+ function parseMobilePickedFolder(input) {
302
+ return z.object({ workspace: workspace.nullable() }).strict().parse(input).workspace;
303
+ }
304
+ export {
305
+ MOBILE_STORAGE_LIMITS,
306
+ createMobileFileSystemBridge,
307
+ encodeMobileBytes,
308
+ parseMobileBootstrap,
309
+ parseMobileExportOutcome,
310
+ parseMobileExportRequest,
311
+ parseMobileExportToken,
312
+ parseMobileOpenRequests,
313
+ parseMobilePickedFolder,
314
+ parseMobileResult
315
+ };