@multitapio/multitap 0.0.14 → 0.0.16

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 (68) hide show
  1. package/dist/channel.d.ts.map +1 -1
  2. package/dist/codegen/config.d.ts +1 -0
  3. package/dist/codegen/config.d.ts.map +1 -1
  4. package/dist/codegen/rust.d.ts.map +1 -1
  5. package/dist/executor.d.ts +4 -2
  6. package/dist/executor.d.ts.map +1 -1
  7. package/dist/init-data.d.ts +23 -2
  8. package/dist/init-data.d.ts.map +1 -1
  9. package/dist/input-codec.d.ts +4 -3
  10. package/dist/input-codec.d.ts.map +1 -1
  11. package/dist/lib.d.ts +2 -0
  12. package/dist/lib.d.ts.map +1 -1
  13. package/dist/lib.js +442 -66
  14. package/dist/loader.d.ts +39 -0
  15. package/dist/loader.d.ts.map +1 -0
  16. package/dist/rollback.d.ts +0 -5
  17. package/dist/rollback.d.ts.map +1 -1
  18. package/dist/schema.d.ts +10 -0
  19. package/dist/schema.d.ts.map +1 -1
  20. package/dist/session.d.ts +3 -4
  21. package/dist/session.d.ts.map +1 -1
  22. package/dist/test-session.d.ts +17 -2
  23. package/dist/test-session.d.ts.map +1 -1
  24. package/dist/types/channel.d.ts.map +1 -1
  25. package/dist/types/codegen/config.d.ts +1 -0
  26. package/dist/types/codegen/config.d.ts.map +1 -1
  27. package/dist/types/codegen/rust.d.ts.map +1 -1
  28. package/dist/types/executor.d.ts +4 -2
  29. package/dist/types/executor.d.ts.map +1 -1
  30. package/dist/types/init-data.d.ts +23 -2
  31. package/dist/types/init-data.d.ts.map +1 -1
  32. package/dist/types/input-codec.d.ts +4 -3
  33. package/dist/types/input-codec.d.ts.map +1 -1
  34. package/dist/types/lib.d.ts +2 -0
  35. package/dist/types/lib.d.ts.map +1 -1
  36. package/dist/types/loader.d.ts +39 -0
  37. package/dist/types/loader.d.ts.map +1 -0
  38. package/dist/types/rollback.d.ts +0 -5
  39. package/dist/types/rollback.d.ts.map +1 -1
  40. package/dist/types/schema.d.ts +10 -0
  41. package/dist/types/schema.d.ts.map +1 -1
  42. package/dist/types/session.d.ts +3 -4
  43. package/dist/types/session.d.ts.map +1 -1
  44. package/dist/types/test-session.d.ts +17 -2
  45. package/dist/types/test-session.d.ts.map +1 -1
  46. package/dist/types/vite/codegen-runner.d.ts +11 -0
  47. package/dist/types/vite/codegen-runner.d.ts.map +1 -1
  48. package/dist/types/vite/plugin.d.ts +3 -14
  49. package/dist/types/vite/plugin.d.ts.map +1 -1
  50. package/dist/types/vite/types.d.ts +73 -0
  51. package/dist/types/vite/types.d.ts.map +1 -1
  52. package/dist/vite/codegen-runner.d.ts +11 -0
  53. package/dist/vite/codegen-runner.d.ts.map +1 -1
  54. package/dist/vite/index.js +2417 -124
  55. package/dist/vite/plugin.d.ts +3 -14
  56. package/dist/vite/plugin.d.ts.map +1 -1
  57. package/dist/vite/types.d.ts +73 -0
  58. package/dist/vite/types.d.ts.map +1 -1
  59. package/package.json +3 -2
  60. package/dist/diagnostics/index.d.ts +0 -12
  61. package/dist/diagnostics/index.d.ts.map +0 -1
  62. package/dist/diagnostics.js +0 -7192
  63. package/dist/types/diagnostics/index.d.ts +0 -12
  64. package/dist/types/diagnostics/index.d.ts.map +0 -1
  65. package/dist/types/vite/module-builder.d.ts +0 -29
  66. package/dist/types/vite/module-builder.d.ts.map +0 -1
  67. package/dist/vite/module-builder.d.ts +0 -29
  68. package/dist/vite/module-builder.d.ts.map +0 -1
@@ -1,21 +1,1714 @@
1
1
  // src/vite/plugin.ts
2
- import { resolve as resolve2, dirname as dirname3 } from "node:path";
2
+ import { createHash } from "node:crypto";
3
+ import { readFile as readFile2 } from "node:fs/promises";
4
+ import { resolve as resolve5, dirname as dirname6, join as join6 } from "node:path";
5
+
6
+ // ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
7
+ import { stat as statcb } from "fs";
8
+ import { stat as stat3, readdir as readdir2 } from "fs/promises";
9
+ import { EventEmitter } from "events";
10
+ import * as sysPath2 from "path";
11
+
12
+ // ../../node_modules/.pnpm/readdirp@4.1.2/node_modules/readdirp/esm/index.js
13
+ import { stat, lstat, readdir, realpath } from "node:fs/promises";
14
+ import { Readable } from "node:stream";
15
+ import { resolve as presolve, relative as prelative, join as pjoin, sep as psep } from "node:path";
16
+ var EntryTypes = {
17
+ FILE_TYPE: "files",
18
+ DIR_TYPE: "directories",
19
+ FILE_DIR_TYPE: "files_directories",
20
+ EVERYTHING_TYPE: "all"
21
+ };
22
+ var defaultOptions = {
23
+ root: ".",
24
+ fileFilter: (_entryInfo) => true,
25
+ directoryFilter: (_entryInfo) => true,
26
+ type: EntryTypes.FILE_TYPE,
27
+ lstat: false,
28
+ depth: 2147483648,
29
+ alwaysStat: false,
30
+ highWaterMark: 4096
31
+ };
32
+ Object.freeze(defaultOptions);
33
+ var RECURSIVE_ERROR_CODE = "READDIRP_RECURSIVE_ERROR";
34
+ var NORMAL_FLOW_ERRORS = /* @__PURE__ */ new Set(["ENOENT", "EPERM", "EACCES", "ELOOP", RECURSIVE_ERROR_CODE]);
35
+ var ALL_TYPES = [
36
+ EntryTypes.DIR_TYPE,
37
+ EntryTypes.EVERYTHING_TYPE,
38
+ EntryTypes.FILE_DIR_TYPE,
39
+ EntryTypes.FILE_TYPE
40
+ ];
41
+ var DIR_TYPES = /* @__PURE__ */ new Set([
42
+ EntryTypes.DIR_TYPE,
43
+ EntryTypes.EVERYTHING_TYPE,
44
+ EntryTypes.FILE_DIR_TYPE
45
+ ]);
46
+ var FILE_TYPES = /* @__PURE__ */ new Set([
47
+ EntryTypes.EVERYTHING_TYPE,
48
+ EntryTypes.FILE_DIR_TYPE,
49
+ EntryTypes.FILE_TYPE
50
+ ]);
51
+ var isNormalFlowError = (error) => NORMAL_FLOW_ERRORS.has(error.code);
52
+ var wantBigintFsStats = process.platform === "win32";
53
+ var emptyFn = (_entryInfo) => true;
54
+ var normalizeFilter = (filter) => {
55
+ if (filter === void 0)
56
+ return emptyFn;
57
+ if (typeof filter === "function")
58
+ return filter;
59
+ if (typeof filter === "string") {
60
+ const fl = filter.trim();
61
+ return (entry) => entry.basename === fl;
62
+ }
63
+ if (Array.isArray(filter)) {
64
+ const trItems = filter.map((item) => item.trim());
65
+ return (entry) => trItems.some((f) => entry.basename === f);
66
+ }
67
+ return emptyFn;
68
+ };
69
+ var ReaddirpStream = class extends Readable {
70
+ constructor(options = {}) {
71
+ super({
72
+ objectMode: true,
73
+ autoDestroy: true,
74
+ highWaterMark: options.highWaterMark
75
+ });
76
+ const opts = { ...defaultOptions, ...options };
77
+ const { root, type } = opts;
78
+ this._fileFilter = normalizeFilter(opts.fileFilter);
79
+ this._directoryFilter = normalizeFilter(opts.directoryFilter);
80
+ const statMethod = opts.lstat ? lstat : stat;
81
+ if (wantBigintFsStats) {
82
+ this._stat = (path) => statMethod(path, { bigint: true });
83
+ } else {
84
+ this._stat = statMethod;
85
+ }
86
+ this._maxDepth = opts.depth ?? defaultOptions.depth;
87
+ this._wantsDir = type ? DIR_TYPES.has(type) : false;
88
+ this._wantsFile = type ? FILE_TYPES.has(type) : false;
89
+ this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
90
+ this._root = presolve(root);
91
+ this._isDirent = !opts.alwaysStat;
92
+ this._statsProp = this._isDirent ? "dirent" : "stats";
93
+ this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
94
+ this.parents = [this._exploreDir(root, 1)];
95
+ this.reading = false;
96
+ this.parent = void 0;
97
+ }
98
+ async _read(batch) {
99
+ if (this.reading)
100
+ return;
101
+ this.reading = true;
102
+ try {
103
+ while (!this.destroyed && batch > 0) {
104
+ const par = this.parent;
105
+ const fil = par && par.files;
106
+ if (fil && fil.length > 0) {
107
+ const { path, depth } = par;
108
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path));
109
+ const awaited = await Promise.all(slice);
110
+ for (const entry of awaited) {
111
+ if (!entry)
112
+ continue;
113
+ if (this.destroyed)
114
+ return;
115
+ const entryType = await this._getEntryType(entry);
116
+ if (entryType === "directory" && this._directoryFilter(entry)) {
117
+ if (depth <= this._maxDepth) {
118
+ this.parents.push(this._exploreDir(entry.fullPath, depth + 1));
119
+ }
120
+ if (this._wantsDir) {
121
+ this.push(entry);
122
+ batch--;
123
+ }
124
+ } else if ((entryType === "file" || this._includeAsFile(entry)) && this._fileFilter(entry)) {
125
+ if (this._wantsFile) {
126
+ this.push(entry);
127
+ batch--;
128
+ }
129
+ }
130
+ }
131
+ } else {
132
+ const parent = this.parents.pop();
133
+ if (!parent) {
134
+ this.push(null);
135
+ break;
136
+ }
137
+ this.parent = await parent;
138
+ if (this.destroyed)
139
+ return;
140
+ }
141
+ }
142
+ } catch (error) {
143
+ this.destroy(error);
144
+ } finally {
145
+ this.reading = false;
146
+ }
147
+ }
148
+ async _exploreDir(path, depth) {
149
+ let files;
150
+ try {
151
+ files = await readdir(path, this._rdOptions);
152
+ } catch (error) {
153
+ this._onError(error);
154
+ }
155
+ return { files, depth, path };
156
+ }
157
+ async _formatEntry(dirent, path) {
158
+ let entry;
159
+ const basename4 = this._isDirent ? dirent.name : dirent;
160
+ try {
161
+ const fullPath = presolve(pjoin(path, basename4));
162
+ entry = { path: prelative(this._root, fullPath), fullPath, basename: basename4 };
163
+ entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
164
+ } catch (err) {
165
+ this._onError(err);
166
+ return;
167
+ }
168
+ return entry;
169
+ }
170
+ _onError(err) {
171
+ if (isNormalFlowError(err) && !this.destroyed) {
172
+ this.emit("warn", err);
173
+ } else {
174
+ this.destroy(err);
175
+ }
176
+ }
177
+ async _getEntryType(entry) {
178
+ if (!entry && this._statsProp in entry) {
179
+ return "";
180
+ }
181
+ const stats = entry[this._statsProp];
182
+ if (stats.isFile())
183
+ return "file";
184
+ if (stats.isDirectory())
185
+ return "directory";
186
+ if (stats && stats.isSymbolicLink()) {
187
+ const full = entry.fullPath;
188
+ try {
189
+ const entryRealPath = await realpath(full);
190
+ const entryRealPathStats = await lstat(entryRealPath);
191
+ if (entryRealPathStats.isFile()) {
192
+ return "file";
193
+ }
194
+ if (entryRealPathStats.isDirectory()) {
195
+ const len = entryRealPath.length;
196
+ if (full.startsWith(entryRealPath) && full.substr(len, 1) === psep) {
197
+ const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
198
+ recursiveError.code = RECURSIVE_ERROR_CODE;
199
+ return this._onError(recursiveError);
200
+ }
201
+ return "directory";
202
+ }
203
+ } catch (error) {
204
+ this._onError(error);
205
+ return "";
206
+ }
207
+ }
208
+ }
209
+ _includeAsFile(entry) {
210
+ const stats = entry && entry[this._statsProp];
211
+ return stats && this._wantsEverything && !stats.isDirectory();
212
+ }
213
+ };
214
+ function readdirp(root, options = {}) {
215
+ let type = options.entryType || options.type;
216
+ if (type === "both")
217
+ type = EntryTypes.FILE_DIR_TYPE;
218
+ if (type)
219
+ options.type = type;
220
+ if (!root) {
221
+ throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");
222
+ } else if (typeof root !== "string") {
223
+ throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");
224
+ } else if (type && !ALL_TYPES.includes(type)) {
225
+ throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(", ")}`);
226
+ }
227
+ options.root = root;
228
+ return new ReaddirpStream(options);
229
+ }
230
+
231
+ // ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/handler.js
232
+ import { watchFile, unwatchFile, watch as fs_watch } from "fs";
233
+ import { open, stat as stat2, lstat as lstat2, realpath as fsrealpath } from "fs/promises";
234
+ import * as sysPath from "path";
235
+ import { type as osType } from "os";
236
+ var STR_DATA = "data";
237
+ var STR_END = "end";
238
+ var STR_CLOSE = "close";
239
+ var EMPTY_FN = () => {
240
+ };
241
+ var pl = process.platform;
242
+ var isWindows = pl === "win32";
243
+ var isMacos = pl === "darwin";
244
+ var isLinux = pl === "linux";
245
+ var isFreeBSD = pl === "freebsd";
246
+ var isIBMi = osType() === "OS400";
247
+ var EVENTS = {
248
+ ALL: "all",
249
+ READY: "ready",
250
+ ADD: "add",
251
+ CHANGE: "change",
252
+ ADD_DIR: "addDir",
253
+ UNLINK: "unlink",
254
+ UNLINK_DIR: "unlinkDir",
255
+ RAW: "raw",
256
+ ERROR: "error"
257
+ };
258
+ var EV = EVENTS;
259
+ var THROTTLE_MODE_WATCH = "watch";
260
+ var statMethods = { lstat: lstat2, stat: stat2 };
261
+ var KEY_LISTENERS = "listeners";
262
+ var KEY_ERR = "errHandlers";
263
+ var KEY_RAW = "rawEmitters";
264
+ var HANDLER_KEYS = [KEY_LISTENERS, KEY_ERR, KEY_RAW];
265
+ var binaryExtensions = /* @__PURE__ */ new Set([
266
+ "3dm",
267
+ "3ds",
268
+ "3g2",
269
+ "3gp",
270
+ "7z",
271
+ "a",
272
+ "aac",
273
+ "adp",
274
+ "afdesign",
275
+ "afphoto",
276
+ "afpub",
277
+ "ai",
278
+ "aif",
279
+ "aiff",
280
+ "alz",
281
+ "ape",
282
+ "apk",
283
+ "appimage",
284
+ "ar",
285
+ "arj",
286
+ "asf",
287
+ "au",
288
+ "avi",
289
+ "bak",
290
+ "baml",
291
+ "bh",
292
+ "bin",
293
+ "bk",
294
+ "bmp",
295
+ "btif",
296
+ "bz2",
297
+ "bzip2",
298
+ "cab",
299
+ "caf",
300
+ "cgm",
301
+ "class",
302
+ "cmx",
303
+ "cpio",
304
+ "cr2",
305
+ "cur",
306
+ "dat",
307
+ "dcm",
308
+ "deb",
309
+ "dex",
310
+ "djvu",
311
+ "dll",
312
+ "dmg",
313
+ "dng",
314
+ "doc",
315
+ "docm",
316
+ "docx",
317
+ "dot",
318
+ "dotm",
319
+ "dra",
320
+ "DS_Store",
321
+ "dsk",
322
+ "dts",
323
+ "dtshd",
324
+ "dvb",
325
+ "dwg",
326
+ "dxf",
327
+ "ecelp4800",
328
+ "ecelp7470",
329
+ "ecelp9600",
330
+ "egg",
331
+ "eol",
332
+ "eot",
333
+ "epub",
334
+ "exe",
335
+ "f4v",
336
+ "fbs",
337
+ "fh",
338
+ "fla",
339
+ "flac",
340
+ "flatpak",
341
+ "fli",
342
+ "flv",
343
+ "fpx",
344
+ "fst",
345
+ "fvt",
346
+ "g3",
347
+ "gh",
348
+ "gif",
349
+ "graffle",
350
+ "gz",
351
+ "gzip",
352
+ "h261",
353
+ "h263",
354
+ "h264",
355
+ "icns",
356
+ "ico",
357
+ "ief",
358
+ "img",
359
+ "ipa",
360
+ "iso",
361
+ "jar",
362
+ "jpeg",
363
+ "jpg",
364
+ "jpgv",
365
+ "jpm",
366
+ "jxr",
367
+ "key",
368
+ "ktx",
369
+ "lha",
370
+ "lib",
371
+ "lvp",
372
+ "lz",
373
+ "lzh",
374
+ "lzma",
375
+ "lzo",
376
+ "m3u",
377
+ "m4a",
378
+ "m4v",
379
+ "mar",
380
+ "mdi",
381
+ "mht",
382
+ "mid",
383
+ "midi",
384
+ "mj2",
385
+ "mka",
386
+ "mkv",
387
+ "mmr",
388
+ "mng",
389
+ "mobi",
390
+ "mov",
391
+ "movie",
392
+ "mp3",
393
+ "mp4",
394
+ "mp4a",
395
+ "mpeg",
396
+ "mpg",
397
+ "mpga",
398
+ "mxu",
399
+ "nef",
400
+ "npx",
401
+ "numbers",
402
+ "nupkg",
403
+ "o",
404
+ "odp",
405
+ "ods",
406
+ "odt",
407
+ "oga",
408
+ "ogg",
409
+ "ogv",
410
+ "otf",
411
+ "ott",
412
+ "pages",
413
+ "pbm",
414
+ "pcx",
415
+ "pdb",
416
+ "pdf",
417
+ "pea",
418
+ "pgm",
419
+ "pic",
420
+ "png",
421
+ "pnm",
422
+ "pot",
423
+ "potm",
424
+ "potx",
425
+ "ppa",
426
+ "ppam",
427
+ "ppm",
428
+ "pps",
429
+ "ppsm",
430
+ "ppsx",
431
+ "ppt",
432
+ "pptm",
433
+ "pptx",
434
+ "psd",
435
+ "pya",
436
+ "pyc",
437
+ "pyo",
438
+ "pyv",
439
+ "qt",
440
+ "rar",
441
+ "ras",
442
+ "raw",
443
+ "resources",
444
+ "rgb",
445
+ "rip",
446
+ "rlc",
447
+ "rmf",
448
+ "rmvb",
449
+ "rpm",
450
+ "rtf",
451
+ "rz",
452
+ "s3m",
453
+ "s7z",
454
+ "scpt",
455
+ "sgi",
456
+ "shar",
457
+ "snap",
458
+ "sil",
459
+ "sketch",
460
+ "slk",
461
+ "smv",
462
+ "snk",
463
+ "so",
464
+ "stl",
465
+ "suo",
466
+ "sub",
467
+ "swf",
468
+ "tar",
469
+ "tbz",
470
+ "tbz2",
471
+ "tga",
472
+ "tgz",
473
+ "thmx",
474
+ "tif",
475
+ "tiff",
476
+ "tlz",
477
+ "ttc",
478
+ "ttf",
479
+ "txz",
480
+ "udf",
481
+ "uvh",
482
+ "uvi",
483
+ "uvm",
484
+ "uvp",
485
+ "uvs",
486
+ "uvu",
487
+ "viv",
488
+ "vob",
489
+ "war",
490
+ "wav",
491
+ "wax",
492
+ "wbmp",
493
+ "wdp",
494
+ "weba",
495
+ "webm",
496
+ "webp",
497
+ "whl",
498
+ "wim",
499
+ "wm",
500
+ "wma",
501
+ "wmv",
502
+ "wmx",
503
+ "woff",
504
+ "woff2",
505
+ "wrm",
506
+ "wvx",
507
+ "xbm",
508
+ "xif",
509
+ "xla",
510
+ "xlam",
511
+ "xls",
512
+ "xlsb",
513
+ "xlsm",
514
+ "xlsx",
515
+ "xlt",
516
+ "xltm",
517
+ "xltx",
518
+ "xm",
519
+ "xmind",
520
+ "xpi",
521
+ "xpm",
522
+ "xwd",
523
+ "xz",
524
+ "z",
525
+ "zip",
526
+ "zipx"
527
+ ]);
528
+ var isBinaryPath = (filePath) => binaryExtensions.has(sysPath.extname(filePath).slice(1).toLowerCase());
529
+ var foreach = (val, fn) => {
530
+ if (val instanceof Set) {
531
+ val.forEach(fn);
532
+ } else {
533
+ fn(val);
534
+ }
535
+ };
536
+ var addAndConvert = (main, prop, item) => {
537
+ let container = main[prop];
538
+ if (!(container instanceof Set)) {
539
+ main[prop] = container = /* @__PURE__ */ new Set([container]);
540
+ }
541
+ container.add(item);
542
+ };
543
+ var clearItem = (cont) => (key) => {
544
+ const set = cont[key];
545
+ if (set instanceof Set) {
546
+ set.clear();
547
+ } else {
548
+ delete cont[key];
549
+ }
550
+ };
551
+ var delFromSet = (main, prop, item) => {
552
+ const container = main[prop];
553
+ if (container instanceof Set) {
554
+ container.delete(item);
555
+ } else if (container === item) {
556
+ delete main[prop];
557
+ }
558
+ };
559
+ var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
560
+ var FsWatchInstances = /* @__PURE__ */ new Map();
561
+ function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
562
+ const handleEvent = (rawEvent, evPath) => {
563
+ listener(path);
564
+ emitRaw(rawEvent, evPath, { watchedPath: path });
565
+ if (evPath && path !== evPath) {
566
+ fsWatchBroadcast(sysPath.resolve(path, evPath), KEY_LISTENERS, sysPath.join(path, evPath));
567
+ }
568
+ };
569
+ try {
570
+ return fs_watch(path, {
571
+ persistent: options.persistent
572
+ }, handleEvent);
573
+ } catch (error) {
574
+ errHandler(error);
575
+ return void 0;
576
+ }
577
+ }
578
+ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
579
+ const cont = FsWatchInstances.get(fullPath);
580
+ if (!cont)
581
+ return;
582
+ foreach(cont[listenerType], (listener) => {
583
+ listener(val1, val2, val3);
584
+ });
585
+ };
586
+ var setFsWatchListener = (path, fullPath, options, handlers) => {
587
+ const { listener, errHandler, rawEmitter } = handlers;
588
+ let cont = FsWatchInstances.get(fullPath);
589
+ let watcher;
590
+ if (!options.persistent) {
591
+ watcher = createFsWatchInstance(path, options, listener, errHandler, rawEmitter);
592
+ if (!watcher)
593
+ return;
594
+ return watcher.close.bind(watcher);
595
+ }
596
+ if (cont) {
597
+ addAndConvert(cont, KEY_LISTENERS, listener);
598
+ addAndConvert(cont, KEY_ERR, errHandler);
599
+ addAndConvert(cont, KEY_RAW, rawEmitter);
600
+ } else {
601
+ watcher = createFsWatchInstance(
602
+ path,
603
+ options,
604
+ fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
605
+ errHandler,
606
+ // no need to use broadcast here
607
+ fsWatchBroadcast.bind(null, fullPath, KEY_RAW)
608
+ );
609
+ if (!watcher)
610
+ return;
611
+ watcher.on(EV.ERROR, async (error) => {
612
+ const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR);
613
+ if (cont)
614
+ cont.watcherUnusable = true;
615
+ if (isWindows && error.code === "EPERM") {
616
+ try {
617
+ const fd = await open(path, "r");
618
+ await fd.close();
619
+ broadcastErr(error);
620
+ } catch (err) {
621
+ }
622
+ } else {
623
+ broadcastErr(error);
624
+ }
625
+ });
626
+ cont = {
627
+ listeners: listener,
628
+ errHandlers: errHandler,
629
+ rawEmitters: rawEmitter,
630
+ watcher
631
+ };
632
+ FsWatchInstances.set(fullPath, cont);
633
+ }
634
+ return () => {
635
+ delFromSet(cont, KEY_LISTENERS, listener);
636
+ delFromSet(cont, KEY_ERR, errHandler);
637
+ delFromSet(cont, KEY_RAW, rawEmitter);
638
+ if (isEmptySet(cont.listeners)) {
639
+ cont.watcher.close();
640
+ FsWatchInstances.delete(fullPath);
641
+ HANDLER_KEYS.forEach(clearItem(cont));
642
+ cont.watcher = void 0;
643
+ Object.freeze(cont);
644
+ }
645
+ };
646
+ };
647
+ var FsWatchFileInstances = /* @__PURE__ */ new Map();
648
+ var setFsWatchFileListener = (path, fullPath, options, handlers) => {
649
+ const { listener, rawEmitter } = handlers;
650
+ let cont = FsWatchFileInstances.get(fullPath);
651
+ const copts = cont && cont.options;
652
+ if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {
653
+ unwatchFile(fullPath);
654
+ cont = void 0;
655
+ }
656
+ if (cont) {
657
+ addAndConvert(cont, KEY_LISTENERS, listener);
658
+ addAndConvert(cont, KEY_RAW, rawEmitter);
659
+ } else {
660
+ cont = {
661
+ listeners: listener,
662
+ rawEmitters: rawEmitter,
663
+ options,
664
+ watcher: watchFile(fullPath, options, (curr, prev) => {
665
+ foreach(cont.rawEmitters, (rawEmitter2) => {
666
+ rawEmitter2(EV.CHANGE, fullPath, { curr, prev });
667
+ });
668
+ const currmtime = curr.mtimeMs;
669
+ if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
670
+ foreach(cont.listeners, (listener2) => listener2(path, curr));
671
+ }
672
+ })
673
+ };
674
+ FsWatchFileInstances.set(fullPath, cont);
675
+ }
676
+ return () => {
677
+ delFromSet(cont, KEY_LISTENERS, listener);
678
+ delFromSet(cont, KEY_RAW, rawEmitter);
679
+ if (isEmptySet(cont.listeners)) {
680
+ FsWatchFileInstances.delete(fullPath);
681
+ unwatchFile(fullPath);
682
+ cont.options = cont.watcher = void 0;
683
+ Object.freeze(cont);
684
+ }
685
+ };
686
+ };
687
+ var NodeFsHandler = class {
688
+ constructor(fsW) {
689
+ this.fsw = fsW;
690
+ this._boundHandleError = (error) => fsW._handleError(error);
691
+ }
692
+ /**
693
+ * Watch file for changes with fs_watchFile or fs_watch.
694
+ * @param path to file or dir
695
+ * @param listener on fs change
696
+ * @returns closer for the watcher instance
697
+ */
698
+ _watchWithNodeFs(path, listener) {
699
+ const opts = this.fsw.options;
700
+ const directory = sysPath.dirname(path);
701
+ const basename4 = sysPath.basename(path);
702
+ const parent = this.fsw._getWatchedDir(directory);
703
+ parent.add(basename4);
704
+ const absolutePath = sysPath.resolve(path);
705
+ const options = {
706
+ persistent: opts.persistent
707
+ };
708
+ if (!listener)
709
+ listener = EMPTY_FN;
710
+ let closer;
711
+ if (opts.usePolling) {
712
+ const enableBin = opts.interval !== opts.binaryInterval;
713
+ options.interval = enableBin && isBinaryPath(basename4) ? opts.binaryInterval : opts.interval;
714
+ closer = setFsWatchFileListener(path, absolutePath, options, {
715
+ listener,
716
+ rawEmitter: this.fsw._emitRaw
717
+ });
718
+ } else {
719
+ closer = setFsWatchListener(path, absolutePath, options, {
720
+ listener,
721
+ errHandler: this._boundHandleError,
722
+ rawEmitter: this.fsw._emitRaw
723
+ });
724
+ }
725
+ return closer;
726
+ }
727
+ /**
728
+ * Watch a file and emit add event if warranted.
729
+ * @returns closer for the watcher instance
730
+ */
731
+ _handleFile(file, stats, initialAdd) {
732
+ if (this.fsw.closed) {
733
+ return;
734
+ }
735
+ const dirname7 = sysPath.dirname(file);
736
+ const basename4 = sysPath.basename(file);
737
+ const parent = this.fsw._getWatchedDir(dirname7);
738
+ let prevStats = stats;
739
+ if (parent.has(basename4))
740
+ return;
741
+ const listener = async (path, newStats) => {
742
+ if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
743
+ return;
744
+ if (!newStats || newStats.mtimeMs === 0) {
745
+ try {
746
+ const newStats2 = await stat2(file);
747
+ if (this.fsw.closed)
748
+ return;
749
+ const at = newStats2.atimeMs;
750
+ const mt = newStats2.mtimeMs;
751
+ if (!at || at <= mt || mt !== prevStats.mtimeMs) {
752
+ this.fsw._emit(EV.CHANGE, file, newStats2);
753
+ }
754
+ if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
755
+ this.fsw._closeFile(path);
756
+ prevStats = newStats2;
757
+ const closer2 = this._watchWithNodeFs(file, listener);
758
+ if (closer2)
759
+ this.fsw._addPathCloser(path, closer2);
760
+ } else {
761
+ prevStats = newStats2;
762
+ }
763
+ } catch (error) {
764
+ this.fsw._remove(dirname7, basename4);
765
+ }
766
+ } else if (parent.has(basename4)) {
767
+ const at = newStats.atimeMs;
768
+ const mt = newStats.mtimeMs;
769
+ if (!at || at <= mt || mt !== prevStats.mtimeMs) {
770
+ this.fsw._emit(EV.CHANGE, file, newStats);
771
+ }
772
+ prevStats = newStats;
773
+ }
774
+ };
775
+ const closer = this._watchWithNodeFs(file, listener);
776
+ if (!(initialAdd && this.fsw.options.ignoreInitial) && this.fsw._isntIgnored(file)) {
777
+ if (!this.fsw._throttle(EV.ADD, file, 0))
778
+ return;
779
+ this.fsw._emit(EV.ADD, file, stats);
780
+ }
781
+ return closer;
782
+ }
783
+ /**
784
+ * Handle symlinks encountered while reading a dir.
785
+ * @param entry returned by readdirp
786
+ * @param directory path of dir being read
787
+ * @param path of this item
788
+ * @param item basename of this item
789
+ * @returns true if no more processing is needed for this entry.
790
+ */
791
+ async _handleSymlink(entry, directory, path, item) {
792
+ if (this.fsw.closed) {
793
+ return;
794
+ }
795
+ const full = entry.fullPath;
796
+ const dir = this.fsw._getWatchedDir(directory);
797
+ if (!this.fsw.options.followSymlinks) {
798
+ this.fsw._incrReadyCount();
799
+ let linkPath;
800
+ try {
801
+ linkPath = await fsrealpath(path);
802
+ } catch (e) {
803
+ this.fsw._emitReady();
804
+ return true;
805
+ }
806
+ if (this.fsw.closed)
807
+ return;
808
+ if (dir.has(item)) {
809
+ if (this.fsw._symlinkPaths.get(full) !== linkPath) {
810
+ this.fsw._symlinkPaths.set(full, linkPath);
811
+ this.fsw._emit(EV.CHANGE, path, entry.stats);
812
+ }
813
+ } else {
814
+ dir.add(item);
815
+ this.fsw._symlinkPaths.set(full, linkPath);
816
+ this.fsw._emit(EV.ADD, path, entry.stats);
817
+ }
818
+ this.fsw._emitReady();
819
+ return true;
820
+ }
821
+ if (this.fsw._symlinkPaths.has(full)) {
822
+ return true;
823
+ }
824
+ this.fsw._symlinkPaths.set(full, true);
825
+ }
826
+ _handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
827
+ directory = sysPath.join(directory, "");
828
+ throttler = this.fsw._throttle("readdir", directory, 1e3);
829
+ if (!throttler)
830
+ return;
831
+ const previous = this.fsw._getWatchedDir(wh.path);
832
+ const current = /* @__PURE__ */ new Set();
833
+ let stream = this.fsw._readdirp(directory, {
834
+ fileFilter: (entry) => wh.filterPath(entry),
835
+ directoryFilter: (entry) => wh.filterDir(entry)
836
+ });
837
+ if (!stream)
838
+ return;
839
+ stream.on(STR_DATA, async (entry) => {
840
+ if (this.fsw.closed) {
841
+ stream = void 0;
842
+ return;
843
+ }
844
+ const item = entry.path;
845
+ let path = sysPath.join(directory, item);
846
+ current.add(item);
847
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path, item)) {
848
+ return;
849
+ }
850
+ if (this.fsw.closed) {
851
+ stream = void 0;
852
+ return;
853
+ }
854
+ if (item === target || !target && !previous.has(item)) {
855
+ this.fsw._incrReadyCount();
856
+ path = sysPath.join(dir, sysPath.relative(dir, path));
857
+ this._addToNodeFs(path, initialAdd, wh, depth + 1);
858
+ }
859
+ }).on(EV.ERROR, this._boundHandleError);
860
+ return new Promise((resolve6, reject) => {
861
+ if (!stream)
862
+ return reject();
863
+ stream.once(STR_END, () => {
864
+ if (this.fsw.closed) {
865
+ stream = void 0;
866
+ return;
867
+ }
868
+ const wasThrottled = throttler ? throttler.clear() : false;
869
+ resolve6(void 0);
870
+ previous.getChildren().filter((item) => {
871
+ return item !== directory && !current.has(item);
872
+ }).forEach((item) => {
873
+ this.fsw._remove(directory, item);
874
+ });
875
+ stream = void 0;
876
+ if (wasThrottled)
877
+ this._handleRead(directory, false, wh, target, dir, depth, throttler);
878
+ });
879
+ });
880
+ }
881
+ /**
882
+ * Read directory to add / remove files from `@watched` list and re-read it on change.
883
+ * @param dir fs path
884
+ * @param stats
885
+ * @param initialAdd
886
+ * @param depth relative to user-supplied path
887
+ * @param target child path targeted for watch
888
+ * @param wh Common watch helpers for this path
889
+ * @param realpath
890
+ * @returns closer for the watcher instance.
891
+ */
892
+ async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath2) {
893
+ const parentDir = this.fsw._getWatchedDir(sysPath.dirname(dir));
894
+ const tracked = parentDir.has(sysPath.basename(dir));
895
+ if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
896
+ this.fsw._emit(EV.ADD_DIR, dir, stats);
897
+ }
898
+ parentDir.add(sysPath.basename(dir));
899
+ this.fsw._getWatchedDir(dir);
900
+ let throttler;
901
+ let closer;
902
+ const oDepth = this.fsw.options.depth;
903
+ if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath2)) {
904
+ if (!target) {
905
+ await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler);
906
+ if (this.fsw.closed)
907
+ return;
908
+ }
909
+ closer = this._watchWithNodeFs(dir, (dirPath, stats2) => {
910
+ if (stats2 && stats2.mtimeMs === 0)
911
+ return;
912
+ this._handleRead(dirPath, false, wh, target, dir, depth, throttler);
913
+ });
914
+ }
915
+ return closer;
916
+ }
917
+ /**
918
+ * Handle added file, directory, or glob pattern.
919
+ * Delegates call to _handleFile / _handleDir after checks.
920
+ * @param path to file or ir
921
+ * @param initialAdd was the file added at watch instantiation?
922
+ * @param priorWh depth relative to user-supplied path
923
+ * @param depth Child path actually targeted for watch
924
+ * @param target Child path actually targeted for watch
925
+ */
926
+ async _addToNodeFs(path, initialAdd, priorWh, depth, target) {
927
+ const ready = this.fsw._emitReady;
928
+ if (this.fsw._isIgnored(path) || this.fsw.closed) {
929
+ ready();
930
+ return false;
931
+ }
932
+ const wh = this.fsw._getWatchHelpers(path);
933
+ if (priorWh) {
934
+ wh.filterPath = (entry) => priorWh.filterPath(entry);
935
+ wh.filterDir = (entry) => priorWh.filterDir(entry);
936
+ }
937
+ try {
938
+ const stats = await statMethods[wh.statMethod](wh.watchPath);
939
+ if (this.fsw.closed)
940
+ return;
941
+ if (this.fsw._isIgnored(wh.watchPath, stats)) {
942
+ ready();
943
+ return false;
944
+ }
945
+ const follow = this.fsw.options.followSymlinks;
946
+ let closer;
947
+ if (stats.isDirectory()) {
948
+ const absPath = sysPath.resolve(path);
949
+ const targetPath = follow ? await fsrealpath(path) : path;
950
+ if (this.fsw.closed)
951
+ return;
952
+ closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
953
+ if (this.fsw.closed)
954
+ return;
955
+ if (absPath !== targetPath && targetPath !== void 0) {
956
+ this.fsw._symlinkPaths.set(absPath, targetPath);
957
+ }
958
+ } else if (stats.isSymbolicLink()) {
959
+ const targetPath = follow ? await fsrealpath(path) : path;
960
+ if (this.fsw.closed)
961
+ return;
962
+ const parent = sysPath.dirname(wh.watchPath);
963
+ this.fsw._getWatchedDir(parent).add(wh.watchPath);
964
+ this.fsw._emit(EV.ADD, wh.watchPath, stats);
965
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath);
966
+ if (this.fsw.closed)
967
+ return;
968
+ if (targetPath !== void 0) {
969
+ this.fsw._symlinkPaths.set(sysPath.resolve(path), targetPath);
970
+ }
971
+ } else {
972
+ closer = this._handleFile(wh.watchPath, stats, initialAdd);
973
+ }
974
+ ready();
975
+ if (closer)
976
+ this.fsw._addPathCloser(path, closer);
977
+ return false;
978
+ } catch (error) {
979
+ if (this.fsw._handleError(error)) {
980
+ ready();
981
+ return path;
982
+ }
983
+ }
984
+ }
985
+ };
986
+
987
+ // ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
988
+ var SLASH = "/";
989
+ var SLASH_SLASH = "//";
990
+ var ONE_DOT = ".";
991
+ var TWO_DOTS = "..";
992
+ var STRING_TYPE = "string";
993
+ var BACK_SLASH_RE = /\\/g;
994
+ var DOUBLE_SLASH_RE = /\/\//;
995
+ var DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
996
+ var REPLACER_RE = /^\.[/\\]/;
997
+ function arrify(item) {
998
+ return Array.isArray(item) ? item : [item];
999
+ }
1000
+ var isMatcherObject = (matcher) => typeof matcher === "object" && matcher !== null && !(matcher instanceof RegExp);
1001
+ function createPattern(matcher) {
1002
+ if (typeof matcher === "function")
1003
+ return matcher;
1004
+ if (typeof matcher === "string")
1005
+ return (string) => matcher === string;
1006
+ if (matcher instanceof RegExp)
1007
+ return (string) => matcher.test(string);
1008
+ if (typeof matcher === "object" && matcher !== null) {
1009
+ return (string) => {
1010
+ if (matcher.path === string)
1011
+ return true;
1012
+ if (matcher.recursive) {
1013
+ const relative3 = sysPath2.relative(matcher.path, string);
1014
+ if (!relative3) {
1015
+ return false;
1016
+ }
1017
+ return !relative3.startsWith("..") && !sysPath2.isAbsolute(relative3);
1018
+ }
1019
+ return false;
1020
+ };
1021
+ }
1022
+ return () => false;
1023
+ }
1024
+ function normalizePath(path) {
1025
+ if (typeof path !== "string")
1026
+ throw new Error("string expected");
1027
+ path = sysPath2.normalize(path);
1028
+ path = path.replace(/\\/g, "/");
1029
+ let prepend = false;
1030
+ if (path.startsWith("//"))
1031
+ prepend = true;
1032
+ const DOUBLE_SLASH_RE2 = /\/\//;
1033
+ while (path.match(DOUBLE_SLASH_RE2))
1034
+ path = path.replace(DOUBLE_SLASH_RE2, "/");
1035
+ if (prepend)
1036
+ path = "/" + path;
1037
+ return path;
1038
+ }
1039
+ function matchPatterns(patterns, testString, stats) {
1040
+ const path = normalizePath(testString);
1041
+ for (let index = 0; index < patterns.length; index++) {
1042
+ const pattern = patterns[index];
1043
+ if (pattern(path, stats)) {
1044
+ return true;
1045
+ }
1046
+ }
1047
+ return false;
1048
+ }
1049
+ function anymatch(matchers, testString) {
1050
+ if (matchers == null) {
1051
+ throw new TypeError("anymatch: specify first argument");
1052
+ }
1053
+ const matchersArray = arrify(matchers);
1054
+ const patterns = matchersArray.map((matcher) => createPattern(matcher));
1055
+ if (testString == null) {
1056
+ return (testString2, stats) => {
1057
+ return matchPatterns(patterns, testString2, stats);
1058
+ };
1059
+ }
1060
+ return matchPatterns(patterns, testString);
1061
+ }
1062
+ var unifyPaths = (paths_) => {
1063
+ const paths = arrify(paths_).flat();
1064
+ if (!paths.every((p) => typeof p === STRING_TYPE)) {
1065
+ throw new TypeError(`Non-string provided as watch path: ${paths}`);
1066
+ }
1067
+ return paths.map(normalizePathToUnix);
1068
+ };
1069
+ var toUnix = (string) => {
1070
+ let str = string.replace(BACK_SLASH_RE, SLASH);
1071
+ let prepend = false;
1072
+ if (str.startsWith(SLASH_SLASH)) {
1073
+ prepend = true;
1074
+ }
1075
+ while (str.match(DOUBLE_SLASH_RE)) {
1076
+ str = str.replace(DOUBLE_SLASH_RE, SLASH);
1077
+ }
1078
+ if (prepend) {
1079
+ str = SLASH + str;
1080
+ }
1081
+ return str;
1082
+ };
1083
+ var normalizePathToUnix = (path) => toUnix(sysPath2.normalize(toUnix(path)));
1084
+ var normalizeIgnored = (cwd = "") => (path) => {
1085
+ if (typeof path === "string") {
1086
+ return normalizePathToUnix(sysPath2.isAbsolute(path) ? path : sysPath2.join(cwd, path));
1087
+ } else {
1088
+ return path;
1089
+ }
1090
+ };
1091
+ var getAbsolutePath = (path, cwd) => {
1092
+ if (sysPath2.isAbsolute(path)) {
1093
+ return path;
1094
+ }
1095
+ return sysPath2.join(cwd, path);
1096
+ };
1097
+ var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
1098
+ var DirEntry = class {
1099
+ constructor(dir, removeWatcher) {
1100
+ this.path = dir;
1101
+ this._removeWatcher = removeWatcher;
1102
+ this.items = /* @__PURE__ */ new Set();
1103
+ }
1104
+ add(item) {
1105
+ const { items } = this;
1106
+ if (!items)
1107
+ return;
1108
+ if (item !== ONE_DOT && item !== TWO_DOTS)
1109
+ items.add(item);
1110
+ }
1111
+ async remove(item) {
1112
+ const { items } = this;
1113
+ if (!items)
1114
+ return;
1115
+ items.delete(item);
1116
+ if (items.size > 0)
1117
+ return;
1118
+ const dir = this.path;
1119
+ try {
1120
+ await readdir2(dir);
1121
+ } catch (err) {
1122
+ if (this._removeWatcher) {
1123
+ this._removeWatcher(sysPath2.dirname(dir), sysPath2.basename(dir));
1124
+ }
1125
+ }
1126
+ }
1127
+ has(item) {
1128
+ const { items } = this;
1129
+ if (!items)
1130
+ return;
1131
+ return items.has(item);
1132
+ }
1133
+ getChildren() {
1134
+ const { items } = this;
1135
+ if (!items)
1136
+ return [];
1137
+ return [...items.values()];
1138
+ }
1139
+ dispose() {
1140
+ this.items.clear();
1141
+ this.path = "";
1142
+ this._removeWatcher = EMPTY_FN;
1143
+ this.items = EMPTY_SET;
1144
+ Object.freeze(this);
1145
+ }
1146
+ };
1147
+ var STAT_METHOD_F = "stat";
1148
+ var STAT_METHOD_L = "lstat";
1149
+ var WatchHelper = class {
1150
+ constructor(path, follow, fsw) {
1151
+ this.fsw = fsw;
1152
+ const watchPath = path;
1153
+ this.path = path = path.replace(REPLACER_RE, "");
1154
+ this.watchPath = watchPath;
1155
+ this.fullWatchPath = sysPath2.resolve(watchPath);
1156
+ this.dirParts = [];
1157
+ this.dirParts.forEach((parts) => {
1158
+ if (parts.length > 1)
1159
+ parts.pop();
1160
+ });
1161
+ this.followSymlinks = follow;
1162
+ this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
1163
+ }
1164
+ entryPath(entry) {
1165
+ return sysPath2.join(this.watchPath, sysPath2.relative(this.watchPath, entry.fullPath));
1166
+ }
1167
+ filterPath(entry) {
1168
+ const { stats } = entry;
1169
+ if (stats && stats.isSymbolicLink())
1170
+ return this.filterDir(entry);
1171
+ const resolvedPath = this.entryPath(entry);
1172
+ return this.fsw._isntIgnored(resolvedPath, stats) && this.fsw._hasReadPermissions(stats);
1173
+ }
1174
+ filterDir(entry) {
1175
+ return this.fsw._isntIgnored(this.entryPath(entry), entry.stats);
1176
+ }
1177
+ };
1178
+ var FSWatcher = class extends EventEmitter {
1179
+ // Not indenting methods for history sake; for now.
1180
+ constructor(_opts = {}) {
1181
+ super();
1182
+ this.closed = false;
1183
+ this._closers = /* @__PURE__ */ new Map();
1184
+ this._ignoredPaths = /* @__PURE__ */ new Set();
1185
+ this._throttled = /* @__PURE__ */ new Map();
1186
+ this._streams = /* @__PURE__ */ new Set();
1187
+ this._symlinkPaths = /* @__PURE__ */ new Map();
1188
+ this._watched = /* @__PURE__ */ new Map();
1189
+ this._pendingWrites = /* @__PURE__ */ new Map();
1190
+ this._pendingUnlinks = /* @__PURE__ */ new Map();
1191
+ this._readyCount = 0;
1192
+ this._readyEmitted = false;
1193
+ const awf = _opts.awaitWriteFinish;
1194
+ const DEF_AWF = { stabilityThreshold: 2e3, pollInterval: 100 };
1195
+ const opts = {
1196
+ // Defaults
1197
+ persistent: true,
1198
+ ignoreInitial: false,
1199
+ ignorePermissionErrors: false,
1200
+ interval: 100,
1201
+ binaryInterval: 300,
1202
+ followSymlinks: true,
1203
+ usePolling: false,
1204
+ // useAsync: false,
1205
+ atomic: true,
1206
+ // NOTE: overwritten later (depends on usePolling)
1207
+ ..._opts,
1208
+ // Change format
1209
+ ignored: _opts.ignored ? arrify(_opts.ignored) : arrify([]),
1210
+ awaitWriteFinish: awf === true ? DEF_AWF : typeof awf === "object" ? { ...DEF_AWF, ...awf } : false
1211
+ };
1212
+ if (isIBMi)
1213
+ opts.usePolling = true;
1214
+ if (opts.atomic === void 0)
1215
+ opts.atomic = !opts.usePolling;
1216
+ const envPoll = process.env.CHOKIDAR_USEPOLLING;
1217
+ if (envPoll !== void 0) {
1218
+ const envLower = envPoll.toLowerCase();
1219
+ if (envLower === "false" || envLower === "0")
1220
+ opts.usePolling = false;
1221
+ else if (envLower === "true" || envLower === "1")
1222
+ opts.usePolling = true;
1223
+ else
1224
+ opts.usePolling = !!envLower;
1225
+ }
1226
+ const envInterval = process.env.CHOKIDAR_INTERVAL;
1227
+ if (envInterval)
1228
+ opts.interval = Number.parseInt(envInterval, 10);
1229
+ let readyCalls = 0;
1230
+ this._emitReady = () => {
1231
+ readyCalls++;
1232
+ if (readyCalls >= this._readyCount) {
1233
+ this._emitReady = EMPTY_FN;
1234
+ this._readyEmitted = true;
1235
+ process.nextTick(() => this.emit(EVENTS.READY));
1236
+ }
1237
+ };
1238
+ this._emitRaw = (...args) => this.emit(EVENTS.RAW, ...args);
1239
+ this._boundRemove = this._remove.bind(this);
1240
+ this.options = opts;
1241
+ this._nodeFsHandler = new NodeFsHandler(this);
1242
+ Object.freeze(opts);
1243
+ }
1244
+ _addIgnoredPath(matcher) {
1245
+ if (isMatcherObject(matcher)) {
1246
+ for (const ignored of this._ignoredPaths) {
1247
+ if (isMatcherObject(ignored) && ignored.path === matcher.path && ignored.recursive === matcher.recursive) {
1248
+ return;
1249
+ }
1250
+ }
1251
+ }
1252
+ this._ignoredPaths.add(matcher);
1253
+ }
1254
+ _removeIgnoredPath(matcher) {
1255
+ this._ignoredPaths.delete(matcher);
1256
+ if (typeof matcher === "string") {
1257
+ for (const ignored of this._ignoredPaths) {
1258
+ if (isMatcherObject(ignored) && ignored.path === matcher) {
1259
+ this._ignoredPaths.delete(ignored);
1260
+ }
1261
+ }
1262
+ }
1263
+ }
1264
+ // Public methods
1265
+ /**
1266
+ * Adds paths to be watched on an existing FSWatcher instance.
1267
+ * @param paths_ file or file list. Other arguments are unused
1268
+ */
1269
+ add(paths_, _origAdd, _internal) {
1270
+ const { cwd } = this.options;
1271
+ this.closed = false;
1272
+ this._closePromise = void 0;
1273
+ let paths = unifyPaths(paths_);
1274
+ if (cwd) {
1275
+ paths = paths.map((path) => {
1276
+ const absPath = getAbsolutePath(path, cwd);
1277
+ return absPath;
1278
+ });
1279
+ }
1280
+ paths.forEach((path) => {
1281
+ this._removeIgnoredPath(path);
1282
+ });
1283
+ this._userIgnored = void 0;
1284
+ if (!this._readyCount)
1285
+ this._readyCount = 0;
1286
+ this._readyCount += paths.length;
1287
+ Promise.all(paths.map(async (path) => {
1288
+ const res = await this._nodeFsHandler._addToNodeFs(path, !_internal, void 0, 0, _origAdd);
1289
+ if (res)
1290
+ this._emitReady();
1291
+ return res;
1292
+ })).then((results) => {
1293
+ if (this.closed)
1294
+ return;
1295
+ results.forEach((item) => {
1296
+ if (item)
1297
+ this.add(sysPath2.dirname(item), sysPath2.basename(_origAdd || item));
1298
+ });
1299
+ });
1300
+ return this;
1301
+ }
1302
+ /**
1303
+ * Close watchers or start ignoring events from specified paths.
1304
+ */
1305
+ unwatch(paths_) {
1306
+ if (this.closed)
1307
+ return this;
1308
+ const paths = unifyPaths(paths_);
1309
+ const { cwd } = this.options;
1310
+ paths.forEach((path) => {
1311
+ if (!sysPath2.isAbsolute(path) && !this._closers.has(path)) {
1312
+ if (cwd)
1313
+ path = sysPath2.join(cwd, path);
1314
+ path = sysPath2.resolve(path);
1315
+ }
1316
+ this._closePath(path);
1317
+ this._addIgnoredPath(path);
1318
+ if (this._watched.has(path)) {
1319
+ this._addIgnoredPath({
1320
+ path,
1321
+ recursive: true
1322
+ });
1323
+ }
1324
+ this._userIgnored = void 0;
1325
+ });
1326
+ return this;
1327
+ }
1328
+ /**
1329
+ * Close watchers and remove all listeners from watched paths.
1330
+ */
1331
+ close() {
1332
+ if (this._closePromise) {
1333
+ return this._closePromise;
1334
+ }
1335
+ this.closed = true;
1336
+ this.removeAllListeners();
1337
+ const closers = [];
1338
+ this._closers.forEach((closerList) => closerList.forEach((closer) => {
1339
+ const promise = closer();
1340
+ if (promise instanceof Promise)
1341
+ closers.push(promise);
1342
+ }));
1343
+ this._streams.forEach((stream) => stream.destroy());
1344
+ this._userIgnored = void 0;
1345
+ this._readyCount = 0;
1346
+ this._readyEmitted = false;
1347
+ this._watched.forEach((dirent) => dirent.dispose());
1348
+ this._closers.clear();
1349
+ this._watched.clear();
1350
+ this._streams.clear();
1351
+ this._symlinkPaths.clear();
1352
+ this._throttled.clear();
1353
+ this._closePromise = closers.length ? Promise.all(closers).then(() => void 0) : Promise.resolve();
1354
+ return this._closePromise;
1355
+ }
1356
+ /**
1357
+ * Expose list of watched paths
1358
+ * @returns for chaining
1359
+ */
1360
+ getWatched() {
1361
+ const watchList = {};
1362
+ this._watched.forEach((entry, dir) => {
1363
+ const key = this.options.cwd ? sysPath2.relative(this.options.cwd, dir) : dir;
1364
+ const index = key || ONE_DOT;
1365
+ watchList[index] = entry.getChildren().sort();
1366
+ });
1367
+ return watchList;
1368
+ }
1369
+ emitWithAll(event, args) {
1370
+ this.emit(event, ...args);
1371
+ if (event !== EVENTS.ERROR)
1372
+ this.emit(EVENTS.ALL, event, ...args);
1373
+ }
1374
+ // Common helpers
1375
+ // --------------
1376
+ /**
1377
+ * Normalize and emit events.
1378
+ * Calling _emit DOES NOT MEAN emit() would be called!
1379
+ * @param event Type of event
1380
+ * @param path File or directory path
1381
+ * @param stats arguments to be passed with event
1382
+ * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
1383
+ */
1384
+ async _emit(event, path, stats) {
1385
+ if (this.closed)
1386
+ return;
1387
+ const opts = this.options;
1388
+ if (isWindows)
1389
+ path = sysPath2.normalize(path);
1390
+ if (opts.cwd)
1391
+ path = sysPath2.relative(opts.cwd, path);
1392
+ const args = [path];
1393
+ if (stats != null)
1394
+ args.push(stats);
1395
+ const awf = opts.awaitWriteFinish;
1396
+ let pw;
1397
+ if (awf && (pw = this._pendingWrites.get(path))) {
1398
+ pw.lastChange = /* @__PURE__ */ new Date();
1399
+ return this;
1400
+ }
1401
+ if (opts.atomic) {
1402
+ if (event === EVENTS.UNLINK) {
1403
+ this._pendingUnlinks.set(path, [event, ...args]);
1404
+ setTimeout(() => {
1405
+ this._pendingUnlinks.forEach((entry, path2) => {
1406
+ this.emit(...entry);
1407
+ this.emit(EVENTS.ALL, ...entry);
1408
+ this._pendingUnlinks.delete(path2);
1409
+ });
1410
+ }, typeof opts.atomic === "number" ? opts.atomic : 100);
1411
+ return this;
1412
+ }
1413
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path)) {
1414
+ event = EVENTS.CHANGE;
1415
+ this._pendingUnlinks.delete(path);
1416
+ }
1417
+ }
1418
+ if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
1419
+ const awfEmit = (err, stats2) => {
1420
+ if (err) {
1421
+ event = EVENTS.ERROR;
1422
+ args[0] = err;
1423
+ this.emitWithAll(event, args);
1424
+ } else if (stats2) {
1425
+ if (args.length > 1) {
1426
+ args[1] = stats2;
1427
+ } else {
1428
+ args.push(stats2);
1429
+ }
1430
+ this.emitWithAll(event, args);
1431
+ }
1432
+ };
1433
+ this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit);
1434
+ return this;
1435
+ }
1436
+ if (event === EVENTS.CHANGE) {
1437
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path, 50);
1438
+ if (isThrottled)
1439
+ return this;
1440
+ }
1441
+ if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
1442
+ const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path) : path;
1443
+ let stats2;
1444
+ try {
1445
+ stats2 = await stat3(fullPath);
1446
+ } catch (err) {
1447
+ }
1448
+ if (!stats2 || this.closed)
1449
+ return;
1450
+ args.push(stats2);
1451
+ }
1452
+ this.emitWithAll(event, args);
1453
+ return this;
1454
+ }
1455
+ /**
1456
+ * Common handler for errors
1457
+ * @returns The error if defined, otherwise the value of the FSWatcher instance's `closed` flag
1458
+ */
1459
+ _handleError(error) {
1460
+ const code = error && error.code;
1461
+ if (error && code !== "ENOENT" && code !== "ENOTDIR" && (!this.options.ignorePermissionErrors || code !== "EPERM" && code !== "EACCES")) {
1462
+ this.emit(EVENTS.ERROR, error);
1463
+ }
1464
+ return error || this.closed;
1465
+ }
1466
+ /**
1467
+ * Helper utility for throttling
1468
+ * @param actionType type being throttled
1469
+ * @param path being acted upon
1470
+ * @param timeout duration of time to suppress duplicate actions
1471
+ * @returns tracking object or false if action should be suppressed
1472
+ */
1473
+ _throttle(actionType, path, timeout) {
1474
+ if (!this._throttled.has(actionType)) {
1475
+ this._throttled.set(actionType, /* @__PURE__ */ new Map());
1476
+ }
1477
+ const action = this._throttled.get(actionType);
1478
+ if (!action)
1479
+ throw new Error("invalid throttle");
1480
+ const actionPath = action.get(path);
1481
+ if (actionPath) {
1482
+ actionPath.count++;
1483
+ return false;
1484
+ }
1485
+ let timeoutObject;
1486
+ const clear = () => {
1487
+ const item = action.get(path);
1488
+ const count = item ? item.count : 0;
1489
+ action.delete(path);
1490
+ clearTimeout(timeoutObject);
1491
+ if (item)
1492
+ clearTimeout(item.timeoutObject);
1493
+ return count;
1494
+ };
1495
+ timeoutObject = setTimeout(clear, timeout);
1496
+ const thr = { timeoutObject, clear, count: 0 };
1497
+ action.set(path, thr);
1498
+ return thr;
1499
+ }
1500
+ _incrReadyCount() {
1501
+ return this._readyCount++;
1502
+ }
1503
+ /**
1504
+ * Awaits write operation to finish.
1505
+ * Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.
1506
+ * @param path being acted upon
1507
+ * @param threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished
1508
+ * @param event
1509
+ * @param awfEmit Callback to be called when ready for event to be emitted.
1510
+ */
1511
+ _awaitWriteFinish(path, threshold, event, awfEmit) {
1512
+ const awf = this.options.awaitWriteFinish;
1513
+ if (typeof awf !== "object")
1514
+ return;
1515
+ const pollInterval = awf.pollInterval;
1516
+ let timeoutHandler;
1517
+ let fullPath = path;
1518
+ if (this.options.cwd && !sysPath2.isAbsolute(path)) {
1519
+ fullPath = sysPath2.join(this.options.cwd, path);
1520
+ }
1521
+ const now = /* @__PURE__ */ new Date();
1522
+ const writes = this._pendingWrites;
1523
+ function awaitWriteFinishFn(prevStat) {
1524
+ statcb(fullPath, (err, curStat) => {
1525
+ if (err || !writes.has(path)) {
1526
+ if (err && err.code !== "ENOENT")
1527
+ awfEmit(err);
1528
+ return;
1529
+ }
1530
+ const now2 = Number(/* @__PURE__ */ new Date());
1531
+ if (prevStat && curStat.size !== prevStat.size) {
1532
+ writes.get(path).lastChange = now2;
1533
+ }
1534
+ const pw = writes.get(path);
1535
+ const df = now2 - pw.lastChange;
1536
+ if (df >= threshold) {
1537
+ writes.delete(path);
1538
+ awfEmit(void 0, curStat);
1539
+ } else {
1540
+ timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
1541
+ }
1542
+ });
1543
+ }
1544
+ if (!writes.has(path)) {
1545
+ writes.set(path, {
1546
+ lastChange: now,
1547
+ cancelWait: () => {
1548
+ writes.delete(path);
1549
+ clearTimeout(timeoutHandler);
1550
+ return event;
1551
+ }
1552
+ });
1553
+ timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
1554
+ }
1555
+ }
1556
+ /**
1557
+ * Determines whether user has asked to ignore this path.
1558
+ */
1559
+ _isIgnored(path, stats) {
1560
+ if (this.options.atomic && DOT_RE.test(path))
1561
+ return true;
1562
+ if (!this._userIgnored) {
1563
+ const { cwd } = this.options;
1564
+ const ign = this.options.ignored;
1565
+ const ignored = (ign || []).map(normalizeIgnored(cwd));
1566
+ const ignoredPaths = [...this._ignoredPaths];
1567
+ const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
1568
+ this._userIgnored = anymatch(list, void 0);
1569
+ }
1570
+ return this._userIgnored(path, stats);
1571
+ }
1572
+ _isntIgnored(path, stat5) {
1573
+ return !this._isIgnored(path, stat5);
1574
+ }
1575
+ /**
1576
+ * Provides a set of common helpers and properties relating to symlink handling.
1577
+ * @param path file or directory pattern being watched
1578
+ */
1579
+ _getWatchHelpers(path) {
1580
+ return new WatchHelper(path, this.options.followSymlinks, this);
1581
+ }
1582
+ // Directory helpers
1583
+ // -----------------
1584
+ /**
1585
+ * Provides directory tracking objects
1586
+ * @param directory path of the directory
1587
+ */
1588
+ _getWatchedDir(directory) {
1589
+ const dir = sysPath2.resolve(directory);
1590
+ if (!this._watched.has(dir))
1591
+ this._watched.set(dir, new DirEntry(dir, this._boundRemove));
1592
+ return this._watched.get(dir);
1593
+ }
1594
+ // File helpers
1595
+ // ------------
1596
+ /**
1597
+ * Check for read permissions: https://stackoverflow.com/a/11781404/1358405
1598
+ */
1599
+ _hasReadPermissions(stats) {
1600
+ if (this.options.ignorePermissionErrors)
1601
+ return true;
1602
+ return Boolean(Number(stats.mode) & 256);
1603
+ }
1604
+ /**
1605
+ * Handles emitting unlink events for
1606
+ * files and directories, and via recursion, for
1607
+ * files and directories within directories that are unlinked
1608
+ * @param directory within which the following item is located
1609
+ * @param item base path of item/directory
1610
+ */
1611
+ _remove(directory, item, isDirectory) {
1612
+ const path = sysPath2.join(directory, item);
1613
+ const fullPath = sysPath2.resolve(path);
1614
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path) || this._watched.has(fullPath);
1615
+ if (!this._throttle("remove", path, 100))
1616
+ return;
1617
+ if (!isDirectory && this._watched.size === 1) {
1618
+ this.add(directory, item, true);
1619
+ }
1620
+ const wp = this._getWatchedDir(path);
1621
+ const nestedDirectoryChildren = wp.getChildren();
1622
+ nestedDirectoryChildren.forEach((nested) => this._remove(path, nested));
1623
+ const parent = this._getWatchedDir(directory);
1624
+ const wasTracked = parent.has(item);
1625
+ parent.remove(item);
1626
+ if (this._symlinkPaths.has(fullPath)) {
1627
+ this._symlinkPaths.delete(fullPath);
1628
+ }
1629
+ let relPath = path;
1630
+ if (this.options.cwd)
1631
+ relPath = sysPath2.relative(this.options.cwd, path);
1632
+ if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
1633
+ const event = this._pendingWrites.get(relPath).cancelWait();
1634
+ if (event === EVENTS.ADD)
1635
+ return;
1636
+ }
1637
+ this._watched.delete(path);
1638
+ this._watched.delete(fullPath);
1639
+ const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
1640
+ if (wasTracked && !this._isIgnored(path))
1641
+ this._emit(eventName, path);
1642
+ this._closePath(path);
1643
+ }
1644
+ /**
1645
+ * Closes all watchers for a path
1646
+ */
1647
+ _closePath(path) {
1648
+ this._closeFile(path);
1649
+ const dir = sysPath2.dirname(path);
1650
+ this._getWatchedDir(dir).remove(sysPath2.basename(path));
1651
+ }
1652
+ /**
1653
+ * Closes only file-specific watchers
1654
+ */
1655
+ _closeFile(path) {
1656
+ const closers = this._closers.get(path);
1657
+ if (!closers)
1658
+ return;
1659
+ closers.forEach((closer) => closer());
1660
+ this._closers.delete(path);
1661
+ }
1662
+ _addPathCloser(path, closer) {
1663
+ if (!closer)
1664
+ return;
1665
+ let list = this._closers.get(path);
1666
+ if (!list) {
1667
+ list = [];
1668
+ this._closers.set(path, list);
1669
+ }
1670
+ list.push(closer);
1671
+ }
1672
+ _readdirp(root, opts) {
1673
+ if (this.closed)
1674
+ return;
1675
+ const options = { type: EVENTS.ALL, alwaysStat: true, lstat: true, ...opts, depth: 0 };
1676
+ let stream = readdirp(root, options);
1677
+ this._streams.add(stream);
1678
+ stream.once(STR_CLOSE, () => {
1679
+ stream = void 0;
1680
+ });
1681
+ stream.once(STR_END, () => {
1682
+ if (stream) {
1683
+ this._streams.delete(stream);
1684
+ stream = void 0;
1685
+ }
1686
+ });
1687
+ return stream;
1688
+ }
1689
+ };
1690
+ function watch(paths, options = {}) {
1691
+ const watcher = new FSWatcher(options);
1692
+ watcher.add(paths);
1693
+ return watcher;
1694
+ }
1695
+ var esm_default = { watch, FSWatcher };
3
1696
 
4
1697
  // src/vite/codegen-runner.ts
5
1698
  import { writeFile, mkdir } from "node:fs/promises";
6
- import { join as join2 } from "node:path";
1699
+ import { join as join4, dirname as dirname4, isAbsolute as isAbsolute3, resolve as resolve4 } from "node:path";
7
1700
 
8
1701
  // src/codegen/config.ts
9
1702
  import { readFileSync, readdirSync, statSync } from "node:fs";
10
- import { join, dirname, isAbsolute, resolve } from "node:path";
1703
+ import { join as join3, dirname as dirname3, isAbsolute as isAbsolute2, resolve as resolve3 } from "node:path";
11
1704
  function findConfig(path) {
12
- const stat2 = statSync(path);
13
- if (!stat2.isDirectory()) {
1705
+ const stat5 = statSync(path);
1706
+ if (!stat5.isDirectory()) {
14
1707
  return path;
15
1708
  }
16
1709
  const entries = readdirSync(path);
17
1710
  const matches = entries.filter(
18
- (entry) => entry.endsWith("mt.config.json") && statSync(join(path, entry)).isFile()
1711
+ (entry) => entry.endsWith("mt.config.json") && statSync(join3(path, entry)).isFile()
19
1712
  );
20
1713
  if (matches.length === 0) {
21
1714
  throw new Error(`No *mt.config.json found in ${path}`);
@@ -23,7 +1716,7 @@ function findConfig(path) {
23
1716
  if (matches.length > 1) {
24
1717
  throw new Error(`Multiple config files found in ${path}: ${matches.join(", ")} (specify exact path)`);
25
1718
  }
26
- return join(path, matches[0]);
1719
+ return join3(path, matches[0]);
27
1720
  }
28
1721
  function loadConfig(path) {
29
1722
  const data = readFileSync(path, "utf-8");
@@ -36,19 +1729,19 @@ function loadConfig(path) {
36
1729
  }
37
1730
  function loadProject(path) {
38
1731
  const configPath = findConfig(path);
39
- const absConfigPath = resolve(configPath);
1732
+ const absConfigPath = resolve3(configPath);
40
1733
  const config = loadConfig(absConfigPath);
41
1734
  return {
42
1735
  config,
43
1736
  configPath: absConfigPath,
44
- dir: dirname(absConfigPath)
1737
+ dir: dirname3(absConfigPath)
45
1738
  };
46
1739
  }
47
1740
  function resolvePath(path, baseDir) {
48
- if (isAbsolute(path)) {
1741
+ if (isAbsolute2(path)) {
49
1742
  return path;
50
1743
  }
51
- return join(baseDir, path);
1744
+ return join3(baseDir, path);
52
1745
  }
53
1746
  function loadConfigGraph(root) {
54
1747
  const plugins = /* @__PURE__ */ new Map();
@@ -78,7 +1771,7 @@ function loadConfigGraph(root) {
78
1771
  `Plugin ${item.pluginPath}: wasm.reservedBytes ${config.wasm.reservedBytes} exceeds maximum ${maxReservedBytes}`
79
1772
  );
80
1773
  }
81
- const pluginDir = dirname(configPath);
1774
+ const pluginDir = dirname3(configPath);
82
1775
  const deps = [];
83
1776
  for (const dep of config.plugins ?? []) {
84
1777
  const absDepPath = resolvePath(dep, pluginDir);
@@ -212,6 +1905,7 @@ function mergeConfigs(graph) {
212
1905
  tickRate: graph.root.config.tickRate,
213
1906
  maxTicks: graph.root.config.maxTicks,
214
1907
  maxParticipants: graph.root.config.maxParticipants,
1908
+ bot: graph.root.config.bot,
215
1909
  input: graph.root.config.input,
216
1910
  state: mergedState
217
1911
  };
@@ -418,6 +2112,26 @@ function toPascalCase(s) {
418
2112
  }
419
2113
  return result;
420
2114
  }
2115
+ var PRIMITIVE_TYPES = /* @__PURE__ */ new Set([
2116
+ "bool",
2117
+ "uint8",
2118
+ "int8",
2119
+ "uint16",
2120
+ "int16",
2121
+ "uint32",
2122
+ "int32",
2123
+ "entityRef",
2124
+ "f32"
2125
+ ]);
2126
+ function parseArrayType(type) {
2127
+ const match = type.match(/^(\w+)\[(\d+)\]$/);
2128
+ if (!match || !match[1] || !match[2]) return null;
2129
+ const elementType = match[1];
2130
+ if (!PRIMITIVE_TYPES.has(elementType)) {
2131
+ return null;
2132
+ }
2133
+ return [elementType, parseInt(match[2], 10)];
2134
+ }
421
2135
  function needsEndian(type) {
422
2136
  switch (type) {
423
2137
  case "uint16":
@@ -483,7 +2197,7 @@ var INPUT_TYPE_SIZES = {
483
2197
  vec3: 12,
484
2198
  quat: 16
485
2199
  };
486
- var PRIMITIVE_TYPES = /* @__PURE__ */ new Set([
2200
+ var PRIMITIVE_TYPES2 = /* @__PURE__ */ new Set([
487
2201
  "bool",
488
2202
  "uint8",
489
2203
  "int8",
@@ -505,12 +2219,12 @@ var INPUT_PRIMITIVE_SCALAR_TYPES = /* @__PURE__ */ new Set([
505
2219
  "f32"
506
2220
  ]);
507
2221
  var ENUM_VARIANT_NAME_RE = /^[A-Za-z][A-Za-z0-9_]*$/;
508
- function parseArrayType(type) {
2222
+ function parseArrayType2(type) {
509
2223
  const match = type.match(/^(\w+)\[(\d+)\]$/);
510
2224
  if (!match || !match[1] || !match[2]) return null;
511
2225
  const elementType = match[1];
512
2226
  const length = parseInt(match[2], 10);
513
- if (!PRIMITIVE_TYPES.has(elementType)) return null;
2227
+ if (!PRIMITIVE_TYPES2.has(elementType)) return null;
514
2228
  return { elementType, length };
515
2229
  }
516
2230
  function parseInputArrayType(type) {
@@ -526,7 +2240,7 @@ function parseInputArrayType(type) {
526
2240
  return { elementType, length };
527
2241
  }
528
2242
  function getTypeSize(type) {
529
- const arrayInfo = parseArrayType(type);
2243
+ const arrayInfo = parseArrayType2(type);
530
2244
  if (arrayInfo) {
531
2245
  const elementSize = TYPE_SIZES[arrayInfo.elementType];
532
2246
  if (elementSize === void 0) {
@@ -694,7 +2408,7 @@ function compileStateSchema(schema) {
694
2408
  throw new Error(`Field '${name}.${rawFieldName}' must have a string 'type'`);
695
2409
  }
696
2410
  const size = getValidatedTypeSize(rawFieldType, name, rawFieldName);
697
- const arrayInfo = parseArrayType(rawFieldType);
2411
+ const arrayInfo = parseArrayType2(rawFieldType);
698
2412
  const compiledField = {
699
2413
  name: rawFieldName,
700
2414
  type: rawFieldType,
@@ -729,7 +2443,7 @@ function compileStateSchema(schema) {
729
2443
  } else {
730
2444
  const fieldType = componentType;
731
2445
  const size = getValidatedTypeSize(fieldType, name);
732
- const arrayInfo = parseArrayType(fieldType);
2446
+ const arrayInfo = parseArrayType2(fieldType);
733
2447
  const compiledField = {
734
2448
  name: "",
735
2449
  type: fieldType,
@@ -827,7 +2541,7 @@ function compileStateSchema(schema) {
827
2541
  if (typeof fieldDef.type !== "string" || fieldDef.type.trim().length === 0) {
828
2542
  throw new Error(`Event field '${eventDef.name}.${fieldDef.name}' must have a string 'type'`);
829
2543
  }
830
- const arrayInfo = parseArrayType(fieldDef.type);
2544
+ const arrayInfo = parseArrayType2(fieldDef.type);
831
2545
  if (arrayInfo) {
832
2546
  throw new Error(
833
2547
  `Event field '${eventDef.name}.${fieldDef.name}' has array type '${fieldDef.type}'; events do not support array types`
@@ -912,7 +2626,7 @@ function getInitDataTypeSize(type) {
912
2626
  }
913
2627
  return 8 * length;
914
2628
  }
915
- const arrayInfo = parseArrayType(type);
2629
+ const arrayInfo = parseArrayType2(type);
916
2630
  if (arrayInfo) {
917
2631
  if (arrayInfo.length > MAX_INIT_DATA_ARRAY_LENGTH) {
918
2632
  throw new Error(`Array length ${arrayInfo.length} exceeds maximum ${MAX_INIT_DATA_ARRAY_LENGTH}`);
@@ -1017,7 +2731,7 @@ function compileInitDataSchema(items) {
1017
2731
  compiledField.arrayLength = vec2Array.length;
1018
2732
  compiledField.arrayElementType = "f32";
1019
2733
  } else {
1020
- const primArray = parseArrayType(field.type);
2734
+ const primArray = parseArrayType2(field.type);
1021
2735
  if (primArray) {
1022
2736
  compiledField.arrayLength = primArray.length;
1023
2737
  compiledField.arrayElementType = primArray.elementType;
@@ -4128,27 +5842,6 @@ pub unsafe fn iter_${lower}(state: *const u8) -> ${event.name}Iter {
4128
5842
  `;
4129
5843
  return out;
4130
5844
  }
4131
- function isArrayType2(type) {
4132
- return /^\w+\[\d+\]$/.test(type);
4133
- }
4134
- function validateInputSchemaForCodegen2(schema) {
4135
- for (const ctrl of schema.controls) {
4136
- if (isArrayType2(ctrl.type)) {
4137
- throw new Error(
4138
- `Input array types are not supported by codegen: control '${ctrl.name}' has type '${ctrl.type}'`
4139
- );
4140
- }
4141
- }
4142
- for (const cmd of schema.commands) {
4143
- for (const arg of cmd.args) {
4144
- if (isArrayType2(arg.type) || arg.arrayLength) {
4145
- throw new Error(
4146
- `Input array types are not supported by codegen: command '${cmd.name}' argument '${arg.name}' has type '${arg.type}'`
4147
- );
4148
- }
4149
- }
4150
- }
4151
- }
4152
5845
  function generateInputHeader2() {
4153
5846
  return `// Language: Rust
4154
5847
  // Input Schema - Control and Command Accessors
@@ -4330,15 +6023,29 @@ pub unsafe fn get_${lower}_w(state: *const u8, entity: EntityRef) -> f32 {
4330
6023
  }
4331
6024
  `;
4332
6025
  break;
4333
- default:
4334
- out += `
6026
+ default: {
6027
+ const arrayInfo = parseArrayType(ctrl.type);
6028
+ if (arrayInfo) {
6029
+ const [elemType, length] = arrayInfo;
6030
+ const rustElemType = rustInputType(elemType);
6031
+ out += `
6032
+ /// Get ${ctrl.name} element from Player component (array of ${length} ${elemType})
6033
+ #[inline]
6034
+ pub unsafe fn get_${lower}(state: *const u8, entity: EntityRef, index: usize) -> ${rustElemType} {
6035
+ get_player_${lower}(state, entity, index)
6036
+ }
6037
+ `;
6038
+ } else {
6039
+ out += `
4335
6040
  /// Get ${ctrl.name} value from Player component
4336
6041
  #[inline]
4337
6042
  pub unsafe fn get_${lower}(state: *const u8, entity: EntityRef) -> ${rustInputType(ctrl.type)} {
4338
6043
  get_player_${lower}(state, entity)
4339
6044
  }
4340
6045
  `;
6046
+ }
4341
6047
  break;
6048
+ }
4342
6049
  }
4343
6050
  return out;
4344
6051
  }
@@ -4357,6 +6064,245 @@ function generateCommandConstants(schema) {
4357
6064
  }
4358
6065
  return out;
4359
6066
  }
6067
+ function generateInputBuilderStruct() {
6068
+ return `
6069
+ // =============================================================================
6070
+ // InputBuilder (for bot modules to construct TLV-encoded inputs)
6071
+ // =============================================================================
6072
+
6073
+ /// Builder for constructing TLV-encoded input payloads.
6074
+ /// Used by bot modules to produce inputs for the act() function.
6075
+ pub struct InputBuilder {
6076
+ buffer: [u8; 256],
6077
+ offset: usize,
6078
+ }
6079
+
6080
+ impl InputBuilder {
6081
+ /// Create a new empty input builder.
6082
+ #[inline]
6083
+ pub fn new() -> Self {
6084
+ Self {
6085
+ buffer: [0u8; 256],
6086
+ offset: 0,
6087
+ }
6088
+ }
6089
+
6090
+ /// Clear all set controls, resetting for reuse.
6091
+ #[inline]
6092
+ pub fn clear(&mut self) {
6093
+ self.offset = 0;
6094
+ }
6095
+
6096
+ /// Encode the input to the output buffer.
6097
+ /// Returns the number of bytes written.
6098
+ #[inline]
6099
+ pub fn encode(&self, output: *mut u8) -> u32 {
6100
+ unsafe {
6101
+ core::ptr::copy_nonoverlapping(
6102
+ self.buffer.as_ptr(),
6103
+ output,
6104
+ self.offset,
6105
+ );
6106
+ }
6107
+ self.offset as u32
6108
+ }
6109
+
6110
+ /// Write a TLV field to the buffer.
6111
+ #[inline]
6112
+ fn write_tlv(&mut self, tag: u8, value: &[u8]) {
6113
+ self.buffer[self.offset] = tag;
6114
+ self.buffer[self.offset + 1] = value.len() as u8;
6115
+ self.buffer[self.offset + 2..self.offset + 2 + value.len()].copy_from_slice(value);
6116
+ self.offset += 2 + value.len();
6117
+ }
6118
+ `;
6119
+ }
6120
+ function generateInputBuilderSetter(ctrl) {
6121
+ const lower = toLowerSnake(ctrl.name);
6122
+ const UPPER = toUpperSnake(ctrl.name);
6123
+ switch (ctrl.type) {
6124
+ case "flags8":
6125
+ return `
6126
+ /// Set ${ctrl.name} flags (bit positions: ${ctrl.options?.join(", ") || "none"})
6127
+ #[inline]
6128
+ pub fn set_${lower}(&mut self, flags: u8) {
6129
+ self.write_tlv(CONTROL_${UPPER}, &[flags]);
6130
+ }
6131
+ `;
6132
+ case "flags16":
6133
+ return `
6134
+ /// Set ${ctrl.name} flags
6135
+ #[inline]
6136
+ pub fn set_${lower}(&mut self, flags: u16) {
6137
+ self.write_tlv(CONTROL_${UPPER}, &flags.to_le_bytes());
6138
+ }
6139
+ `;
6140
+ case "flags32":
6141
+ return `
6142
+ /// Set ${ctrl.name} flags
6143
+ #[inline]
6144
+ pub fn set_${lower}(&mut self, flags: u32) {
6145
+ self.write_tlv(CONTROL_${UPPER}, &flags.to_le_bytes());
6146
+ }
6147
+ `;
6148
+ case "bool":
6149
+ return `
6150
+ /// Set ${ctrl.name} boolean
6151
+ #[inline]
6152
+ pub fn set_${lower}(&mut self, value: bool) {
6153
+ self.write_tlv(CONTROL_${UPPER}, &[if value { 1 } else { 0 }]);
6154
+ }
6155
+ `;
6156
+ case "uint8":
6157
+ return `
6158
+ /// Set ${ctrl.name} value
6159
+ #[inline]
6160
+ pub fn set_${lower}(&mut self, value: u8) {
6161
+ self.write_tlv(CONTROL_${UPPER}, &[value]);
6162
+ }
6163
+ `;
6164
+ case "int8":
6165
+ return `
6166
+ /// Set ${ctrl.name} value
6167
+ #[inline]
6168
+ pub fn set_${lower}(&mut self, value: i8) {
6169
+ self.write_tlv(CONTROL_${UPPER}, &[value as u8]);
6170
+ }
6171
+ `;
6172
+ case "uint16":
6173
+ return `
6174
+ /// Set ${ctrl.name} value
6175
+ #[inline]
6176
+ pub fn set_${lower}(&mut self, value: u16) {
6177
+ self.write_tlv(CONTROL_${UPPER}, &value.to_le_bytes());
6178
+ }
6179
+ `;
6180
+ case "int16":
6181
+ return `
6182
+ /// Set ${ctrl.name} value
6183
+ #[inline]
6184
+ pub fn set_${lower}(&mut self, value: i16) {
6185
+ self.write_tlv(CONTROL_${UPPER}, &value.to_le_bytes());
6186
+ }
6187
+ `;
6188
+ case "uint32":
6189
+ return `
6190
+ /// Set ${ctrl.name} value
6191
+ #[inline]
6192
+ pub fn set_${lower}(&mut self, value: u32) {
6193
+ self.write_tlv(CONTROL_${UPPER}, &value.to_le_bytes());
6194
+ }
6195
+ `;
6196
+ case "int32":
6197
+ return `
6198
+ /// Set ${ctrl.name} value
6199
+ #[inline]
6200
+ pub fn set_${lower}(&mut self, value: i32) {
6201
+ self.write_tlv(CONTROL_${UPPER}, &value.to_le_bytes());
6202
+ }
6203
+ `;
6204
+ case "f32":
6205
+ return `
6206
+ /// Set ${ctrl.name} value
6207
+ #[inline]
6208
+ pub fn set_${lower}(&mut self, value: f32) {
6209
+ self.write_tlv(CONTROL_${UPPER}, &value.to_le_bytes());
6210
+ }
6211
+ `;
6212
+ case "vec2":
6213
+ return `
6214
+ /// Set ${ctrl.name} vector (x, y)
6215
+ #[inline]
6216
+ pub fn set_${lower}(&mut self, x: f32, y: f32) {
6217
+ let mut value = [0u8; 8];
6218
+ value[0..4].copy_from_slice(&x.to_le_bytes());
6219
+ value[4..8].copy_from_slice(&y.to_le_bytes());
6220
+ self.write_tlv(CONTROL_${UPPER}, &value);
6221
+ }
6222
+ `;
6223
+ case "vec3":
6224
+ return `
6225
+ /// Set ${ctrl.name} vector (x, y, z)
6226
+ #[inline]
6227
+ pub fn set_${lower}(&mut self, x: f32, y: f32, z: f32) {
6228
+ let mut value = [0u8; 12];
6229
+ value[0..4].copy_from_slice(&x.to_le_bytes());
6230
+ value[4..8].copy_from_slice(&y.to_le_bytes());
6231
+ value[8..12].copy_from_slice(&z.to_le_bytes());
6232
+ self.write_tlv(CONTROL_${UPPER}, &value);
6233
+ }
6234
+ `;
6235
+ case "quat":
6236
+ return `
6237
+ /// Set ${ctrl.name} quaternion (x, y, z, w)
6238
+ #[inline]
6239
+ pub fn set_${lower}(&mut self, x: f32, y: f32, z: f32, w: f32) {
6240
+ let mut value = [0u8; 16];
6241
+ value[0..4].copy_from_slice(&x.to_le_bytes());
6242
+ value[4..8].copy_from_slice(&y.to_le_bytes());
6243
+ value[8..12].copy_from_slice(&z.to_le_bytes());
6244
+ value[12..16].copy_from_slice(&w.to_le_bytes());
6245
+ self.write_tlv(CONTROL_${UPPER}, &value);
6246
+ }
6247
+ `;
6248
+ default: {
6249
+ const arrayInfo = parseArrayType(ctrl.type);
6250
+ if (arrayInfo) {
6251
+ const [elemType, length] = arrayInfo;
6252
+ const rustElemType = rustInputType(elemType);
6253
+ const elemSize = getElementSize(elemType);
6254
+ const totalSize = elemSize * length;
6255
+ if (elemSize === 1) {
6256
+ return `
6257
+ /// Set ${ctrl.name} array (${length} x ${elemType})
6258
+ #[inline]
6259
+ pub fn set_${lower}(&mut self, values: &[${rustElemType}; ${length}]) {
6260
+ self.write_tlv(CONTROL_${UPPER}, unsafe { &*(values as *const [${rustElemType}; ${length}] as *const [u8; ${totalSize}]) });
6261
+ }
6262
+ `;
6263
+ } else {
6264
+ let body = ` let mut buf = [0u8; ${totalSize}];
6265
+ `;
6266
+ for (let i = 0; i < length; i++) {
6267
+ const offset = i * elemSize;
6268
+ body += ` buf[${offset}..${offset + elemSize}].copy_from_slice(&values[${i}].to_le_bytes());
6269
+ `;
6270
+ }
6271
+ body += ` self.write_tlv(CONTROL_${UPPER}, &buf);`;
6272
+ return `
6273
+ /// Set ${ctrl.name} array (${length} x ${elemType})
6274
+ #[inline]
6275
+ pub fn set_${lower}(&mut self, values: &[${rustElemType}; ${length}]) {
6276
+ ${body}
6277
+ }
6278
+ `;
6279
+ }
6280
+ }
6281
+ throw new Error(`Unknown control type '${ctrl.type}' in InputBuilder generation`);
6282
+ }
6283
+ }
6284
+ }
6285
+ function generateInputBuilderClose() {
6286
+ return `}
6287
+
6288
+ impl Default for InputBuilder {
6289
+ fn default() -> Self {
6290
+ Self::new()
6291
+ }
6292
+ }
6293
+ `;
6294
+ }
6295
+ function generateInputBuilder(schema) {
6296
+ if (schema.controls.length === 0) {
6297
+ return "";
6298
+ }
6299
+ let out = generateInputBuilderStruct();
6300
+ for (const ctrl of schema.controls) {
6301
+ out += generateInputBuilderSetter(ctrl);
6302
+ }
6303
+ out += generateInputBuilderClose();
6304
+ return out;
6305
+ }
4360
6306
  function generateGameAllocator() {
4361
6307
  return `
4362
6308
  // =============================================================================
@@ -4675,7 +6621,6 @@ var RustGenerator = class {
4675
6621
  return out;
4676
6622
  }
4677
6623
  generateInput(schema) {
4678
- validateInputSchemaForCodegen2(schema);
4679
6624
  let out = generateInputHeader2();
4680
6625
  if (schema.controls.length > 0) {
4681
6626
  out += generateControlConstants2(schema);
@@ -4692,6 +6637,7 @@ var RustGenerator = class {
4692
6637
  if (schema.commands.length > 0) {
4693
6638
  out += generateCommandConstants(schema);
4694
6639
  }
6640
+ out += generateInputBuilder(schema);
4695
6641
  return out;
4696
6642
  }
4697
6643
  generateInitData(schema) {
@@ -4729,8 +6675,21 @@ async function runCodegen(configPath, options) {
4729
6675
  const project = loadProject(configPath);
4730
6676
  const graph = loadConfigGraph(project);
4731
6677
  const merged = mergeConfigs(graph);
6678
+ const botPath = isAbsolute3(project.config.bot) ? project.config.bot : resolve4(project.dir, project.config.bot);
6679
+ const botConfigPath = findConfig(botPath);
6680
+ const botConfig = loadConfig(botConfigPath);
6681
+ if (!botConfig.wasm) {
6682
+ throw new Error(`Bot plugin ${botPath}: missing required wasm.reservedBytes in config`);
6683
+ }
6684
+ if (botConfig.wasm.reservedBytes <= 0) {
6685
+ throw new Error(`Bot plugin ${botPath}: wasm.reservedBytes must be > 0`);
6686
+ }
6687
+ const bot = {
6688
+ path: dirname4(botConfigPath),
6689
+ reservedBytes: botConfig.wasm.reservedBytes
6690
+ };
4732
6691
  if (verbose) {
4733
- console.log(`[multitap] Loaded ${graph.order.length} plugin(s)`);
6692
+ console.log(`[multitap] Loaded ${graph.order.length} plugin(s) + bot`);
4734
6693
  }
4735
6694
  const compiledInput = compileInputSchema(merged.config.input);
4736
6695
  const preparedState = prepareStateSchema(merged.config.state, compiledInput);
@@ -4745,7 +6704,7 @@ async function runCodegen(configPath, options) {
4745
6704
  const tsGen = new TypeScriptGenerator({ maxParticipants: merged.config.maxParticipants });
4746
6705
  const tsCode = tsGen.generateGame(compiledState, compiledInput, compiledInitData);
4747
6706
  await mkdir(generatedDir, { recursive: true });
4748
- const tsPath = join2(generatedDir, "state.ts");
6707
+ const tsPath = join4(generatedDir, "state.ts");
4749
6708
  await writeFile(tsPath, tsCode, "utf-8");
4750
6709
  if (verbose) {
4751
6710
  console.log(`[multitap] Generated ${tsPath}`);
@@ -4753,37 +6712,45 @@ async function runCodegen(configPath, options) {
4753
6712
  const rustGen = new RustGenerator({ maxParticipants: merged.config.maxParticipants });
4754
6713
  const rustCode = rustGen.generateGame(compiledState, compiledInput, compiledInitData);
4755
6714
  for (const pluginPath of merged.pluginOrder) {
4756
- const rustDir = join2(pluginPath, "src");
6715
+ const rustDir = join4(pluginPath, "src");
4757
6716
  await mkdir(rustDir, { recursive: true });
4758
- const rustPath = join2(rustDir, "generated.rs");
6717
+ const rustPath = join4(rustDir, "generated.rs");
4759
6718
  await writeFile(rustPath, rustCode, "utf-8");
4760
6719
  if (verbose) {
4761
6720
  console.log(`[multitap] Generated ${rustPath}`);
4762
6721
  }
4763
6722
  }
6723
+ const botRustDir = join4(bot.path, "src");
6724
+ await mkdir(botRustDir, { recursive: true });
6725
+ const botRustPath = join4(botRustDir, "generated.rs");
6726
+ await writeFile(botRustPath, rustCode, "utf-8");
6727
+ if (verbose) {
6728
+ console.log(`[multitap] Generated ${botRustPath}`);
6729
+ }
4764
6730
  return {
4765
6731
  compiledState,
4766
6732
  compiledInput,
4767
6733
  compiledInitData,
4768
6734
  mergedConfig: merged,
4769
- graph
6735
+ graph,
6736
+ bot
4770
6737
  };
4771
6738
  }
4772
6739
 
4773
6740
  // src/vite/wasm-compiler.ts
4774
6741
  import { spawn } from "node:child_process";
4775
- import { readFile, readdir, stat } from "node:fs/promises";
4776
- import { join as join3, basename, dirname as dirname2 } from "node:path";
6742
+ import { readFile, readdir as readdir3, stat as stat4 } from "node:fs/promises";
6743
+ import { join as join5, basename as basename3, dirname as dirname5 } from "node:path";
4777
6744
  var WASM_PAGE_SIZE = 65536;
4778
6745
  async function findCargoToml(startDir) {
4779
6746
  let dir = startDir;
4780
6747
  while (true) {
4781
- const cargoPath = join3(dir, "Cargo.toml");
6748
+ const cargoPath = join5(dir, "Cargo.toml");
4782
6749
  try {
4783
- await stat(cargoPath);
6750
+ await stat4(cargoPath);
4784
6751
  return dir;
4785
6752
  } catch {
4786
- const parent = dirname2(dir);
6753
+ const parent = dirname5(dir);
4787
6754
  if (parent === dir) {
4788
6755
  throw new Error(`Cargo.toml not found starting from ${startDir}`);
4789
6756
  }
@@ -4792,17 +6759,17 @@ async function findCargoToml(startDir) {
4792
6759
  }
4793
6760
  }
4794
6761
  async function findWasmFile(targetDir) {
4795
- const wasmDir = join3(targetDir, "wasm32-unknown-unknown", "release");
4796
- const entries = await readdir(wasmDir);
6762
+ const wasmDir = join5(targetDir, "wasm32-unknown-unknown", "release");
6763
+ const entries = await readdir3(wasmDir);
4797
6764
  for (const entry of entries) {
4798
6765
  if (entry.endsWith(".wasm")) {
4799
- return join3(wasmDir, entry);
6766
+ return join5(wasmDir, entry);
4800
6767
  }
4801
6768
  }
4802
6769
  throw new Error(`No .wasm file found in ${wasmDir}`);
4803
6770
  }
4804
6771
  function runCommand(command, args, options) {
4805
- return new Promise((resolve3, reject) => {
6772
+ return new Promise((resolve6, reject) => {
4806
6773
  const proc = spawn(command, args, {
4807
6774
  cwd: options.cwd,
4808
6775
  env: options.env,
@@ -4822,14 +6789,14 @@ function runCommand(command, args, options) {
4822
6789
  reject(new Error(`${command} exited with code ${code}
4823
6790
  ${stderr}`));
4824
6791
  } else {
4825
- resolve3();
6792
+ resolve6();
4826
6793
  }
4827
6794
  });
4828
6795
  });
4829
6796
  }
4830
6797
  async function compilePluginWasm(pluginPath, globalBase, verbose = false) {
4831
6798
  const cargoDir = await findCargoToml(pluginPath);
4832
- const targetDir = join3(cargoDir, "target");
6799
+ const targetDir = join5(cargoDir, "target");
4833
6800
  const rustFlags = `-C link-args=--import-memory -C link-args=--global-base=${globalBase} -C link-args=--stack-first`;
4834
6801
  await runCommand(
4835
6802
  "cargo",
@@ -4843,7 +6810,7 @@ async function compilePluginWasm(pluginPath, globalBase, verbose = false) {
4843
6810
  const wasmPath = await findWasmFile(targetDir);
4844
6811
  const wasmBytes = await readFile(wasmPath);
4845
6812
  return {
4846
- name: basename(pluginPath),
6813
+ name: basename3(pluginPath),
4847
6814
  wasmBytes: new Uint8Array(wasmBytes),
4848
6815
  reservedBytes: 0
4849
6816
  // Will be set by caller from config
@@ -4861,10 +6828,7 @@ function calculateGlobalBases(pluginOrder, reservedBytesMap) {
4861
6828
  return bases;
4862
6829
  }
4863
6830
 
4864
- // src/vite/module-builder.ts
4865
- function bytesToBase64(data) {
4866
- return Buffer.from(data).toString("base64");
4867
- }
6831
+ // src/vite/plugin.ts
4868
6832
  function prepareStateSchemaForSerialization(schema) {
4869
6833
  return {
4870
6834
  maxEntities: schema.maxEntities,
@@ -4895,43 +6859,66 @@ function prepareInitDataSchemaForSerialization(schema) {
4895
6859
  totalSize: schema.totalSize
4896
6860
  };
4897
6861
  }
4898
- function buildVirtualModule(options) {
4899
- const { config, plugins, compiledState, compiledInitData } = options;
4900
- const lines = [];
4901
- lines.push("function base64ToUint8Array(b64) {");
4902
- lines.push(" const binary = atob(b64);");
4903
- lines.push(" const bytes = new Uint8Array(binary.length);");
4904
- lines.push(" for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);");
4905
- lines.push(" return bytes;");
4906
- lines.push("}");
4907
- lines.push("");
4908
- lines.push("const plugins = [");
4909
- for (const p of plugins) {
4910
- lines.push(
4911
- ` { name: ${JSON.stringify(p.name)}, wasmBytes: base64ToUint8Array(${JSON.stringify(bytesToBase64(p.wasmBytes))}), reservedBytes: ${p.reservedBytes} },`
4912
- );
6862
+ function prepareInputSchemaForSerialization(schema) {
6863
+ return {
6864
+ controls: schema.controls,
6865
+ commands: schema.commands
6866
+ };
6867
+ }
6868
+ function buildManifest(assets) {
6869
+ return {
6870
+ config: "./mt.config.json",
6871
+ initData: "./mt.init.json",
6872
+ simulation: {
6873
+ plugins: assets.plugins.map((p) => ({
6874
+ name: p.name,
6875
+ url: `./${p.name}.${p.hash}.wasm`,
6876
+ hash: p.hash,
6877
+ reservedBytes: p.reservedBytes
6878
+ }))
6879
+ },
6880
+ bot: {
6881
+ url: `./bot.${assets.bot.hash}.wasm`,
6882
+ hash: assets.bot.hash,
6883
+ reservedBytes: assets.bot.reservedBytes
6884
+ }
6885
+ };
6886
+ }
6887
+ function analyzeChanges(changedFiles, root, pluginPaths, botPath) {
6888
+ const changes = [];
6889
+ for (const file of changedFiles) {
6890
+ if (file === resolve5(root, "mt.config.json")) {
6891
+ changes.push({ kind: "config" });
6892
+ continue;
6893
+ }
6894
+ for (const pluginPath of pluginPaths) {
6895
+ if (file === resolve5(pluginPath, "mt.config.json")) {
6896
+ changes.push({ kind: "config" });
6897
+ break;
6898
+ }
6899
+ }
6900
+ if (file === resolve5(root, "mt.init.json")) {
6901
+ changes.push({ kind: "init-data" });
6902
+ continue;
6903
+ }
6904
+ if (file.startsWith(botPath) && file.endsWith(".rs")) {
6905
+ changes.push({ kind: "bot-rust" });
6906
+ continue;
6907
+ }
6908
+ for (const pluginPath of pluginPaths) {
6909
+ if (file.startsWith(pluginPath) && file.endsWith(".rs")) {
6910
+ const existing = changes.find(
6911
+ (c) => c.kind === "rust" && c.pluginPath === pluginPath
6912
+ );
6913
+ if (!existing) {
6914
+ changes.push({ kind: "rust", pluginPath });
6915
+ }
6916
+ break;
6917
+ }
6918
+ }
4913
6919
  }
4914
- lines.push("];");
4915
- lines.push("");
4916
- const stateJSON = JSON.stringify(prepareStateSchemaForSerialization(compiledState));
4917
- const inputJSON = JSON.stringify(config.input);
4918
- const initDataJSON = compiledInitData ? JSON.stringify(prepareInitDataSchemaForSerialization(compiledInitData)) : "undefined";
4919
- lines.push(`const schema = { state: ${stateJSON}, input: ${inputJSON}, initData: ${initDataJSON} };`);
4920
- lines.push("");
4921
- lines.push("export default {");
4922
- lines.push(` appID: ${JSON.stringify(config.appID)},`);
4923
- lines.push(` tickRate: ${config.tickRate},`);
4924
- lines.push(` maxTicks: ${config.maxTicks},`);
4925
- lines.push(` maxParticipants: ${config.maxParticipants},`);
4926
- lines.push(" plugins,");
4927
- lines.push(" schema,");
4928
- lines.push("};");
4929
- return lines.join("\n");
6920
+ return { changes, changedFiles };
4930
6921
  }
4931
-
4932
- // src/vite/plugin.ts
4933
- var VIRTUAL_PREFIX = "\0multitap:";
4934
- var IMPORT_PATTERN = /^multitap:(.+\.json)$/;
4935
6922
  function multitapPlugin(options = {}) {
4936
6923
  const {
4937
6924
  generatedDir = "./generated",
@@ -4939,38 +6926,230 @@ function multitapPlugin(options = {}) {
4939
6926
  skipWasm = false
4940
6927
  } = options;
4941
6928
  let resolvedConfig;
6929
+ let generatedAssets = null;
6930
+ let codegenResult = null;
6931
+ let devServer = null;
6932
+ let fileWatcher = null;
6933
+ function setupFileWatcher() {
6934
+ if (!devServer || !codegenResult || skipWasm) return;
6935
+ if (fileWatcher) return;
6936
+ const root = resolvedConfig.root;
6937
+ const pluginPaths = codegenResult.mergedConfig.pluginOrder;
6938
+ const botPath = codegenResult.bot.path;
6939
+ const watchPatterns = [
6940
+ resolve5(root, "mt.config.json"),
6941
+ resolve5(root, "mt.init.json"),
6942
+ ...pluginPaths.map((p) => join6(p, "src")),
6943
+ ...pluginPaths.map((p) => resolve5(p, "mt.config.json")),
6944
+ join6(botPath, "src")
6945
+ ];
6946
+ if (verbose) {
6947
+ console.log(`[multitap] Watching: ${watchPatterns.join(", ")}`);
6948
+ }
6949
+ fileWatcher = esm_default.watch(watchPatterns, {
6950
+ ignoreInitial: true,
6951
+ awaitWriteFinish: { stabilityThreshold: 50, pollInterval: 10 }
6952
+ });
6953
+ fileWatcher.on("ready", () => {
6954
+ if (verbose) {
6955
+ console.log("[multitap] File watcher ready");
6956
+ }
6957
+ });
6958
+ fileWatcher.on("error", (err) => {
6959
+ console.error("[multitap] Watcher error:", err);
6960
+ });
6961
+ let debounceTimer = null;
6962
+ const pendingChanges = /* @__PURE__ */ new Set();
6963
+ const handleRebuild = async (files) => {
6964
+ const analysis = analyzeChanges(files, root, pluginPaths, botPath);
6965
+ if (analysis.changes.length === 0) {
6966
+ if (verbose) {
6967
+ console.log(`[multitap] No relevant changes detected in: ${files.join(", ")}`);
6968
+ }
6969
+ return;
6970
+ }
6971
+ const needsFullRebuild = analysis.changes.some((c) => c.kind === "config");
6972
+ console.log(`[multitap] Rebuilding: ${analysis.changes.map((c) => c.kind).join(", ")}`);
6973
+ if (verbose) {
6974
+ console.log(`[multitap] Changed files: ${files.join(", ")}`);
6975
+ }
6976
+ try {
6977
+ if (needsFullRebuild) {
6978
+ if (verbose) {
6979
+ console.log("[multitap] Full rebuild triggered by config change");
6980
+ }
6981
+ const configPath = resolve5(root, "mt.config.json");
6982
+ codegenResult = await runCodegen(configPath, {
6983
+ generatedDir: resolve5(root, generatedDir),
6984
+ verbose
6985
+ });
6986
+ const reservedBytesMap = /* @__PURE__ */ new Map();
6987
+ for (const [pluginPath, node] of codegenResult.graph.plugins) {
6988
+ reservedBytesMap.set(pluginPath, node.config.wasm.reservedBytes);
6989
+ }
6990
+ const globalBases = calculateGlobalBases(codegenResult.mergedConfig.pluginOrder, reservedBytesMap);
6991
+ let totalSimulationBytes = 0;
6992
+ const newPlugins = [];
6993
+ for (const pluginPath of codegenResult.mergedConfig.pluginOrder) {
6994
+ const globalBase = globalBases.get(pluginPath);
6995
+ const reservedBytes = reservedBytesMap.get(pluginPath);
6996
+ if (verbose) {
6997
+ console.log(`[multitap] Recompiling ${pluginPath}`);
6998
+ }
6999
+ const result = await compilePluginWasm(pluginPath, globalBase, verbose);
7000
+ const hash = createHash("sha256").update(result.wasmBytes).digest("hex").slice(0, 8);
7001
+ newPlugins.push({
7002
+ name: result.name,
7003
+ wasmBytes: result.wasmBytes,
7004
+ hash,
7005
+ reservedBytes
7006
+ });
7007
+ totalSimulationBytes += Math.ceil(reservedBytes / WASM_PAGE_SIZE) * WASM_PAGE_SIZE;
7008
+ }
7009
+ const botGlobalBase = totalSimulationBytes;
7010
+ const botResult = await compilePluginWasm(codegenResult.bot.path, botGlobalBase, verbose);
7011
+ const botHash = createHash("sha256").update(botResult.wasmBytes).digest("hex").slice(0, 8);
7012
+ const initDataPath = resolve5(dirname6(configPath), "mt.init.json");
7013
+ const initData = JSON.parse(await readFile2(initDataPath, "utf-8"));
7014
+ const configFile = {
7015
+ appID: codegenResult.mergedConfig.config.appID,
7016
+ tickRate: codegenResult.mergedConfig.config.tickRate,
7017
+ maxTicks: codegenResult.mergedConfig.config.maxTicks,
7018
+ maxParticipants: codegenResult.mergedConfig.config.maxParticipants,
7019
+ schema: {
7020
+ state: prepareStateSchemaForSerialization(codegenResult.compiledState),
7021
+ input: prepareInputSchemaForSerialization(codegenResult.compiledInput),
7022
+ ...codegenResult.compiledInitData && {
7023
+ initData: prepareInitDataSchemaForSerialization(codegenResult.compiledInitData)
7024
+ }
7025
+ }
7026
+ };
7027
+ generatedAssets = {
7028
+ config: configFile,
7029
+ initData,
7030
+ plugins: newPlugins,
7031
+ bot: {
7032
+ wasmBytes: botResult.wasmBytes,
7033
+ hash: botHash,
7034
+ reservedBytes: codegenResult.bot.reservedBytes
7035
+ }
7036
+ };
7037
+ } else {
7038
+ const initDataChanged = analysis.changes.some((c) => c.kind === "init-data");
7039
+ const rustChanges = analysis.changes.filter((c) => c.kind === "rust");
7040
+ const botRustChanged = analysis.changes.some((c) => c.kind === "bot-rust");
7041
+ if (initDataChanged) {
7042
+ if (verbose) {
7043
+ console.log("[multitap] Reloading init data");
7044
+ }
7045
+ const initDataPath = resolve5(root, "mt.init.json");
7046
+ generatedAssets.initData = JSON.parse(await readFile2(initDataPath, "utf-8"));
7047
+ }
7048
+ if (rustChanges.length > 0 && codegenResult && generatedAssets) {
7049
+ const reservedBytesMap = /* @__PURE__ */ new Map();
7050
+ for (const [pluginPath, node] of codegenResult.graph.plugins) {
7051
+ reservedBytesMap.set(pluginPath, node.config.wasm.reservedBytes);
7052
+ }
7053
+ const globalBases = calculateGlobalBases(codegenResult.mergedConfig.pluginOrder, reservedBytesMap);
7054
+ for (const change of rustChanges) {
7055
+ const globalBase = globalBases.get(change.pluginPath);
7056
+ const reservedBytes = reservedBytesMap.get(change.pluginPath);
7057
+ if (verbose) {
7058
+ console.log(`[multitap] Recompiling ${change.pluginPath}`);
7059
+ }
7060
+ const result = await compilePluginWasm(change.pluginPath, globalBase, verbose);
7061
+ const hash = createHash("sha256").update(result.wasmBytes).digest("hex").slice(0, 8);
7062
+ const pluginIndex = generatedAssets.plugins.findIndex((p) => p.name === result.name);
7063
+ if (pluginIndex !== -1) {
7064
+ generatedAssets.plugins[pluginIndex] = {
7065
+ name: result.name,
7066
+ wasmBytes: result.wasmBytes,
7067
+ hash,
7068
+ reservedBytes
7069
+ };
7070
+ }
7071
+ }
7072
+ }
7073
+ if (botRustChanged && codegenResult && generatedAssets) {
7074
+ let totalSimulationBytes = 0;
7075
+ for (const plugin of generatedAssets.plugins) {
7076
+ totalSimulationBytes += Math.ceil(plugin.reservedBytes / WASM_PAGE_SIZE) * WASM_PAGE_SIZE;
7077
+ }
7078
+ const botGlobalBase = totalSimulationBytes;
7079
+ if (verbose) {
7080
+ console.log(`[multitap] Recompiling bot ${codegenResult.bot.path}`);
7081
+ }
7082
+ const botResult = await compilePluginWasm(codegenResult.bot.path, botGlobalBase, verbose);
7083
+ const botHash = createHash("sha256").update(botResult.wasmBytes).digest("hex").slice(0, 8);
7084
+ generatedAssets.bot = {
7085
+ wasmBytes: botResult.wasmBytes,
7086
+ hash: botHash,
7087
+ reservedBytes: codegenResult.bot.reservedBytes
7088
+ };
7089
+ }
7090
+ }
7091
+ console.log("[multitap] Reloading page");
7092
+ devServer.ws.send({ type: "full-reload" });
7093
+ } catch (error) {
7094
+ const err = error instanceof Error ? error : new Error(String(error));
7095
+ console.error(`[multitap] Rebuild failed:`, err.message);
7096
+ devServer.ws.send({
7097
+ type: "error",
7098
+ err: {
7099
+ message: err.message,
7100
+ stack: err.stack || "",
7101
+ plugin: "vite-plugin-multitap"
7102
+ }
7103
+ });
7104
+ }
7105
+ };
7106
+ fileWatcher.on("change", (file) => {
7107
+ if (verbose) {
7108
+ console.log(`[multitap] File changed: ${file}`);
7109
+ }
7110
+ pendingChanges.add(file);
7111
+ if (debounceTimer) clearTimeout(debounceTimer);
7112
+ debounceTimer = setTimeout(() => {
7113
+ const files = [...pendingChanges];
7114
+ pendingChanges.clear();
7115
+ void handleRebuild(files);
7116
+ }, 100);
7117
+ });
7118
+ devServer.httpServer?.on("close", () => {
7119
+ void fileWatcher?.close();
7120
+ });
7121
+ }
4942
7122
  return {
4943
7123
  name: "vite-plugin-multitap",
4944
- // Run before other plugins (especially vite:json) to intercept multitap: imports
4945
7124
  enforce: "pre",
4946
7125
  configResolved(config) {
4947
7126
  resolvedConfig = config;
4948
7127
  },
4949
- resolveId(source, importer) {
4950
- const match = source.match(IMPORT_PATTERN);
4951
- if (!match || !match[1]) return null;
4952
- const relativePath = match[1];
4953
- const resolveDir = importer ? dirname3(importer) : resolvedConfig.root;
4954
- const absolutePath = resolve2(resolveDir, relativePath);
4955
- return VIRTUAL_PREFIX + absolutePath.replace(/\.json$/, "");
4956
- },
4957
- async load(id) {
4958
- if (!id.startsWith(VIRTUAL_PREFIX)) return null;
4959
- const absoluteConfigPath = id.slice(VIRTUAL_PREFIX.length) + ".json";
7128
+ /**
7129
+ * Run codegen and WASM compilation at build start.
7130
+ */
7131
+ async buildStart() {
7132
+ const configPath = resolve5(resolvedConfig.root, "mt.config.json");
4960
7133
  if (verbose) {
4961
- console.log(`[multitap] Building config: ${absoluteConfigPath}`);
7134
+ console.log(`[multitap] Building config: ${configPath}`);
4962
7135
  }
4963
- const codegenResult = await runCodegen(absoluteConfigPath, {
4964
- generatedDir: resolve2(resolvedConfig.root, generatedDir),
7136
+ codegenResult = await runCodegen(configPath, {
7137
+ generatedDir: resolve5(resolvedConfig.root, generatedDir),
4965
7138
  verbose
4966
7139
  });
4967
7140
  const plugins = [];
7141
+ let bot = {
7142
+ wasmBytes: new Uint8Array(),
7143
+ hash: "00000000",
7144
+ reservedBytes: codegenResult.bot.reservedBytes
7145
+ };
4968
7146
  if (!skipWasm) {
4969
7147
  const reservedBytesMap = /* @__PURE__ */ new Map();
4970
7148
  for (const [pluginPath, node] of codegenResult.graph.plugins) {
4971
7149
  reservedBytesMap.set(pluginPath, node.config.wasm.reservedBytes);
4972
7150
  }
4973
7151
  const globalBases = calculateGlobalBases(codegenResult.mergedConfig.pluginOrder, reservedBytesMap);
7152
+ let totalSimulationBytes = 0;
4974
7153
  for (const pluginPath of codegenResult.mergedConfig.pluginOrder) {
4975
7154
  const globalBase = globalBases.get(pluginPath);
4976
7155
  const reservedBytes = reservedBytesMap.get(pluginPath);
@@ -4978,20 +7157,134 @@ function multitapPlugin(options = {}) {
4978
7157
  console.log(`[multitap] Compiling ${pluginPath} (globalBase=${globalBase})`);
4979
7158
  }
4980
7159
  const result = await compilePluginWasm(pluginPath, globalBase, verbose);
4981
- result.reservedBytes = reservedBytes;
4982
- plugins.push(result);
7160
+ const hash = createHash("sha256").update(result.wasmBytes).digest("hex").slice(0, 8);
7161
+ plugins.push({
7162
+ name: result.name,
7163
+ wasmBytes: result.wasmBytes,
7164
+ hash,
7165
+ reservedBytes
7166
+ });
7167
+ totalSimulationBytes += Math.ceil(reservedBytes / WASM_PAGE_SIZE) * WASM_PAGE_SIZE;
4983
7168
  }
7169
+ const botGlobalBase = totalSimulationBytes;
7170
+ if (verbose) {
7171
+ console.log(`[multitap] Compiling bot ${codegenResult.bot.path} (globalBase=${botGlobalBase})`);
7172
+ }
7173
+ const botResult = await compilePluginWasm(codegenResult.bot.path, botGlobalBase, verbose);
7174
+ const botHash = createHash("sha256").update(botResult.wasmBytes).digest("hex").slice(0, 8);
7175
+ bot = {
7176
+ wasmBytes: botResult.wasmBytes,
7177
+ hash: botHash,
7178
+ reservedBytes: codegenResult.bot.reservedBytes
7179
+ };
4984
7180
  }
4985
- const moduleCode = buildVirtualModule({
4986
- config: codegenResult.mergedConfig.config,
7181
+ const initDataPath = resolve5(dirname6(configPath), "mt.init.json");
7182
+ const initData = JSON.parse(await readFile2(initDataPath, "utf-8"));
7183
+ const configFile = {
7184
+ appID: codegenResult.mergedConfig.config.appID,
7185
+ tickRate: codegenResult.mergedConfig.config.tickRate,
7186
+ maxTicks: codegenResult.mergedConfig.config.maxTicks,
7187
+ maxParticipants: codegenResult.mergedConfig.config.maxParticipants,
7188
+ schema: {
7189
+ state: prepareStateSchemaForSerialization(codegenResult.compiledState),
7190
+ input: prepareInputSchemaForSerialization(codegenResult.compiledInput),
7191
+ ...codegenResult.compiledInitData && {
7192
+ initData: prepareInitDataSchemaForSerialization(codegenResult.compiledInitData)
7193
+ }
7194
+ }
7195
+ };
7196
+ generatedAssets = {
7197
+ config: configFile,
7198
+ initData,
4987
7199
  plugins,
4988
- compiledState: codegenResult.compiledState,
4989
- compiledInitData: codegenResult.compiledInitData
4990
- });
7200
+ bot
7201
+ };
4991
7202
  if (verbose) {
4992
7203
  console.log(`[multitap] Build complete`);
4993
7204
  }
4994
- return moduleCode;
7205
+ setupFileWatcher();
7206
+ },
7207
+ /**
7208
+ * Serve generated files in dev mode via middleware.
7209
+ */
7210
+ configureServer(server) {
7211
+ devServer = server;
7212
+ setupFileWatcher();
7213
+ server.middlewares.use((req, res, next) => {
7214
+ if (!generatedAssets) return next();
7215
+ const url = req.url || "";
7216
+ if (url === "/mt.manifest.json") {
7217
+ const manifest = buildManifest(generatedAssets);
7218
+ res.setHeader("Content-Type", "application/json");
7219
+ res.setHeader("Cache-Control", "no-cache");
7220
+ res.end(JSON.stringify(manifest, null, 2));
7221
+ return;
7222
+ }
7223
+ if (url === "/mt.config.json") {
7224
+ res.setHeader("Content-Type", "application/json");
7225
+ res.setHeader("Cache-Control", "no-cache");
7226
+ res.end(JSON.stringify(generatedAssets.config, null, 2));
7227
+ return;
7228
+ }
7229
+ if (url === "/mt.init.json") {
7230
+ res.setHeader("Content-Type", "application/json");
7231
+ res.setHeader("Cache-Control", "no-cache");
7232
+ res.end(JSON.stringify(generatedAssets.initData, null, 2));
7233
+ return;
7234
+ }
7235
+ const wasmMatch = url.match(/^\/([^/]+)\.([a-f0-9]+)\.wasm$/);
7236
+ if (wasmMatch) {
7237
+ const [, name, hash] = wasmMatch;
7238
+ const plugin = generatedAssets.plugins.find((p) => p.name === name && p.hash === hash);
7239
+ if (plugin) {
7240
+ res.setHeader("Content-Type", "application/wasm");
7241
+ res.setHeader("Cache-Control", "no-cache");
7242
+ res.end(Buffer.from(plugin.wasmBytes));
7243
+ return;
7244
+ }
7245
+ if (name === "bot" && hash === generatedAssets.bot.hash) {
7246
+ res.setHeader("Content-Type", "application/wasm");
7247
+ res.setHeader("Cache-Control", "no-cache");
7248
+ res.end(Buffer.from(generatedAssets.bot.wasmBytes));
7249
+ return;
7250
+ }
7251
+ }
7252
+ next();
7253
+ });
7254
+ },
7255
+ /**
7256
+ * Emit generated files in production build.
7257
+ */
7258
+ generateBundle() {
7259
+ if (!generatedAssets) return;
7260
+ for (const plugin of generatedAssets.plugins) {
7261
+ this.emitFile({
7262
+ type: "asset",
7263
+ fileName: `${plugin.name}.${plugin.hash}.wasm`,
7264
+ source: plugin.wasmBytes
7265
+ });
7266
+ }
7267
+ this.emitFile({
7268
+ type: "asset",
7269
+ fileName: `bot.${generatedAssets.bot.hash}.wasm`,
7270
+ source: generatedAssets.bot.wasmBytes
7271
+ });
7272
+ const manifest = buildManifest(generatedAssets);
7273
+ this.emitFile({
7274
+ type: "asset",
7275
+ fileName: "mt.manifest.json",
7276
+ source: JSON.stringify(manifest, null, 2)
7277
+ });
7278
+ this.emitFile({
7279
+ type: "asset",
7280
+ fileName: "mt.config.json",
7281
+ source: JSON.stringify(generatedAssets.config, null, 2)
7282
+ });
7283
+ this.emitFile({
7284
+ type: "asset",
7285
+ fileName: "mt.init.json",
7286
+ source: JSON.stringify(generatedAssets.initData, null, 2)
7287
+ });
4995
7288
  }
4996
7289
  };
4997
7290
  }