@playcademy/vite-plugin 0.0.1-beta.3 → 0.0.1-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -18,6 +18,76 @@ var __toESM = (mod, isNodeMode, target) => {
18
18
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
19
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
20
20
 
21
+ // ../../node_modules/picocolors/picocolors.js
22
+ var require_picocolors = __commonJS((exports, module) => {
23
+ var p = process || {};
24
+ var argv = p.argv || [];
25
+ var env = p.env || {};
26
+ var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
27
+ var formatter = (open, close, replace = open) => (input) => {
28
+ let string = "" + input, index = string.indexOf(close, open.length);
29
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
30
+ };
31
+ var replaceClose = (string, close, replace, index) => {
32
+ let result = "", cursor = 0;
33
+ do {
34
+ result += string.substring(cursor, index) + replace;
35
+ cursor = index + close.length;
36
+ index = string.indexOf(close, cursor);
37
+ } while (~index);
38
+ return result + string.substring(cursor);
39
+ };
40
+ var createColors = (enabled = isColorSupported) => {
41
+ let f = enabled ? formatter : () => String;
42
+ return {
43
+ isColorSupported: enabled,
44
+ reset: f("\x1B[0m", "\x1B[0m"),
45
+ bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
46
+ dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
47
+ italic: f("\x1B[3m", "\x1B[23m"),
48
+ underline: f("\x1B[4m", "\x1B[24m"),
49
+ inverse: f("\x1B[7m", "\x1B[27m"),
50
+ hidden: f("\x1B[8m", "\x1B[28m"),
51
+ strikethrough: f("\x1B[9m", "\x1B[29m"),
52
+ black: f("\x1B[30m", "\x1B[39m"),
53
+ red: f("\x1B[31m", "\x1B[39m"),
54
+ green: f("\x1B[32m", "\x1B[39m"),
55
+ yellow: f("\x1B[33m", "\x1B[39m"),
56
+ blue: f("\x1B[34m", "\x1B[39m"),
57
+ magenta: f("\x1B[35m", "\x1B[39m"),
58
+ cyan: f("\x1B[36m", "\x1B[39m"),
59
+ white: f("\x1B[37m", "\x1B[39m"),
60
+ gray: f("\x1B[90m", "\x1B[39m"),
61
+ bgBlack: f("\x1B[40m", "\x1B[49m"),
62
+ bgRed: f("\x1B[41m", "\x1B[49m"),
63
+ bgGreen: f("\x1B[42m", "\x1B[49m"),
64
+ bgYellow: f("\x1B[43m", "\x1B[49m"),
65
+ bgBlue: f("\x1B[44m", "\x1B[49m"),
66
+ bgMagenta: f("\x1B[45m", "\x1B[49m"),
67
+ bgCyan: f("\x1B[46m", "\x1B[49m"),
68
+ bgWhite: f("\x1B[47m", "\x1B[49m"),
69
+ blackBright: f("\x1B[90m", "\x1B[39m"),
70
+ redBright: f("\x1B[91m", "\x1B[39m"),
71
+ greenBright: f("\x1B[92m", "\x1B[39m"),
72
+ yellowBright: f("\x1B[93m", "\x1B[39m"),
73
+ blueBright: f("\x1B[94m", "\x1B[39m"),
74
+ magentaBright: f("\x1B[95m", "\x1B[39m"),
75
+ cyanBright: f("\x1B[96m", "\x1B[39m"),
76
+ whiteBright: f("\x1B[97m", "\x1B[39m"),
77
+ bgBlackBright: f("\x1B[100m", "\x1B[49m"),
78
+ bgRedBright: f("\x1B[101m", "\x1B[49m"),
79
+ bgGreenBright: f("\x1B[102m", "\x1B[49m"),
80
+ bgYellowBright: f("\x1B[103m", "\x1B[49m"),
81
+ bgBlueBright: f("\x1B[104m", "\x1B[49m"),
82
+ bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
83
+ bgCyanBright: f("\x1B[106m", "\x1B[49m"),
84
+ bgWhiteBright: f("\x1B[107m", "\x1B[49m")
85
+ };
86
+ };
87
+ module.exports = createColors();
88
+ module.exports.createColors = createColors;
89
+ });
90
+
21
91
  // ../../node_modules/readdir-glob/node_modules/minimatch/lib/path.js
22
92
  var require_path = __commonJS((exports, module) => {
23
93
  var isWindows = typeof process === "object" && process && process.platform === "win32";
@@ -240,8 +310,8 @@ var require_minimatch = __commonJS((exports, module) => {
240
310
  return new Minimatch(pattern, options).match(p);
241
311
  };
242
312
  module.exports = minimatch;
243
- var path = require_path();
244
- minimatch.sep = path.sep;
313
+ var path2 = require_path();
314
+ minimatch.sep = path2.sep;
245
315
  var GLOBSTAR = Symbol("globstar **");
246
316
  minimatch.GLOBSTAR = GLOBSTAR;
247
317
  var expand = require_brace_expansion();
@@ -755,8 +825,8 @@ globstar while`, file, fr, pattern, pr, swallowee);
755
825
  if (f === "/" && partial)
756
826
  return true;
757
827
  const options = this.options;
758
- if (path.sep !== "/") {
759
- f = f.split(path.sep).join("/");
828
+ if (path2.sep !== "/") {
829
+ f = f.split(path2.sep).join("/");
760
830
  }
761
831
  f = f.split(slashSplit);
762
832
  this.debug(this.pattern, "split", f);
@@ -795,13 +865,13 @@ globstar while`, file, fr, pattern, pr, swallowee);
795
865
  // ../../node_modules/readdir-glob/index.js
796
866
  var require_readdir_glob = __commonJS((exports, module) => {
797
867
  module.exports = readdirGlob;
798
- var fs = __require("fs");
868
+ var fs2 = __require("fs");
799
869
  var { EventEmitter } = __require("events");
800
870
  var { Minimatch } = require_minimatch();
801
871
  var { resolve } = __require("path");
802
872
  function readdir(dir, strict) {
803
873
  return new Promise((resolve2, reject) => {
804
- fs.readdir(dir, { withFileTypes: true }, (err, files) => {
874
+ fs2.readdir(dir, { withFileTypes: true }, (err, files) => {
805
875
  if (err) {
806
876
  switch (err.code) {
807
877
  case "ENOTDIR":
@@ -830,7 +900,7 @@ var require_readdir_glob = __commonJS((exports, module) => {
830
900
  }
831
901
  function stat(file, followSymlinks) {
832
902
  return new Promise((resolve2, reject) => {
833
- const statFunc = followSymlinks ? fs.stat : fs.lstat;
903
+ const statFunc = followSymlinks ? fs2.stat : fs2.lstat;
834
904
  statFunc(file, (err, stats) => {
835
905
  if (err) {
836
906
  switch (err.code) {
@@ -851,8 +921,8 @@ var require_readdir_glob = __commonJS((exports, module) => {
851
921
  });
852
922
  });
853
923
  }
854
- async function* exploreWalkAsync(dir, path, followSymlinks, useStat, shouldSkip, strict) {
855
- let files = await readdir(path + dir, strict);
924
+ async function* exploreWalkAsync(dir, path2, followSymlinks, useStat, shouldSkip, strict) {
925
+ let files = await readdir(path2 + dir, strict);
856
926
  for (const file of files) {
857
927
  let name = file.name;
858
928
  if (name === undefined) {
@@ -861,7 +931,7 @@ var require_readdir_glob = __commonJS((exports, module) => {
861
931
  }
862
932
  const filename = dir + "/" + name;
863
933
  const relative = filename.slice(1);
864
- const absolute = path + "/" + relative;
934
+ const absolute = path2 + "/" + relative;
865
935
  let stats = null;
866
936
  if (useStat || followSymlinks) {
867
937
  stats = await stat(absolute, followSymlinks);
@@ -875,15 +945,15 @@ var require_readdir_glob = __commonJS((exports, module) => {
875
945
  if (stats.isDirectory()) {
876
946
  if (!shouldSkip(relative)) {
877
947
  yield { relative, absolute, stats };
878
- yield* exploreWalkAsync(filename, path, followSymlinks, useStat, shouldSkip, false);
948
+ yield* exploreWalkAsync(filename, path2, followSymlinks, useStat, shouldSkip, false);
879
949
  }
880
950
  } else {
881
951
  yield { relative, absolute, stats };
882
952
  }
883
953
  }
884
954
  }
885
- async function* explore(path, followSymlinks, useStat, shouldSkip) {
886
- yield* exploreWalkAsync("", path, followSymlinks, useStat, shouldSkip, true);
955
+ async function* explore(path2, followSymlinks, useStat, shouldSkip) {
956
+ yield* exploreWalkAsync("", path2, followSymlinks, useStat, shouldSkip, true);
887
957
  }
888
958
  function readOptions(options) {
889
959
  return {
@@ -2954,54 +3024,54 @@ var require_polyfills = __commonJS((exports, module) => {
2954
3024
  }
2955
3025
  var chdir;
2956
3026
  module.exports = patch;
2957
- function patch(fs) {
3027
+ function patch(fs2) {
2958
3028
  if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
2959
- patchLchmod(fs);
2960
- }
2961
- if (!fs.lutimes) {
2962
- patchLutimes(fs);
2963
- }
2964
- fs.chown = chownFix(fs.chown);
2965
- fs.fchown = chownFix(fs.fchown);
2966
- fs.lchown = chownFix(fs.lchown);
2967
- fs.chmod = chmodFix(fs.chmod);
2968
- fs.fchmod = chmodFix(fs.fchmod);
2969
- fs.lchmod = chmodFix(fs.lchmod);
2970
- fs.chownSync = chownFixSync(fs.chownSync);
2971
- fs.fchownSync = chownFixSync(fs.fchownSync);
2972
- fs.lchownSync = chownFixSync(fs.lchownSync);
2973
- fs.chmodSync = chmodFixSync(fs.chmodSync);
2974
- fs.fchmodSync = chmodFixSync(fs.fchmodSync);
2975
- fs.lchmodSync = chmodFixSync(fs.lchmodSync);
2976
- fs.stat = statFix(fs.stat);
2977
- fs.fstat = statFix(fs.fstat);
2978
- fs.lstat = statFix(fs.lstat);
2979
- fs.statSync = statFixSync(fs.statSync);
2980
- fs.fstatSync = statFixSync(fs.fstatSync);
2981
- fs.lstatSync = statFixSync(fs.lstatSync);
2982
- if (fs.chmod && !fs.lchmod) {
2983
- fs.lchmod = function(path, mode, cb) {
3029
+ patchLchmod(fs2);
3030
+ }
3031
+ if (!fs2.lutimes) {
3032
+ patchLutimes(fs2);
3033
+ }
3034
+ fs2.chown = chownFix(fs2.chown);
3035
+ fs2.fchown = chownFix(fs2.fchown);
3036
+ fs2.lchown = chownFix(fs2.lchown);
3037
+ fs2.chmod = chmodFix(fs2.chmod);
3038
+ fs2.fchmod = chmodFix(fs2.fchmod);
3039
+ fs2.lchmod = chmodFix(fs2.lchmod);
3040
+ fs2.chownSync = chownFixSync(fs2.chownSync);
3041
+ fs2.fchownSync = chownFixSync(fs2.fchownSync);
3042
+ fs2.lchownSync = chownFixSync(fs2.lchownSync);
3043
+ fs2.chmodSync = chmodFixSync(fs2.chmodSync);
3044
+ fs2.fchmodSync = chmodFixSync(fs2.fchmodSync);
3045
+ fs2.lchmodSync = chmodFixSync(fs2.lchmodSync);
3046
+ fs2.stat = statFix(fs2.stat);
3047
+ fs2.fstat = statFix(fs2.fstat);
3048
+ fs2.lstat = statFix(fs2.lstat);
3049
+ fs2.statSync = statFixSync(fs2.statSync);
3050
+ fs2.fstatSync = statFixSync(fs2.fstatSync);
3051
+ fs2.lstatSync = statFixSync(fs2.lstatSync);
3052
+ if (fs2.chmod && !fs2.lchmod) {
3053
+ fs2.lchmod = function(path2, mode, cb) {
2984
3054
  if (cb)
2985
3055
  process.nextTick(cb);
2986
3056
  };
2987
- fs.lchmodSync = function() {};
3057
+ fs2.lchmodSync = function() {};
2988
3058
  }
2989
- if (fs.chown && !fs.lchown) {
2990
- fs.lchown = function(path, uid, gid, cb) {
3059
+ if (fs2.chown && !fs2.lchown) {
3060
+ fs2.lchown = function(path2, uid, gid, cb) {
2991
3061
  if (cb)
2992
3062
  process.nextTick(cb);
2993
3063
  };
2994
- fs.lchownSync = function() {};
3064
+ fs2.lchownSync = function() {};
2995
3065
  }
2996
3066
  if (platform === "win32") {
2997
- fs.rename = typeof fs.rename !== "function" ? fs.rename : function(fs$rename) {
3067
+ fs2.rename = typeof fs2.rename !== "function" ? fs2.rename : function(fs$rename) {
2998
3068
  function rename(from, to, cb) {
2999
3069
  var start = Date.now();
3000
3070
  var backoff = 0;
3001
3071
  fs$rename(from, to, function CB(er) {
3002
3072
  if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 60000) {
3003
3073
  setTimeout(function() {
3004
- fs.stat(to, function(stater, st) {
3074
+ fs2.stat(to, function(stater, st) {
3005
3075
  if (stater && stater.code === "ENOENT")
3006
3076
  fs$rename(from, to, CB);
3007
3077
  else
@@ -3019,9 +3089,9 @@ var require_polyfills = __commonJS((exports, module) => {
3019
3089
  if (Object.setPrototypeOf)
3020
3090
  Object.setPrototypeOf(rename, fs$rename);
3021
3091
  return rename;
3022
- }(fs.rename);
3092
+ }(fs2.rename);
3023
3093
  }
3024
- fs.read = typeof fs.read !== "function" ? fs.read : function(fs$read) {
3094
+ fs2.read = typeof fs2.read !== "function" ? fs2.read : function(fs$read) {
3025
3095
  function read(fd, buffer, offset, length, position, callback_) {
3026
3096
  var callback;
3027
3097
  if (callback_ && typeof callback_ === "function") {
@@ -3029,23 +3099,23 @@ var require_polyfills = __commonJS((exports, module) => {
3029
3099
  callback = function(er, _2, __) {
3030
3100
  if (er && er.code === "EAGAIN" && eagCounter < 10) {
3031
3101
  eagCounter++;
3032
- return fs$read.call(fs, fd, buffer, offset, length, position, callback);
3102
+ return fs$read.call(fs2, fd, buffer, offset, length, position, callback);
3033
3103
  }
3034
3104
  callback_.apply(this, arguments);
3035
3105
  };
3036
3106
  }
3037
- return fs$read.call(fs, fd, buffer, offset, length, position, callback);
3107
+ return fs$read.call(fs2, fd, buffer, offset, length, position, callback);
3038
3108
  }
3039
3109
  if (Object.setPrototypeOf)
3040
3110
  Object.setPrototypeOf(read, fs$read);
3041
3111
  return read;
3042
- }(fs.read);
3043
- fs.readSync = typeof fs.readSync !== "function" ? fs.readSync : function(fs$readSync) {
3112
+ }(fs2.read);
3113
+ fs2.readSync = typeof fs2.readSync !== "function" ? fs2.readSync : function(fs$readSync) {
3044
3114
  return function(fd, buffer, offset, length, position) {
3045
3115
  var eagCounter = 0;
3046
3116
  while (true) {
3047
3117
  try {
3048
- return fs$readSync.call(fs, fd, buffer, offset, length, position);
3118
+ return fs$readSync.call(fs2, fd, buffer, offset, length, position);
3049
3119
  } catch (er) {
3050
3120
  if (er.code === "EAGAIN" && eagCounter < 10) {
3051
3121
  eagCounter++;
@@ -3055,90 +3125,90 @@ var require_polyfills = __commonJS((exports, module) => {
3055
3125
  }
3056
3126
  }
3057
3127
  };
3058
- }(fs.readSync);
3059
- function patchLchmod(fs2) {
3060
- fs2.lchmod = function(path, mode, callback) {
3061
- fs2.open(path, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
3128
+ }(fs2.readSync);
3129
+ function patchLchmod(fs3) {
3130
+ fs3.lchmod = function(path2, mode, callback) {
3131
+ fs3.open(path2, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
3062
3132
  if (err) {
3063
3133
  if (callback)
3064
3134
  callback(err);
3065
3135
  return;
3066
3136
  }
3067
- fs2.fchmod(fd, mode, function(err2) {
3068
- fs2.close(fd, function(err22) {
3137
+ fs3.fchmod(fd, mode, function(err2) {
3138
+ fs3.close(fd, function(err22) {
3069
3139
  if (callback)
3070
3140
  callback(err2 || err22);
3071
3141
  });
3072
3142
  });
3073
3143
  });
3074
3144
  };
3075
- fs2.lchmodSync = function(path, mode) {
3076
- var fd = fs2.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
3145
+ fs3.lchmodSync = function(path2, mode) {
3146
+ var fd = fs3.openSync(path2, constants.O_WRONLY | constants.O_SYMLINK, mode);
3077
3147
  var threw = true;
3078
3148
  var ret;
3079
3149
  try {
3080
- ret = fs2.fchmodSync(fd, mode);
3150
+ ret = fs3.fchmodSync(fd, mode);
3081
3151
  threw = false;
3082
3152
  } finally {
3083
3153
  if (threw) {
3084
3154
  try {
3085
- fs2.closeSync(fd);
3155
+ fs3.closeSync(fd);
3086
3156
  } catch (er) {}
3087
3157
  } else {
3088
- fs2.closeSync(fd);
3158
+ fs3.closeSync(fd);
3089
3159
  }
3090
3160
  }
3091
3161
  return ret;
3092
3162
  };
3093
3163
  }
3094
- function patchLutimes(fs2) {
3095
- if (constants.hasOwnProperty("O_SYMLINK") && fs2.futimes) {
3096
- fs2.lutimes = function(path, at, mt, cb) {
3097
- fs2.open(path, constants.O_SYMLINK, function(er, fd) {
3164
+ function patchLutimes(fs3) {
3165
+ if (constants.hasOwnProperty("O_SYMLINK") && fs3.futimes) {
3166
+ fs3.lutimes = function(path2, at, mt, cb) {
3167
+ fs3.open(path2, constants.O_SYMLINK, function(er, fd) {
3098
3168
  if (er) {
3099
3169
  if (cb)
3100
3170
  cb(er);
3101
3171
  return;
3102
3172
  }
3103
- fs2.futimes(fd, at, mt, function(er2) {
3104
- fs2.close(fd, function(er22) {
3173
+ fs3.futimes(fd, at, mt, function(er2) {
3174
+ fs3.close(fd, function(er22) {
3105
3175
  if (cb)
3106
3176
  cb(er2 || er22);
3107
3177
  });
3108
3178
  });
3109
3179
  });
3110
3180
  };
3111
- fs2.lutimesSync = function(path, at, mt) {
3112
- var fd = fs2.openSync(path, constants.O_SYMLINK);
3181
+ fs3.lutimesSync = function(path2, at, mt) {
3182
+ var fd = fs3.openSync(path2, constants.O_SYMLINK);
3113
3183
  var ret;
3114
3184
  var threw = true;
3115
3185
  try {
3116
- ret = fs2.futimesSync(fd, at, mt);
3186
+ ret = fs3.futimesSync(fd, at, mt);
3117
3187
  threw = false;
3118
3188
  } finally {
3119
3189
  if (threw) {
3120
3190
  try {
3121
- fs2.closeSync(fd);
3191
+ fs3.closeSync(fd);
3122
3192
  } catch (er) {}
3123
3193
  } else {
3124
- fs2.closeSync(fd);
3194
+ fs3.closeSync(fd);
3125
3195
  }
3126
3196
  }
3127
3197
  return ret;
3128
3198
  };
3129
- } else if (fs2.futimes) {
3130
- fs2.lutimes = function(_a, _b, _c, cb) {
3199
+ } else if (fs3.futimes) {
3200
+ fs3.lutimes = function(_a, _b, _c, cb) {
3131
3201
  if (cb)
3132
3202
  process.nextTick(cb);
3133
3203
  };
3134
- fs2.lutimesSync = function() {};
3204
+ fs3.lutimesSync = function() {};
3135
3205
  }
3136
3206
  }
3137
3207
  function chmodFix(orig) {
3138
3208
  if (!orig)
3139
3209
  return orig;
3140
3210
  return function(target, mode, cb) {
3141
- return orig.call(fs, target, mode, function(er) {
3211
+ return orig.call(fs2, target, mode, function(er) {
3142
3212
  if (chownErOk(er))
3143
3213
  er = null;
3144
3214
  if (cb)
@@ -3151,7 +3221,7 @@ var require_polyfills = __commonJS((exports, module) => {
3151
3221
  return orig;
3152
3222
  return function(target, mode) {
3153
3223
  try {
3154
- return orig.call(fs, target, mode);
3224
+ return orig.call(fs2, target, mode);
3155
3225
  } catch (er) {
3156
3226
  if (!chownErOk(er))
3157
3227
  throw er;
@@ -3162,7 +3232,7 @@ var require_polyfills = __commonJS((exports, module) => {
3162
3232
  if (!orig)
3163
3233
  return orig;
3164
3234
  return function(target, uid, gid, cb) {
3165
- return orig.call(fs, target, uid, gid, function(er) {
3235
+ return orig.call(fs2, target, uid, gid, function(er) {
3166
3236
  if (chownErOk(er))
3167
3237
  er = null;
3168
3238
  if (cb)
@@ -3175,7 +3245,7 @@ var require_polyfills = __commonJS((exports, module) => {
3175
3245
  return orig;
3176
3246
  return function(target, uid, gid) {
3177
3247
  try {
3178
- return orig.call(fs, target, uid, gid);
3248
+ return orig.call(fs2, target, uid, gid);
3179
3249
  } catch (er) {
3180
3250
  if (!chownErOk(er))
3181
3251
  throw er;
@@ -3200,14 +3270,14 @@ var require_polyfills = __commonJS((exports, module) => {
3200
3270
  if (cb)
3201
3271
  cb.apply(this, arguments);
3202
3272
  }
3203
- return options ? orig.call(fs, target, options, callback) : orig.call(fs, target, callback);
3273
+ return options ? orig.call(fs2, target, options, callback) : orig.call(fs2, target, callback);
3204
3274
  };
3205
3275
  }
3206
3276
  function statFixSync(orig) {
3207
3277
  if (!orig)
3208
3278
  return orig;
3209
3279
  return function(target, options) {
3210
- var stats = options ? orig.call(fs, target, options) : orig.call(fs, target);
3280
+ var stats = options ? orig.call(fs2, target, options) : orig.call(fs2, target);
3211
3281
  if (stats) {
3212
3282
  if (stats.uid < 0)
3213
3283
  stats.uid += 4294967296;
@@ -3236,17 +3306,17 @@ var require_polyfills = __commonJS((exports, module) => {
3236
3306
  var require_legacy_streams = __commonJS((exports, module) => {
3237
3307
  var Stream = __require("stream").Stream;
3238
3308
  module.exports = legacy;
3239
- function legacy(fs) {
3309
+ function legacy(fs2) {
3240
3310
  return {
3241
3311
  ReadStream,
3242
3312
  WriteStream
3243
3313
  };
3244
- function ReadStream(path, options) {
3314
+ function ReadStream(path2, options) {
3245
3315
  if (!(this instanceof ReadStream))
3246
- return new ReadStream(path, options);
3316
+ return new ReadStream(path2, options);
3247
3317
  Stream.call(this);
3248
3318
  var self2 = this;
3249
- this.path = path;
3319
+ this.path = path2;
3250
3320
  this.fd = null;
3251
3321
  this.readable = true;
3252
3322
  this.paused = false;
@@ -3281,7 +3351,7 @@ var require_legacy_streams = __commonJS((exports, module) => {
3281
3351
  });
3282
3352
  return;
3283
3353
  }
3284
- fs.open(this.path, this.flags, this.mode, function(err, fd) {
3354
+ fs2.open(this.path, this.flags, this.mode, function(err, fd) {
3285
3355
  if (err) {
3286
3356
  self2.emit("error", err);
3287
3357
  self2.readable = false;
@@ -3292,11 +3362,11 @@ var require_legacy_streams = __commonJS((exports, module) => {
3292
3362
  self2._read();
3293
3363
  });
3294
3364
  }
3295
- function WriteStream(path, options) {
3365
+ function WriteStream(path2, options) {
3296
3366
  if (!(this instanceof WriteStream))
3297
- return new WriteStream(path, options);
3367
+ return new WriteStream(path2, options);
3298
3368
  Stream.call(this);
3299
- this.path = path;
3369
+ this.path = path2;
3300
3370
  this.fd = null;
3301
3371
  this.writable = true;
3302
3372
  this.flags = "w";
@@ -3321,7 +3391,7 @@ var require_legacy_streams = __commonJS((exports, module) => {
3321
3391
  this.busy = false;
3322
3392
  this._queue = [];
3323
3393
  if (this.fd === null) {
3324
- this._open = fs.open;
3394
+ this._open = fs2.open;
3325
3395
  this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);
3326
3396
  this.flush();
3327
3397
  }
@@ -3351,7 +3421,7 @@ var require_clone = __commonJS((exports, module) => {
3351
3421
 
3352
3422
  // ../../node_modules/graceful-fs/graceful-fs.js
3353
3423
  var require_graceful_fs = __commonJS((exports, module) => {
3354
- var fs = __require("fs");
3424
+ var fs2 = __require("fs");
3355
3425
  var polyfills = require_polyfills();
3356
3426
  var legacy = require_legacy_streams();
3357
3427
  var clone = require_clone();
@@ -3383,12 +3453,12 @@ var require_graceful_fs = __commonJS((exports, module) => {
3383
3453
  GFS4: `);
3384
3454
  console.error(m);
3385
3455
  };
3386
- if (!fs[gracefulQueue]) {
3456
+ if (!fs2[gracefulQueue]) {
3387
3457
  queue = global[gracefulQueue] || [];
3388
- publishQueue(fs, queue);
3389
- fs.close = function(fs$close) {
3458
+ publishQueue(fs2, queue);
3459
+ fs2.close = function(fs$close) {
3390
3460
  function close(fd, cb) {
3391
- return fs$close.call(fs, fd, function(err) {
3461
+ return fs$close.call(fs2, fd, function(err) {
3392
3462
  if (!err) {
3393
3463
  resetQueue();
3394
3464
  }
@@ -3400,48 +3470,48 @@ GFS4: `);
3400
3470
  value: fs$close
3401
3471
  });
3402
3472
  return close;
3403
- }(fs.close);
3404
- fs.closeSync = function(fs$closeSync) {
3473
+ }(fs2.close);
3474
+ fs2.closeSync = function(fs$closeSync) {
3405
3475
  function closeSync(fd) {
3406
- fs$closeSync.apply(fs, arguments);
3476
+ fs$closeSync.apply(fs2, arguments);
3407
3477
  resetQueue();
3408
3478
  }
3409
3479
  Object.defineProperty(closeSync, previousSymbol, {
3410
3480
  value: fs$closeSync
3411
3481
  });
3412
3482
  return closeSync;
3413
- }(fs.closeSync);
3483
+ }(fs2.closeSync);
3414
3484
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
3415
3485
  process.on("exit", function() {
3416
- debug(fs[gracefulQueue]);
3417
- __require("assert").equal(fs[gracefulQueue].length, 0);
3486
+ debug(fs2[gracefulQueue]);
3487
+ __require("assert").equal(fs2[gracefulQueue].length, 0);
3418
3488
  });
3419
3489
  }
3420
3490
  }
3421
3491
  var queue;
3422
3492
  if (!global[gracefulQueue]) {
3423
- publishQueue(global, fs[gracefulQueue]);
3424
- }
3425
- module.exports = patch(clone(fs));
3426
- if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
3427
- module.exports = patch(fs);
3428
- fs.__patched = true;
3429
- }
3430
- function patch(fs2) {
3431
- polyfills(fs2);
3432
- fs2.gracefulify = patch;
3433
- fs2.createReadStream = createReadStream;
3434
- fs2.createWriteStream = createWriteStream;
3435
- var fs$readFile = fs2.readFile;
3436
- fs2.readFile = readFile;
3437
- function readFile(path, options, cb) {
3493
+ publishQueue(global, fs2[gracefulQueue]);
3494
+ }
3495
+ module.exports = patch(clone(fs2));
3496
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs2.__patched) {
3497
+ module.exports = patch(fs2);
3498
+ fs2.__patched = true;
3499
+ }
3500
+ function patch(fs3) {
3501
+ polyfills(fs3);
3502
+ fs3.gracefulify = patch;
3503
+ fs3.createReadStream = createReadStream;
3504
+ fs3.createWriteStream = createWriteStream;
3505
+ var fs$readFile = fs3.readFile;
3506
+ fs3.readFile = readFile;
3507
+ function readFile(path2, options, cb) {
3438
3508
  if (typeof options === "function")
3439
3509
  cb = options, options = null;
3440
- return go$readFile(path, options, cb);
3441
- function go$readFile(path2, options2, cb2, startTime) {
3442
- return fs$readFile(path2, options2, function(err) {
3510
+ return go$readFile(path2, options, cb);
3511
+ function go$readFile(path3, options2, cb2, startTime) {
3512
+ return fs$readFile(path3, options2, function(err) {
3443
3513
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
3444
- enqueue([go$readFile, [path2, options2, cb2], err, startTime || Date.now(), Date.now()]);
3514
+ enqueue([go$readFile, [path3, options2, cb2], err, startTime || Date.now(), Date.now()]);
3445
3515
  else {
3446
3516
  if (typeof cb2 === "function")
3447
3517
  cb2.apply(this, arguments);
@@ -3449,16 +3519,16 @@ GFS4: `);
3449
3519
  });
3450
3520
  }
3451
3521
  }
3452
- var fs$writeFile = fs2.writeFile;
3453
- fs2.writeFile = writeFile;
3454
- function writeFile(path, data, options, cb) {
3522
+ var fs$writeFile = fs3.writeFile;
3523
+ fs3.writeFile = writeFile;
3524
+ function writeFile(path2, data, options, cb) {
3455
3525
  if (typeof options === "function")
3456
3526
  cb = options, options = null;
3457
- return go$writeFile(path, data, options, cb);
3458
- function go$writeFile(path2, data2, options2, cb2, startTime) {
3459
- return fs$writeFile(path2, data2, options2, function(err) {
3527
+ return go$writeFile(path2, data, options, cb);
3528
+ function go$writeFile(path3, data2, options2, cb2, startTime) {
3529
+ return fs$writeFile(path3, data2, options2, function(err) {
3460
3530
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
3461
- enqueue([go$writeFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
3531
+ enqueue([go$writeFile, [path3, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
3462
3532
  else {
3463
3533
  if (typeof cb2 === "function")
3464
3534
  cb2.apply(this, arguments);
@@ -3466,17 +3536,17 @@ GFS4: `);
3466
3536
  });
3467
3537
  }
3468
3538
  }
3469
- var fs$appendFile = fs2.appendFile;
3539
+ var fs$appendFile = fs3.appendFile;
3470
3540
  if (fs$appendFile)
3471
- fs2.appendFile = appendFile;
3472
- function appendFile(path, data, options, cb) {
3541
+ fs3.appendFile = appendFile;
3542
+ function appendFile(path2, data, options, cb) {
3473
3543
  if (typeof options === "function")
3474
3544
  cb = options, options = null;
3475
- return go$appendFile(path, data, options, cb);
3476
- function go$appendFile(path2, data2, options2, cb2, startTime) {
3477
- return fs$appendFile(path2, data2, options2, function(err) {
3545
+ return go$appendFile(path2, data, options, cb);
3546
+ function go$appendFile(path3, data2, options2, cb2, startTime) {
3547
+ return fs$appendFile(path3, data2, options2, function(err) {
3478
3548
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
3479
- enqueue([go$appendFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
3549
+ enqueue([go$appendFile, [path3, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
3480
3550
  else {
3481
3551
  if (typeof cb2 === "function")
3482
3552
  cb2.apply(this, arguments);
@@ -3484,9 +3554,9 @@ GFS4: `);
3484
3554
  });
3485
3555
  }
3486
3556
  }
3487
- var fs$copyFile = fs2.copyFile;
3557
+ var fs$copyFile = fs3.copyFile;
3488
3558
  if (fs$copyFile)
3489
- fs2.copyFile = copyFile;
3559
+ fs3.copyFile = copyFile;
3490
3560
  function copyFile(src, dest, flags, cb) {
3491
3561
  if (typeof flags === "function") {
3492
3562
  cb = flags;
@@ -3504,24 +3574,24 @@ GFS4: `);
3504
3574
  });
3505
3575
  }
3506
3576
  }
3507
- var fs$readdir = fs2.readdir;
3508
- fs2.readdir = readdir;
3577
+ var fs$readdir = fs3.readdir;
3578
+ fs3.readdir = readdir;
3509
3579
  var noReaddirOptionVersions = /^v[0-5]\./;
3510
- function readdir(path, options, cb) {
3580
+ function readdir(path2, options, cb) {
3511
3581
  if (typeof options === "function")
3512
3582
  cb = options, options = null;
3513
- var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir(path2, options2, cb2, startTime) {
3514
- return fs$readdir(path2, fs$readdirCallback(path2, options2, cb2, startTime));
3515
- } : function go$readdir(path2, options2, cb2, startTime) {
3516
- return fs$readdir(path2, options2, fs$readdirCallback(path2, options2, cb2, startTime));
3583
+ var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir(path3, options2, cb2, startTime) {
3584
+ return fs$readdir(path3, fs$readdirCallback(path3, options2, cb2, startTime));
3585
+ } : function go$readdir(path3, options2, cb2, startTime) {
3586
+ return fs$readdir(path3, options2, fs$readdirCallback(path3, options2, cb2, startTime));
3517
3587
  };
3518
- return go$readdir(path, options, cb);
3519
- function fs$readdirCallback(path2, options2, cb2, startTime) {
3588
+ return go$readdir(path2, options, cb);
3589
+ function fs$readdirCallback(path3, options2, cb2, startTime) {
3520
3590
  return function(err, files) {
3521
3591
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
3522
3592
  enqueue([
3523
3593
  go$readdir,
3524
- [path2, options2, cb2],
3594
+ [path3, options2, cb2],
3525
3595
  err,
3526
3596
  startTime || Date.now(),
3527
3597
  Date.now()
@@ -3536,21 +3606,21 @@ GFS4: `);
3536
3606
  }
3537
3607
  }
3538
3608
  if (process.version.substr(0, 4) === "v0.8") {
3539
- var legStreams = legacy(fs2);
3609
+ var legStreams = legacy(fs3);
3540
3610
  ReadStream = legStreams.ReadStream;
3541
3611
  WriteStream = legStreams.WriteStream;
3542
3612
  }
3543
- var fs$ReadStream = fs2.ReadStream;
3613
+ var fs$ReadStream = fs3.ReadStream;
3544
3614
  if (fs$ReadStream) {
3545
3615
  ReadStream.prototype = Object.create(fs$ReadStream.prototype);
3546
3616
  ReadStream.prototype.open = ReadStream$open;
3547
3617
  }
3548
- var fs$WriteStream = fs2.WriteStream;
3618
+ var fs$WriteStream = fs3.WriteStream;
3549
3619
  if (fs$WriteStream) {
3550
3620
  WriteStream.prototype = Object.create(fs$WriteStream.prototype);
3551
3621
  WriteStream.prototype.open = WriteStream$open;
3552
3622
  }
3553
- Object.defineProperty(fs2, "ReadStream", {
3623
+ Object.defineProperty(fs3, "ReadStream", {
3554
3624
  get: function() {
3555
3625
  return ReadStream;
3556
3626
  },
@@ -3560,7 +3630,7 @@ GFS4: `);
3560
3630
  enumerable: true,
3561
3631
  configurable: true
3562
3632
  });
3563
- Object.defineProperty(fs2, "WriteStream", {
3633
+ Object.defineProperty(fs3, "WriteStream", {
3564
3634
  get: function() {
3565
3635
  return WriteStream;
3566
3636
  },
@@ -3571,7 +3641,7 @@ GFS4: `);
3571
3641
  configurable: true
3572
3642
  });
3573
3643
  var FileReadStream = ReadStream;
3574
- Object.defineProperty(fs2, "FileReadStream", {
3644
+ Object.defineProperty(fs3, "FileReadStream", {
3575
3645
  get: function() {
3576
3646
  return FileReadStream;
3577
3647
  },
@@ -3582,7 +3652,7 @@ GFS4: `);
3582
3652
  configurable: true
3583
3653
  });
3584
3654
  var FileWriteStream = WriteStream;
3585
- Object.defineProperty(fs2, "FileWriteStream", {
3655
+ Object.defineProperty(fs3, "FileWriteStream", {
3586
3656
  get: function() {
3587
3657
  return FileWriteStream;
3588
3658
  },
@@ -3592,7 +3662,7 @@ GFS4: `);
3592
3662
  enumerable: true,
3593
3663
  configurable: true
3594
3664
  });
3595
- function ReadStream(path, options) {
3665
+ function ReadStream(path2, options) {
3596
3666
  if (this instanceof ReadStream)
3597
3667
  return fs$ReadStream.apply(this, arguments), this;
3598
3668
  else
@@ -3612,7 +3682,7 @@ GFS4: `);
3612
3682
  }
3613
3683
  });
3614
3684
  }
3615
- function WriteStream(path, options) {
3685
+ function WriteStream(path2, options) {
3616
3686
  if (this instanceof WriteStream)
3617
3687
  return fs$WriteStream.apply(this, arguments), this;
3618
3688
  else
@@ -3630,22 +3700,22 @@ GFS4: `);
3630
3700
  }
3631
3701
  });
3632
3702
  }
3633
- function createReadStream(path, options) {
3634
- return new fs2.ReadStream(path, options);
3703
+ function createReadStream(path2, options) {
3704
+ return new fs3.ReadStream(path2, options);
3635
3705
  }
3636
- function createWriteStream(path, options) {
3637
- return new fs2.WriteStream(path, options);
3706
+ function createWriteStream(path2, options) {
3707
+ return new fs3.WriteStream(path2, options);
3638
3708
  }
3639
- var fs$open = fs2.open;
3640
- fs2.open = open;
3641
- function open(path, flags, mode, cb) {
3709
+ var fs$open = fs3.open;
3710
+ fs3.open = open;
3711
+ function open(path2, flags, mode, cb) {
3642
3712
  if (typeof mode === "function")
3643
3713
  cb = mode, mode = null;
3644
- return go$open(path, flags, mode, cb);
3645
- function go$open(path2, flags2, mode2, cb2, startTime) {
3646
- return fs$open(path2, flags2, mode2, function(err, fd) {
3714
+ return go$open(path2, flags, mode, cb);
3715
+ function go$open(path3, flags2, mode2, cb2, startTime) {
3716
+ return fs$open(path3, flags2, mode2, function(err, fd) {
3647
3717
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
3648
- enqueue([go$open, [path2, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
3718
+ enqueue([go$open, [path3, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
3649
3719
  else {
3650
3720
  if (typeof cb2 === "function")
3651
3721
  cb2.apply(this, arguments);
@@ -3653,20 +3723,20 @@ GFS4: `);
3653
3723
  });
3654
3724
  }
3655
3725
  }
3656
- return fs2;
3726
+ return fs3;
3657
3727
  }
3658
3728
  function enqueue(elem) {
3659
3729
  debug("ENQUEUE", elem[0].name, elem[1]);
3660
- fs[gracefulQueue].push(elem);
3730
+ fs2[gracefulQueue].push(elem);
3661
3731
  retry();
3662
3732
  }
3663
3733
  var retryTimer;
3664
3734
  function resetQueue() {
3665
3735
  var now = Date.now();
3666
- for (var i = 0;i < fs[gracefulQueue].length; ++i) {
3667
- if (fs[gracefulQueue][i].length > 2) {
3668
- fs[gracefulQueue][i][3] = now;
3669
- fs[gracefulQueue][i][4] = now;
3736
+ for (var i = 0;i < fs2[gracefulQueue].length; ++i) {
3737
+ if (fs2[gracefulQueue][i].length > 2) {
3738
+ fs2[gracefulQueue][i][3] = now;
3739
+ fs2[gracefulQueue][i][4] = now;
3670
3740
  }
3671
3741
  }
3672
3742
  retry();
@@ -3674,9 +3744,9 @@ GFS4: `);
3674
3744
  function retry() {
3675
3745
  clearTimeout(retryTimer);
3676
3746
  retryTimer = undefined;
3677
- if (fs[gracefulQueue].length === 0)
3747
+ if (fs2[gracefulQueue].length === 0)
3678
3748
  return;
3679
- var elem = fs[gracefulQueue].shift();
3749
+ var elem = fs2[gracefulQueue].shift();
3680
3750
  var fn = elem[0];
3681
3751
  var args = elem[1];
3682
3752
  var err = elem[2];
@@ -3698,7 +3768,7 @@ GFS4: `);
3698
3768
  debug("RETRY", fn.name, args);
3699
3769
  fn.apply(null, args.concat([startTime]));
3700
3770
  } else {
3701
- fs[gracefulQueue].push(elem);
3771
+ fs2[gracefulQueue].push(elem);
3702
3772
  }
3703
3773
  }
3704
3774
  if (retryTimer === undefined) {
@@ -5827,24 +5897,24 @@ var require_normalize_path = __commonJS((exports, module) => {
5827
5897
  * Copyright (c) 2014-2018, Jon Schlinkert.
5828
5898
  * Released under the MIT License.
5829
5899
  */
5830
- module.exports = function(path, stripTrailing) {
5831
- if (typeof path !== "string") {
5900
+ module.exports = function(path2, stripTrailing) {
5901
+ if (typeof path2 !== "string") {
5832
5902
  throw new TypeError("expected path to be a string");
5833
5903
  }
5834
- if (path === "\\" || path === "/")
5904
+ if (path2 === "\\" || path2 === "/")
5835
5905
  return "/";
5836
- var len = path.length;
5906
+ var len = path2.length;
5837
5907
  if (len <= 1)
5838
- return path;
5908
+ return path2;
5839
5909
  var prefix = "";
5840
- if (len > 4 && path[3] === "\\") {
5841
- var ch = path[2];
5842
- if ((ch === "?" || ch === ".") && path.slice(0, 2) === "\\\\") {
5843
- path = path.slice(2);
5910
+ if (len > 4 && path2[3] === "\\") {
5911
+ var ch = path2[2];
5912
+ if ((ch === "?" || ch === ".") && path2.slice(0, 2) === "\\\\") {
5913
+ path2 = path2.slice(2);
5844
5914
  prefix = "//";
5845
5915
  }
5846
5916
  }
5847
- var segs = path.split(/[/\\]+/);
5917
+ var segs = path2.split(/[/\\]+/);
5848
5918
  if (stripTrailing !== false && segs[segs.length - 1] === "") {
5849
5919
  segs.pop();
5850
5920
  }
@@ -14151,11 +14221,11 @@ var require_commonjs = __commonJS((exports) => {
14151
14221
  return (f) => f.length === len && f !== "." && f !== "..";
14152
14222
  };
14153
14223
  var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
14154
- var path = {
14224
+ var path2 = {
14155
14225
  win32: { sep: "\\" },
14156
14226
  posix: { sep: "/" }
14157
14227
  };
14158
- exports.sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
14228
+ exports.sep = defaultPlatform === "win32" ? path2.win32.sep : path2.posix.sep;
14159
14229
  exports.minimatch.sep = exports.sep;
14160
14230
  exports.GLOBSTAR = Symbol("globstar **");
14161
14231
  exports.minimatch.GLOBSTAR = exports.GLOBSTAR;
@@ -16827,12 +16897,12 @@ var require_commonjs4 = __commonJS((exports) => {
16827
16897
  childrenCache() {
16828
16898
  return this.#children;
16829
16899
  }
16830
- resolve(path) {
16831
- if (!path) {
16900
+ resolve(path2) {
16901
+ if (!path2) {
16832
16902
  return this;
16833
16903
  }
16834
- const rootPath = this.getRootString(path);
16835
- const dir = path.substring(rootPath.length);
16904
+ const rootPath = this.getRootString(path2);
16905
+ const dir = path2.substring(rootPath.length);
16836
16906
  const dirParts = dir.split(this.splitSep);
16837
16907
  const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
16838
16908
  return result;
@@ -17362,8 +17432,8 @@ var require_commonjs4 = __commonJS((exports) => {
17362
17432
  newChild(name, type = UNKNOWN, opts = {}) {
17363
17433
  return new PathWin32(name, type, this.root, this.roots, this.nocase, this.childrenCache(), opts);
17364
17434
  }
17365
- getRootString(path) {
17366
- return node_path_1.win32.parse(path).root;
17435
+ getRootString(path2) {
17436
+ return node_path_1.win32.parse(path2).root;
17367
17437
  }
17368
17438
  getRoot(rootPath) {
17369
17439
  rootPath = uncToDrive(rootPath.toUpperCase());
@@ -17390,8 +17460,8 @@ var require_commonjs4 = __commonJS((exports) => {
17390
17460
  constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
17391
17461
  super(name, type, root, roots, nocase, children, opts);
17392
17462
  }
17393
- getRootString(path) {
17394
- return path.startsWith("/") ? "/" : "";
17463
+ getRootString(path2) {
17464
+ return path2.startsWith("/") ? "/" : "";
17395
17465
  }
17396
17466
  getRoot(_rootPath) {
17397
17467
  return this.root;
@@ -17412,8 +17482,8 @@ var require_commonjs4 = __commonJS((exports) => {
17412
17482
  #children;
17413
17483
  nocase;
17414
17484
  #fs;
17415
- constructor(cwd = process.cwd(), pathImpl, sep, { nocase, childrenCacheSize = 16 * 1024, fs = defaultFS } = {}) {
17416
- this.#fs = fsFromOption(fs);
17485
+ constructor(cwd = process.cwd(), pathImpl, sep, { nocase, childrenCacheSize = 16 * 1024, fs: fs2 = defaultFS } = {}) {
17486
+ this.#fs = fsFromOption(fs2);
17417
17487
  if (cwd instanceof URL || cwd.startsWith("file://")) {
17418
17488
  cwd = (0, node_url_1.fileURLToPath)(cwd);
17419
17489
  }
@@ -17449,11 +17519,11 @@ var require_commonjs4 = __commonJS((exports) => {
17449
17519
  }
17450
17520
  this.cwd = prev;
17451
17521
  }
17452
- depth(path = this.cwd) {
17453
- if (typeof path === "string") {
17454
- path = this.cwd.resolve(path);
17522
+ depth(path2 = this.cwd) {
17523
+ if (typeof path2 === "string") {
17524
+ path2 = this.cwd.resolve(path2);
17455
17525
  }
17456
- return path.depth();
17526
+ return path2.depth();
17457
17527
  }
17458
17528
  childrenCache() {
17459
17529
  return this.#children;
@@ -17869,9 +17939,9 @@ var require_commonjs4 = __commonJS((exports) => {
17869
17939
  process2();
17870
17940
  return results;
17871
17941
  }
17872
- chdir(path = this.cwd) {
17942
+ chdir(path2 = this.cwd) {
17873
17943
  const oldCwd = this.cwd;
17874
- this.cwd = typeof path === "string" ? this.cwd.resolve(path) : path;
17944
+ this.cwd = typeof path2 === "string" ? this.cwd.resolve(path2) : path2;
17875
17945
  this.cwd[setAsCwd](oldCwd);
17876
17946
  }
17877
17947
  }
@@ -17890,8 +17960,8 @@ var require_commonjs4 = __commonJS((exports) => {
17890
17960
  parseRootPath(dir) {
17891
17961
  return node_path_1.win32.parse(dir).root.toUpperCase();
17892
17962
  }
17893
- newRoot(fs) {
17894
- return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs });
17963
+ newRoot(fs2) {
17964
+ return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs: fs2 });
17895
17965
  }
17896
17966
  isAbsolute(p) {
17897
17967
  return p.startsWith("/") || p.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(p);
@@ -17909,8 +17979,8 @@ var require_commonjs4 = __commonJS((exports) => {
17909
17979
  parseRootPath(_dir) {
17910
17980
  return "/";
17911
17981
  }
17912
- newRoot(fs) {
17913
- return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs });
17982
+ newRoot(fs2) {
17983
+ return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs: fs2 });
17914
17984
  }
17915
17985
  isAbsolute(p) {
17916
17986
  return p.startsWith("/");
@@ -18184,8 +18254,8 @@ var require_processor = __commonJS((exports) => {
18184
18254
  this.store.set(target, current === undefined ? n : n & current);
18185
18255
  }
18186
18256
  entries() {
18187
- return [...this.store.entries()].map(([path, n]) => [
18188
- path,
18257
+ return [...this.store.entries()].map(([path2, n]) => [
18258
+ path2,
18189
18259
  !!(n & 2),
18190
18260
  !!(n & 1)
18191
18261
  ]);
@@ -18398,9 +18468,9 @@ var require_walker = __commonJS((exports) => {
18398
18468
  signal;
18399
18469
  maxDepth;
18400
18470
  includeChildMatches;
18401
- constructor(patterns, path, opts) {
18471
+ constructor(patterns, path2, opts) {
18402
18472
  this.patterns = patterns;
18403
- this.path = path;
18473
+ this.path = path2;
18404
18474
  this.opts = opts;
18405
18475
  this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
18406
18476
  this.includeChildMatches = opts.includeChildMatches !== false;
@@ -18419,11 +18489,11 @@ var require_walker = __commonJS((exports) => {
18419
18489
  });
18420
18490
  }
18421
18491
  }
18422
- #ignored(path) {
18423
- return this.seen.has(path) || !!this.#ignore?.ignored?.(path);
18492
+ #ignored(path2) {
18493
+ return this.seen.has(path2) || !!this.#ignore?.ignored?.(path2);
18424
18494
  }
18425
- #childrenIgnored(path) {
18426
- return !!this.#ignore?.childrenIgnored?.(path);
18495
+ #childrenIgnored(path2) {
18496
+ return !!this.#ignore?.childrenIgnored?.(path2);
18427
18497
  }
18428
18498
  pause() {
18429
18499
  this.paused = true;
@@ -18637,8 +18707,8 @@ var require_walker = __commonJS((exports) => {
18637
18707
 
18638
18708
  class GlobWalker extends GlobUtil {
18639
18709
  matches = new Set;
18640
- constructor(patterns, path, opts) {
18641
- super(patterns, path, opts);
18710
+ constructor(patterns, path2, opts) {
18711
+ super(patterns, path2, opts);
18642
18712
  }
18643
18713
  matchEmit(e) {
18644
18714
  this.matches.add(e);
@@ -18677,8 +18747,8 @@ var require_walker = __commonJS((exports) => {
18677
18747
 
18678
18748
  class GlobStream extends GlobUtil {
18679
18749
  results;
18680
- constructor(patterns, path, opts) {
18681
- super(patterns, path, opts);
18750
+ constructor(patterns, path2, opts) {
18751
+ super(patterns, path2, opts);
18682
18752
  this.results = new minipass_1.Minipass({
18683
18753
  signal: this.signal,
18684
18754
  objectMode: true
@@ -18996,8 +19066,8 @@ var require_commonjs5 = __commonJS((exports) => {
18996
19066
 
18997
19067
  // ../../node_modules/archiver-utils/file.js
18998
19068
  var require_file = __commonJS((exports, module) => {
18999
- var fs = require_graceful_fs();
19000
- var path = __require("path");
19069
+ var fs2 = require_graceful_fs();
19070
+ var path2 = __require("path");
19001
19071
  var flatten = require_flatten();
19002
19072
  var difference = require_difference();
19003
19073
  var union = require_union();
@@ -19022,8 +19092,8 @@ var require_file = __commonJS((exports, module) => {
19022
19092
  return result;
19023
19093
  };
19024
19094
  file.exists = function() {
19025
- var filepath = path.join.apply(path, arguments);
19026
- return fs.existsSync(filepath);
19095
+ var filepath = path2.join.apply(path2, arguments);
19096
+ return fs2.existsSync(filepath);
19027
19097
  };
19028
19098
  file.expand = function(...args) {
19029
19099
  var options = isPlainObject(args[0]) ? args.shift() : {};
@@ -19036,12 +19106,12 @@ var require_file = __commonJS((exports, module) => {
19036
19106
  });
19037
19107
  if (options.filter) {
19038
19108
  matches = matches.filter(function(filepath) {
19039
- filepath = path.join(options.cwd || "", filepath);
19109
+ filepath = path2.join(options.cwd || "", filepath);
19040
19110
  try {
19041
19111
  if (typeof options.filter === "function") {
19042
19112
  return options.filter(filepath);
19043
19113
  } else {
19044
- return fs.statSync(filepath)[options.filter]();
19114
+ return fs2.statSync(filepath)[options.filter]();
19045
19115
  }
19046
19116
  } catch (e) {
19047
19117
  return false;
@@ -19053,7 +19123,7 @@ var require_file = __commonJS((exports, module) => {
19053
19123
  file.expandMapping = function(patterns, destBase, options) {
19054
19124
  options = Object.assign({
19055
19125
  rename: function(destBase2, destPath) {
19056
- return path.join(destBase2 || "", destPath);
19126
+ return path2.join(destBase2 || "", destPath);
19057
19127
  }
19058
19128
  }, options);
19059
19129
  var files = [];
@@ -19061,14 +19131,14 @@ var require_file = __commonJS((exports, module) => {
19061
19131
  file.expand(options, patterns).forEach(function(src) {
19062
19132
  var destPath = src;
19063
19133
  if (options.flatten) {
19064
- destPath = path.basename(destPath);
19134
+ destPath = path2.basename(destPath);
19065
19135
  }
19066
19136
  if (options.ext) {
19067
19137
  destPath = destPath.replace(/(\.[^\/]*)?$/, options.ext);
19068
19138
  }
19069
19139
  var dest = options.rename(destBase, destPath, options);
19070
19140
  if (options.cwd) {
19071
- src = path.join(options.cwd, src);
19141
+ src = path2.join(options.cwd, src);
19072
19142
  }
19073
19143
  dest = dest.replace(pathSeparatorRe, "/");
19074
19144
  src = src.replace(pathSeparatorRe, "/");
@@ -19147,8 +19217,8 @@ var require_file = __commonJS((exports, module) => {
19147
19217
 
19148
19218
  // ../../node_modules/archiver-utils/index.js
19149
19219
  var require_archiver_utils = __commonJS((exports, module) => {
19150
- var fs = require_graceful_fs();
19151
- var path = __require("path");
19220
+ var fs2 = require_graceful_fs();
19221
+ var path2 = __require("path");
19152
19222
  var isStream = require_is_stream();
19153
19223
  var lazystream = require_lazystream();
19154
19224
  var normalizePath = require_normalize_path();
@@ -19196,7 +19266,7 @@ var require_archiver_utils = __commonJS((exports, module) => {
19196
19266
  };
19197
19267
  utils.lazyReadStream = function(filepath) {
19198
19268
  return new lazystream.Readable(function() {
19199
- return fs.createReadStream(filepath);
19269
+ return fs2.createReadStream(filepath);
19200
19270
  });
19201
19271
  };
19202
19272
  utils.normalizeInputSource = function(source) {
@@ -19224,7 +19294,7 @@ var require_archiver_utils = __commonJS((exports, module) => {
19224
19294
  callback = base;
19225
19295
  base = dirpath;
19226
19296
  }
19227
- fs.readdir(dirpath, function(err, list) {
19297
+ fs2.readdir(dirpath, function(err, list) {
19228
19298
  var i = 0;
19229
19299
  var file;
19230
19300
  var filepath;
@@ -19236,11 +19306,11 @@ var require_archiver_utils = __commonJS((exports, module) => {
19236
19306
  if (!file) {
19237
19307
  return callback(null, results);
19238
19308
  }
19239
- filepath = path.join(dirpath, file);
19240
- fs.stat(filepath, function(err2, stats) {
19309
+ filepath = path2.join(dirpath, file);
19310
+ fs2.stat(filepath, function(err2, stats) {
19241
19311
  results.push({
19242
19312
  path: filepath,
19243
- relative: path.relative(base, filepath).replace(/\\/g, "/"),
19313
+ relative: path2.relative(base, filepath).replace(/\\/g, "/"),
19244
19314
  stats
19245
19315
  });
19246
19316
  if (stats && stats.isDirectory()) {
@@ -24961,10 +25031,10 @@ var require_ours2 = __commonJS((exports, module) => {
24961
25031
 
24962
25032
  // ../../node_modules/archiver/lib/core.js
24963
25033
  var require_core = __commonJS((exports, module) => {
24964
- var fs = __require("fs");
25034
+ var fs2 = __require("fs");
24965
25035
  var glob = require_readdir_glob();
24966
25036
  var async = require_async();
24967
- var path = __require("path");
25037
+ var path2 = __require("path");
24968
25038
  var util = require_archiver_utils();
24969
25039
  var inherits = __require("util").inherits;
24970
25040
  var ArchiverError = require_error();
@@ -25025,7 +25095,7 @@ var require_core = __commonJS((exports, module) => {
25025
25095
  data.sourcePath = filepath;
25026
25096
  task.data = data;
25027
25097
  this._entriesCount++;
25028
- if (data.stats && data.stats instanceof fs.Stats) {
25098
+ if (data.stats && data.stats instanceof fs2.Stats) {
25029
25099
  task = this._updateQueueTaskWithStats(task, data.stats);
25030
25100
  if (task) {
25031
25101
  if (data.stats.size) {
@@ -25196,7 +25266,7 @@ var require_core = __commonJS((exports, module) => {
25196
25266
  callback();
25197
25267
  return;
25198
25268
  }
25199
- fs.lstat(task.filepath, function(err, stats) {
25269
+ fs2.lstat(task.filepath, function(err, stats) {
25200
25270
  if (this._state.aborted) {
25201
25271
  setImmediate(callback);
25202
25272
  return;
@@ -25239,10 +25309,10 @@ var require_core = __commonJS((exports, module) => {
25239
25309
  task.data.sourceType = "buffer";
25240
25310
  task.source = Buffer.concat([]);
25241
25311
  } else if (stats.isSymbolicLink() && this._moduleSupports("symlink")) {
25242
- var linkPath = fs.readlinkSync(task.filepath);
25243
- var dirName = path.dirname(task.filepath);
25312
+ var linkPath = fs2.readlinkSync(task.filepath);
25313
+ var dirName = path2.dirname(task.filepath);
25244
25314
  task.data.type = "symlink";
25245
- task.data.linkname = path.relative(dirName, path.resolve(dirName, linkPath));
25315
+ task.data.linkname = path2.relative(dirName, path2.resolve(dirName, linkPath));
25246
25316
  task.data.sourceType = "buffer";
25247
25317
  task.source = Buffer.concat([]);
25248
25318
  } else {
@@ -40818,83 +40888,43 @@ var require_archiver = __commonJS((exports, module) => {
40818
40888
  module.exports = vending;
40819
40889
  });
40820
40890
 
40821
- // ../../node_modules/picocolors/picocolors.js
40822
- var require_picocolors = __commonJS((exports, module) => {
40823
- var p = process || {};
40824
- var argv = p.argv || [];
40825
- var env = p.env || {};
40826
- var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
40827
- var formatter = (open, close, replace = open) => (input) => {
40828
- let string = "" + input, index = string.indexOf(close, open.length);
40829
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
40830
- };
40831
- var replaceClose = (string, close, replace, index) => {
40832
- let result = "", cursor = 0;
40833
- do {
40834
- result += string.substring(cursor, index) + replace;
40835
- cursor = index + close.length;
40836
- index = string.indexOf(close, cursor);
40837
- } while (~index);
40838
- return result + string.substring(cursor);
40839
- };
40840
- var createColors = (enabled = isColorSupported) => {
40841
- let f = enabled ? formatter : () => String;
40842
- return {
40843
- isColorSupported: enabled,
40844
- reset: f("\x1B[0m", "\x1B[0m"),
40845
- bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
40846
- dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
40847
- italic: f("\x1B[3m", "\x1B[23m"),
40848
- underline: f("\x1B[4m", "\x1B[24m"),
40849
- inverse: f("\x1B[7m", "\x1B[27m"),
40850
- hidden: f("\x1B[8m", "\x1B[28m"),
40851
- strikethrough: f("\x1B[9m", "\x1B[29m"),
40852
- black: f("\x1B[30m", "\x1B[39m"),
40853
- red: f("\x1B[31m", "\x1B[39m"),
40854
- green: f("\x1B[32m", "\x1B[39m"),
40855
- yellow: f("\x1B[33m", "\x1B[39m"),
40856
- blue: f("\x1B[34m", "\x1B[39m"),
40857
- magenta: f("\x1B[35m", "\x1B[39m"),
40858
- cyan: f("\x1B[36m", "\x1B[39m"),
40859
- white: f("\x1B[37m", "\x1B[39m"),
40860
- gray: f("\x1B[90m", "\x1B[39m"),
40861
- bgBlack: f("\x1B[40m", "\x1B[49m"),
40862
- bgRed: f("\x1B[41m", "\x1B[49m"),
40863
- bgGreen: f("\x1B[42m", "\x1B[49m"),
40864
- bgYellow: f("\x1B[43m", "\x1B[49m"),
40865
- bgBlue: f("\x1B[44m", "\x1B[49m"),
40866
- bgMagenta: f("\x1B[45m", "\x1B[49m"),
40867
- bgCyan: f("\x1B[46m", "\x1B[49m"),
40868
- bgWhite: f("\x1B[47m", "\x1B[49m"),
40869
- blackBright: f("\x1B[90m", "\x1B[39m"),
40870
- redBright: f("\x1B[91m", "\x1B[39m"),
40871
- greenBright: f("\x1B[92m", "\x1B[39m"),
40872
- yellowBright: f("\x1B[93m", "\x1B[39m"),
40873
- blueBright: f("\x1B[94m", "\x1B[39m"),
40874
- magentaBright: f("\x1B[95m", "\x1B[39m"),
40875
- cyanBright: f("\x1B[96m", "\x1B[39m"),
40876
- whiteBright: f("\x1B[97m", "\x1B[39m"),
40877
- bgBlackBright: f("\x1B[100m", "\x1B[49m"),
40878
- bgRedBright: f("\x1B[101m", "\x1B[49m"),
40879
- bgGreenBright: f("\x1B[102m", "\x1B[49m"),
40880
- bgYellowBright: f("\x1B[103m", "\x1B[49m"),
40881
- bgBlueBright: f("\x1B[104m", "\x1B[49m"),
40882
- bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
40883
- bgCyanBright: f("\x1B[106m", "\x1B[49m"),
40884
- bgWhiteBright: f("\x1B[107m", "\x1B[49m")
40885
- };
40886
- };
40887
- module.exports = createColors();
40888
- module.exports.createColors = createColors;
40889
- });
40890
-
40891
40891
  // src/index.ts
40892
- var import_archiver = __toESM(require_archiver(), 1);
40892
+ import path3 from "node:path";
40893
+
40894
+ // src/lib/sandbox.ts
40893
40895
  var import_picocolors = __toESM(require_picocolors(), 1);
40896
+ import { startServer, version as sandboxVersion } from "@playcademy/sandbox";
40897
+
40898
+ // src/utils.ts
40894
40899
  import path from "node:path";
40895
- import fs from "node:fs/promises";
40896
- import { createWriteStream } from "node:fs";
40897
- var LOG_LINE_TOTAL_WIDTH = 60;
40900
+ import fs from "node:fs";
40901
+ function extractProjectInfo(viteConfig) {
40902
+ const projectRoot = viteConfig.root;
40903
+ const directoryName = path.basename(projectRoot);
40904
+ let packageJson = {};
40905
+ try {
40906
+ const packageJsonPath = path.join(projectRoot, "package.json");
40907
+ if (fs.existsSync(packageJsonPath)) {
40908
+ const packageJsonContent = fs.readFileSync(packageJsonPath, "utf-8");
40909
+ packageJson = JSON.parse(packageJsonContent);
40910
+ }
40911
+ } catch {}
40912
+ const name = typeof packageJson.name === "string" ? packageJson.name : "";
40913
+ let slug = name;
40914
+ if (slug.includes("/")) {
40915
+ slug = slug.split("/")[1] || slug;
40916
+ }
40917
+ if (!slug) {
40918
+ slug = directoryName;
40919
+ }
40920
+ const displayName = slug.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
40921
+ return {
40922
+ slug,
40923
+ displayName,
40924
+ version: (typeof packageJson.version === "string" ? packageJson.version : null) || "dev",
40925
+ description: typeof packageJson.description === "string" ? packageJson.description : undefined
40926
+ };
40927
+ }
40898
40928
  function formatNumberWithCommas(numStr) {
40899
40929
  if (!numStr)
40900
40930
  return numStr;
@@ -40904,40 +40934,349 @@ function formatNumberWithCommas(numStr) {
40904
40934
  parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
40905
40935
  return parts.join(".");
40906
40936
  }
40937
+ async function findAvailablePort(startPort = 4321) {
40938
+ const { createServer } = await import("node:net");
40939
+ return new Promise((resolve, reject) => {
40940
+ const server = createServer();
40941
+ server.listen(startPort, () => {
40942
+ const address = server.address();
40943
+ const port = address && typeof address === "object" ? address.port : startPort;
40944
+ server.close(() => resolve(port));
40945
+ });
40946
+ server.on("error", () => {
40947
+ findAvailablePort(startPort + 1).then(resolve).catch(reject);
40948
+ });
40949
+ });
40950
+ }
40951
+
40952
+ // src/lib/sandbox.ts
40953
+ function printSandboxInfo(viteConfig, availablePort, projectInfo) {
40954
+ viteConfig.logger.info("");
40955
+ viteConfig.logger.info(` ${import_picocolors.default.green(import_picocolors.default.bold("PLAYCADEMY"))} ${import_picocolors.default.green(`v${sandboxVersion}`)}`);
40956
+ viteConfig.logger.info("");
40957
+ viteConfig.logger.info(` ${import_picocolors.default.green("➜")} ${import_picocolors.default.bold("Game:")} ${import_picocolors.default.cyan(projectInfo.slug)}`);
40958
+ viteConfig.logger.info(` ${import_picocolors.default.green("➜")} ${import_picocolors.default.bold("Sandbox:")} ${import_picocolors.default.cyan(`http://localhost:${import_picocolors.default.bold(availablePort.toString())}/api`)}`);
40959
+ viteConfig.logger.info("");
40960
+ }
40961
+ async function startSandbox(viteConfig, autoStart = true, verbose = false) {
40962
+ if (!autoStart || viteConfig.command !== "serve") {
40963
+ return {
40964
+ url: "http://localhost:4321/api",
40965
+ project: null,
40966
+ cleanup: () => {}
40967
+ };
40968
+ }
40969
+ try {
40970
+ const availablePort = await findAvailablePort(4321);
40971
+ const sandboxUrl = `http://localhost:${availablePort}/api`;
40972
+ const projectInfo = extractProjectInfo(viteConfig);
40973
+ const server = await startServer({
40974
+ port: availablePort,
40975
+ verbose,
40976
+ seed: true,
40977
+ project: projectInfo
40978
+ });
40979
+ setTimeout(() => {
40980
+ printSandboxInfo(viteConfig, availablePort, projectInfo);
40981
+ }, 100);
40982
+ return {
40983
+ url: sandboxUrl,
40984
+ project: projectInfo,
40985
+ cleanup: () => {
40986
+ if (server && typeof server.close === "function") {
40987
+ server.close();
40988
+ viteConfig.logger.info(import_picocolors.default.yellow("[Playcademy] Sandbox server stopped"));
40989
+ }
40990
+ }
40991
+ };
40992
+ } catch (error) {
40993
+ viteConfig.logger.error(import_picocolors.default.red(`[Playcademy] Failed to start sandbox: ${error}`));
40994
+ return {
40995
+ url: "http://localhost:4321/api",
40996
+ project: null,
40997
+ cleanup: () => {}
40998
+ };
40999
+ }
41000
+ }
41001
+
41002
+ // src/shell.html
41003
+ var shell_default = `<!doctype html>
41004
+ <html lang="en">
41005
+ <head>
41006
+ <meta charset="UTF-8" />
41007
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
41008
+ <title>Playcademy Dev Environment</title>
41009
+ <script type="importmap">
41010
+ {
41011
+ "imports": {
41012
+ "@playcademy/sdk": "https://esm.sh/@playcademy/sdk@latest"
41013
+ }
41014
+ }
41015
+ </script>
41016
+ <style>
41017
+ * {
41018
+ margin: 0;
41019
+ padding: 0;
41020
+ box-sizing: border-box;
41021
+ }
41022
+
41023
+ body {
41024
+ display: flex;
41025
+ flex-direction: column;
41026
+ font-family: serif;
41027
+ height: 100vh;
41028
+ }
41029
+
41030
+ header {
41031
+ padding: 0.5rem 1rem;
41032
+ background-color: rgb(238, 238, 238);
41033
+ border-bottom: 1px solid #ccc;
41034
+ }
41035
+
41036
+ header h2 {
41037
+ margin: 0;
41038
+ padding: 0.2rem 0;
41039
+ font-size: 1.25rem;
41040
+ }
41041
+
41042
+ .header-content {
41043
+ display: flex;
41044
+ justify-content: space-between;
41045
+ align-items: center;
41046
+ }
41047
+
41048
+ .header-left {
41049
+ flex: 1;
41050
+ }
41051
+
41052
+ .user-info {
41053
+ display: flex;
41054
+ align-items: center;
41055
+ gap: 1rem;
41056
+ }
41057
+
41058
+ .status {
41059
+ font-size: 0.9rem;
41060
+ color: #666;
41061
+ }
41062
+
41063
+ .game-container {
41064
+ flex: 1;
41065
+ position: relative;
41066
+ overflow: hidden;
41067
+ background-color: #f8f8f8;
41068
+ }
41069
+
41070
+ .game-frame {
41071
+ position: absolute;
41072
+ inset: 0;
41073
+ border: none;
41074
+ width: 100%;
41075
+ height: 100%;
41076
+ }
41077
+
41078
+ .loading {
41079
+ position: absolute;
41080
+ inset: 0;
41081
+ display: flex;
41082
+ align-items: center;
41083
+ justify-content: center;
41084
+ color: #666;
41085
+ font-size: 1.2rem;
41086
+ background-color: #f8f8f8;
41087
+ }
41088
+
41089
+ .error {
41090
+ position: absolute;
41091
+ inset: 0;
41092
+ display: flex;
41093
+ flex-direction: column;
41094
+ align-items: center;
41095
+ justify-content: center;
41096
+ color: #d32f2f;
41097
+ background-color: #ffebee;
41098
+ }
41099
+
41100
+ .hidden {
41101
+ display: none;
41102
+ }
41103
+ </style>
41104
+ </head>
41105
+ <body>
41106
+ <header>
41107
+ <div class="header-content">
41108
+ <div class="header-left">
41109
+ <h2>Playcademy - Development</h2>
41110
+ </div>
41111
+ <div class="user-info">
41112
+ <div class="status" id="status"></div>
41113
+ </div>
41114
+ </div>
41115
+ </header>
41116
+
41117
+ <div class="game-container">
41118
+ <div class="loading" id="loading">Loading your game...</div>
41119
+
41120
+ <div class="error hidden" id="error">
41121
+ <div>❌ Failed to load game</div>
41122
+ <div
41123
+ style="margin-top: 0.5rem; font-size: 0.9rem; opacity: 0.8"
41124
+ id="errorMessage"
41125
+ ></div>
41126
+ </div>
41127
+
41128
+ <iframe
41129
+ class="game-frame hidden"
41130
+ id="gameFrame"
41131
+ src="/game"
41132
+ ></iframe>
41133
+ </div>
41134
+
41135
+ <script type="module">
41136
+ import { bus, BusEvents } from '@playcademy/sdk'
41137
+
41138
+ const status = document.getElementById('status')
41139
+ const loading = document.getElementById('loading')
41140
+ const error = document.getElementById('error')
41141
+ const errorMessage = document.getElementById('errorMessage')
41142
+ const gameFrame = document.getElementById('gameFrame')
41143
+
41144
+ const logIfDebug = (...args) => {
41145
+ if (window.PLAYCADEMY_DEBUG) {
41146
+ console.log('[PlaycademyDevShell]', ...args)
41147
+ }
41148
+ }
41149
+
41150
+ logIfDebug('Playcademy Dev Shell initialized')
41151
+
41152
+ async function checkSandboxConnection() {
41153
+ try {
41154
+ const response = await fetch('{{SANDBOX_URL}}/users/me', {
41155
+ headers: {
41156
+ Authorization: 'Bearer dev-token',
41157
+ },
41158
+ })
41159
+
41160
+ if (response.ok) {
41161
+ status.textContent = ''
41162
+ logIfDebug('Sandbox API connection successful')
41163
+ } else {
41164
+ throw new Error('Sandbox API not available')
41165
+ }
41166
+ } catch (err) {
41167
+ logIfDebug('Sandbox connection failed:', err)
41168
+ status.textContent = '⚠️ Sandbox Offline'
41169
+ }
41170
+ }
41171
+
41172
+ // Load the game iframe
41173
+ function loadGame() {
41174
+ gameFrame.onload = () => {
41175
+ loading.classList.add('hidden')
41176
+ gameFrame.classList.remove('hidden')
41177
+
41178
+ logIfDebug(
41179
+ 'Game iframe loaded, sending PLAYCADEMY_INIT message',
41180
+ )
41181
+
41182
+ gameFrame.contentWindow.postMessage(
41183
+ {
41184
+ type: BusEvents.INIT,
41185
+ payload: {
41186
+ baseUrl: '{{SANDBOX_URL}}',
41187
+ token: 'dev-token',
41188
+ gameId: '{{GAME_ID}}',
41189
+ },
41190
+ },
41191
+ '*',
41192
+ )
41193
+ }
41194
+
41195
+ gameFrame.onerror = () => {
41196
+ loading.classList.add('hidden')
41197
+ error.classList.remove('hidden')
41198
+ errorMessage.textContent = 'Game iframe failed to load'
41199
+ logIfDebug('Game iframe failed to load')
41200
+ }
41201
+
41202
+ gameFrame.src = '/game'
41203
+ }
41204
+
41205
+ window.addEventListener('message', event => {
41206
+ if (event.source === gameFrame.contentWindow) {
41207
+ const { type, ...payload } = event.data || {}
41208
+ if (type && type.startsWith('PLAYCADEMY_')) {
41209
+ logIfDebug('Received message from game:', type, payload)
41210
+ bus.emit(type, payload)
41211
+ }
41212
+ }
41213
+ })
41214
+
41215
+ // Initialize
41216
+ checkSandboxConnection()
41217
+ loadGame()
41218
+ </script>
41219
+ </body>
41220
+ </html>
41221
+ `;
41222
+
41223
+ // src/lib/server.ts
41224
+ function generateLoaderHTML(sandboxUrl, gameId) {
41225
+ return shell_default.replace(/{{SANDBOX_URL}}/g, sandboxUrl).replace(/{{GAME_ID}}/g, gameId);
41226
+ }
41227
+ function devServerMiddleware(server, sandboxUrl, project) {
41228
+ server.middlewares.use("/", (req, res, next) => {
41229
+ if (req.url === "/" && req.method === "GET") {
41230
+ res.setHeader("Content-Type", "text/html");
41231
+ const gameId = project.slug;
41232
+ res.end(generateLoaderHTML(sandboxUrl, gameId));
41233
+ return;
41234
+ }
41235
+ next();
41236
+ });
41237
+ }
41238
+
41239
+ // src/lib/manifest.ts
41240
+ var import_archiver = __toESM(require_archiver(), 1);
41241
+ var import_picocolors2 = __toESM(require_picocolors(), 1);
41242
+ import path2 from "node:path";
41243
+ import fs2 from "node:fs/promises";
41244
+ import { createWriteStream } from "node:fs";
41245
+ var LOG_LINE_TOTAL_WIDTH = 60;
40907
41246
  async function generatePlaycademyManifest(config, options, outDir, buildOutputs) {
40908
41247
  const manifestData = {
40909
41248
  version: "1",
40910
41249
  bootMode: options.bootMode,
40911
41250
  entryPoint: options.entryPoint,
40912
41251
  styles: options.styles || [],
40913
- engine: options.engine || "custom",
41252
+ platform: options.platform || "web",
40914
41253
  createdAt: new Date().toISOString()
40915
41254
  };
40916
- const manifestPath = path.resolve(outDir, "playcademy.manifest.json");
41255
+ const manifestPath = path2.resolve(outDir, "playcademy.manifest.json");
40917
41256
  const manifestJson = JSON.stringify(manifestData, null, 2);
40918
- await fs.writeFile(manifestPath, manifestJson);
41257
+ await fs2.writeFile(manifestPath, manifestJson);
40919
41258
  try {
40920
- const stats = await fs.stat(manifestPath);
40921
- buildOutputs.manifestPath = path.relative(config.root, manifestPath);
41259
+ const stats = await fs2.stat(manifestPath);
41260
+ buildOutputs.manifestPath = path2.relative(config.root, manifestPath);
40922
41261
  buildOutputs.manifestSizeKb = (stats.size / 1024).toFixed(2);
40923
41262
  } catch (statError) {
40924
41263
  config.logger.warn(`[Playcademy] Could not get stats for manifest file: ${statError}`);
40925
41264
  }
40926
41265
  }
40927
41266
  async function createOutputZipArchive(config, outDir, buildOutputs) {
40928
- const projectRoot = path.resolve(config.root);
40929
- const projectName = path.basename(projectRoot);
40930
- const playcademyDir = path.resolve(projectRoot, ".playcademy");
40931
- await fs.mkdir(playcademyDir, { recursive: true });
41267
+ const projectRoot = path2.resolve(config.root);
41268
+ const projectName = path2.basename(projectRoot);
41269
+ const playcademyDir = path2.resolve(projectRoot, ".playcademy");
41270
+ await fs2.mkdir(playcademyDir, { recursive: true });
40932
41271
  const zipName = `${projectName}.zip`;
40933
- const zipOutPath = path.resolve(playcademyDir, zipName);
41272
+ const zipOutPath = path2.resolve(playcademyDir, zipName);
40934
41273
  const output = createWriteStream(zipOutPath);
40935
41274
  const archive = import_archiver.default("zip", {
40936
41275
  zlib: { level: 9 }
40937
41276
  });
40938
41277
  await new Promise((resolve, reject) => {
40939
41278
  output.on("close", () => {
40940
- buildOutputs.zipPath = path.relative(config.root, zipOutPath);
41279
+ buildOutputs.zipPath = path2.relative(config.root, zipOutPath);
40941
41280
  buildOutputs.zipSizeKb = (archive.pointer() / 1024).toFixed(2);
40942
41281
  resolve();
40943
41282
  });
@@ -40952,64 +41291,77 @@ function performPlaycademyLogging(config, buildOutputs) {
40952
41291
  return;
40953
41292
  }
40954
41293
  config.logger.info("");
40955
- config.logger.info(import_picocolors.default.magenta("[Playcademy]"));
41294
+ config.logger.info(import_picocolors2.default.magenta("[Playcademy]"));
40956
41295
  if (buildOutputs.manifestPath && buildOutputs.manifestSizeKb) {
40957
- const dir = path.dirname(buildOutputs.manifestPath);
40958
- const file = path.basename(buildOutputs.manifestPath);
41296
+ const dir = path2.dirname(buildOutputs.manifestPath);
41297
+ const file = path2.basename(buildOutputs.manifestPath);
40959
41298
  const uncoloredPathLength = (dir === "." ? 0 : dir.length + 1) + file.length;
40960
- const coloredPath = `${import_picocolors.default.dim(dir === "." ? "" : dir + "/")}${import_picocolors.default.green(file)}`;
41299
+ const coloredPath = `${import_picocolors2.default.dim(dir === "." ? "" : dir + "/")}${import_picocolors2.default.green(file)}`;
40961
41300
  const formattedNumber = formatNumberWithCommas(buildOutputs.manifestSizeKb);
40962
41301
  const sizeString = `${formattedNumber} kB`;
40963
- const formattedSize = import_picocolors.default.bold(import_picocolors.default.yellow(sizeString));
41302
+ const formattedSize = import_picocolors2.default.bold(import_picocolors2.default.yellow(sizeString));
40964
41303
  const paddingNeeded = Math.max(2, LOG_LINE_TOTAL_WIDTH - uncoloredPathLength - sizeString.length);
40965
41304
  const paddingSpaces = " ".repeat(paddingNeeded);
40966
41305
  config.logger.info(`${coloredPath}${paddingSpaces}${formattedSize}`);
40967
41306
  }
40968
41307
  if (buildOutputs.zipPath && buildOutputs.zipSizeKb) {
40969
- let dir = path.dirname(buildOutputs.zipPath);
40970
- const file = path.basename(buildOutputs.zipPath);
41308
+ let dir = path2.dirname(buildOutputs.zipPath);
41309
+ const file = path2.basename(buildOutputs.zipPath);
40971
41310
  if (dir === ".")
40972
41311
  dir = "";
40973
41312
  const uncoloredPathLength = (dir ? dir.length + 1 : 0) + file.length;
40974
- const coloredPath = `${dir ? import_picocolors.default.dim(dir + "/") : ""}${import_picocolors.default.green(file)}`;
41313
+ const coloredPath = `${dir ? import_picocolors2.default.dim(dir + "/") : ""}${import_picocolors2.default.green(file)}`;
40975
41314
  const formattedNumber = formatNumberWithCommas(buildOutputs.zipSizeKb);
40976
41315
  const sizeString = `${formattedNumber} kB`;
40977
- const formattedSize = import_picocolors.default.bold(import_picocolors.default.yellow(sizeString));
41316
+ const formattedSize = import_picocolors2.default.bold(import_picocolors2.default.yellow(sizeString));
40978
41317
  const paddingNeeded = Math.max(2, LOG_LINE_TOTAL_WIDTH - uncoloredPathLength - sizeString.length);
40979
41318
  const paddingSpaces = " ".repeat(paddingNeeded);
40980
41319
  config.logger.info(`${coloredPath}${paddingSpaces}${formattedSize}`);
40981
41320
  }
40982
41321
  config.logger.info("");
40983
41322
  }
41323
+
41324
+ // src/index.ts
40984
41325
  function playcademy(options = {}) {
40985
41326
  let viteConfig;
40986
41327
  let currentBuildOutputs = {};
40987
- const finalOptions = {
40988
- bootMode: options.bootMode ?? "iframe",
40989
- entryPoint: options.entryPoint ?? "index.html",
40990
- styles: options.styles ?? [],
40991
- engine: options.engine ?? "custom",
40992
- autoZip: process.env.CI === "true" ? false : options.autoZip ?? false
41328
+ let sandboxCleanup = null;
41329
+ const exportOptions = options.export ?? {};
41330
+ const sandboxOptions = options.sandbox ?? {};
41331
+ const _options = {
41332
+ bootMode: exportOptions.bootMode ?? "iframe",
41333
+ entryPoint: exportOptions.entryPoint ?? "index.html",
41334
+ styles: exportOptions.styles ?? [],
41335
+ platform: exportOptions.platform ?? "web",
41336
+ autoZip: exportOptions.autoZip ?? false,
41337
+ sandboxUrl: sandboxOptions.url ?? "http://localhost:4321/api",
41338
+ startSandbox: sandboxOptions.autoStart ?? true,
41339
+ verbose: sandboxOptions.verbose ?? false
40993
41340
  };
40994
41341
  return {
40995
41342
  name: "vite-plugin-playcademy",
40996
41343
  config(userConfig) {
40997
- if (userConfig.base === undefined) {
40998
- return {
40999
- base: "./"
41000
- };
41001
- }
41002
- return {};
41344
+ return userConfig.base === undefined ? { base: "./" } : {};
41003
41345
  },
41004
41346
  configResolved(resolvedConfig) {
41005
41347
  viteConfig = resolvedConfig;
41006
41348
  currentBuildOutputs = {};
41007
41349
  },
41350
+ async configureServer(server) {
41351
+ const sandbox = await startSandbox(viteConfig, _options.startSandbox, _options.verbose);
41352
+ sandboxCleanup = sandbox.cleanup;
41353
+ if (sandbox.project) {
41354
+ devServerMiddleware(server, sandbox.url, sandbox.project);
41355
+ }
41356
+ server.httpServer?.on("close", () => {
41357
+ sandboxCleanup?.();
41358
+ });
41359
+ },
41008
41360
  async writeBundle() {
41009
- const outDir = viteConfig.build.outDir || path.join(process.cwd(), "dist");
41361
+ const outDir = viteConfig.build.outDir || path3.join(process.cwd(), "dist");
41010
41362
  try {
41011
- await generatePlaycademyManifest(viteConfig, finalOptions, outDir, currentBuildOutputs);
41012
- if (finalOptions.autoZip) {
41363
+ await generatePlaycademyManifest(viteConfig, _options, outDir, currentBuildOutputs);
41364
+ if (_options.autoZip) {
41013
41365
  await createOutputZipArchive(viteConfig, outDir, currentBuildOutputs);
41014
41366
  }
41015
41367
  } catch (error) {