eser 4.0.6 → 4.0.8

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 (2) hide show
  1. package/eser.js +1592 -1484
  2. package/package.json +1 -1
package/eser.js CHANGED
@@ -55,89 +55,108 @@ var init_types = __esm({
55
55
  });
56
56
 
57
57
  // pkg/@eser/standards/runtime/detect.ts
58
- var detectRuntime, getRuntimeVersion, isDeno, isNode, isBun, isWorkerd, isBrowser, isServer, isEdge;
58
+ var globalRef, isWorkerdEnv, isBrowserEnv, detectRuntime, versionGetters, getRuntimeVersion, isDeno, isNode, isBun, isWorkerd, isBrowser, SERVER_RUNTIMES, isServer, isEdge;
59
59
  var init_detect = __esm({
60
60
  "pkg/@eser/standards/runtime/detect.ts"() {
61
+ globalRef = globalThis;
62
+ isWorkerdEnv = () => typeof globalRef.caches !== "undefined" && typeof globalRef.Request !== "undefined" && typeof globalRef.Response !== "undefined" && typeof globalRef.window === "undefined" && typeof globalRef.document === "undefined";
63
+ isBrowserEnv = () => typeof globalRef.window !== "undefined" || typeof globalRef.document !== "undefined";
61
64
  detectRuntime = () => {
62
- if (typeof globalThis !== "undefined") {
63
- if (typeof globalThis.Bun !== "undefined") {
64
- return "bun";
65
- }
66
- if (typeof globalThis.Deno !== "undefined") {
67
- return "deno";
68
- }
69
- const proc = globalThis.process;
70
- if (proc?.versions?.node && !proc?.versions?.bun) {
71
- return "node";
72
- }
73
- const g = globalThis;
74
- if (typeof g.caches !== "undefined" && typeof g.Request !== "undefined" && typeof g.Response !== "undefined" && typeof g.window === "undefined" && typeof g.document === "undefined") {
75
- return "workerd";
76
- }
77
- if (typeof g.window !== "undefined" || typeof g.document !== "undefined") {
78
- return "browser";
79
- }
80
- }
65
+ if (typeof globalThis === "undefined") return "unknown";
66
+ if (typeof globalRef.Bun !== "undefined") return "bun";
67
+ if (typeof globalRef.Deno !== "undefined") return "deno";
68
+ const proc = globalRef.process;
69
+ if (proc?.versions?.node && !proc?.versions?.bun) return "node";
70
+ if (isWorkerdEnv()) return "workerd";
71
+ if (isBrowserEnv()) return "browser";
81
72
  return "unknown";
82
73
  };
83
- getRuntimeVersion = () => {
84
- const runtime2 = detectRuntime();
85
- switch (runtime2) {
86
- case "deno": {
87
- return globalThis.Deno?.version?.deno ?? "unknown";
88
- }
89
- case "bun": {
90
- return globalThis.Bun?.version ?? "unknown";
91
- }
92
- case "node": {
93
- return globalThis.process?.versions?.node ?? "unknown";
94
- }
95
- case "workerd": {
96
- return "unknown";
97
- }
98
- case "browser": {
99
- return globalThis.navigator?.userAgent ?? "unknown";
100
- }
101
- default: {
102
- return "unknown";
103
- }
104
- }
74
+ versionGetters = {
75
+ deno: () => globalRef.Deno?.version?.deno ?? "unknown",
76
+ bun: () => globalRef.Bun?.version ?? "unknown",
77
+ node: () => globalRef.process?.versions?.node ?? "unknown",
78
+ workerd: () => "unknown",
79
+ browser: () => globalRef.navigator?.userAgent ?? "unknown",
80
+ unknown: () => "unknown"
105
81
  };
82
+ getRuntimeVersion = () => versionGetters[detectRuntime()]();
106
83
  isDeno = () => detectRuntime() === "deno";
107
84
  isNode = () => detectRuntime() === "node";
108
85
  isBun = () => detectRuntime() === "bun";
109
86
  isWorkerd = () => detectRuntime() === "workerd";
110
87
  isBrowser = () => detectRuntime() === "browser";
111
- isServer = () => {
112
- const rt = detectRuntime();
113
- return rt === "deno" || rt === "node" || rt === "bun";
88
+ SERVER_RUNTIMES = /* @__PURE__ */ new Set([
89
+ "deno",
90
+ "node",
91
+ "bun"
92
+ ]);
93
+ isServer = () => SERVER_RUNTIMES.has(detectRuntime());
94
+ isEdge = () => detectRuntime() === "workerd";
95
+ }
96
+ });
97
+
98
+ // pkg/@eser/standards/runtime/helpers.ts
99
+ var getEnvVar, getFirstEnvVar, tryRequire, getProcess, getNavigator;
100
+ var init_helpers = __esm({
101
+ "pkg/@eser/standards/runtime/helpers.ts"() {
102
+ getEnvVar = (key) => {
103
+ if (typeof Deno !== "undefined" && Deno.env?.get) {
104
+ return Deno.env.get(key);
105
+ }
106
+ const proc = globalThis.process;
107
+ if (proc?.env) {
108
+ return proc.env[key];
109
+ }
110
+ return void 0;
111
+ };
112
+ getFirstEnvVar = (...keys) => {
113
+ for (const key of keys) {
114
+ const value2 = getEnvVar(key);
115
+ if (value2 !== void 0) {
116
+ return value2;
117
+ }
118
+ }
119
+ return void 0;
120
+ };
121
+ tryRequire = (moduleName) => {
122
+ try {
123
+ const requireFn = globalThis.require;
124
+ if (requireFn instanceof Function) {
125
+ return requireFn(moduleName);
126
+ }
127
+ } catch {
128
+ }
129
+ return void 0;
114
130
  };
115
- isEdge = () => {
116
- const rt = detectRuntime();
117
- return rt === "workerd";
131
+ getProcess = () => {
132
+ return globalThis.process;
133
+ };
134
+ getNavigator = () => {
135
+ return globalThis.navigator;
118
136
  };
119
137
  }
120
138
  });
121
139
 
122
140
  // pkg/@eser/standards/runtime/platform.ts
123
- var getPlatform, getArch, getHomedir, getTmpdir, getPlatformInfo;
141
+ var PLATFORM_MAP, getPlatform, ARCH_MAP, getArch, getHomedir, getTmpdir, getPlatformInfo;
124
142
  var init_platform = __esm({
125
143
  "pkg/@eser/standards/runtime/platform.ts"() {
144
+ init_helpers();
145
+ PLATFORM_MAP = {
146
+ darwin: "darwin",
147
+ linux: "linux",
148
+ windows: "windows",
149
+ win32: "windows"
150
+ };
126
151
  getPlatform = () => {
127
152
  if (typeof Deno !== "undefined" && Deno.build?.os) {
128
- const os = Deno.build.os;
129
- if (os === "darwin") return "darwin";
130
- if (os === "linux") return "linux";
131
- if (os === "windows") return "windows";
153
+ return PLATFORM_MAP[Deno.build.os] ?? "linux";
132
154
  }
133
- const proc = globalThis.process;
155
+ const proc = getProcess();
134
156
  if (proc?.platform) {
135
- const platform = proc.platform;
136
- if (platform === "darwin") return "darwin";
137
- if (platform === "linux") return "linux";
138
- if (platform === "win32") return "windows";
157
+ return PLATFORM_MAP[proc.platform] ?? "linux";
139
158
  }
140
- const nav = globalThis.navigator;
159
+ const nav = getNavigator();
141
160
  if (nav?.userAgent) {
142
161
  const ua = nav.userAgent.toLowerCase();
143
162
  if (ua.includes("mac")) return "darwin";
@@ -146,19 +165,21 @@ var init_platform = __esm({
146
165
  }
147
166
  return "linux";
148
167
  };
168
+ ARCH_MAP = {
169
+ x86_64: "amd64",
170
+ x64: "amd64",
171
+ aarch64: "arm64",
172
+ arm64: "arm64"
173
+ };
149
174
  getArch = () => {
150
175
  if (typeof Deno !== "undefined" && Deno.build?.arch) {
151
- const arch = Deno.build.arch;
152
- if (arch === "x86_64") return "amd64";
153
- if (arch === "aarch64") return "arm64";
176
+ return ARCH_MAP[Deno.build.arch] ?? "amd64";
154
177
  }
155
- const proc = globalThis.process;
178
+ const proc = getProcess();
156
179
  if (proc?.arch) {
157
- const arch = proc.arch;
158
- if (arch === "x64") return "amd64";
159
- if (arch === "arm64") return "arm64";
180
+ return ARCH_MAP[proc.arch] ?? "amd64";
160
181
  }
161
- const nav = globalThis.navigator;
182
+ const nav = getNavigator();
162
183
  if (nav?.userAgent) {
163
184
  const ua = nav.userAgent.toLowerCase();
164
185
  if (ua.includes("arm64") || ua.includes("aarch64")) return "arm64";
@@ -166,50 +187,22 @@ var init_platform = __esm({
166
187
  return "amd64";
167
188
  };
168
189
  getHomedir = () => {
169
- if (typeof Deno !== "undefined" && Deno.env?.get) {
170
- const home = Deno.env.get("HOME") ?? Deno.env.get("USERPROFILE");
171
- if (home) return home;
172
- }
173
- const proc = globalThis.process;
174
- if (proc?.env) {
175
- const home = proc.env.HOME ?? proc.env.USERPROFILE;
176
- if (home) return home;
177
- }
178
- try {
179
- const os = globalThis.require?.("os");
180
- if (os?.homedir) {
181
- return os.homedir();
182
- }
183
- } catch {
184
- }
185
- const platform = getPlatform();
186
- if (platform === "windows") {
187
- return "C:\\Users\\Default";
190
+ const home = getFirstEnvVar("HOME", "USERPROFILE");
191
+ if (home) return home;
192
+ const os = tryRequire("os");
193
+ if (os?.homedir) {
194
+ return os.homedir();
188
195
  }
189
- return "/home";
196
+ return getPlatform() === "windows" ? "C:\\Users\\Default" : "/home";
190
197
  };
191
198
  getTmpdir = () => {
192
- if (typeof Deno !== "undefined" && Deno.env?.get) {
193
- const tmp = Deno.env.get("TMPDIR") ?? Deno.env.get("TMP") ?? Deno.env.get("TEMP");
194
- if (tmp) return tmp;
195
- }
196
- const proc = globalThis.process;
197
- if (proc?.env) {
198
- const tmp = proc.env.TMPDIR ?? proc.env.TMP ?? proc.env.TEMP;
199
- if (tmp) return tmp;
200
- }
201
- try {
202
- const os = globalThis.require?.("os");
203
- if (os?.tmpdir) {
204
- return os.tmpdir();
205
- }
206
- } catch {
199
+ const tmp = getFirstEnvVar("TMPDIR", "TMP", "TEMP");
200
+ if (tmp) return tmp;
201
+ const os = tryRequire("os");
202
+ if (os?.tmpdir) {
203
+ return os.tmpdir();
207
204
  }
208
- const platform = getPlatform();
209
- if (platform === "windows") {
210
- return "C:\\Windows\\Temp";
211
- }
212
- return "/tmp";
205
+ return getPlatform() === "windows" ? "C:\\Windows\\Temp" : "/tmp";
213
206
  };
214
207
  getPlatformInfo = () => {
215
208
  return {
@@ -222,520 +215,89 @@ var init_platform = __esm({
222
215
  }
223
216
  });
224
217
 
225
- // pkg/@eser/standards/runtime/capabilities.ts
226
- var FULL_CAPABILITIES, DENO_CAPABILITIES, NODE_CAPABILITIES, BUN_CAPABILITIES, WORKERD_CAPABILITIES, BROWSER_CAPABILITIES, UNKNOWN_CAPABILITIES, getCapabilities, hasCapability;
227
- var init_capabilities = __esm({
228
- "pkg/@eser/standards/runtime/capabilities.ts"() {
229
- FULL_CAPABILITIES = {
230
- fs: true,
231
- fsSync: true,
232
- exec: true,
233
- process: true,
234
- env: true,
235
- stdin: true,
236
- stdout: true,
237
- kv: false
238
- };
239
- DENO_CAPABILITIES = {
240
- fs: true,
241
- fsSync: true,
242
- exec: true,
243
- process: true,
244
- env: true,
245
- stdin: true,
246
- stdout: true,
247
- kv: true
248
- };
249
- NODE_CAPABILITIES = {
250
- fs: true,
251
- fsSync: true,
252
- exec: true,
253
- process: true,
254
- env: true,
255
- stdin: true,
256
- stdout: true,
257
- kv: false
258
- };
259
- BUN_CAPABILITIES = {
260
- fs: true,
261
- fsSync: true,
262
- exec: true,
263
- process: true,
264
- env: true,
265
- stdin: true,
266
- stdout: true,
267
- kv: false
268
- };
269
- WORKERD_CAPABILITIES = {
270
- fs: false,
271
- fsSync: false,
272
- exec: false,
273
- process: false,
274
- env: true,
275
- stdin: false,
276
- stdout: false,
277
- kv: true
278
- };
279
- BROWSER_CAPABILITIES = {
280
- fs: false,
281
- fsSync: false,
282
- exec: false,
283
- process: false,
284
- env: false,
285
- stdin: false,
286
- stdout: false,
287
- kv: false
288
- };
289
- UNKNOWN_CAPABILITIES = {
290
- fs: false,
291
- fsSync: false,
292
- exec: false,
293
- process: false,
294
- env: false,
295
- stdin: false,
296
- stdout: false,
297
- kv: false
298
- };
299
- getCapabilities = (runtime2) => {
300
- switch (runtime2) {
301
- case "deno":
302
- return DENO_CAPABILITIES;
303
- case "node":
304
- return NODE_CAPABILITIES;
305
- case "bun":
306
- return BUN_CAPABILITIES;
307
- case "workerd":
308
- return WORKERD_CAPABILITIES;
309
- case "browser":
310
- return BROWSER_CAPABILITIES;
311
- default:
312
- return UNKNOWN_CAPABILITIES;
313
- }
314
- };
315
- hasCapability = (runtime2, capability) => {
316
- return getCapabilities(runtime2)[capability];
317
- };
218
+ // deno:https://jsr.io/@std/internal/1.0.12/_os.ts
219
+ function checkWindows() {
220
+ const global = globalThis;
221
+ const os = global.Deno?.build?.os;
222
+ return typeof os === "string" ? os === "windows" : global.navigator?.platform?.startsWith("Win") ?? global.process?.platform?.startsWith("win") ?? false;
223
+ }
224
+ var init_os = __esm({
225
+ "deno:https://jsr.io/@std/internal/1.0.12/_os.ts"() {
318
226
  }
319
227
  });
320
228
 
321
- // pkg/@eser/standards/runtime/polyfills/path.ts
322
- var POSIX_SEP, POSIX_DELIMITER, normalizeSlashes, join, resolve, dirname, basename, extname, normalize, isAbsolute, relative, parse, format, posixPath;
323
- var init_path = __esm({
324
- "pkg/@eser/standards/runtime/polyfills/path.ts"() {
325
- POSIX_SEP = "/";
326
- POSIX_DELIMITER = ":";
327
- normalizeSlashes = (path) => {
328
- return path.replace(/\\/g, "/").replace(/\/+/g, "/");
329
- };
330
- join = (...paths) => {
331
- if (paths.length === 0) return ".";
332
- const joined = paths.filter((p) => p.length > 0).join(POSIX_SEP);
333
- if (joined.length === 0) return ".";
334
- return normalize(joined);
335
- };
336
- resolve = (...paths) => {
337
- let resolvedPath = "";
338
- let resolvedAbsolute = false;
339
- for (let i = paths.length - 1; i >= 0 && !resolvedAbsolute; i--) {
340
- const segment = paths[i];
341
- if (segment === void 0 || segment.length === 0) continue;
342
- resolvedPath = `${segment}/${resolvedPath}`;
343
- resolvedAbsolute = isAbsolute(segment);
344
- }
345
- resolvedPath = normalizeSlashes(resolvedPath);
346
- if (resolvedPath.length > 1 && resolvedPath.endsWith("/")) {
347
- resolvedPath = resolvedPath.slice(0, -1);
348
- }
349
- return normalize(resolvedPath) ?? ".";
350
- };
351
- dirname = (path) => {
352
- if (path.length === 0) return ".";
353
- path = normalizeSlashes(path);
354
- while (path.length > 1 && path.endsWith("/")) {
355
- path = path.slice(0, -1);
356
- }
357
- const lastSlash = path.lastIndexOf("/");
358
- if (lastSlash === -1) return ".";
359
- if (lastSlash === 0) return "/";
360
- return path.slice(0, lastSlash);
361
- };
362
- basename = (path, suffix) => {
363
- if (path.length === 0) return "";
364
- path = normalizeSlashes(path);
365
- while (path.length > 1 && path.endsWith("/")) {
366
- path = path.slice(0, -1);
367
- }
368
- const lastSlash = path.lastIndexOf("/");
369
- let base = lastSlash === -1 ? path : path.slice(lastSlash + 1);
370
- if (suffix && base.endsWith(suffix)) {
371
- base = base.slice(0, -suffix.length);
372
- }
373
- return base;
374
- };
375
- extname = (path) => {
376
- const base = basename(path);
377
- const lastDot = base.lastIndexOf(".");
378
- if (lastDot <= 0 || lastDot === base.length - 1) {
379
- return "";
229
+ // deno:https://jsr.io/@std/internal/1.0.12/os.ts
230
+ var isWindows;
231
+ var init_os2 = __esm({
232
+ "deno:https://jsr.io/@std/internal/1.0.12/os.ts"() {
233
+ init_os();
234
+ isWindows = checkWindows();
235
+ }
236
+ });
237
+
238
+ // deno:https://jsr.io/@std/path/1.1.4/_common/assert_path.ts
239
+ function assertPath(path) {
240
+ if (typeof path !== "string") {
241
+ throw new TypeError(`Path must be a string, received "${JSON.stringify(path)}"`);
242
+ }
243
+ }
244
+ var init_assert_path = __esm({
245
+ "deno:https://jsr.io/@std/path/1.1.4/_common/assert_path.ts"() {
246
+ }
247
+ });
248
+
249
+ // deno:https://jsr.io/@std/path/1.1.4/_common/basename.ts
250
+ function stripSuffix(name, suffix) {
251
+ if (suffix.length >= name.length) {
252
+ return name;
253
+ }
254
+ const lenDiff = name.length - suffix.length;
255
+ for (let i = suffix.length - 1; i >= 0; --i) {
256
+ if (name.charCodeAt(lenDiff + i) !== suffix.charCodeAt(i)) {
257
+ return name;
258
+ }
259
+ }
260
+ return name.slice(0, -suffix.length);
261
+ }
262
+ function lastPathSegment(path, isSep, start = 0) {
263
+ let matchedNonSeparator = false;
264
+ let end = path.length;
265
+ for (let i = path.length - 1; i >= start; --i) {
266
+ if (isSep(path.charCodeAt(i))) {
267
+ if (matchedNonSeparator) {
268
+ start = i + 1;
269
+ break;
380
270
  }
381
- return base.slice(lastDot);
382
- };
383
- normalize = (path) => {
384
- if (path.length === 0) return ".";
385
- path = normalizeSlashes(path);
386
- const isAbs = path.startsWith("/");
387
- const trailingSlash = path.endsWith("/");
388
- const segments = path.split("/").filter((s) => s.length > 0);
389
- const result = [];
390
- for (const segment of segments) {
391
- if (segment === ".") {
392
- continue;
393
- }
394
- if (segment === "..") {
395
- if (result.length > 0 && result[result.length - 1] !== "..") {
396
- result.pop();
397
- } else if (!isAbs) {
398
- result.push("..");
399
- }
400
- } else {
401
- result.push(segment);
402
- }
403
- }
404
- let normalized = result.join("/");
405
- if (isAbs) {
406
- normalized = `/${normalized}`;
407
- }
408
- if (trailingSlash && normalized.length > 1) {
409
- normalized += "/";
410
- }
411
- return normalized ?? ".";
412
- };
413
- isAbsolute = (path) => {
414
- if (path.length === 0) return false;
415
- if (path.startsWith("/")) return true;
416
- if (path.length >= 3 && /^[a-zA-Z]:[/\\]/.test(path)) {
417
- return true;
418
- }
419
- return false;
420
- };
421
- relative = (from, to) => {
422
- if (from === to) return "";
423
- from = resolve(from);
424
- to = resolve(to);
425
- if (from === to) return "";
426
- const fromParts = from.split("/").filter((p) => p.length > 0);
427
- const toParts = to.split("/").filter((p) => p.length > 0);
428
- let commonLength = 0;
429
- const minLength = Math.min(fromParts.length, toParts.length);
430
- for (let i = 0; i < minLength; i++) {
431
- if (fromParts[i] !== toParts[i]) break;
432
- commonLength++;
433
- }
434
- const upCount = fromParts.length - commonLength;
435
- const remaining = toParts.slice(commonLength);
436
- const result = [
437
- ...Array(upCount).fill(".."),
438
- ...remaining
439
- ];
440
- return result.join("/") ?? ".";
441
- };
442
- parse = (path) => {
443
- if (path.length === 0) {
444
- return {
445
- root: "",
446
- dir: "",
447
- base: "",
448
- ext: "",
449
- name: ""
450
- };
451
- }
452
- path = normalizeSlashes(path);
453
- let root = "";
454
- let dir = "";
455
- const base = basename(path);
456
- const ext = extname(path);
457
- const name = ext ? base.slice(0, -ext.length) : base;
458
- if (path.startsWith("/")) {
459
- root = "/";
460
- } else if (/^[a-zA-Z]:[/\\]/.test(path)) {
461
- root = path.slice(0, 3);
462
- }
463
- dir = dirname(path);
464
- if (dir === ".") {
465
- dir = "";
466
- }
467
- return {
468
- root,
469
- dir,
470
- base,
471
- ext,
472
- name
473
- };
474
- };
475
- format = (pathObject) => {
476
- const { root = "", dir, base, ext = "", name = "" } = pathObject;
477
- const finalBase = base ?? name + ext;
478
- if (dir) {
479
- if (dir === root) {
480
- return `${dir}${finalBase}`;
481
- }
482
- return `${dir}/${finalBase}`;
483
- }
484
- return `${root}${finalBase}`;
485
- };
486
- posixPath = {
487
- join,
488
- resolve,
489
- dirname,
490
- basename,
491
- extname,
492
- normalize,
493
- isAbsolute,
494
- relative,
495
- parse,
496
- format,
497
- sep: POSIX_SEP,
498
- delimiter: POSIX_DELIMITER
499
- };
271
+ } else if (!matchedNonSeparator) {
272
+ matchedNonSeparator = true;
273
+ end = i + 1;
274
+ }
275
+ }
276
+ return path.slice(start, end);
277
+ }
278
+ function assertArgs(path, suffix) {
279
+ assertPath(path);
280
+ if (path.length === 0) return path;
281
+ if (typeof suffix !== "string") {
282
+ throw new TypeError(`Suffix must be a string, received "${JSON.stringify(suffix)}"`);
283
+ }
284
+ }
285
+ var init_basename = __esm({
286
+ "deno:https://jsr.io/@std/path/1.1.4/_common/basename.ts"() {
287
+ init_assert_path();
500
288
  }
501
289
  });
502
290
 
503
- // pkg/@eser/standards/runtime/file-search.ts
504
- var searchFileHierarchy;
505
- var init_file_search = __esm({
506
- "pkg/@eser/standards/runtime/file-search.ts"() {
507
- init_mod2();
508
- searchFileHierarchy = async (startDir, filenames, options = {}) => {
509
- const { searchParents = false } = options;
510
- let dir = startDir;
511
- while (true) {
512
- for (const name of filenames) {
513
- const filepath = runtime.path.join(dir, name);
514
- const exists = await runtime.fs.exists(filepath);
515
- if (exists) {
516
- const stat3 = await runtime.fs.stat(filepath);
517
- if (stat3.isFile) {
518
- return filepath;
519
- }
520
- }
521
- }
522
- if (!searchParents) {
523
- break;
524
- }
525
- const parent = runtime.path.dirname(dir);
526
- if (parent === dir) {
527
- break;
528
- }
529
- dir = parent;
530
- }
531
- return void 0;
532
- };
533
- }
534
- });
535
-
536
- // pkg/@eser/standards/runtime/adapters/workerd.ts
537
- var createWorkerdFs, createWorkerdPath, createWorkerdExec, envStorage, createWorkerdEnv, populateEnvFromContext, clearEnv, createWorkerdProcess, createWorkerdRuntime;
538
- var init_workerd = __esm({
539
- "pkg/@eser/standards/runtime/adapters/workerd.ts"() {
540
- init_types();
541
- init_capabilities();
542
- init_path();
543
- createWorkerdFs = () => {
544
- const throwNotAvailable = () => {
545
- throw new RuntimeCapabilityError("fs", "workerd");
546
- };
547
- return {
548
- readFile: throwNotAvailable,
549
- readTextFile: throwNotAvailable,
550
- writeFile: throwNotAvailable,
551
- writeTextFile: throwNotAvailable,
552
- exists: throwNotAvailable,
553
- stat: throwNotAvailable,
554
- lstat: throwNotAvailable,
555
- mkdir: throwNotAvailable,
556
- remove: throwNotAvailable,
557
- readDir: () => {
558
- throw new RuntimeCapabilityError("fs", "workerd");
559
- },
560
- copyFile: throwNotAvailable,
561
- rename: throwNotAvailable,
562
- makeTempDir: throwNotAvailable
563
- };
564
- };
565
- createWorkerdPath = () => {
566
- return posixPath;
567
- };
568
- createWorkerdExec = () => {
569
- const throwNotAvailable = () => {
570
- throw new RuntimeCapabilityError("exec", "workerd");
571
- };
572
- return {
573
- spawn: throwNotAvailable,
574
- exec: throwNotAvailable,
575
- execJson: throwNotAvailable,
576
- spawnChild: throwNotAvailable
577
- };
578
- };
579
- envStorage = /* @__PURE__ */ new Map();
580
- createWorkerdEnv = () => {
581
- return {
582
- get(key) {
583
- return envStorage.get(key);
584
- },
585
- set(key, value2) {
586
- envStorage.set(key, value2);
587
- },
588
- delete(key) {
589
- envStorage.delete(key);
590
- },
591
- has(key) {
592
- return envStorage.has(key);
593
- },
594
- toObject() {
595
- return Object.fromEntries(envStorage);
596
- }
597
- };
598
- };
599
- populateEnvFromContext = (env) => {
600
- for (const [key, value2] of Object.entries(env)) {
601
- if (typeof value2 === "string") {
602
- envStorage.set(key, value2);
603
- }
604
- }
605
- };
606
- clearEnv = () => {
607
- envStorage.clear();
608
- };
609
- createWorkerdProcess = () => {
610
- const throwNotAvailable = () => {
611
- throw new RuntimeCapabilityError("process", "workerd");
612
- };
613
- return {
614
- exit: throwNotAvailable,
615
- cwd: throwNotAvailable,
616
- chdir: throwNotAvailable,
617
- hostname: throwNotAvailable,
618
- execPath: throwNotAvailable,
619
- get args() {
620
- throw new RuntimeCapabilityError("process", "workerd");
621
- },
622
- get pid() {
623
- throw new RuntimeCapabilityError("process", "workerd");
624
- },
625
- get stdin() {
626
- throw new RuntimeCapabilityError("process", "workerd");
627
- },
628
- get stdout() {
629
- throw new RuntimeCapabilityError("process", "workerd");
630
- },
631
- get stderr() {
632
- throw new RuntimeCapabilityError("process", "workerd");
633
- }
634
- };
635
- };
636
- createWorkerdRuntime = () => {
637
- const fs = createWorkerdFs();
638
- const path = createWorkerdPath();
639
- const exec2 = createWorkerdExec();
640
- const env = createWorkerdEnv();
641
- const process = createWorkerdProcess();
642
- return {
643
- name: "workerd",
644
- version: "unknown",
645
- capabilities: WORKERD_CAPABILITIES,
646
- fs,
647
- path,
648
- exec: exec2,
649
- env,
650
- process
651
- };
652
- };
653
- }
654
- });
655
-
656
- // deno:https://jsr.io/@std/internal/1.0.12/_os.ts
657
- function checkWindows() {
658
- const global = globalThis;
659
- const os = global.Deno?.build?.os;
660
- return typeof os === "string" ? os === "windows" : global.navigator?.platform?.startsWith("Win") ?? global.process?.platform?.startsWith("win") ?? false;
661
- }
662
- var init_os = __esm({
663
- "deno:https://jsr.io/@std/internal/1.0.12/_os.ts"() {
664
- }
665
- });
666
-
667
- // deno:https://jsr.io/@std/internal/1.0.12/os.ts
668
- var isWindows;
669
- var init_os2 = __esm({
670
- "deno:https://jsr.io/@std/internal/1.0.12/os.ts"() {
671
- init_os();
672
- isWindows = checkWindows();
673
- }
674
- });
675
-
676
- // deno:https://jsr.io/@std/path/1.1.4/_common/assert_path.ts
677
- function assertPath(path) {
678
- if (typeof path !== "string") {
679
- throw new TypeError(`Path must be a string, received "${JSON.stringify(path)}"`);
680
- }
681
- }
682
- var init_assert_path = __esm({
683
- "deno:https://jsr.io/@std/path/1.1.4/_common/assert_path.ts"() {
684
- }
685
- });
686
-
687
- // deno:https://jsr.io/@std/path/1.1.4/_common/basename.ts
688
- function stripSuffix(name, suffix) {
689
- if (suffix.length >= name.length) {
690
- return name;
691
- }
692
- const lenDiff = name.length - suffix.length;
693
- for (let i = suffix.length - 1; i >= 0; --i) {
694
- if (name.charCodeAt(lenDiff + i) !== suffix.charCodeAt(i)) {
695
- return name;
696
- }
697
- }
698
- return name.slice(0, -suffix.length);
699
- }
700
- function lastPathSegment(path, isSep, start = 0) {
701
- let matchedNonSeparator = false;
702
- let end = path.length;
703
- for (let i = path.length - 1; i >= start; --i) {
704
- if (isSep(path.charCodeAt(i))) {
705
- if (matchedNonSeparator) {
706
- start = i + 1;
707
- break;
708
- }
709
- } else if (!matchedNonSeparator) {
710
- matchedNonSeparator = true;
711
- end = i + 1;
712
- }
713
- }
714
- return path.slice(start, end);
715
- }
716
- function assertArgs(path, suffix) {
717
- assertPath(path);
718
- if (path.length === 0) return path;
719
- if (typeof suffix !== "string") {
720
- throw new TypeError(`Suffix must be a string, received "${JSON.stringify(suffix)}"`);
721
- }
722
- }
723
- var init_basename = __esm({
724
- "deno:https://jsr.io/@std/path/1.1.4/_common/basename.ts"() {
725
- init_assert_path();
726
- }
727
- });
728
-
729
- // deno:https://jsr.io/@std/path/1.1.4/_common/from_file_url.ts
730
- function assertArg(url) {
731
- url = url instanceof URL ? url : new URL(url);
732
- if (url.protocol !== "file:") {
733
- throw new TypeError(`URL must be a file URL: received "${url.protocol}"`);
734
- }
735
- return url;
736
- }
737
- var init_from_file_url = __esm({
738
- "deno:https://jsr.io/@std/path/1.1.4/_common/from_file_url.ts"() {
291
+ // deno:https://jsr.io/@std/path/1.1.4/_common/from_file_url.ts
292
+ function assertArg(url) {
293
+ url = url instanceof URL ? url : new URL(url);
294
+ if (url.protocol !== "file:") {
295
+ throw new TypeError(`URL must be a file URL: received "${url.protocol}"`);
296
+ }
297
+ return url;
298
+ }
299
+ var init_from_file_url = __esm({
300
+ "deno:https://jsr.io/@std/path/1.1.4/_common/from_file_url.ts"() {
739
301
  }
740
302
  });
741
303
 
@@ -796,7 +358,7 @@ var init_util = __esm({
796
358
  });
797
359
 
798
360
  // deno:https://jsr.io/@std/path/1.1.4/posix/basename.ts
799
- function basename2(path, suffix = "") {
361
+ function basename(path, suffix = "") {
800
362
  if (path instanceof URL) {
801
363
  path = fromFileUrl(path);
802
364
  }
@@ -846,7 +408,7 @@ var init_from_file_url3 = __esm({
846
408
  });
847
409
 
848
410
  // deno:https://jsr.io/@std/path/1.1.4/windows/basename.ts
849
- function basename3(path, suffix = "") {
411
+ function basename2(path, suffix = "") {
850
412
  if (path instanceof URL) {
851
413
  path = fromFileUrl2(path);
852
414
  }
@@ -873,8 +435,8 @@ var init_basename3 = __esm({
873
435
  });
874
436
 
875
437
  // deno:https://jsr.io/@std/path/1.1.4/basename.ts
876
- function basename4(path, suffix = "") {
877
- return isWindows ? basename3(path, suffix) : basename2(path, suffix);
438
+ function basename3(path, suffix = "") {
439
+ return isWindows ? basename2(path, suffix) : basename(path, suffix);
878
440
  }
879
441
  var init_basename4 = __esm({
880
442
  "deno:https://jsr.io/@std/path/1.1.4/basename.ts"() {
@@ -907,7 +469,7 @@ var init_dirname = __esm({
907
469
  });
908
470
 
909
471
  // deno:https://jsr.io/@std/path/1.1.4/posix/dirname.ts
910
- function dirname2(path) {
472
+ function dirname(path) {
911
473
  if (path instanceof URL) {
912
474
  path = fromFileUrl(path);
913
475
  }
@@ -939,7 +501,7 @@ var init_dirname2 = __esm({
939
501
  });
940
502
 
941
503
  // deno:https://jsr.io/@std/path/1.1.4/windows/dirname.ts
942
- function dirname3(path) {
504
+ function dirname2(path) {
943
505
  if (path instanceof URL) {
944
506
  path = fromFileUrl2(path);
945
507
  }
@@ -1016,8 +578,8 @@ var init_dirname3 = __esm({
1016
578
  });
1017
579
 
1018
580
  // deno:https://jsr.io/@std/path/1.1.4/dirname.ts
1019
- function dirname4(path) {
1020
- return isWindows ? dirname3(path) : dirname2(path);
581
+ function dirname3(path) {
582
+ return isWindows ? dirname2(path) : dirname(path);
1021
583
  }
1022
584
  var init_dirname4 = __esm({
1023
585
  "deno:https://jsr.io/@std/path/1.1.4/dirname.ts"() {
@@ -1028,7 +590,7 @@ var init_dirname4 = __esm({
1028
590
  });
1029
591
 
1030
592
  // deno:https://jsr.io/@std/path/1.1.4/posix/extname.ts
1031
- function extname2(path) {
593
+ function extname(path) {
1032
594
  if (path instanceof URL) {
1033
595
  path = fromFileUrl(path);
1034
596
  }
@@ -1075,7 +637,7 @@ var init_extname = __esm({
1075
637
  });
1076
638
 
1077
639
  // deno:https://jsr.io/@std/path/1.1.4/windows/extname.ts
1078
- function extname3(path) {
640
+ function extname2(path) {
1079
641
  if (path instanceof URL) {
1080
642
  path = fromFileUrl2(path);
1081
643
  }
@@ -1126,8 +688,8 @@ var init_extname2 = __esm({
1126
688
  });
1127
689
 
1128
690
  // deno:https://jsr.io/@std/path/1.1.4/extname.ts
1129
- function extname4(path) {
1130
- return isWindows ? extname3(path) : extname2(path);
691
+ function extname3(path) {
692
+ return isWindows ? extname2(path) : extname(path);
1131
693
  }
1132
694
  var init_extname3 = __esm({
1133
695
  "deno:https://jsr.io/@std/path/1.1.4/extname.ts"() {
@@ -1157,7 +719,7 @@ var init_format = __esm({
1157
719
  });
1158
720
 
1159
721
  // deno:https://jsr.io/@std/path/1.1.4/posix/format.ts
1160
- function format2(pathObject) {
722
+ function format(pathObject) {
1161
723
  assertArg3(pathObject);
1162
724
  return _format("/", pathObject);
1163
725
  }
@@ -1168,7 +730,7 @@ var init_format2 = __esm({
1168
730
  });
1169
731
 
1170
732
  // deno:https://jsr.io/@std/path/1.1.4/windows/format.ts
1171
- function format3(pathObject) {
733
+ function format2(pathObject) {
1172
734
  assertArg3(pathObject);
1173
735
  return _format("\\", pathObject);
1174
736
  }
@@ -1179,8 +741,8 @@ var init_format3 = __esm({
1179
741
  });
1180
742
 
1181
743
  // deno:https://jsr.io/@std/path/1.1.4/format.ts
1182
- function format4(pathObject) {
1183
- return isWindows ? format3(pathObject) : format2(pathObject);
744
+ function format3(pathObject) {
745
+ return isWindows ? format2(pathObject) : format(pathObject);
1184
746
  }
1185
747
  var init_format4 = __esm({
1186
748
  "deno:https://jsr.io/@std/path/1.1.4/format.ts"() {
@@ -1203,7 +765,7 @@ var init_from_file_url4 = __esm({
1203
765
  });
1204
766
 
1205
767
  // deno:https://jsr.io/@std/path/1.1.4/posix/is_absolute.ts
1206
- function isAbsolute2(path) {
768
+ function isAbsolute(path) {
1207
769
  assertPath(path);
1208
770
  return path.length > 0 && isPosixPathSeparator(path.charCodeAt(0));
1209
771
  }
@@ -1215,7 +777,7 @@ var init_is_absolute = __esm({
1215
777
  });
1216
778
 
1217
779
  // deno:https://jsr.io/@std/path/1.1.4/windows/is_absolute.ts
1218
- function isAbsolute3(path) {
780
+ function isAbsolute2(path) {
1219
781
  assertPath(path);
1220
782
  const len = path.length;
1221
783
  if (len === 0) return false;
@@ -1238,8 +800,8 @@ var init_is_absolute2 = __esm({
1238
800
  });
1239
801
 
1240
802
  // deno:https://jsr.io/@std/path/1.1.4/is_absolute.ts
1241
- function isAbsolute4(path) {
1242
- return isWindows ? isAbsolute3(path) : isAbsolute2(path);
803
+ function isAbsolute3(path) {
804
+ return isWindows ? isAbsolute2(path) : isAbsolute(path);
1243
805
  }
1244
806
  var init_is_absolute3 = __esm({
1245
807
  "deno:https://jsr.io/@std/path/1.1.4/is_absolute.ts"() {
@@ -1322,7 +884,7 @@ var init_normalize_string = __esm({
1322
884
  });
1323
885
 
1324
886
  // deno:https://jsr.io/@std/path/1.1.4/posix/normalize.ts
1325
- function normalize2(path) {
887
+ function normalize(path) {
1326
888
  if (path instanceof URL) {
1327
889
  path = fromFileUrl(path);
1328
890
  }
@@ -1345,7 +907,7 @@ var init_normalize2 = __esm({
1345
907
  });
1346
908
 
1347
909
  // deno:https://jsr.io/@std/path/1.1.4/posix/join.ts
1348
- function join2(path, ...paths) {
910
+ function join(path, ...paths) {
1349
911
  if (path === void 0) return ".";
1350
912
  if (path instanceof URL) {
1351
913
  path = fromFileUrl(path);
@@ -1356,7 +918,7 @@ function join2(path, ...paths) {
1356
918
  ] : paths;
1357
919
  paths.forEach((path2) => assertPath(path2));
1358
920
  const joined = paths.filter((path2) => path2.length > 0).join("/");
1359
- return joined === "" ? "." : normalize2(joined);
921
+ return joined === "" ? "." : normalize(joined);
1360
922
  }
1361
923
  var init_join = __esm({
1362
924
  "deno:https://jsr.io/@std/path/1.1.4/posix/join.ts"() {
@@ -1367,7 +929,7 @@ var init_join = __esm({
1367
929
  });
1368
930
 
1369
931
  // deno:https://jsr.io/@std/path/1.1.4/windows/normalize.ts
1370
- function normalize3(path) {
932
+ function normalize2(path) {
1371
933
  if (path instanceof URL) {
1372
934
  path = fromFileUrl2(path);
1373
935
  }
@@ -1456,7 +1018,7 @@ var init_normalize3 = __esm({
1456
1018
  });
1457
1019
 
1458
1020
  // deno:https://jsr.io/@std/path/1.1.4/windows/join.ts
1459
- function join3(path, ...paths) {
1021
+ function join2(path, ...paths) {
1460
1022
  if (path instanceof URL) {
1461
1023
  path = fromFileUrl2(path);
1462
1024
  }
@@ -1492,7 +1054,7 @@ function join3(path, ...paths) {
1492
1054
  }
1493
1055
  if (slashCount >= 2) joined = `\\${joined.slice(slashCount)}`;
1494
1056
  }
1495
- return normalize3(joined);
1057
+ return normalize2(joined);
1496
1058
  }
1497
1059
  var init_join2 = __esm({
1498
1060
  "deno:https://jsr.io/@std/path/1.1.4/windows/join.ts"() {
@@ -1504,8 +1066,8 @@ var init_join2 = __esm({
1504
1066
  });
1505
1067
 
1506
1068
  // deno:https://jsr.io/@std/path/1.1.4/join.ts
1507
- function join4(path, ...paths) {
1508
- return isWindows ? join3(path, ...paths) : join2(path, ...paths);
1069
+ function join3(path, ...paths) {
1070
+ return isWindows ? join2(path, ...paths) : join(path, ...paths);
1509
1071
  }
1510
1072
  var init_join3 = __esm({
1511
1073
  "deno:https://jsr.io/@std/path/1.1.4/join.ts"() {
@@ -1516,8 +1078,8 @@ var init_join3 = __esm({
1516
1078
  });
1517
1079
 
1518
1080
  // deno:https://jsr.io/@std/path/1.1.4/normalize.ts
1519
- function normalize4(path) {
1520
- return isWindows ? normalize3(path) : normalize2(path);
1081
+ function normalize3(path) {
1082
+ return isWindows ? normalize2(path) : normalize(path);
1521
1083
  }
1522
1084
  var init_normalize4 = __esm({
1523
1085
  "deno:https://jsr.io/@std/path/1.1.4/normalize.ts"() {
@@ -1528,7 +1090,7 @@ var init_normalize4 = __esm({
1528
1090
  });
1529
1091
 
1530
1092
  // deno:https://jsr.io/@std/path/1.1.4/posix/parse.ts
1531
- function parse2(path) {
1093
+ function parse(path) {
1532
1094
  assertPath(path);
1533
1095
  const ret = {
1534
1096
  root: "",
@@ -1608,7 +1170,7 @@ var init_parse = __esm({
1608
1170
  });
1609
1171
 
1610
1172
  // deno:https://jsr.io/@std/path/1.1.4/windows/parse.ts
1611
- function parse3(path) {
1173
+ function parse2(path) {
1612
1174
  assertPath(path);
1613
1175
  const ret = {
1614
1176
  root: "",
@@ -1724,8 +1286,8 @@ var init_parse2 = __esm({
1724
1286
  });
1725
1287
 
1726
1288
  // deno:https://jsr.io/@std/path/1.1.4/parse.ts
1727
- function parse4(path) {
1728
- return isWindows ? parse3(path) : parse2(path);
1289
+ function parse3(path) {
1290
+ return isWindows ? parse2(path) : parse(path);
1729
1291
  }
1730
1292
  var init_parse3 = __esm({
1731
1293
  "deno:https://jsr.io/@std/path/1.1.4/parse.ts"() {
@@ -1736,7 +1298,7 @@ var init_parse3 = __esm({
1736
1298
  });
1737
1299
 
1738
1300
  // deno:https://jsr.io/@std/path/1.1.4/posix/resolve.ts
1739
- function resolve2(...pathSegments) {
1301
+ function resolve(...pathSegments) {
1740
1302
  let resolvedPath = "";
1741
1303
  let resolvedAbsolute = false;
1742
1304
  for (let i = pathSegments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
@@ -1784,10 +1346,10 @@ var init_relative = __esm({
1784
1346
  });
1785
1347
 
1786
1348
  // deno:https://jsr.io/@std/path/1.1.4/posix/relative.ts
1787
- function relative2(from, to) {
1349
+ function relative(from, to) {
1788
1350
  assertArgs2(from, to);
1789
- from = resolve2(from);
1790
- to = resolve2(to);
1351
+ from = resolve(from);
1352
+ to = resolve(to);
1791
1353
  if (from === to) return "";
1792
1354
  let fromStart = 1;
1793
1355
  const fromEnd = from.length;
@@ -1849,7 +1411,7 @@ var init_relative2 = __esm({
1849
1411
  });
1850
1412
 
1851
1413
  // deno:https://jsr.io/@std/path/1.1.4/windows/resolve.ts
1852
- function resolve3(...pathSegments) {
1414
+ function resolve2(...pathSegments) {
1853
1415
  let resolvedDevice = "";
1854
1416
  let resolvedTail = "";
1855
1417
  let resolvedAbsolute = false;
@@ -1952,10 +1514,10 @@ var init_resolve2 = __esm({
1952
1514
  });
1953
1515
 
1954
1516
  // deno:https://jsr.io/@std/path/1.1.4/windows/relative.ts
1955
- function relative3(from, to) {
1517
+ function relative2(from, to) {
1956
1518
  assertArgs2(from, to);
1957
- const fromOrig = resolve3(from);
1958
- const toOrig = resolve3(to);
1519
+ const fromOrig = resolve2(from);
1520
+ const toOrig = resolve2(to);
1959
1521
  if (fromOrig === toOrig) return "";
1960
1522
  from = fromOrig.toLowerCase();
1961
1523
  to = toOrig.toLowerCase();
@@ -2032,8 +1594,8 @@ var init_relative3 = __esm({
2032
1594
  });
2033
1595
 
2034
1596
  // deno:https://jsr.io/@std/path/1.1.4/relative.ts
2035
- function relative4(from, to) {
2036
- return isWindows ? relative3(from, to) : relative2(from, to);
1597
+ function relative3(from, to) {
1598
+ return isWindows ? relative2(from, to) : relative(from, to);
2037
1599
  }
2038
1600
  var init_relative4 = __esm({
2039
1601
  "deno:https://jsr.io/@std/path/1.1.4/relative.ts"() {
@@ -2044,8 +1606,8 @@ var init_relative4 = __esm({
2044
1606
  });
2045
1607
 
2046
1608
  // deno:https://jsr.io/@std/path/1.1.4/resolve.ts
2047
- function resolve4(...pathSegments) {
2048
- return isWindows ? resolve3(...pathSegments) : resolve2(...pathSegments);
1609
+ function resolve3(...pathSegments) {
1610
+ return isWindows ? resolve2(...pathSegments) : resolve(...pathSegments);
2049
1611
  }
2050
1612
  var init_resolve3 = __esm({
2051
1613
  "deno:https://jsr.io/@std/path/1.1.4/resolve.ts"() {
@@ -2440,11 +2002,11 @@ function normalizeGlob(glob, options = {}) {
2440
2002
  throw new Error(`Glob contains invalid characters: "${glob}"`);
2441
2003
  }
2442
2004
  if (!globstar) {
2443
- return normalize2(glob);
2005
+ return normalize(glob);
2444
2006
  }
2445
2007
  const s = SEPARATOR_PATTERN2.source;
2446
2008
  const badParentPattern = new RegExp(`(?<=(${s}|^)\\*\\*${s})\\.\\.(?=${s}|$)`, "g");
2447
- return normalize2(glob.replace(badParentPattern, "\0")).replace(/\0/g, "..");
2009
+ return normalize(glob.replace(badParentPattern, "\0")).replace(/\0/g, "..");
2448
2010
  }
2449
2011
  var init_normalize_glob = __esm({
2450
2012
  "deno:https://jsr.io/@std/path/1.1.4/posix/normalize_glob.ts"() {
@@ -2457,7 +2019,7 @@ var init_normalize_glob = __esm({
2457
2019
  function joinGlobs(globs, options = {}) {
2458
2020
  const { globstar = false } = options;
2459
2021
  if (!globstar || globs.length === 0) {
2460
- return join2(...globs);
2022
+ return join(...globs);
2461
2023
  }
2462
2024
  let joined;
2463
2025
  for (const glob of globs) {
@@ -2496,11 +2058,11 @@ function normalizeGlob2(glob, options = {}) {
2496
2058
  throw new Error(`Glob contains invalid characters: "${glob}"`);
2497
2059
  }
2498
2060
  if (!globstar) {
2499
- return normalize3(glob);
2061
+ return normalize2(glob);
2500
2062
  }
2501
2063
  const s = SEPARATOR_PATTERN3.source;
2502
2064
  const badParentPattern = new RegExp(`(?<=(${s}|^)\\*\\*${s})\\.\\.(?=${s}|$)`, "g");
2503
- return normalize3(glob.replace(badParentPattern, "\0")).replace(/\0/g, "..");
2065
+ return normalize2(glob.replace(badParentPattern, "\0")).replace(/\0/g, "..");
2504
2066
  }
2505
2067
  var init_normalize_glob2 = __esm({
2506
2068
  "deno:https://jsr.io/@std/path/1.1.4/windows/normalize_glob.ts"() {
@@ -2513,7 +2075,7 @@ var init_normalize_glob2 = __esm({
2513
2075
  function joinGlobs2(globs, options = {}) {
2514
2076
  const { globstar = false } = options;
2515
2077
  if (!globstar || globs.length === 0) {
2516
- return join3(...globs);
2078
+ return join2(...globs);
2517
2079
  }
2518
2080
  let joined;
2519
2081
  for (const glob of globs) {
@@ -2583,184 +2145,541 @@ var init_mod = __esm({
2583
2145
  }
2584
2146
  });
2585
2147
 
2148
+ // pkg/@eser/standards/runtime/adapters/shared.ts
2149
+ var mapStdioToNode, getStdioModes, getNodeStdioArray;
2150
+ var init_shared = __esm({
2151
+ "pkg/@eser/standards/runtime/adapters/shared.ts"() {
2152
+ mapStdioToNode = (mode) => {
2153
+ if (mode === "inherit") return "inherit";
2154
+ if (mode === "piped") return "pipe";
2155
+ return "ignore";
2156
+ };
2157
+ getStdioModes = (options) => ({
2158
+ stdin: options?.stdin ?? "null",
2159
+ stdout: options?.stdout ?? "piped",
2160
+ stderr: options?.stderr ?? "piped"
2161
+ });
2162
+ getNodeStdioArray = (options) => {
2163
+ const modes = getStdioModes(options);
2164
+ return [
2165
+ mapStdioToNode(modes.stdin),
2166
+ mapStdioToNode(modes.stdout),
2167
+ mapStdioToNode(modes.stderr)
2168
+ ];
2169
+ };
2170
+ }
2171
+ });
2172
+
2586
2173
  // pkg/@eser/standards/runtime/adapters/deno.ts
2587
- var createDenoFs, createDenoPath, createDenoExec, createDenoEnv, createDenoProcess, createDenoRuntime;
2174
+ var DENO_CAPABILITIES, createDenoFs, createDenoPath, createDenoExec, createDenoEnv, createDenoProcess, createDenoRuntime;
2588
2175
  var init_deno = __esm({
2589
2176
  "pkg/@eser/standards/runtime/adapters/deno.ts"() {
2590
2177
  init_mod();
2591
2178
  init_types();
2592
- init_capabilities();
2593
- createDenoFs = () => {
2594
- const mapFileInfo = (info) => ({
2595
- isFile: info.isFile,
2596
- isDirectory: info.isDirectory,
2597
- isSymlink: info.isSymlink,
2598
- size: info.size,
2599
- mtime: info.mtime,
2600
- atime: info.atime,
2601
- birthtime: info.birthtime
2179
+ init_shared();
2180
+ DENO_CAPABILITIES = {
2181
+ fs: true,
2182
+ fsSync: true,
2183
+ exec: true,
2184
+ process: true,
2185
+ env: true,
2186
+ stdin: true,
2187
+ stdout: true,
2188
+ kv: true
2189
+ };
2190
+ createDenoFs = () => {
2191
+ const mapFileInfo = (info) => ({
2192
+ isFile: info.isFile,
2193
+ isDirectory: info.isDirectory,
2194
+ isSymlink: info.isSymlink,
2195
+ size: info.size,
2196
+ mtime: info.mtime,
2197
+ atime: info.atime,
2198
+ birthtime: info.birthtime
2199
+ });
2200
+ return {
2201
+ async readFile(path, options) {
2202
+ try {
2203
+ return await Deno.readFile(path, {
2204
+ signal: options?.signal
2205
+ });
2206
+ } catch (error) {
2207
+ if (error instanceof Deno.errors.NotFound) {
2208
+ throw new NotFoundError(path);
2209
+ }
2210
+ throw error;
2211
+ }
2212
+ },
2213
+ async readTextFile(path, options) {
2214
+ try {
2215
+ return await Deno.readTextFile(path, {
2216
+ signal: options?.signal
2217
+ });
2218
+ } catch (error) {
2219
+ if (error instanceof Deno.errors.NotFound) {
2220
+ throw new NotFoundError(path);
2221
+ }
2222
+ throw error;
2223
+ }
2224
+ },
2225
+ async writeFile(path, data, options) {
2226
+ await Deno.writeFile(path, data, {
2227
+ signal: options?.signal,
2228
+ mode: options?.mode,
2229
+ create: options?.create ?? true,
2230
+ append: options?.append ?? false
2231
+ });
2232
+ },
2233
+ async writeTextFile(path, data, options) {
2234
+ await Deno.writeTextFile(path, data, {
2235
+ signal: options?.signal,
2236
+ mode: options?.mode,
2237
+ create: options?.create ?? true,
2238
+ append: options?.append ?? false
2239
+ });
2240
+ },
2241
+ async exists(path) {
2242
+ try {
2243
+ await Deno.stat(path);
2244
+ return true;
2245
+ } catch (error) {
2246
+ if (error instanceof Deno.errors.NotFound) {
2247
+ return false;
2248
+ }
2249
+ throw error;
2250
+ }
2251
+ },
2252
+ async stat(path) {
2253
+ try {
2254
+ const info = await Deno.stat(path);
2255
+ return mapFileInfo(info);
2256
+ } catch (error) {
2257
+ if (error instanceof Deno.errors.NotFound) {
2258
+ throw new NotFoundError(path);
2259
+ }
2260
+ throw error;
2261
+ }
2262
+ },
2263
+ async lstat(path) {
2264
+ try {
2265
+ const info = await Deno.lstat(path);
2266
+ return mapFileInfo(info);
2267
+ } catch (error) {
2268
+ if (error instanceof Deno.errors.NotFound) {
2269
+ throw new NotFoundError(path);
2270
+ }
2271
+ throw error;
2272
+ }
2273
+ },
2274
+ async mkdir(path, options) {
2275
+ await Deno.mkdir(path, {
2276
+ recursive: options?.recursive ?? false,
2277
+ mode: options?.mode
2278
+ });
2279
+ },
2280
+ async remove(path, options) {
2281
+ try {
2282
+ await Deno.remove(path, {
2283
+ recursive: options?.recursive ?? false
2284
+ });
2285
+ } catch (error) {
2286
+ if (error instanceof Deno.errors.NotFound) {
2287
+ throw new NotFoundError(path);
2288
+ }
2289
+ throw error;
2290
+ }
2291
+ },
2292
+ async *readDir(path) {
2293
+ try {
2294
+ for await (const entry of Deno.readDir(path)) {
2295
+ yield {
2296
+ name: entry.name,
2297
+ isFile: entry.isFile,
2298
+ isDirectory: entry.isDirectory,
2299
+ isSymlink: entry.isSymlink
2300
+ };
2301
+ }
2302
+ } catch (error) {
2303
+ if (error instanceof Deno.errors.NotFound) {
2304
+ throw new NotFoundError(path);
2305
+ }
2306
+ throw error;
2307
+ }
2308
+ },
2309
+ async copyFile(from, to) {
2310
+ await Deno.copyFile(from, to);
2311
+ },
2312
+ async rename(from, to) {
2313
+ await Deno.rename(from, to);
2314
+ },
2315
+ async makeTempDir(options) {
2316
+ return await Deno.makeTempDir({
2317
+ dir: options?.dir,
2318
+ prefix: options?.prefix,
2319
+ suffix: options?.suffix
2320
+ });
2321
+ }
2322
+ };
2323
+ };
2324
+ createDenoPath = () => {
2325
+ return {
2326
+ join: join3,
2327
+ resolve: resolve3,
2328
+ dirname: dirname3,
2329
+ basename: basename3,
2330
+ extname: extname3,
2331
+ normalize: normalize3,
2332
+ isAbsolute: isAbsolute3,
2333
+ relative: relative3,
2334
+ parse: parse3,
2335
+ format: format3,
2336
+ sep: SEPARATOR,
2337
+ delimiter: DELIMITER
2338
+ };
2339
+ };
2340
+ createDenoExec = () => {
2341
+ return {
2342
+ async spawn(cmd, args = [], options) {
2343
+ const modes = getStdioModes(options);
2344
+ const command = new Deno.Command(cmd, {
2345
+ args,
2346
+ cwd: options?.cwd,
2347
+ env: options?.env,
2348
+ stdin: modes.stdin,
2349
+ stdout: modes.stdout,
2350
+ stderr: modes.stderr,
2351
+ signal: options?.signal
2352
+ });
2353
+ const result = await command.output();
2354
+ return {
2355
+ success: result.success,
2356
+ code: result.code,
2357
+ stdout: modes.stdout === "piped" ? result.stdout : new Uint8Array(),
2358
+ stderr: modes.stderr === "piped" ? result.stderr : new Uint8Array()
2359
+ };
2360
+ },
2361
+ async exec(cmd, args = [], options) {
2362
+ const result = await this.spawn(cmd, args, options);
2363
+ if (!result.success) {
2364
+ const stderr = new TextDecoder().decode(result.stderr);
2365
+ throw new ProcessError(cmd, result.code, stderr);
2366
+ }
2367
+ return new TextDecoder().decode(result.stdout).trim();
2368
+ },
2369
+ async execJson(cmd, args = [], options) {
2370
+ const output = await this.exec(cmd, args, options);
2371
+ return JSON.parse(output);
2372
+ },
2373
+ spawnChild(cmd, args = [], options) {
2374
+ const modes = getStdioModes(options);
2375
+ const command = new Deno.Command(cmd, {
2376
+ args,
2377
+ cwd: options?.cwd,
2378
+ env: options?.env,
2379
+ stdin: modes.stdin,
2380
+ stdout: modes.stdout,
2381
+ stderr: modes.stderr,
2382
+ signal: options?.signal
2383
+ });
2384
+ const process = command.spawn();
2385
+ const collectStream = (stream, mode) => {
2386
+ if (mode !== "piped" || !stream) {
2387
+ return Promise.resolve(new Uint8Array());
2388
+ }
2389
+ return new Response(stream).arrayBuffer().then((b) => new Uint8Array(b));
2390
+ };
2391
+ return {
2392
+ pid: process.pid,
2393
+ stdin: modes.stdin === "piped" ? process.stdin : null,
2394
+ stdout: modes.stdout === "piped" ? process.stdout : null,
2395
+ stderr: modes.stderr === "piped" ? process.stderr : null,
2396
+ status: process.status.then((status) => ({
2397
+ success: status.success,
2398
+ code: status.code,
2399
+ signal: status.signal ?? void 0
2400
+ })),
2401
+ output: async () => {
2402
+ const stdoutStream = modes.stdout === "piped" ? process.stdout : null;
2403
+ const stderrStream = modes.stderr === "piped" ? process.stderr : null;
2404
+ const [status, stdout, stderr] = await Promise.all([
2405
+ process.status,
2406
+ collectStream(stdoutStream, modes.stdout),
2407
+ collectStream(stderrStream, modes.stderr)
2408
+ ]);
2409
+ return {
2410
+ success: status.success,
2411
+ code: status.code,
2412
+ stdout,
2413
+ stderr
2414
+ };
2415
+ },
2416
+ kill: (signal) => {
2417
+ process.kill(signal);
2418
+ }
2419
+ };
2420
+ }
2421
+ };
2422
+ };
2423
+ createDenoEnv = () => {
2424
+ return {
2425
+ get(key) {
2426
+ return Deno.env.get(key);
2427
+ },
2428
+ set(key, value2) {
2429
+ Deno.env.set(key, value2);
2430
+ },
2431
+ delete(key) {
2432
+ Deno.env.delete(key);
2433
+ },
2434
+ has(key) {
2435
+ return Deno.env.get(key) !== void 0;
2436
+ },
2437
+ toObject() {
2438
+ return Deno.env.toObject();
2439
+ }
2440
+ };
2441
+ };
2442
+ createDenoProcess = () => {
2443
+ return {
2444
+ exit(code2) {
2445
+ Deno.exit(code2);
2446
+ },
2447
+ cwd() {
2448
+ return Deno.cwd();
2449
+ },
2450
+ chdir(path) {
2451
+ Deno.chdir(path);
2452
+ },
2453
+ hostname() {
2454
+ return Deno.hostname();
2455
+ },
2456
+ execPath() {
2457
+ return Deno.execPath();
2458
+ },
2459
+ args: Deno.args,
2460
+ pid: Deno.pid,
2461
+ stdin: Deno.stdin.readable,
2462
+ stdout: Deno.stdout.writable,
2463
+ stderr: Deno.stderr.writable
2464
+ };
2465
+ };
2466
+ createDenoRuntime = () => {
2467
+ const fs = createDenoFs();
2468
+ const path = createDenoPath();
2469
+ const exec2 = createDenoExec();
2470
+ const env = createDenoEnv();
2471
+ const process = createDenoProcess();
2472
+ return {
2473
+ name: "deno",
2474
+ version: Deno.version.deno,
2475
+ capabilities: DENO_CAPABILITIES,
2476
+ fs,
2477
+ path,
2478
+ exec: exec2,
2479
+ env,
2480
+ process
2481
+ };
2482
+ };
2483
+ }
2484
+ });
2485
+
2486
+ // pkg/@eser/standards/runtime/adapters/node.ts
2487
+ import * as nodeFsPromises from "node:fs/promises";
2488
+ import * as nodePath from "node:path";
2489
+ import * as nodeOs from "node:os";
2490
+ import * as nodeChildProcess from "node:child_process";
2491
+ import nodeProcess from "node:process";
2492
+ import { Buffer as Buffer2 } from "node:buffer";
2493
+ import { Readable, Writable } from "node:stream";
2494
+ var NODE_CAPABILITIES, createNodeFs, createNodePath, createNodeExec, createNodeEnv, createNodeProcess, createNodeRuntime;
2495
+ var init_node = __esm({
2496
+ "pkg/@eser/standards/runtime/adapters/node.ts"() {
2497
+ init_types();
2498
+ init_shared();
2499
+ NODE_CAPABILITIES = {
2500
+ fs: true,
2501
+ fsSync: true,
2502
+ exec: true,
2503
+ process: true,
2504
+ env: true,
2505
+ stdin: true,
2506
+ stdout: true,
2507
+ kv: false
2508
+ };
2509
+ createNodeFs = () => {
2510
+ const mapStats = (stats) => ({
2511
+ isFile: stats.isFile(),
2512
+ isDirectory: stats.isDirectory(),
2513
+ isSymlink: stats.isSymbolicLink(),
2514
+ size: stats.size,
2515
+ mtime: stats.mtime,
2516
+ atime: stats.atime,
2517
+ birthtime: stats.birthtime
2602
2518
  });
2519
+ const handleError = (error, path) => {
2520
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") {
2521
+ throw new NotFoundError(path);
2522
+ }
2523
+ throw error;
2524
+ };
2603
2525
  return {
2604
2526
  async readFile(path, options) {
2605
2527
  try {
2606
- return await Deno.readFile(path, {
2528
+ const buffer = await nodeFsPromises.readFile(path, {
2607
2529
  signal: options?.signal
2608
2530
  });
2531
+ return new Uint8Array(buffer);
2609
2532
  } catch (error) {
2610
- if (error instanceof Deno.errors.NotFound) {
2611
- throw new NotFoundError(path);
2612
- }
2613
- throw error;
2533
+ return handleError(error, path);
2614
2534
  }
2615
2535
  },
2616
2536
  async readTextFile(path, options) {
2617
2537
  try {
2618
- return await Deno.readTextFile(path, {
2538
+ return await nodeFsPromises.readFile(path, {
2539
+ encoding: "utf-8",
2619
2540
  signal: options?.signal
2620
2541
  });
2621
2542
  } catch (error) {
2622
- if (error instanceof Deno.errors.NotFound) {
2623
- throw new NotFoundError(path);
2624
- }
2625
- throw error;
2543
+ return handleError(error, path);
2626
2544
  }
2627
2545
  },
2628
2546
  async writeFile(path, data, options) {
2629
- await Deno.writeFile(path, data, {
2547
+ const flag = options?.append ? "a" : "w";
2548
+ await nodeFsPromises.writeFile(path, data, {
2630
2549
  signal: options?.signal,
2631
2550
  mode: options?.mode,
2632
- create: options?.create ?? true,
2633
- append: options?.append ?? false
2551
+ flag
2634
2552
  });
2635
2553
  },
2636
2554
  async writeTextFile(path, data, options) {
2637
- await Deno.writeTextFile(path, data, {
2555
+ const flag = options?.append ? "a" : "w";
2556
+ await nodeFsPromises.writeFile(path, data, {
2557
+ encoding: "utf-8",
2638
2558
  signal: options?.signal,
2639
2559
  mode: options?.mode,
2640
- create: options?.create ?? true,
2641
- append: options?.append ?? false
2560
+ flag
2642
2561
  });
2643
2562
  },
2644
2563
  async exists(path) {
2645
2564
  try {
2646
- await Deno.stat(path);
2565
+ await nodeFsPromises.access(path);
2647
2566
  return true;
2648
- } catch (error) {
2649
- if (error instanceof Deno.errors.NotFound) {
2650
- return false;
2651
- }
2652
- throw error;
2567
+ } catch {
2568
+ return false;
2653
2569
  }
2654
2570
  },
2655
2571
  async stat(path) {
2656
2572
  try {
2657
- const info = await Deno.stat(path);
2658
- return mapFileInfo(info);
2573
+ const stats = await nodeFsPromises.stat(path);
2574
+ return mapStats(stats);
2659
2575
  } catch (error) {
2660
- if (error instanceof Deno.errors.NotFound) {
2661
- throw new NotFoundError(path);
2662
- }
2663
- throw error;
2576
+ return handleError(error, path);
2664
2577
  }
2665
2578
  },
2666
2579
  async lstat(path) {
2667
2580
  try {
2668
- const info = await Deno.lstat(path);
2669
- return mapFileInfo(info);
2581
+ const stats = await nodeFsPromises.lstat(path);
2582
+ return mapStats(stats);
2670
2583
  } catch (error) {
2671
- if (error instanceof Deno.errors.NotFound) {
2672
- throw new NotFoundError(path);
2673
- }
2674
- throw error;
2584
+ return handleError(error, path);
2675
2585
  }
2676
2586
  },
2677
2587
  async mkdir(path, options) {
2678
- await Deno.mkdir(path, {
2588
+ await nodeFsPromises.mkdir(path, {
2679
2589
  recursive: options?.recursive ?? false,
2680
2590
  mode: options?.mode
2681
2591
  });
2682
2592
  },
2683
2593
  async remove(path, options) {
2684
2594
  try {
2685
- await Deno.remove(path, {
2686
- recursive: options?.recursive ?? false
2595
+ await nodeFsPromises.rm(path, {
2596
+ recursive: options?.recursive ?? false,
2597
+ force: false
2687
2598
  });
2688
2599
  } catch (error) {
2689
- if (error instanceof Deno.errors.NotFound) {
2690
- throw new NotFoundError(path);
2691
- }
2692
- throw error;
2600
+ handleError(error, path);
2693
2601
  }
2694
2602
  },
2695
2603
  async *readDir(path) {
2696
2604
  try {
2697
- for await (const entry of Deno.readDir(path)) {
2605
+ const entries = await nodeFsPromises.readdir(path, {
2606
+ withFileTypes: true
2607
+ });
2608
+ for (const entry of entries) {
2698
2609
  yield {
2699
2610
  name: entry.name,
2700
- isFile: entry.isFile,
2701
- isDirectory: entry.isDirectory,
2702
- isSymlink: entry.isSymlink
2611
+ isFile: entry.isFile(),
2612
+ isDirectory: entry.isDirectory(),
2613
+ isSymlink: entry.isSymbolicLink()
2703
2614
  };
2704
2615
  }
2705
2616
  } catch (error) {
2706
- if (error instanceof Deno.errors.NotFound) {
2707
- throw new NotFoundError(path);
2708
- }
2709
- throw error;
2617
+ handleError(error, path);
2710
2618
  }
2711
2619
  },
2712
2620
  async copyFile(from, to) {
2713
- await Deno.copyFile(from, to);
2621
+ await nodeFsPromises.copyFile(from, to);
2714
2622
  },
2715
2623
  async rename(from, to) {
2716
- await Deno.rename(from, to);
2624
+ await nodeFsPromises.rename(from, to);
2717
2625
  },
2718
2626
  async makeTempDir(options) {
2719
- return await Deno.makeTempDir({
2720
- dir: options?.dir,
2721
- prefix: options?.prefix,
2722
- suffix: options?.suffix
2723
- });
2627
+ const dir = options?.dir ?? nodeOs.tmpdir();
2628
+ const prefix = options?.prefix ?? "";
2629
+ const suffix = options?.suffix ?? "";
2630
+ const tempPath = await nodeFsPromises.mkdtemp(nodePath.join(dir, prefix));
2631
+ if (suffix) {
2632
+ const newPath = tempPath + suffix;
2633
+ await nodeFsPromises.rename(tempPath, newPath);
2634
+ return newPath;
2635
+ }
2636
+ return tempPath;
2724
2637
  }
2725
2638
  };
2726
2639
  };
2727
- createDenoPath = () => {
2640
+ createNodePath = () => {
2728
2641
  return {
2729
- join: join4,
2730
- resolve: resolve4,
2731
- dirname: dirname4,
2732
- basename: basename4,
2733
- extname: extname4,
2734
- normalize: normalize4,
2735
- isAbsolute: isAbsolute4,
2736
- relative: relative4,
2737
- parse: parse4,
2738
- format: format4,
2739
- sep: SEPARATOR,
2740
- delimiter: DELIMITER
2642
+ join: nodePath.join,
2643
+ resolve: nodePath.resolve,
2644
+ dirname: nodePath.dirname,
2645
+ basename: nodePath.basename,
2646
+ extname: nodePath.extname,
2647
+ normalize: nodePath.normalize,
2648
+ isAbsolute: nodePath.isAbsolute,
2649
+ relative: nodePath.relative,
2650
+ parse: nodePath.parse,
2651
+ format: nodePath.format,
2652
+ sep: nodePath.sep,
2653
+ delimiter: nodePath.delimiter
2741
2654
  };
2742
2655
  };
2743
- createDenoExec = () => {
2656
+ createNodeExec = () => {
2744
2657
  return {
2745
- async spawn(cmd, args = [], options) {
2746
- const stdoutMode = options?.stdout ?? "piped";
2747
- const stderrMode = options?.stderr ?? "piped";
2748
- const command = new Deno.Command(cmd, {
2749
- args,
2750
- cwd: options?.cwd,
2751
- env: options?.env,
2752
- stdin: options?.stdin ?? "null",
2753
- stdout: stdoutMode,
2754
- stderr: stderrMode,
2755
- signal: options?.signal
2658
+ spawn(cmd, args = [], options) {
2659
+ return new Promise((resolve7, reject) => {
2660
+ const proc = nodeChildProcess.spawn(cmd, args, {
2661
+ cwd: options?.cwd,
2662
+ env: options?.env ? {
2663
+ ...nodeProcess.env,
2664
+ ...options.env
2665
+ } : void 0,
2666
+ stdio: getNodeStdioArray(options),
2667
+ signal: options?.signal
2668
+ });
2669
+ const stdoutChunks = [];
2670
+ const stderrChunks = [];
2671
+ proc.stdout?.on("data", (chunk) => stdoutChunks.push(chunk));
2672
+ proc.stderr?.on("data", (chunk) => stderrChunks.push(chunk));
2673
+ proc.on("error", reject);
2674
+ proc.on("close", (code2) => {
2675
+ resolve7({
2676
+ success: code2 === 0,
2677
+ code: code2 ?? 1,
2678
+ stdout: new Uint8Array(Buffer2.concat(stdoutChunks)),
2679
+ stderr: new Uint8Array(Buffer2.concat(stderrChunks))
2680
+ });
2681
+ });
2756
2682
  });
2757
- const result = await command.output();
2758
- return {
2759
- success: result.success,
2760
- code: result.code,
2761
- stdout: stdoutMode === "piped" ? result.stdout : new Uint8Array(),
2762
- stderr: stderrMode === "piped" ? result.stderr : new Uint8Array()
2763
- };
2764
2683
  },
2765
2684
  async exec(cmd, args = [], options) {
2766
2685
  const result = await this.spawn(cmd, args, options);
@@ -2775,103 +2694,110 @@ var init_deno = __esm({
2775
2694
  return JSON.parse(output);
2776
2695
  },
2777
2696
  spawnChild(cmd, args = [], options) {
2778
- const stdinMode = options?.stdin ?? "null";
2779
- const stdoutMode = options?.stdout ?? "piped";
2780
- const stderrMode = options?.stderr ?? "piped";
2781
- const command = new Deno.Command(cmd, {
2782
- args,
2697
+ const proc = nodeChildProcess.spawn(cmd, args, {
2783
2698
  cwd: options?.cwd,
2784
- env: options?.env,
2785
- stdin: stdinMode,
2786
- stdout: stdoutMode,
2787
- stderr: stderrMode,
2699
+ env: options?.env ? {
2700
+ ...nodeProcess.env,
2701
+ ...options.env
2702
+ } : void 0,
2703
+ stdio: getNodeStdioArray(options),
2788
2704
  signal: options?.signal
2789
2705
  });
2790
- const process = command.spawn();
2706
+ const stdoutChunks = [];
2707
+ const stderrChunks = [];
2708
+ proc.stdout?.on("data", (chunk) => stdoutChunks.push(chunk));
2709
+ proc.stderr?.on("data", (chunk) => stderrChunks.push(chunk));
2710
+ const statusPromise = new Promise((resolve7, reject) => {
2711
+ proc.on("error", reject);
2712
+ proc.on("close", (code2, signal) => {
2713
+ resolve7({
2714
+ success: code2 === 0,
2715
+ code: code2 ?? 1,
2716
+ signal: signal ?? void 0
2717
+ });
2718
+ });
2719
+ });
2791
2720
  return {
2792
- pid: process.pid,
2793
- // Only access streams if they were configured as "piped"
2794
- stdin: stdinMode === "piped" ? process.stdin : null,
2795
- stdout: stdoutMode === "piped" ? process.stdout : null,
2796
- stderr: stderrMode === "piped" ? process.stderr : null,
2797
- status: process.status.then((status) => ({
2798
- success: status.success,
2799
- code: status.code,
2800
- signal: status.signal ?? void 0
2801
- })),
2721
+ pid: proc.pid,
2722
+ stdin: proc.stdin ? Writable.toWeb(proc.stdin) : null,
2723
+ stdout: proc.stdout ? Readable.toWeb(proc.stdout) : null,
2724
+ stderr: proc.stderr ? Readable.toWeb(proc.stderr) : null,
2725
+ status: statusPromise,
2802
2726
  output: async () => {
2803
- const [status, stdout, stderr] = await Promise.all([
2804
- process.status,
2805
- stdoutMode === "piped" ? new Response(process.stdout).arrayBuffer().then((b) => new Uint8Array(b)) : Promise.resolve(new Uint8Array()),
2806
- stderrMode === "piped" ? new Response(process.stderr).arrayBuffer().then((b) => new Uint8Array(b)) : Promise.resolve(new Uint8Array())
2807
- ]);
2727
+ const status = await statusPromise;
2808
2728
  return {
2809
2729
  success: status.success,
2810
2730
  code: status.code,
2811
- stdout,
2812
- stderr
2731
+ stdout: new Uint8Array(Buffer2.concat(stdoutChunks)),
2732
+ stderr: new Uint8Array(Buffer2.concat(stderrChunks))
2813
2733
  };
2814
2734
  },
2815
2735
  kill: (signal) => {
2816
- process.kill(signal);
2736
+ proc.kill(signal);
2817
2737
  }
2818
2738
  };
2819
2739
  }
2820
2740
  };
2821
2741
  };
2822
- createDenoEnv = () => {
2742
+ createNodeEnv = () => {
2823
2743
  return {
2824
2744
  get(key) {
2825
- return Deno.env.get(key);
2745
+ return nodeProcess.env[key];
2826
2746
  },
2827
2747
  set(key, value2) {
2828
- Deno.env.set(key, value2);
2748
+ nodeProcess.env[key] = value2;
2829
2749
  },
2830
2750
  delete(key) {
2831
- Deno.env.delete(key);
2751
+ delete nodeProcess.env[key];
2832
2752
  },
2833
2753
  has(key) {
2834
- return Deno.env.get(key) !== void 0;
2754
+ return key in nodeProcess.env;
2835
2755
  },
2836
2756
  toObject() {
2837
- return Deno.env.toObject();
2757
+ const result = {};
2758
+ for (const [key, value2] of Object.entries(nodeProcess.env)) {
2759
+ if (value2 !== void 0) {
2760
+ result[key] = value2;
2761
+ }
2762
+ }
2763
+ return result;
2838
2764
  }
2839
2765
  };
2840
2766
  };
2841
- createDenoProcess = () => {
2767
+ createNodeProcess = () => {
2842
2768
  return {
2843
2769
  exit(code2) {
2844
- Deno.exit(code2);
2770
+ nodeProcess.exit(code2);
2845
2771
  },
2846
2772
  cwd() {
2847
- return Deno.cwd();
2773
+ return nodeProcess.cwd();
2848
2774
  },
2849
2775
  chdir(path) {
2850
- Deno.chdir(path);
2776
+ nodeProcess.chdir(path);
2851
2777
  },
2852
2778
  hostname() {
2853
- return Deno.hostname();
2779
+ return nodeOs.hostname();
2854
2780
  },
2855
2781
  execPath() {
2856
- return Deno.execPath();
2782
+ return nodeProcess.execPath;
2857
2783
  },
2858
- args: Deno.args,
2859
- pid: Deno.pid,
2860
- stdin: Deno.stdin.readable,
2861
- stdout: Deno.stdout.writable,
2862
- stderr: Deno.stderr.writable
2784
+ args: nodeProcess.argv.slice(2),
2785
+ pid: nodeProcess.pid,
2786
+ stdin: Readable.toWeb(nodeProcess.stdin),
2787
+ stdout: Writable.toWeb(nodeProcess.stdout),
2788
+ stderr: Writable.toWeb(nodeProcess.stderr)
2863
2789
  };
2864
2790
  };
2865
- createDenoRuntime = () => {
2866
- const fs = createDenoFs();
2867
- const path = createDenoPath();
2868
- const exec2 = createDenoExec();
2869
- const env = createDenoEnv();
2870
- const process = createDenoProcess();
2791
+ createNodeRuntime = () => {
2792
+ const fs = createNodeFs();
2793
+ const path = createNodePath();
2794
+ const exec2 = createNodeExec();
2795
+ const env = createNodeEnv();
2796
+ const process = createNodeProcess();
2871
2797
  return {
2872
- name: "deno",
2873
- version: Deno.version.deno,
2874
- capabilities: DENO_CAPABILITIES,
2798
+ name: "node",
2799
+ version: nodeProcess.versions.node,
2800
+ capabilities: NODE_CAPABILITIES,
2875
2801
  fs,
2876
2802
  path,
2877
2803
  exec: exec2,
@@ -2882,20 +2808,28 @@ var init_deno = __esm({
2882
2808
  }
2883
2809
  });
2884
2810
 
2885
- // pkg/@eser/standards/runtime/adapters/node.ts
2886
- import * as nodeFsPromises from "node:fs/promises";
2887
- import * as nodePath from "node:path";
2888
- import * as nodeOs from "node:os";
2889
- import * as nodeChildProcess from "node:child_process";
2890
- import nodeProcess from "node:process";
2891
- import { Buffer as Buffer2 } from "node:buffer";
2892
- import { Readable, Writable } from "node:stream";
2893
- var createNodeFs, createNodePath, createNodeExec, createNodeEnv, createNodeProcess, createNodeRuntime;
2894
- var init_node = __esm({
2895
- "pkg/@eser/standards/runtime/adapters/node.ts"() {
2811
+ // pkg/@eser/standards/runtime/adapters/bun.ts
2812
+ import * as nodeFsPromises2 from "node:fs/promises";
2813
+ import * as nodePath2 from "node:path";
2814
+ import * as nodeOs2 from "node:os";
2815
+ import nodeProcess2 from "node:process";
2816
+ import { Readable as Readable2, Writable as Writable2 } from "node:stream";
2817
+ var BUN_CAPABILITIES, createBunFs, createBunPath, readStream, createBunExec, createBunEnv, createBunProcess, createBunRuntime;
2818
+ var init_bun = __esm({
2819
+ "pkg/@eser/standards/runtime/adapters/bun.ts"() {
2896
2820
  init_types();
2897
- init_capabilities();
2898
- createNodeFs = () => {
2821
+ init_shared();
2822
+ BUN_CAPABILITIES = {
2823
+ fs: true,
2824
+ fsSync: true,
2825
+ exec: true,
2826
+ process: true,
2827
+ env: true,
2828
+ stdin: true,
2829
+ stdout: true,
2830
+ kv: false
2831
+ };
2832
+ createBunFs = () => {
2899
2833
  const mapStats = (stats) => ({
2900
2834
  isFile: stats.isFile(),
2901
2835
  isDirectory: stats.isDirectory(),
@@ -2914,7 +2848,7 @@ var init_node = __esm({
2914
2848
  return {
2915
2849
  async readFile(path, options) {
2916
2850
  try {
2917
- const buffer = await nodeFsPromises.readFile(path, {
2851
+ const buffer = await nodeFsPromises2.readFile(path, {
2918
2852
  signal: options?.signal
2919
2853
  });
2920
2854
  return new Uint8Array(buffer);
@@ -2924,7 +2858,7 @@ var init_node = __esm({
2924
2858
  },
2925
2859
  async readTextFile(path, options) {
2926
2860
  try {
2927
- return await nodeFsPromises.readFile(path, {
2861
+ return await nodeFsPromises2.readFile(path, {
2928
2862
  encoding: "utf-8",
2929
2863
  signal: options?.signal
2930
2864
  });
@@ -2934,7 +2868,7 @@ var init_node = __esm({
2934
2868
  },
2935
2869
  async writeFile(path, data, options) {
2936
2870
  const flag = options?.append ? "a" : "w";
2937
- await nodeFsPromises.writeFile(path, data, {
2871
+ await nodeFsPromises2.writeFile(path, data, {
2938
2872
  signal: options?.signal,
2939
2873
  mode: options?.mode,
2940
2874
  flag
@@ -2942,7 +2876,7 @@ var init_node = __esm({
2942
2876
  },
2943
2877
  async writeTextFile(path, data, options) {
2944
2878
  const flag = options?.append ? "a" : "w";
2945
- await nodeFsPromises.writeFile(path, data, {
2879
+ await nodeFsPromises2.writeFile(path, data, {
2946
2880
  encoding: "utf-8",
2947
2881
  signal: options?.signal,
2948
2882
  mode: options?.mode,
@@ -2951,7 +2885,7 @@ var init_node = __esm({
2951
2885
  },
2952
2886
  async exists(path) {
2953
2887
  try {
2954
- await nodeFsPromises.access(path);
2888
+ await nodeFsPromises2.access(path);
2955
2889
  return true;
2956
2890
  } catch {
2957
2891
  return false;
@@ -2959,7 +2893,7 @@ var init_node = __esm({
2959
2893
  },
2960
2894
  async stat(path) {
2961
2895
  try {
2962
- const stats = await nodeFsPromises.stat(path);
2896
+ const stats = await nodeFsPromises2.stat(path);
2963
2897
  return mapStats(stats);
2964
2898
  } catch (error) {
2965
2899
  return handleError(error, path);
@@ -2967,21 +2901,21 @@ var init_node = __esm({
2967
2901
  },
2968
2902
  async lstat(path) {
2969
2903
  try {
2970
- const stats = await nodeFsPromises.lstat(path);
2904
+ const stats = await nodeFsPromises2.lstat(path);
2971
2905
  return mapStats(stats);
2972
2906
  } catch (error) {
2973
2907
  return handleError(error, path);
2974
2908
  }
2975
2909
  },
2976
2910
  async mkdir(path, options) {
2977
- await nodeFsPromises.mkdir(path, {
2911
+ await nodeFsPromises2.mkdir(path, {
2978
2912
  recursive: options?.recursive ?? false,
2979
2913
  mode: options?.mode
2980
2914
  });
2981
2915
  },
2982
2916
  async remove(path, options) {
2983
2917
  try {
2984
- await nodeFsPromises.rm(path, {
2918
+ await nodeFsPromises2.rm(path, {
2985
2919
  recursive: options?.recursive ?? false,
2986
2920
  force: false
2987
2921
  });
@@ -2991,7 +2925,7 @@ var init_node = __esm({
2991
2925
  },
2992
2926
  async *readDir(path) {
2993
2927
  try {
2994
- const entries = await nodeFsPromises.readdir(path, {
2928
+ const entries = await nodeFsPromises2.readdir(path, {
2995
2929
  withFileTypes: true
2996
2930
  });
2997
2931
  for (const entry of entries) {
@@ -3007,78 +2941,88 @@ var init_node = __esm({
3007
2941
  }
3008
2942
  },
3009
2943
  async copyFile(from, to) {
3010
- await nodeFsPromises.copyFile(from, to);
2944
+ await nodeFsPromises2.copyFile(from, to);
3011
2945
  },
3012
2946
  async rename(from, to) {
3013
- await nodeFsPromises.rename(from, to);
2947
+ await nodeFsPromises2.rename(from, to);
3014
2948
  },
3015
2949
  async makeTempDir(options) {
3016
- const dir = options?.dir ?? nodeOs.tmpdir();
2950
+ const dir = options?.dir ?? nodeOs2.tmpdir();
3017
2951
  const prefix = options?.prefix ?? "";
3018
2952
  const suffix = options?.suffix ?? "";
3019
- const tempPath = await nodeFsPromises.mkdtemp(nodePath.join(dir, prefix));
2953
+ const tempPath = await nodeFsPromises2.mkdtemp(nodePath2.join(dir, prefix));
3020
2954
  if (suffix) {
3021
2955
  const newPath = tempPath + suffix;
3022
- await nodeFsPromises.rename(tempPath, newPath);
2956
+ await nodeFsPromises2.rename(tempPath, newPath);
3023
2957
  return newPath;
3024
2958
  }
3025
2959
  return tempPath;
3026
2960
  }
3027
2961
  };
3028
2962
  };
3029
- createNodePath = () => {
2963
+ createBunPath = () => {
3030
2964
  return {
3031
- join: nodePath.join,
3032
- resolve: nodePath.resolve,
3033
- dirname: nodePath.dirname,
3034
- basename: nodePath.basename,
3035
- extname: nodePath.extname,
3036
- normalize: nodePath.normalize,
3037
- isAbsolute: nodePath.isAbsolute,
3038
- relative: nodePath.relative,
3039
- parse: nodePath.parse,
3040
- format: nodePath.format,
3041
- sep: nodePath.sep,
3042
- delimiter: nodePath.delimiter
2965
+ join: nodePath2.join,
2966
+ resolve: nodePath2.resolve,
2967
+ dirname: nodePath2.dirname,
2968
+ basename: nodePath2.basename,
2969
+ extname: nodePath2.extname,
2970
+ normalize: nodePath2.normalize,
2971
+ isAbsolute: nodePath2.isAbsolute,
2972
+ relative: nodePath2.relative,
2973
+ parse: nodePath2.parse,
2974
+ format: nodePath2.format,
2975
+ sep: nodePath2.sep,
2976
+ delimiter: nodePath2.delimiter
3043
2977
  };
3044
2978
  };
3045
- createNodeExec = () => {
2979
+ readStream = async (stream) => {
2980
+ if (!stream) return new Uint8Array(0);
2981
+ const chunks = [];
2982
+ const reader = stream.getReader();
2983
+ try {
2984
+ while (true) {
2985
+ const { done, value: value2 } = await reader.read();
2986
+ if (done) break;
2987
+ chunks.push(value2);
2988
+ }
2989
+ } finally {
2990
+ reader.releaseLock();
2991
+ }
2992
+ const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
2993
+ const result = new Uint8Array(totalLength);
2994
+ let offset = 0;
2995
+ for (const chunk of chunks) {
2996
+ result.set(chunk, offset);
2997
+ offset += chunk.length;
2998
+ }
2999
+ return result;
3000
+ };
3001
+ createBunExec = () => {
3046
3002
  return {
3047
- spawn(cmd, args = [], options) {
3048
- return new Promise((resolve7, reject) => {
3049
- const proc = nodeChildProcess.spawn(cmd, args, {
3050
- cwd: options?.cwd,
3051
- env: options?.env ? {
3052
- ...nodeProcess.env,
3053
- ...options.env
3054
- } : void 0,
3055
- stdio: [
3056
- options?.stdin === "inherit" ? "inherit" : options?.stdin === "piped" ? "pipe" : "ignore",
3057
- options?.stdout === "inherit" ? "inherit" : options?.stdout === "null" ? "ignore" : "pipe",
3058
- options?.stderr === "inherit" ? "inherit" : options?.stderr === "null" ? "ignore" : "pipe"
3059
- ],
3060
- signal: options?.signal
3061
- });
3062
- const stdoutChunks = [];
3063
- const stderrChunks = [];
3064
- proc.stdout?.on("data", (chunk) => {
3065
- stdoutChunks.push(chunk);
3066
- });
3067
- proc.stderr?.on("data", (chunk) => {
3068
- stderrChunks.push(chunk);
3069
- });
3070
- proc.on("error", reject);
3071
- proc.on("close", (code2) => {
3072
- const stdout = new Uint8Array(Buffer2.concat(stdoutChunks));
3073
- const stderr = new Uint8Array(Buffer2.concat(stderrChunks));
3074
- resolve7({
3075
- success: code2 === 0,
3076
- code: code2 ?? 1,
3077
- stdout,
3078
- stderr
3079
- });
3080
- });
3003
+ async spawn(cmd, args = [], options) {
3004
+ const [stdinMode, stdoutMode, stderrMode] = getNodeStdioArray(options);
3005
+ const proc = Bun.spawn([
3006
+ cmd,
3007
+ ...args
3008
+ ], {
3009
+ cwd: options?.cwd,
3010
+ env: options?.env,
3011
+ stdin: stdinMode,
3012
+ stdout: stdoutMode,
3013
+ stderr: stderrMode
3081
3014
  });
3015
+ const [exitCode, stdout, stderr] = await Promise.all([
3016
+ proc.exited,
3017
+ readStream(proc.stdout),
3018
+ readStream(proc.stderr)
3019
+ ]);
3020
+ return {
3021
+ success: exitCode === 0,
3022
+ code: exitCode,
3023
+ stdout,
3024
+ stderr
3025
+ };
3082
3026
  },
3083
3027
  async exec(cmd, args = [], options) {
3084
3028
  const result = await this.spawn(cmd, args, options);
@@ -3093,59 +3037,39 @@ var init_node = __esm({
3093
3037
  return JSON.parse(output);
3094
3038
  },
3095
3039
  spawnChild(cmd, args = [], options) {
3096
- const mapStdio = (value2) => {
3097
- if (value2 === "inherit") {
3098
- return "inherit";
3099
- }
3100
- if (value2 === "piped") {
3101
- return "pipe";
3102
- }
3103
- return "ignore";
3104
- };
3105
- const proc = nodeChildProcess.spawn(cmd, args, {
3040
+ const [stdinMode, stdoutMode, stderrMode] = getNodeStdioArray(options);
3041
+ const proc = Bun.spawn([
3042
+ cmd,
3043
+ ...args
3044
+ ], {
3106
3045
  cwd: options?.cwd,
3107
- env: options?.env ? {
3108
- ...nodeProcess.env,
3109
- ...options.env
3110
- } : void 0,
3111
- stdio: [
3112
- mapStdio(options?.stdin),
3113
- mapStdio(options?.stdout ?? "piped"),
3114
- mapStdio(options?.stderr ?? "piped")
3115
- ],
3116
- signal: options?.signal
3117
- });
3118
- const stdoutChunks = [];
3119
- const stderrChunks = [];
3120
- proc.stdout?.on("data", (chunk) => {
3121
- stdoutChunks.push(chunk);
3122
- });
3123
- proc.stderr?.on("data", (chunk) => {
3124
- stderrChunks.push(chunk);
3125
- });
3126
- const statusPromise = new Promise((resolve7, reject) => {
3127
- proc.on("error", reject);
3128
- proc.on("close", (code2, signal) => {
3129
- resolve7({
3130
- success: code2 === 0,
3131
- code: code2 ?? 1,
3132
- signal: signal ?? void 0
3133
- });
3134
- });
3046
+ env: options?.env,
3047
+ stdin: stdinMode,
3048
+ stdout: stdoutMode,
3049
+ stderr: stderrMode
3135
3050
  });
3051
+ const statusPromise = proc.exited.then((code2) => ({
3052
+ success: code2 === 0,
3053
+ code: code2,
3054
+ signal: void 0
3055
+ }));
3136
3056
  return {
3137
3057
  pid: proc.pid,
3138
- stdin: proc.stdin ? Writable.toWeb(proc.stdin) : null,
3139
- stdout: proc.stdout ? Readable.toWeb(proc.stdout) : null,
3140
- stderr: proc.stderr ? Readable.toWeb(proc.stderr) : null,
3058
+ stdin: proc.stdin,
3059
+ stdout: proc.stdout,
3060
+ stderr: proc.stderr,
3141
3061
  status: statusPromise,
3142
3062
  output: async () => {
3143
- const status = await statusPromise;
3063
+ const [status, stdout, stderr] = await Promise.all([
3064
+ statusPromise,
3065
+ readStream(proc.stdout),
3066
+ readStream(proc.stderr)
3067
+ ]);
3144
3068
  return {
3145
3069
  success: status.success,
3146
3070
  code: status.code,
3147
- stdout: new Uint8Array(Buffer2.concat(stdoutChunks)),
3148
- stderr: new Uint8Array(Buffer2.concat(stderrChunks))
3071
+ stdout,
3072
+ stderr
3149
3073
  };
3150
3074
  },
3151
3075
  kill: (signal) => {
@@ -3155,23 +3079,23 @@ var init_node = __esm({
3155
3079
  }
3156
3080
  };
3157
3081
  };
3158
- createNodeEnv = () => {
3082
+ createBunEnv = () => {
3159
3083
  return {
3160
3084
  get(key) {
3161
- return nodeProcess.env[key];
3085
+ return nodeProcess2.env[key];
3162
3086
  },
3163
3087
  set(key, value2) {
3164
- nodeProcess.env[key] = value2;
3088
+ nodeProcess2.env[key] = value2;
3165
3089
  },
3166
3090
  delete(key) {
3167
- delete nodeProcess.env[key];
3091
+ delete nodeProcess2.env[key];
3168
3092
  },
3169
3093
  has(key) {
3170
- return key in nodeProcess.env;
3094
+ return key in nodeProcess2.env;
3171
3095
  },
3172
3096
  toObject() {
3173
3097
  const result = {};
3174
- for (const [key, value2] of Object.entries(nodeProcess.env)) {
3098
+ for (const [key, value2] of Object.entries(nodeProcess2.env)) {
3175
3099
  if (value2 !== void 0) {
3176
3100
  result[key] = value2;
3177
3101
  }
@@ -3180,40 +3104,40 @@ var init_node = __esm({
3180
3104
  }
3181
3105
  };
3182
3106
  };
3183
- createNodeProcess = () => {
3107
+ createBunProcess = () => {
3184
3108
  return {
3185
3109
  exit(code2) {
3186
- nodeProcess.exit(code2);
3110
+ nodeProcess2.exit(code2);
3187
3111
  },
3188
3112
  cwd() {
3189
- return nodeProcess.cwd();
3113
+ return nodeProcess2.cwd();
3190
3114
  },
3191
3115
  chdir(path) {
3192
- nodeProcess.chdir(path);
3116
+ nodeProcess2.chdir(path);
3193
3117
  },
3194
3118
  hostname() {
3195
- return nodeOs.hostname();
3119
+ return nodeOs2.hostname();
3196
3120
  },
3197
3121
  execPath() {
3198
- return nodeProcess.execPath;
3122
+ return nodeProcess2.execPath;
3199
3123
  },
3200
- args: nodeProcess.argv.slice(2),
3201
- pid: nodeProcess.pid,
3202
- stdin: Readable.toWeb(nodeProcess.stdin),
3203
- stdout: Writable.toWeb(nodeProcess.stdout),
3204
- stderr: Writable.toWeb(nodeProcess.stderr)
3124
+ args: nodeProcess2.argv.slice(2),
3125
+ pid: nodeProcess2.pid,
3126
+ stdin: Readable2.toWeb(nodeProcess2.stdin),
3127
+ stdout: Writable2.toWeb(nodeProcess2.stdout),
3128
+ stderr: Writable2.toWeb(nodeProcess2.stderr)
3205
3129
  };
3206
3130
  };
3207
- createNodeRuntime = () => {
3208
- const fs = createNodeFs();
3209
- const path = createNodePath();
3210
- const exec2 = createNodeExec();
3211
- const env = createNodeEnv();
3212
- const process = createNodeProcess();
3131
+ createBunRuntime = () => {
3132
+ const fs = createBunFs();
3133
+ const path = createBunPath();
3134
+ const exec2 = createBunExec();
3135
+ const env = createBunEnv();
3136
+ const process = createBunProcess();
3213
3137
  return {
3214
- name: "node",
3215
- version: nodeProcess.versions.node,
3216
- capabilities: NODE_CAPABILITIES,
3138
+ name: "bun",
3139
+ version: Bun.version,
3140
+ capabilities: BUN_CAPABILITIES,
3217
3141
  fs,
3218
3142
  path,
3219
3143
  exec: exec2,
@@ -3224,324 +3148,307 @@ var init_node = __esm({
3224
3148
  }
3225
3149
  });
3226
3150
 
3227
- // pkg/@eser/standards/runtime/adapters/bun.ts
3228
- import * as nodeFsPromises2 from "node:fs/promises";
3229
- import * as nodePath2 from "node:path";
3230
- import * as nodeOs2 from "node:os";
3231
- import nodeProcess2 from "node:process";
3232
- import { Readable as Readable2, Writable as Writable2 } from "node:stream";
3233
- var createBunFs, createBunPath, readStream, createBunExec, createBunEnv, createBunProcess, createBunRuntime;
3234
- var init_bun = __esm({
3235
- "pkg/@eser/standards/runtime/adapters/bun.ts"() {
3236
- init_types();
3237
- init_capabilities();
3238
- createBunFs = () => {
3239
- const mapStats = (stats) => ({
3240
- isFile: stats.isFile(),
3241
- isDirectory: stats.isDirectory(),
3242
- isSymlink: stats.isSymbolicLink(),
3243
- size: stats.size,
3244
- mtime: stats.mtime,
3245
- atime: stats.atime,
3246
- birthtime: stats.birthtime
3247
- });
3248
- const handleError = (error, path) => {
3249
- if (error instanceof Error && "code" in error && error.code === "ENOENT") {
3250
- throw new NotFoundError(path);
3151
+ // pkg/@eser/standards/runtime/polyfills/path.ts
3152
+ var POSIX_SEP, POSIX_DELIMITER, normalizeSlashes, join6, resolve6, dirname6, basename6, extname6, normalize6, isAbsolute6, relative6, parse6, format6, posixPath;
3153
+ var init_path = __esm({
3154
+ "pkg/@eser/standards/runtime/polyfills/path.ts"() {
3155
+ POSIX_SEP = "/";
3156
+ POSIX_DELIMITER = ":";
3157
+ normalizeSlashes = (path) => {
3158
+ return path.replace(/\\/g, "/").replace(/\/+/g, "/");
3159
+ };
3160
+ join6 = (...paths) => {
3161
+ if (paths.length === 0) return ".";
3162
+ const joined = paths.filter((p) => p.length > 0).join(POSIX_SEP);
3163
+ if (joined.length === 0) return ".";
3164
+ return normalize6(joined);
3165
+ };
3166
+ resolve6 = (...paths) => {
3167
+ let resolvedPath = "";
3168
+ let resolvedAbsolute = false;
3169
+ for (let i = paths.length - 1; i >= 0 && !resolvedAbsolute; i--) {
3170
+ const segment = paths[i];
3171
+ if (segment === void 0 || segment.length === 0) continue;
3172
+ resolvedPath = `${segment}/${resolvedPath}`;
3173
+ resolvedAbsolute = isAbsolute6(segment);
3174
+ }
3175
+ resolvedPath = normalizeSlashes(resolvedPath);
3176
+ if (resolvedPath.length > 1 && resolvedPath.endsWith("/")) {
3177
+ resolvedPath = resolvedPath.slice(0, -1);
3178
+ }
3179
+ return normalize6(resolvedPath) ?? ".";
3180
+ };
3181
+ dirname6 = (path) => {
3182
+ if (path.length === 0) return ".";
3183
+ path = normalizeSlashes(path);
3184
+ while (path.length > 1 && path.endsWith("/")) {
3185
+ path = path.slice(0, -1);
3186
+ }
3187
+ const lastSlash = path.lastIndexOf("/");
3188
+ if (lastSlash === -1) return ".";
3189
+ if (lastSlash === 0) return "/";
3190
+ return path.slice(0, lastSlash);
3191
+ };
3192
+ basename6 = (path, suffix) => {
3193
+ if (path.length === 0) return "";
3194
+ path = normalizeSlashes(path);
3195
+ while (path.length > 1 && path.endsWith("/")) {
3196
+ path = path.slice(0, -1);
3197
+ }
3198
+ const lastSlash = path.lastIndexOf("/");
3199
+ let base = lastSlash === -1 ? path : path.slice(lastSlash + 1);
3200
+ if (suffix && base.endsWith(suffix)) {
3201
+ base = base.slice(0, -suffix.length);
3202
+ }
3203
+ return base;
3204
+ };
3205
+ extname6 = (path) => {
3206
+ const base = basename6(path);
3207
+ const lastDot = base.lastIndexOf(".");
3208
+ if (lastDot <= 0 || lastDot === base.length - 1) {
3209
+ return "";
3210
+ }
3211
+ return base.slice(lastDot);
3212
+ };
3213
+ normalize6 = (path) => {
3214
+ if (path.length === 0) return ".";
3215
+ path = normalizeSlashes(path);
3216
+ const isAbs = path.startsWith("/");
3217
+ const trailingSlash = path.endsWith("/");
3218
+ const segments = path.split("/").filter((s) => s.length > 0);
3219
+ const result = [];
3220
+ for (const segment of segments) {
3221
+ if (segment === ".") {
3222
+ continue;
3251
3223
  }
3252
- throw error;
3253
- };
3254
- return {
3255
- async readFile(path, options) {
3256
- try {
3257
- const buffer = await nodeFsPromises2.readFile(path, {
3258
- signal: options?.signal
3259
- });
3260
- return new Uint8Array(buffer);
3261
- } catch (error) {
3262
- return handleError(error, path);
3263
- }
3264
- },
3265
- async readTextFile(path, options) {
3266
- try {
3267
- return await nodeFsPromises2.readFile(path, {
3268
- encoding: "utf-8",
3269
- signal: options?.signal
3270
- });
3271
- } catch (error) {
3272
- return handleError(error, path);
3273
- }
3274
- },
3275
- async writeFile(path, data, options) {
3276
- const flag = options?.append ? "a" : "w";
3277
- await nodeFsPromises2.writeFile(path, data, {
3278
- signal: options?.signal,
3279
- mode: options?.mode,
3280
- flag
3281
- });
3282
- },
3283
- async writeTextFile(path, data, options) {
3284
- const flag = options?.append ? "a" : "w";
3285
- await nodeFsPromises2.writeFile(path, data, {
3286
- encoding: "utf-8",
3287
- signal: options?.signal,
3288
- mode: options?.mode,
3289
- flag
3290
- });
3291
- },
3292
- async exists(path) {
3293
- try {
3294
- await nodeFsPromises2.access(path);
3295
- return true;
3296
- } catch {
3297
- return false;
3298
- }
3299
- },
3300
- async stat(path) {
3301
- try {
3302
- const stats = await nodeFsPromises2.stat(path);
3303
- return mapStats(stats);
3304
- } catch (error) {
3305
- return handleError(error, path);
3306
- }
3307
- },
3308
- async lstat(path) {
3309
- try {
3310
- const stats = await nodeFsPromises2.lstat(path);
3311
- return mapStats(stats);
3312
- } catch (error) {
3313
- return handleError(error, path);
3314
- }
3315
- },
3316
- async mkdir(path, options) {
3317
- await nodeFsPromises2.mkdir(path, {
3318
- recursive: options?.recursive ?? false,
3319
- mode: options?.mode
3320
- });
3321
- },
3322
- async remove(path, options) {
3323
- try {
3324
- await nodeFsPromises2.rm(path, {
3325
- recursive: options?.recursive ?? false,
3326
- force: false
3327
- });
3328
- } catch (error) {
3329
- handleError(error, path);
3330
- }
3331
- },
3332
- async *readDir(path) {
3333
- try {
3334
- const entries = await nodeFsPromises2.readdir(path, {
3335
- withFileTypes: true
3336
- });
3337
- for (const entry of entries) {
3338
- yield {
3339
- name: entry.name,
3340
- isFile: entry.isFile(),
3341
- isDirectory: entry.isDirectory(),
3342
- isSymlink: entry.isSymbolicLink()
3343
- };
3344
- }
3345
- } catch (error) {
3346
- handleError(error, path);
3347
- }
3348
- },
3349
- async copyFile(from, to) {
3350
- await nodeFsPromises2.copyFile(from, to);
3351
- },
3352
- async rename(from, to) {
3353
- await nodeFsPromises2.rename(from, to);
3354
- },
3355
- async makeTempDir(options) {
3356
- const dir = options?.dir ?? nodeOs2.tmpdir();
3357
- const prefix = options?.prefix ?? "";
3358
- const suffix = options?.suffix ?? "";
3359
- const tempPath = await nodeFsPromises2.mkdtemp(nodePath2.join(dir, prefix));
3360
- if (suffix) {
3361
- const newPath = tempPath + suffix;
3362
- await nodeFsPromises2.rename(tempPath, newPath);
3363
- return newPath;
3224
+ if (segment === "..") {
3225
+ if (result.length > 0 && result[result.length - 1] !== "..") {
3226
+ result.pop();
3227
+ } else if (!isAbs) {
3228
+ result.push("..");
3364
3229
  }
3365
- return tempPath;
3230
+ } else {
3231
+ result.push(segment);
3366
3232
  }
3367
- };
3233
+ }
3234
+ let normalized = result.join("/");
3235
+ if (isAbs) {
3236
+ normalized = `/${normalized}`;
3237
+ }
3238
+ if (trailingSlash && normalized.length > 1) {
3239
+ normalized += "/";
3240
+ }
3241
+ return normalized ?? ".";
3242
+ };
3243
+ isAbsolute6 = (path) => {
3244
+ if (path.length === 0) return false;
3245
+ if (path.startsWith("/")) return true;
3246
+ if (path.length >= 3 && /^[a-zA-Z]:[/\\]/.test(path)) {
3247
+ return true;
3248
+ }
3249
+ return false;
3368
3250
  };
3369
- createBunPath = () => {
3251
+ relative6 = (from, to) => {
3252
+ if (from === to) return "";
3253
+ from = resolve6(from);
3254
+ to = resolve6(to);
3255
+ if (from === to) return "";
3256
+ const fromParts = from.split("/").filter((p) => p.length > 0);
3257
+ const toParts = to.split("/").filter((p) => p.length > 0);
3258
+ let commonLength = 0;
3259
+ const minLength = Math.min(fromParts.length, toParts.length);
3260
+ for (let i = 0; i < minLength; i++) {
3261
+ if (fromParts[i] !== toParts[i]) break;
3262
+ commonLength++;
3263
+ }
3264
+ const upCount = fromParts.length - commonLength;
3265
+ const remaining = toParts.slice(commonLength);
3266
+ const result = [
3267
+ ...Array(upCount).fill(".."),
3268
+ ...remaining
3269
+ ];
3270
+ return result.join("/") ?? ".";
3271
+ };
3272
+ parse6 = (path) => {
3273
+ if (path.length === 0) {
3274
+ return {
3275
+ root: "",
3276
+ dir: "",
3277
+ base: "",
3278
+ ext: "",
3279
+ name: ""
3280
+ };
3281
+ }
3282
+ path = normalizeSlashes(path);
3283
+ let root = "";
3284
+ let dir = "";
3285
+ const base = basename6(path);
3286
+ const ext = extname6(path);
3287
+ const name = ext ? base.slice(0, -ext.length) : base;
3288
+ if (path.startsWith("/")) {
3289
+ root = "/";
3290
+ } else if (/^[a-zA-Z]:[/\\]/.test(path)) {
3291
+ root = path.slice(0, 3);
3292
+ }
3293
+ dir = dirname6(path);
3294
+ if (dir === ".") {
3295
+ dir = "";
3296
+ }
3370
3297
  return {
3371
- join: nodePath2.join,
3372
- resolve: nodePath2.resolve,
3373
- dirname: nodePath2.dirname,
3374
- basename: nodePath2.basename,
3375
- extname: nodePath2.extname,
3376
- normalize: nodePath2.normalize,
3377
- isAbsolute: nodePath2.isAbsolute,
3378
- relative: nodePath2.relative,
3379
- parse: nodePath2.parse,
3380
- format: nodePath2.format,
3381
- sep: nodePath2.sep,
3382
- delimiter: nodePath2.delimiter
3298
+ root,
3299
+ dir,
3300
+ base,
3301
+ ext,
3302
+ name
3383
3303
  };
3384
3304
  };
3385
- readStream = async (stream) => {
3386
- if (!stream) return new Uint8Array(0);
3387
- const chunks = [];
3388
- const reader = stream.getReader();
3389
- try {
3390
- while (true) {
3391
- const { done, value: value2 } = await reader.read();
3392
- if (done) break;
3393
- chunks.push(value2);
3305
+ format6 = (pathObject) => {
3306
+ const { root = "", dir, base, ext = "", name = "" } = pathObject;
3307
+ const finalBase = base ?? name + ext;
3308
+ if (dir) {
3309
+ if (dir === root) {
3310
+ return `${dir}${finalBase}`;
3394
3311
  }
3395
- } finally {
3396
- reader.releaseLock();
3397
- }
3398
- const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
3399
- const result = new Uint8Array(totalLength);
3400
- let offset = 0;
3401
- for (const chunk of chunks) {
3402
- result.set(chunk, offset);
3403
- offset += chunk.length;
3312
+ return `${dir}/${finalBase}`;
3404
3313
  }
3405
- return result;
3314
+ return `${root}${finalBase}`;
3406
3315
  };
3407
- createBunExec = () => {
3316
+ posixPath = {
3317
+ join: join6,
3318
+ resolve: resolve6,
3319
+ dirname: dirname6,
3320
+ basename: basename6,
3321
+ extname: extname6,
3322
+ normalize: normalize6,
3323
+ isAbsolute: isAbsolute6,
3324
+ relative: relative6,
3325
+ parse: parse6,
3326
+ format: format6,
3327
+ sep: POSIX_SEP,
3328
+ delimiter: POSIX_DELIMITER
3329
+ };
3330
+ }
3331
+ });
3332
+
3333
+ // pkg/@eser/standards/runtime/adapters/workerd.ts
3334
+ var WORKERD_CAPABILITIES, createWorkerdFs, createWorkerdPath, createWorkerdExec, envStorage, createWorkerdEnv, populateEnvFromContext, clearEnv, createWorkerdProcess, createWorkerdRuntime;
3335
+ var init_workerd = __esm({
3336
+ "pkg/@eser/standards/runtime/adapters/workerd.ts"() {
3337
+ init_types();
3338
+ init_path();
3339
+ WORKERD_CAPABILITIES = {
3340
+ fs: false,
3341
+ fsSync: false,
3342
+ exec: false,
3343
+ process: false,
3344
+ env: true,
3345
+ stdin: false,
3346
+ stdout: false,
3347
+ kv: true
3348
+ };
3349
+ createWorkerdFs = () => {
3350
+ const throwNotAvailable = () => {
3351
+ throw new RuntimeCapabilityError("fs", "workerd");
3352
+ };
3408
3353
  return {
3409
- async spawn(cmd, args = [], options) {
3410
- const proc = Bun.spawn([
3411
- cmd,
3412
- ...args
3413
- ], {
3414
- cwd: options?.cwd,
3415
- env: options?.env,
3416
- stdin: options?.stdin === "inherit" ? "inherit" : options?.stdin === "piped" ? "pipe" : "ignore",
3417
- stdout: options?.stdout === "inherit" ? "inherit" : options?.stdout === "null" ? "ignore" : "pipe",
3418
- stderr: options?.stderr === "inherit" ? "inherit" : options?.stderr === "null" ? "ignore" : "pipe"
3419
- });
3420
- const [exitCode, stdout, stderr] = await Promise.all([
3421
- proc.exited,
3422
- readStream(proc.stdout),
3423
- readStream(proc.stderr)
3424
- ]);
3425
- return {
3426
- success: exitCode === 0,
3427
- code: exitCode,
3428
- stdout,
3429
- stderr
3430
- };
3431
- },
3432
- async exec(cmd, args = [], options) {
3433
- const result = await this.spawn(cmd, args, options);
3434
- if (!result.success) {
3435
- const stderr = new TextDecoder().decode(result.stderr);
3436
- throw new ProcessError(cmd, result.code, stderr);
3437
- }
3438
- return new TextDecoder().decode(result.stdout).trim();
3439
- },
3440
- async execJson(cmd, args = [], options) {
3441
- const output = await this.exec(cmd, args, options);
3442
- return JSON.parse(output);
3354
+ readFile: throwNotAvailable,
3355
+ readTextFile: throwNotAvailable,
3356
+ writeFile: throwNotAvailable,
3357
+ writeTextFile: throwNotAvailable,
3358
+ exists: throwNotAvailable,
3359
+ stat: throwNotAvailable,
3360
+ lstat: throwNotAvailable,
3361
+ mkdir: throwNotAvailable,
3362
+ remove: throwNotAvailable,
3363
+ readDir: () => {
3364
+ throw new RuntimeCapabilityError("fs", "workerd");
3443
3365
  },
3444
- spawnChild(cmd, args = [], options) {
3445
- const proc = Bun.spawn([
3446
- cmd,
3447
- ...args
3448
- ], {
3449
- cwd: options?.cwd,
3450
- env: options?.env,
3451
- stdin: options?.stdin === "inherit" ? "inherit" : options?.stdin === "piped" ? "pipe" : "ignore",
3452
- stdout: options?.stdout === "inherit" ? "inherit" : options?.stdout === "null" ? "ignore" : "pipe",
3453
- stderr: options?.stderr === "inherit" ? "inherit" : options?.stderr === "null" ? "ignore" : "pipe"
3454
- });
3455
- const statusPromise = proc.exited.then((code2) => ({
3456
- success: code2 === 0,
3457
- code: code2,
3458
- signal: void 0
3459
- }));
3460
- return {
3461
- pid: proc.pid,
3462
- stdin: proc.stdin,
3463
- stdout: proc.stdout,
3464
- stderr: proc.stderr,
3465
- status: statusPromise,
3466
- output: async () => {
3467
- const [status, stdout, stderr] = await Promise.all([
3468
- statusPromise,
3469
- readStream(proc.stdout),
3470
- readStream(proc.stderr)
3471
- ]);
3472
- return {
3473
- success: status.success,
3474
- code: status.code,
3475
- stdout,
3476
- stderr
3477
- };
3478
- },
3479
- kill: (signal) => {
3480
- proc.kill(signal);
3481
- }
3482
- };
3483
- }
3366
+ copyFile: throwNotAvailable,
3367
+ rename: throwNotAvailable,
3368
+ makeTempDir: throwNotAvailable
3484
3369
  };
3485
3370
  };
3486
- createBunEnv = () => {
3371
+ createWorkerdPath = () => {
3372
+ return posixPath;
3373
+ };
3374
+ createWorkerdExec = () => {
3375
+ const throwNotAvailable = () => {
3376
+ throw new RuntimeCapabilityError("exec", "workerd");
3377
+ };
3378
+ return {
3379
+ spawn: throwNotAvailable,
3380
+ exec: throwNotAvailable,
3381
+ execJson: throwNotAvailable,
3382
+ spawnChild: throwNotAvailable
3383
+ };
3384
+ };
3385
+ envStorage = /* @__PURE__ */ new Map();
3386
+ createWorkerdEnv = () => {
3487
3387
  return {
3488
3388
  get(key) {
3489
- return nodeProcess2.env[key];
3389
+ return envStorage.get(key);
3490
3390
  },
3491
3391
  set(key, value2) {
3492
- nodeProcess2.env[key] = value2;
3392
+ envStorage.set(key, value2);
3493
3393
  },
3494
3394
  delete(key) {
3495
- delete nodeProcess2.env[key];
3395
+ envStorage.delete(key);
3496
3396
  },
3497
3397
  has(key) {
3498
- return key in nodeProcess2.env;
3398
+ return envStorage.has(key);
3499
3399
  },
3500
3400
  toObject() {
3501
- const result = {};
3502
- for (const [key, value2] of Object.entries(nodeProcess2.env)) {
3503
- if (value2 !== void 0) {
3504
- result[key] = value2;
3505
- }
3506
- }
3507
- return result;
3401
+ return Object.fromEntries(envStorage);
3508
3402
  }
3509
3403
  };
3510
3404
  };
3511
- createBunProcess = () => {
3405
+ populateEnvFromContext = (env) => {
3406
+ for (const [key, value2] of Object.entries(env)) {
3407
+ if (value2 !== null && value2 !== void 0 && value2.constructor === String) {
3408
+ envStorage.set(key, value2);
3409
+ }
3410
+ }
3411
+ };
3412
+ clearEnv = () => {
3413
+ envStorage.clear();
3414
+ };
3415
+ createWorkerdProcess = () => {
3416
+ const throwNotAvailable = () => {
3417
+ throw new RuntimeCapabilityError("process", "workerd");
3418
+ };
3512
3419
  return {
3513
- exit(code2) {
3514
- nodeProcess2.exit(code2);
3515
- },
3516
- cwd() {
3517
- return nodeProcess2.cwd();
3420
+ exit: throwNotAvailable,
3421
+ cwd: throwNotAvailable,
3422
+ chdir: throwNotAvailable,
3423
+ hostname: throwNotAvailable,
3424
+ execPath: throwNotAvailable,
3425
+ get args() {
3426
+ throw new RuntimeCapabilityError("process", "workerd");
3518
3427
  },
3519
- chdir(path) {
3520
- nodeProcess2.chdir(path);
3428
+ get pid() {
3429
+ throw new RuntimeCapabilityError("process", "workerd");
3521
3430
  },
3522
- hostname() {
3523
- return nodeOs2.hostname();
3431
+ get stdin() {
3432
+ throw new RuntimeCapabilityError("process", "workerd");
3524
3433
  },
3525
- execPath() {
3526
- return nodeProcess2.execPath;
3434
+ get stdout() {
3435
+ throw new RuntimeCapabilityError("process", "workerd");
3527
3436
  },
3528
- args: nodeProcess2.argv.slice(2),
3529
- pid: nodeProcess2.pid,
3530
- stdin: Readable2.toWeb(nodeProcess2.stdin),
3531
- stdout: Writable2.toWeb(nodeProcess2.stdout),
3532
- stderr: Writable2.toWeb(nodeProcess2.stderr)
3437
+ get stderr() {
3438
+ throw new RuntimeCapabilityError("process", "workerd");
3439
+ }
3533
3440
  };
3534
3441
  };
3535
- createBunRuntime = () => {
3536
- const fs = createBunFs();
3537
- const path = createBunPath();
3538
- const exec2 = createBunExec();
3539
- const env = createBunEnv();
3540
- const process = createBunProcess();
3442
+ createWorkerdRuntime = () => {
3443
+ const fs = createWorkerdFs();
3444
+ const path = createWorkerdPath();
3445
+ const exec2 = createWorkerdExec();
3446
+ const env = createWorkerdEnv();
3447
+ const process = createWorkerdProcess();
3541
3448
  return {
3542
- name: "bun",
3543
- version: Bun.version,
3544
- capabilities: BUN_CAPABILITIES,
3449
+ name: "workerd",
3450
+ version: "unknown",
3451
+ capabilities: WORKERD_CAPABILITIES,
3545
3452
  fs,
3546
3453
  path,
3547
3454
  exec: exec2,
@@ -3552,6 +3459,103 @@ var init_bun = __esm({
3552
3459
  }
3553
3460
  });
3554
3461
 
3462
+ // pkg/@eser/standards/runtime/capabilities.ts
3463
+ var FULL_CAPABILITIES, BROWSER_CAPABILITIES, UNKNOWN_CAPABILITIES, getCapabilities, hasCapability;
3464
+ var init_capabilities = __esm({
3465
+ "pkg/@eser/standards/runtime/capabilities.ts"() {
3466
+ init_deno();
3467
+ init_node();
3468
+ init_bun();
3469
+ init_workerd();
3470
+ init_deno();
3471
+ init_node();
3472
+ init_bun();
3473
+ init_workerd();
3474
+ FULL_CAPABILITIES = {
3475
+ fs: true,
3476
+ fsSync: true,
3477
+ exec: true,
3478
+ process: true,
3479
+ env: true,
3480
+ stdin: true,
3481
+ stdout: true,
3482
+ kv: false
3483
+ };
3484
+ BROWSER_CAPABILITIES = {
3485
+ fs: false,
3486
+ fsSync: false,
3487
+ exec: false,
3488
+ process: false,
3489
+ env: false,
3490
+ stdin: false,
3491
+ stdout: false,
3492
+ kv: false
3493
+ };
3494
+ UNKNOWN_CAPABILITIES = {
3495
+ fs: false,
3496
+ fsSync: false,
3497
+ exec: false,
3498
+ process: false,
3499
+ env: false,
3500
+ stdin: false,
3501
+ stdout: false,
3502
+ kv: false
3503
+ };
3504
+ getCapabilities = (runtime2) => {
3505
+ switch (runtime2) {
3506
+ case "deno":
3507
+ return DENO_CAPABILITIES;
3508
+ case "node":
3509
+ return NODE_CAPABILITIES;
3510
+ case "bun":
3511
+ return BUN_CAPABILITIES;
3512
+ case "workerd":
3513
+ return WORKERD_CAPABILITIES;
3514
+ case "browser":
3515
+ return BROWSER_CAPABILITIES;
3516
+ default:
3517
+ return UNKNOWN_CAPABILITIES;
3518
+ }
3519
+ };
3520
+ hasCapability = (runtime2, capability) => {
3521
+ return getCapabilities(runtime2)[capability];
3522
+ };
3523
+ }
3524
+ });
3525
+
3526
+ // pkg/@eser/standards/runtime/file-search.ts
3527
+ var searchFileHierarchy;
3528
+ var init_file_search = __esm({
3529
+ "pkg/@eser/standards/runtime/file-search.ts"() {
3530
+ init_mod2();
3531
+ searchFileHierarchy = async (startDir, filenames, options = {}) => {
3532
+ const { searchParents = false } = options;
3533
+ let dir = startDir;
3534
+ while (true) {
3535
+ for (const name of filenames) {
3536
+ const filepath = runtime.path.join(dir, name);
3537
+ const exists = await runtime.fs.exists(filepath);
3538
+ if (exists) {
3539
+ const stat3 = await runtime.fs.stat(filepath);
3540
+ if (stat3.isFile) {
3541
+ return filepath;
3542
+ }
3543
+ }
3544
+ }
3545
+ if (!searchParents) {
3546
+ break;
3547
+ }
3548
+ const parent = runtime.path.dirname(dir);
3549
+ if (parent === dir) {
3550
+ break;
3551
+ }
3552
+ dir = parent;
3553
+ }
3554
+ return void 0;
3555
+ };
3556
+ }
3557
+ });
3558
+
3555
3559
  // pkg/@eser/standards/runtime/mod.ts
3556
3560
  var mod_exports2 = {};
3557
3561
  __export(mod_exports2, {
@@ -3589,7 +3593,7 @@ __export(mod_exports2, {
3589
3593
  runtime: () => runtime,
3590
3594
  searchFileHierarchy: () => searchFileHierarchy
3591
3595
  });
3592
- var createMinimalRuntime, createRuntime, runtime;
3596
+ var createThrowFn, createStubFs, createStubExec, createStubProcess, createStubEnv, createMinimalRuntime, runtimeFactories, overrideKeys, hasOverrides, mergeRuntime, createRuntime, runtime;
3593
3597
  var init_mod2 = __esm({
3594
3598
  "pkg/@eser/standards/runtime/mod.ts"() {
3595
3599
  init_types();
@@ -3607,111 +3611,116 @@ var init_mod2 = __esm({
3607
3611
  init_node();
3608
3612
  init_bun();
3609
3613
  init_workerd();
3610
- createMinimalRuntime = (name, capabilities = UNKNOWN_CAPABILITIES) => {
3611
- const throwFs = () => {
3612
- throw new RuntimeCapabilityError("fs", name);
3614
+ createThrowFn = (capability, runtimeName) => {
3615
+ return () => {
3616
+ throw new RuntimeCapabilityError(capability, runtimeName);
3613
3617
  };
3614
- const throwExec = () => {
3615
- throw new RuntimeCapabilityError("exec", name);
3618
+ };
3619
+ createStubFs = (runtimeName) => {
3620
+ const throwFs = createThrowFn("fs", runtimeName);
3621
+ return {
3622
+ readFile: throwFs,
3623
+ readTextFile: throwFs,
3624
+ writeFile: throwFs,
3625
+ writeTextFile: throwFs,
3626
+ exists: throwFs,
3627
+ stat: throwFs,
3628
+ lstat: throwFs,
3629
+ mkdir: throwFs,
3630
+ remove: throwFs,
3631
+ readDir: throwFs,
3632
+ copyFile: throwFs,
3633
+ rename: throwFs,
3634
+ makeTempDir: throwFs
3616
3635
  };
3617
- const throwProcess = () => {
3618
- throw new RuntimeCapabilityError("process", name);
3636
+ };
3637
+ createStubExec = (runtimeName) => {
3638
+ const throwExec = createThrowFn("exec", runtimeName);
3639
+ return {
3640
+ spawn: throwExec,
3641
+ exec: throwExec,
3642
+ execJson: throwExec,
3643
+ spawnChild: throwExec
3619
3644
  };
3645
+ };
3646
+ createStubProcess = (runtimeName) => {
3647
+ const throwProcess = createThrowFn("process", runtimeName);
3620
3648
  return {
3621
- name,
3622
- version: "unknown",
3623
- capabilities,
3624
- fs: {
3625
- readFile: throwFs,
3626
- readTextFile: throwFs,
3627
- writeFile: throwFs,
3628
- writeTextFile: throwFs,
3629
- exists: throwFs,
3630
- stat: throwFs,
3631
- lstat: throwFs,
3632
- mkdir: throwFs,
3633
- remove: throwFs,
3634
- readDir: () => {
3635
- throw new RuntimeCapabilityError("fs", name);
3636
- },
3637
- copyFile: throwFs,
3638
- rename: throwFs,
3639
- makeTempDir: throwFs
3649
+ exit: throwProcess,
3650
+ cwd: throwProcess,
3651
+ chdir: throwProcess,
3652
+ hostname: throwProcess,
3653
+ execPath: throwProcess,
3654
+ get args() {
3655
+ throw new RuntimeCapabilityError("process", runtimeName);
3656
+ },
3657
+ get pid() {
3658
+ throw new RuntimeCapabilityError("process", runtimeName);
3640
3659
  },
3641
- path: posixPath,
3642
- exec: {
3643
- spawn: throwExec,
3644
- exec: throwExec,
3645
- execJson: throwExec,
3646
- spawnChild: throwExec
3660
+ get stdin() {
3661
+ throw new RuntimeCapabilityError("process", runtimeName);
3647
3662
  },
3648
- env: {
3649
- get: () => void 0,
3650
- set: () => {
3651
- },
3652
- delete: () => {
3653
- },
3654
- has: () => false,
3655
- toObject: () => ({})
3663
+ get stdout() {
3664
+ throw new RuntimeCapabilityError("process", runtimeName);
3656
3665
  },
3657
- process: {
3658
- exit: throwProcess,
3659
- cwd: throwProcess,
3660
- chdir: throwProcess,
3661
- hostname: throwProcess,
3662
- execPath: throwProcess,
3663
- get args() {
3664
- throw new RuntimeCapabilityError("process", name);
3665
- },
3666
- get pid() {
3667
- throw new RuntimeCapabilityError("process", name);
3668
- },
3669
- get stdin() {
3670
- throw new RuntimeCapabilityError("process", name);
3671
- },
3672
- get stdout() {
3673
- throw new RuntimeCapabilityError("process", name);
3674
- },
3675
- get stderr() {
3676
- throw new RuntimeCapabilityError("process", name);
3677
- }
3666
+ get stderr() {
3667
+ throw new RuntimeCapabilityError("process", runtimeName);
3678
3668
  }
3679
3669
  };
3680
3670
  };
3671
+ createStubEnv = () => ({
3672
+ get: () => void 0,
3673
+ set: () => {
3674
+ },
3675
+ delete: () => {
3676
+ },
3677
+ has: () => false,
3678
+ toObject: () => ({})
3679
+ });
3680
+ createMinimalRuntime = (name, capabilities = UNKNOWN_CAPABILITIES) => ({
3681
+ name,
3682
+ version: "unknown",
3683
+ capabilities,
3684
+ fs: createStubFs(name),
3685
+ path: posixPath,
3686
+ exec: createStubExec(name),
3687
+ env: createStubEnv(),
3688
+ process: createStubProcess(name)
3689
+ });
3690
+ runtimeFactories = {
3691
+ deno: createDenoRuntime,
3692
+ node: createNodeRuntime,
3693
+ bun: createBunRuntime,
3694
+ workerd: createWorkerdRuntime
3695
+ };
3696
+ overrideKeys = [
3697
+ "fs",
3698
+ "exec",
3699
+ "env",
3700
+ "path",
3701
+ "process"
3702
+ ];
3703
+ hasOverrides = (options) => options !== void 0 && overrideKeys.some((key) => options[key] !== void 0);
3704
+ mergeRuntime = (base, options, capabilities) => ({
3705
+ name: base.name,
3706
+ version: base.version,
3707
+ capabilities,
3708
+ fs: options.fs ?? base.fs,
3709
+ path: options.path ?? base.path,
3710
+ exec: options.exec ?? base.exec,
3711
+ env: options.env ?? base.env,
3712
+ process: options.process ?? base.process
3713
+ });
3681
3714
  createRuntime = (options) => {
3682
3715
  const runtimeName = detectRuntime();
3683
3716
  const capabilities = {
3684
3717
  ...getCapabilities(runtimeName),
3685
3718
  ...options?.capabilities
3686
3719
  };
3687
- let baseRuntime;
3688
- switch (runtimeName) {
3689
- case "deno":
3690
- baseRuntime = createDenoRuntime();
3691
- break;
3692
- case "node":
3693
- baseRuntime = createNodeRuntime();
3694
- break;
3695
- case "bun":
3696
- baseRuntime = createBunRuntime();
3697
- break;
3698
- case "workerd":
3699
- baseRuntime = createWorkerdRuntime();
3700
- break;
3701
- default:
3702
- baseRuntime = createMinimalRuntime(runtimeName, capabilities);
3703
- }
3704
- if (options?.fs || options?.exec || options?.env || options?.path || options?.process) {
3705
- return {
3706
- name: baseRuntime.name,
3707
- version: baseRuntime.version,
3708
- capabilities,
3709
- fs: options.fs ?? baseRuntime.fs,
3710
- path: options.path ?? baseRuntime.path,
3711
- exec: options.exec ?? baseRuntime.exec,
3712
- env: options.env ?? baseRuntime.env,
3713
- process: options.process ?? baseRuntime.process
3714
- };
3720
+ const factory = runtimeFactories[runtimeName];
3721
+ const baseRuntime = factory?.() ?? createMinimalRuntime(runtimeName, capabilities);
3722
+ if (options !== void 0 && hasOverrides(options)) {
3723
+ return mergeRuntime(baseRuntime, options, capabilities);
3715
3724
  }
3716
3725
  return baseRuntime;
3717
3726
  };
@@ -5872,8 +5881,8 @@ var init_to_path_string = __esm({
5872
5881
  // deno:https://jsr.io/@std/fs/1.0.21/_create_walk_entry.ts
5873
5882
  async function createWalkEntry(path) {
5874
5883
  path = toPathString(path);
5875
- path = normalize4(path);
5876
- const name = basename4(path);
5884
+ path = normalize3(path);
5885
+ const name = basename3(path);
5877
5886
  const info = await Deno.stat(path);
5878
5887
  return {
5879
5888
  path,
@@ -5920,7 +5929,7 @@ async function* walk(root, options) {
5920
5929
  return;
5921
5930
  }
5922
5931
  for await (const entry of Deno.readDir(root)) {
5923
- let path = join4(root, entry.name);
5932
+ let path = join3(root, entry.name);
5924
5933
  let { isSymlink, isDirectory } = entry;
5925
5934
  if (isSymlink) {
5926
5935
  if (!followSymlinks) {
@@ -7212,7 +7221,7 @@ var init_loader = __esm({
7212
7221
  }
7213
7222
  };
7214
7223
  getFileFormat = (filepath) => {
7215
- const ext = extname2(filepath);
7224
+ const ext = extname(filepath);
7216
7225
  if (ext === ".json") {
7217
7226
  return FileFormats.Json;
7218
7227
  }
@@ -7291,12 +7300,125 @@ var init_mod7 = __esm({
7291
7300
  }
7292
7301
  });
7293
7302
 
7303
+ // pkg/@eser/fp/get.ts
7304
+ var get;
7305
+ var init_get = __esm({
7306
+ "pkg/@eser/fp/get.ts"() {
7307
+ get = (object, path, defaultValue) => {
7308
+ if (object === null || object === void 0) {
7309
+ return defaultValue;
7310
+ }
7311
+ const length = path.length;
7312
+ if (length === 0) {
7313
+ return object;
7314
+ }
7315
+ let current = object;
7316
+ for (let i = 0; i < length; i++) {
7317
+ if (current === null || current === void 0) {
7318
+ return defaultValue;
7319
+ }
7320
+ const key = path[i];
7321
+ current = current[key];
7322
+ }
7323
+ return current === void 0 ? defaultValue : current;
7324
+ };
7325
+ }
7326
+ });
7327
+
7328
+ // pkg/@eser/fp/deep-merge.ts
7329
+ var DEEP_MERGE_DEFAULT_MAX_DEPTH, DeepMergeError, deepMerge2;
7330
+ var init_deep_merge2 = __esm({
7331
+ "pkg/@eser/fp/deep-merge.ts"() {
7332
+ DEEP_MERGE_DEFAULT_MAX_DEPTH = 100;
7333
+ DeepMergeError = class extends Error {
7334
+ constructor(message) {
7335
+ super(message);
7336
+ this.name = "DeepMergeError";
7337
+ }
7338
+ };
7339
+ deepMerge2 = (instance, other, options) => {
7340
+ const maxDepth = options?.maxDepth ?? DEEP_MERGE_DEFAULT_MAX_DEPTH;
7341
+ const seenInstance = /* @__PURE__ */ new WeakSet();
7342
+ const seenOther = /* @__PURE__ */ new WeakSet();
7343
+ const mergeRecursive = (inst, oth, currentDepth) => {
7344
+ if (!(inst instanceof Object)) {
7345
+ return inst;
7346
+ }
7347
+ if (seenInstance.has(inst)) {
7348
+ throw new DeepMergeError("Circular reference detected in first argument: cannot deep merge objects with circular references");
7349
+ }
7350
+ if (oth instanceof Object && seenOther.has(oth)) {
7351
+ throw new DeepMergeError("Circular reference detected in second argument: cannot deep merge objects with circular references");
7352
+ }
7353
+ if (currentDepth > maxDepth) {
7354
+ throw new DeepMergeError(`Maximum recursion depth exceeded (${maxDepth}). Objects are too deeply nested or contain circular references.`);
7355
+ }
7356
+ seenInstance.add(inst);
7357
+ if (oth instanceof Object) {
7358
+ seenOther.add(oth);
7359
+ }
7360
+ try {
7361
+ const Type = inst.constructor;
7362
+ const result = new Type();
7363
+ const instKeys = Object.keys(inst);
7364
+ const processedKeys = /* @__PURE__ */ new Set();
7365
+ for (let i = 0, len = instKeys.length; i < len; i++) {
7366
+ const itemKey = instKeys[i];
7367
+ const recordValue = inst[itemKey];
7368
+ const otherKeyExists = oth !== void 0 && itemKey in oth;
7369
+ const otherValue = oth?.[itemKey];
7370
+ processedKeys.add(itemKey);
7371
+ if (recordValue instanceof Object && recordValue.constructor !== Array) {
7372
+ let mergedValue;
7373
+ if (otherKeyExists && otherValue instanceof Object && otherValue.constructor !== Array) {
7374
+ mergedValue = mergeRecursive(recordValue, otherValue, currentDepth + 1);
7375
+ } else if (otherKeyExists) {
7376
+ mergedValue = otherValue;
7377
+ } else {
7378
+ mergedValue = mergeRecursive(recordValue, {}, currentDepth + 1);
7379
+ }
7380
+ result[itemKey] = mergedValue;
7381
+ } else {
7382
+ result[itemKey] = otherKeyExists ? otherValue : recordValue;
7383
+ }
7384
+ }
7385
+ if (oth === void 0) {
7386
+ return result;
7387
+ }
7388
+ const otherKeys = Object.keys(oth);
7389
+ for (let i = 0, len = otherKeys.length; i < len; i++) {
7390
+ const itemKey = otherKeys[i];
7391
+ if (processedKeys.has(itemKey)) {
7392
+ continue;
7393
+ }
7394
+ const otherValue = oth[itemKey];
7395
+ if (otherValue instanceof Object && otherValue.constructor !== Array) {
7396
+ result[itemKey] = mergeRecursive({}, otherValue, currentDepth + 1);
7397
+ } else {
7398
+ result[itemKey] = otherValue;
7399
+ }
7400
+ }
7401
+ return result;
7402
+ } finally {
7403
+ seenInstance.delete(inst);
7404
+ if (oth instanceof Object) {
7405
+ seenOther.delete(oth);
7406
+ }
7407
+ }
7408
+ };
7409
+ return mergeRecursive(instance, other, 0);
7410
+ };
7411
+ }
7412
+ });
7413
+
7294
7414
  // pkg/@eser/codebase/package/loader.ts
7295
7415
  var PackageLoadError, tryLoadConfigFile, findConfigFiles, getPropertyByPath, extractField, mergeFieldMappings, sortByPriority, load, tryLoad, getFilesWithField, getBaseDir;
7296
7416
  var init_loader2 = __esm({
7297
7417
  "pkg/@eser/codebase/package/loader.ts"() {
7298
7418
  init_mod4();
7299
7419
  init_mod7();
7420
+ init_get();
7421
+ init_deep_merge2();
7300
7422
  init_mod2();
7301
7423
  init_types3();
7302
7424
  PackageLoadError = class extends Error {
@@ -7334,7 +7456,7 @@ var init_loader2 = __esm({
7334
7456
  findConfigFiles = async (baseDir, includeFiles) => {
7335
7457
  const results = [];
7336
7458
  for (const fileType of includeFiles) {
7337
- const filepath = join2(baseDir, fileType);
7459
+ const filepath = join(baseDir, fileType);
7338
7460
  const loaded = await tryLoadConfigFile(filepath, fileType);
7339
7461
  if (loaded) {
7340
7462
  results.push(loaded);
@@ -7343,15 +7465,7 @@ var init_loader2 = __esm({
7343
7465
  return results;
7344
7466
  };
7345
7467
  getPropertyByPath = (obj, path) => {
7346
- const parts = path.split(".");
7347
- let current = obj;
7348
- for (const part of parts) {
7349
- if (current === null || current === void 0 || typeof current !== "object") {
7350
- return void 0;
7351
- }
7352
- current = current[part];
7353
- }
7354
- return current;
7468
+ return get(obj, path.split("."));
7355
7469
  };
7356
7470
  extractField = (fieldName, loadedFiles, fieldMappings) => {
7357
7471
  let primaryValue;
@@ -7391,16 +7505,7 @@ var init_loader2 = __esm({
7391
7505
  if (customMappings === void 0) {
7392
7506
  return DEFAULT_FIELD_MAPPINGS;
7393
7507
  }
7394
- const merged = {
7395
- ...DEFAULT_FIELD_MAPPINGS
7396
- };
7397
- for (const [field, mapping] of Object.entries(customMappings)) {
7398
- merged[field] = {
7399
- ...merged[field],
7400
- ...mapping
7401
- };
7402
- }
7403
- return merged;
7508
+ return deepMerge2(DEFAULT_FIELD_MAPPINGS, customMappings);
7404
7509
  };
7405
7510
  sortByPriority = (files) => {
7406
7511
  return [
@@ -7411,14 +7516,14 @@ var init_loader2 = __esm({
7411
7516
  const { baseDir = ".", includeFiles = CONFIG_FILE_PRIORITY, fieldMappings, searchParents = false } = options;
7412
7517
  const mergedMappings = mergeFieldMappings(fieldMappings);
7413
7518
  const sortedFiles = sortByPriority(includeFiles);
7414
- let searchDir = resolve2(baseDir);
7519
+ let searchDir = resolve(baseDir);
7415
7520
  let loadedFiles = [];
7416
7521
  while (true) {
7417
7522
  loadedFiles = await findConfigFiles(searchDir, sortedFiles);
7418
7523
  if (loadedFiles.length > 0 || !searchParents) {
7419
7524
  break;
7420
7525
  }
7421
- const parent = dirname2(searchDir);
7526
+ const parent = dirname(searchDir);
7422
7527
  if (parent === searchDir) {
7423
7528
  break;
7424
7529
  }
@@ -7622,7 +7727,7 @@ var init_writer = __esm({
7622
7727
  function split(path) {
7623
7728
  const s = SEPARATOR_PATTERN.source;
7624
7729
  const segments = path.replace(new RegExp(`^${s}|${s}$`, "g"), "").split(SEPARATOR_PATTERN);
7625
- const isAbsolute_ = isAbsolute4(path);
7730
+ const isAbsolute_ = isAbsolute3(path);
7626
7731
  const split2 = {
7627
7732
  segments,
7628
7733
  isAbsolute: isAbsolute_,
@@ -7652,8 +7757,8 @@ async function* expandGlob(glob, options) {
7652
7757
  globstar,
7653
7758
  caseInsensitive
7654
7759
  };
7655
- const absRoot = isGlobAbsolute ? root : resolve4(root);
7656
- const resolveFromRoot = (path) => resolve4(absRoot, path);
7760
+ const absRoot = isGlobAbsolute ? root : resolve3(root);
7761
+ const resolveFromRoot = (path) => resolve3(absRoot, path);
7657
7762
  const excludePatterns = exclude.map(resolveFromRoot).map((s) => globToRegExp3(s, globOptions));
7658
7763
  const shouldInclude = (path) => !excludePatterns.some((p) => p.test(path));
7659
7764
  let fixedRoot = isGlobAbsolute ? winRoot ?? "/" : absRoot;
@@ -7776,7 +7881,7 @@ var init_workspace = __esm({
7776
7881
  });
7777
7882
  } catch (e) {
7778
7883
  if (e instanceof PackageLoadError) {
7779
- console.log(`No package config file found in ${resolve2(path)}`);
7884
+ console.log(`No package config file found in ${resolve(path)}`);
7780
7885
  runtime.process.exit(1);
7781
7886
  }
7782
7887
  throw e;
@@ -7785,7 +7890,7 @@ var init_workspace = __esm({
7785
7890
  expandWorkspacePaths = async (root, patterns) => {
7786
7891
  const paths = [];
7787
7892
  for (const pattern of patterns) {
7788
- const fullPattern = join2(root, pattern);
7893
+ const fullPattern = join(root, pattern);
7789
7894
  if (pattern.includes("*") || pattern.includes("?")) {
7790
7895
  for await (const entry of expandGlob(fullPattern, {
7791
7896
  includeDirs: true
@@ -7894,10 +7999,10 @@ var init_workspace_discovery = __esm({
7894
7999
  return [];
7895
8000
  };
7896
8001
  resolveModulePath = (specifier, basePath) => {
7897
- if (isAbsolute2(specifier)) {
8002
+ if (isAbsolute(specifier)) {
7898
8003
  return specifier;
7899
8004
  }
7900
- return resolve2(basePath, specifier);
8005
+ return resolve(basePath, specifier);
7901
8006
  };
7902
8007
  getPackageFiles = async (packagePath) => {
7903
8008
  const files = [];
@@ -7912,8 +8017,8 @@ var init_workspace_discovery = __esm({
7912
8017
  /\.git/
7913
8018
  ]
7914
8019
  })) {
7915
- const relativePath = relative2(packagePath, entry.path);
7916
- const fileName = basename2(relativePath);
8020
+ const relativePath = relative(packagePath, entry.path);
8021
+ const fileName = basename(relativePath);
7917
8022
  if (fileName.endsWith("_test.ts") || fileName.endsWith("_bench.ts")) {
7918
8023
  continue;
7919
8024
  }
@@ -8104,7 +8209,7 @@ var init_check_mod_exports = __esm({
8104
8209
  const packages = await discoverPackages(root);
8105
8210
  const missingExports = [];
8106
8211
  for (const pkg of packages) {
8107
- const modPath = join2(pkg.path, "mod.ts");
8212
+ const modPath = join(pkg.path, "mod.ts");
8108
8213
  let modContent;
8109
8214
  try {
8110
8215
  modContent = await runtime.fs.readTextFile(modPath);
@@ -8117,7 +8222,7 @@ var init_check_mod_exports = __esm({
8117
8222
  ].map((e) => normalizePath(e)));
8118
8223
  const files = await getPackageFiles(pkg.path);
8119
8224
  for (const file of files) {
8120
- const fileName = basename2(file);
8225
+ const fileName = basename(file);
8121
8226
  if (!shouldBeExported(fileName)) {
8122
8227
  continue;
8123
8228
  }
@@ -8203,7 +8308,7 @@ var init_check_export_names = __esm({
8203
8308
  if (cleanSegment.length === 0) {
8204
8309
  continue;
8205
8310
  }
8206
- const ext = extname2(cleanSegment);
8311
+ const ext = extname(cleanSegment);
8207
8312
  if (ext.length > 0) {
8208
8313
  cleanSegment = cleanSegment.slice(0, -ext.length);
8209
8314
  }
@@ -8479,7 +8584,7 @@ var init_check_licenses = __esm({
8479
8584
  validateLicenses = async (options = {}) => {
8480
8585
  const { fix = false } = options;
8481
8586
  const baseUrl = new URL(".", import.meta.url);
8482
- const defaultRoot = join2(fromFileUrl(baseUrl.href), "..");
8587
+ const defaultRoot = join(fromFileUrl(baseUrl.href), "..");
8483
8588
  const root = options.root ?? defaultRoot;
8484
8589
  const issues = [];
8485
8590
  let checked = 0;
@@ -8587,11 +8692,18 @@ var init_licenses = __esm({
8587
8692
  }
8588
8693
  });
8589
8694
 
8695
+ // pkg/@eser/fp/group-by.ts
8696
+ var init_group_by = __esm({
8697
+ "pkg/@eser/fp/group-by.ts"() {
8698
+ }
8699
+ });
8700
+
8590
8701
  // pkg/@eser/codebase/check-package-configs.ts
8591
8702
  var deepEqual, getFieldValue, isNpmJsrSpec, fromNpmJsrToDeno, convertPkgDepToDenoImport, isWorkspaceDep, checkDependencies, checkPackage, checkPackageConfigs;
8592
8703
  var init_check_package_configs = __esm({
8593
8704
  async "pkg/@eser/codebase/check-package-configs.ts"() {
8594
8705
  init_colors();
8706
+ init_group_by();
8595
8707
  init_mod2();
8596
8708
  init_mod8();
8597
8709
  init_types3();
@@ -9117,27 +9229,18 @@ var buildParseOptions = (flags) => {
9117
9229
  default: defaultValues
9118
9230
  };
9119
9231
  };
9232
+ var isString = (value2) => value2 !== null && value2 !== void 0 && value2.constructor === String;
9233
+ var coercers = {
9234
+ boolean: (value2) => Boolean(value2),
9235
+ number: (value2) => isString(value2) ? Number(value2) : value2,
9236
+ string: (value2) => String(value2),
9237
+ "string[]": (value2) => Array.isArray(value2) ? value2.map(String) : [
9238
+ String(value2)
9239
+ ]
9240
+ };
9120
9241
  var coerceValue = (value2, type) => {
9121
- if (value2 === void 0) {
9122
- return void 0;
9123
- }
9124
- switch (type) {
9125
- case "boolean":
9126
- return Boolean(value2);
9127
- case "number":
9128
- return typeof value2 === "string" ? Number(value2) : value2;
9129
- case "string":
9130
- return String(value2);
9131
- case "string[]":
9132
- if (Array.isArray(value2)) {
9133
- return value2.map(String);
9134
- }
9135
- return value2 !== void 0 ? [
9136
- String(value2)
9137
- ] : [];
9138
- default:
9139
- return value2;
9140
- }
9242
+ if (value2 === void 0) return void 0;
9243
+ return coercers[type]?.(value2) ?? value2;
9141
9244
  };
9142
9245
  var extractFlags = (parsed, flags) => {
9143
9246
  const result = {};
@@ -9161,75 +9264,80 @@ var validateRequiredFlags = (flags, definitions) => {
9161
9264
  };
9162
9265
 
9163
9266
  // pkg/@eser/shell/args/help.ts
9164
- var padRight = (str2, len) => {
9165
- return str2 + " ".repeat(Math.max(0, len - str2.length));
9166
- };
9267
+ var padRight = (str2, len) => str2 + " ".repeat(Math.max(0, len - str2.length));
9167
9268
  var formatFlag = (flag) => {
9168
- let name = `--${flag.name}`;
9169
- if (flag.short !== void 0) {
9170
- name = `-${flag.short}, ${name}`;
9171
- }
9172
- if (flag.type !== "boolean") {
9173
- name += ` <${flag.type}>`;
9269
+ const short = flag.short !== void 0 ? `-${flag.short}, ` : "";
9270
+ const typeSuffix = flag.type !== "boolean" ? ` <${flag.type}>` : "";
9271
+ return `${short}--${flag.name}${typeSuffix}`;
9272
+ };
9273
+ var generateTitle = (meta, fullName) => {
9274
+ const title = meta.description !== void 0 ? `${fullName} - ${meta.description}` : fullName;
9275
+ return [
9276
+ title,
9277
+ ""
9278
+ ];
9279
+ };
9280
+ var generateUsage = (meta, fullName) => {
9281
+ if (meta.usage !== void 0) {
9282
+ return [
9283
+ "Usage:",
9284
+ ` ${meta.usage}`,
9285
+ ""
9286
+ ];
9174
9287
  }
9175
- return name;
9288
+ const commands2 = meta.children.length > 0 ? " <command>" : "";
9289
+ const options = meta.flags.length > 0 ? " [options]" : "";
9290
+ return [
9291
+ "Usage:",
9292
+ ` ${fullName}${commands2}${options}`,
9293
+ ""
9294
+ ];
9295
+ };
9296
+ var generateCommands = (children) => {
9297
+ if (children.length === 0) return [];
9298
+ const maxLen = Math.max(...children.map((c) => c.name.length));
9299
+ const lines = children.map((c) => ` ${padRight(c.name, maxLen + 2)}${c.description ?? ""}`);
9300
+ return [
9301
+ "Commands:",
9302
+ ...lines,
9303
+ ""
9304
+ ];
9305
+ };
9306
+ var generateOptions = (flags) => {
9307
+ if (flags.length === 0) return [];
9308
+ const formatted = flags.map((f) => ({
9309
+ flag: formatFlag(f),
9310
+ desc: f.description
9311
+ }));
9312
+ const maxLen = Math.max(...formatted.map((f) => f.flag.length));
9313
+ const lines = formatted.map(({ flag, desc }) => ` ${padRight(flag, maxLen + 2)}${desc}`);
9314
+ return [
9315
+ "Options:",
9316
+ ...lines,
9317
+ ""
9318
+ ];
9319
+ };
9320
+ var generateExamples = (examples) => {
9321
+ if (!examples?.length) return [];
9322
+ return [
9323
+ "Examples:",
9324
+ ...examples.map((e) => ` ${e}`),
9325
+ ""
9326
+ ];
9176
9327
  };
9177
9328
  var generateHelp = (meta, commandPath) => {
9178
- const lines = [];
9179
9329
  const fullName = commandPath.join(" ");
9180
- if (meta.description !== void 0) {
9181
- lines.push(`${fullName} - ${meta.description}`);
9182
- } else {
9183
- lines.push(fullName);
9184
- }
9185
- lines.push("");
9186
- if (meta.usage !== void 0) {
9187
- lines.push("Usage:");
9188
- lines.push(` ${meta.usage}`);
9189
- } else {
9190
- let usage = fullName;
9191
- if (meta.children.length > 0) {
9192
- usage += " <command>";
9193
- }
9194
- if (meta.flags.length > 0) {
9195
- usage += " [options]";
9196
- }
9197
- lines.push("Usage:");
9198
- lines.push(` ${usage}`);
9199
- }
9200
- lines.push("");
9201
- if (meta.children.length > 0) {
9202
- lines.push("Commands:");
9203
- const maxLen = Math.max(...meta.children.map((c) => c.name.length));
9204
- for (const child of meta.children) {
9205
- const desc = child.description ?? "";
9206
- lines.push(` ${padRight(child.name, maxLen + 2)}${desc}`);
9207
- }
9208
- lines.push("");
9209
- }
9210
- if (meta.flags.length > 0) {
9211
- lines.push("Options:");
9212
- const formatted = meta.flags.map((f) => ({
9213
- flag: formatFlag(f),
9214
- desc: f.description
9215
- }));
9216
- const maxLen = Math.max(...formatted.map((f) => f.flag.length));
9217
- for (const { flag, desc } of formatted) {
9218
- lines.push(` ${padRight(flag, maxLen + 2)}${desc}`);
9219
- }
9220
- lines.push("");
9221
- }
9222
- if (meta.examples !== void 0 && meta.examples.length > 0) {
9223
- lines.push("Examples:");
9224
- for (const example of meta.examples) {
9225
- lines.push(` ${example}`);
9226
- }
9227
- lines.push("");
9228
- }
9330
+ const sections = [
9331
+ ...generateTitle(meta, fullName),
9332
+ ...generateUsage(meta, fullName),
9333
+ ...generateCommands(meta.children),
9334
+ ...generateOptions(meta.flags),
9335
+ ...generateExamples(meta.examples)
9336
+ ];
9229
9337
  if (meta.children.length > 0) {
9230
- lines.push(`Run '${fullName} <command> --help' for more information on a command.`);
9338
+ sections.push(`Run '${fullName} <command> --help' for more information on a command.`);
9231
9339
  }
9232
- return lines.join("\n");
9340
+ return sections.join("\n");
9233
9341
  };
9234
9342
 
9235
9343
  // pkg/@eser/shell/completions/generators/bash.ts
@@ -9835,7 +9943,7 @@ var CONFIG_FILENAMES = [
9835
9943
  ];
9836
9944
  var loadProjectConfig = async (dir) => {
9837
9945
  for (const filename of CONFIG_FILENAMES) {
9838
- const filepath = join4(dir, filename);
9946
+ const filepath = join3(dir, filename);
9839
9947
  try {
9840
9948
  const content = await runtime.fs.readTextFile(filepath);
9841
9949
  const config = parse7(content);
@@ -10887,12 +10995,12 @@ var UntarStream = class {
10887
10995
  init_mod();
10888
10996
  var extractTarball = async (stream, targetDir, options = {}) => {
10889
10997
  const { stripComponents = 0, subpath } = options;
10890
- const normalizedSubpath = subpath !== void 0 ? normalize4(subpath).replace(/^\/+/, "") : void 0;
10998
+ const normalizedSubpath = subpath !== void 0 ? normalize3(subpath).replace(/^\/+/, "") : void 0;
10891
10999
  const decompressed = stream.pipeThrough(new DecompressionStream("gzip"));
10892
11000
  const untarStream = decompressed.pipeThrough(new UntarStream());
10893
11001
  for await (const entry of untarStream) {
10894
- const entryPath = normalize4(entry.path);
10895
- if (entryPath.startsWith("..") || isAbsolute4(entryPath)) {
11002
+ const entryPath = normalize3(entry.path);
11003
+ if (entryPath.startsWith("..") || isAbsolute3(entryPath)) {
10896
11004
  if (entry.readable !== void 0) {
10897
11005
  await entry.readable.cancel();
10898
11006
  }
@@ -10922,8 +11030,8 @@ var extractTarball = async (stream, targetDir, options = {}) => {
10922
11030
  continue;
10923
11031
  }
10924
11032
  }
10925
- const outputPath = normalizedSubpath !== void 0 ? join4(targetDir, strippedPath.slice(normalizedSubpath.length).replace(/^\/+/, "")) : join4(targetDir, strippedPath);
10926
- await ensureDir(dirname4(outputPath));
11033
+ const outputPath = normalizedSubpath !== void 0 ? join3(targetDir, strippedPath.slice(normalizedSubpath.length).replace(/^\/+/, "")) : join3(targetDir, strippedPath);
11034
+ await ensureDir(dirname3(outputPath));
10927
11035
  if (entry.readable !== void 0) {
10928
11036
  const file = await Deno.create(outputPath);
10929
11037
  await entry.readable.pipeTo(file.writable);
@@ -11046,7 +11154,7 @@ var CONFIG_FILENAMES2 = [
11046
11154
  ];
11047
11155
  var loadTemplateConfig = async (dir) => {
11048
11156
  for (const filename of CONFIG_FILENAMES2) {
11049
- const filepath = join4(dir, filename);
11157
+ const filepath = join3(dir, filename);
11050
11158
  try {
11051
11159
  const content = await runtime.fs.readTextFile(filepath);
11052
11160
  const config = parse7(content);
@@ -11128,7 +11236,7 @@ ${errors.join("\n")}`);
11128
11236
  };
11129
11237
  var getConfigFilePath = async (dir) => {
11130
11238
  for (const filename of CONFIG_FILENAMES2) {
11131
- const filepath = join4(dir, filename);
11239
+ const filepath = join3(dir, filename);
11132
11240
  try {
11133
11241
  await runtime.fs.stat(filepath);
11134
11242
  return filepath;
@@ -11181,7 +11289,7 @@ var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
11181
11289
  ".webm"
11182
11290
  ]);
11183
11291
  var isBinaryFile = (filepath) => {
11184
- const ext = extname4(filepath).toLowerCase();
11292
+ const ext = extname3(filepath).toLowerCase();
11185
11293
  return BINARY_EXTENSIONS.has(ext);
11186
11294
  };
11187
11295
  var shouldIgnore = (relativePath, ignorePatterns) => {
@@ -11224,7 +11332,7 @@ var processTemplate = async (dir, options) => {
11224
11332
  for await (const entry of walk(dir, {
11225
11333
  includeDirs: true
11226
11334
  })) {
11227
- const relativePath = relative4(dir, entry.path);
11335
+ const relativePath = relative3(dir, entry.path);
11228
11336
  if (relativePath === "") {
11229
11337
  continue;
11230
11338
  }
@@ -11240,8 +11348,8 @@ var processTemplate = async (dir, options) => {
11240
11348
  }
11241
11349
  }
11242
11350
  for (const filepath of filesToProcess) {
11243
- const filename = basename4(filepath);
11244
- const dirPath = dirname4(filepath);
11351
+ const filename = basename3(filepath);
11352
+ const dirPath = dirname3(filepath);
11245
11353
  if (!isBinaryFile(filepath)) {
11246
11354
  try {
11247
11355
  const content = await runtime.fs.readTextFile(filepath);
@@ -11257,7 +11365,7 @@ var processTemplate = async (dir, options) => {
11257
11365
  }
11258
11366
  if (hasVariables(filename)) {
11259
11367
  const newFilename = substituteVariables(filename, variables);
11260
- const newPath = join4(dirPath, newFilename);
11368
+ const newPath = join3(dirPath, newFilename);
11261
11369
  if (newPath !== filepath) {
11262
11370
  await Deno.rename(filepath, newPath);
11263
11371
  }
@@ -11265,10 +11373,10 @@ var processTemplate = async (dir, options) => {
11265
11373
  }
11266
11374
  dirsToRename.sort((a, b) => b.split(SEPARATOR).length - a.split(SEPARATOR).length);
11267
11375
  for (const dirPath of dirsToRename) {
11268
- const dirname7 = basename4(dirPath);
11269
- const parentDir = dirname4(dirPath);
11376
+ const dirname7 = basename3(dirPath);
11377
+ const parentDir = dirname3(dirPath);
11270
11378
  const newDirname = substituteVariables(dirname7, variables);
11271
- const newPath = join4(parentDir, newDirname);
11379
+ const newPath = join3(parentDir, newDirname);
11272
11380
  if (newPath !== dirPath) {
11273
11381
  await Deno.rename(dirPath, newPath);
11274
11382
  }
@@ -11287,7 +11395,7 @@ var removeConfigFile = async (filepath) => {
11287
11395
  // pkg/@eser/codebase/scaffolding/scaffold.ts
11288
11396
  var scaffold = async (options) => {
11289
11397
  const { specifier, targetDir, variables: providedVariables = {}, force = false, skipPostInstall = false, interactive = false } = options;
11290
- const absoluteTargetDir = isAbsolute4(targetDir) ? targetDir : join4(runtime.process.cwd(), targetDir);
11398
+ const absoluteTargetDir = isAbsolute3(targetDir) ? targetDir : join3(runtime.process.cwd(), targetDir);
11291
11399
  try {
11292
11400
  const entries = [];
11293
11401
  for await (const entry of Deno.readDir(absoluteTargetDir)) {
@@ -11695,22 +11803,22 @@ var getRcFilePath = (shell) => {
11695
11803
  const home = getHomeDir();
11696
11804
  switch (shell) {
11697
11805
  case "zsh":
11698
- return join4(home, ".zshrc");
11806
+ return join3(home, ".zshrc");
11699
11807
  case "bash":
11700
- return join4(home, ".bashrc");
11808
+ return join3(home, ".bashrc");
11701
11809
  case "fish":
11702
- return join4(home, ".config", "fish", "config.fish");
11810
+ return join3(home, ".config", "fish", "config.fish");
11703
11811
  }
11704
11812
  };
11705
11813
  var getCompletionsFilePath = (shell, appName) => {
11706
11814
  const home = getHomeDir();
11707
11815
  switch (shell) {
11708
11816
  case "zsh":
11709
- return join4(home, ".zshrc");
11817
+ return join3(home, ".zshrc");
11710
11818
  case "bash":
11711
- return join4(home, ".bashrc");
11819
+ return join3(home, ".bashrc");
11712
11820
  case "fish":
11713
- return join4(home, ".config", "fish", "completions", `${appName}.fish`);
11821
+ return join3(home, ".config", "fish", "completions", `${appName}.fish`);
11714
11822
  }
11715
11823
  };
11716
11824
  var getCompletionEvalLine = (shell, appName) => {
@@ -11768,7 +11876,7 @@ var addCompletions = async (shell) => {
11768
11876
  try {
11769
11877
  if (config.completionType === "file") {
11770
11878
  const fishPath = config.completionsFile;
11771
- const dir = dirname4(fishPath);
11879
+ const dir = dirname3(fishPath);
11772
11880
  try {
11773
11881
  await runtime2.fs.mkdir(dir, {
11774
11882
  recursive: true
@@ -12080,7 +12188,7 @@ var systemCommand = new Command("system").description("Commands related with thi
12080
12188
  // pkg/@eser/cli/package.json
12081
12189
  var package_default = {
12082
12190
  name: "@eser/cli",
12083
- version: "4.0.6",
12191
+ version: "4.0.8",
12084
12192
  type: "module",
12085
12193
  exports: "./main.ts",
12086
12194
  bin: {