@marko/run 0.7.1 → 0.7.3

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.
@@ -1,18 +1,362 @@
1
1
  // src/adapter/index.ts
2
- import fs2 from "fs";
2
+ import fs5 from "fs";
3
3
  import inspector from "inspector";
4
- import path2 from "path";
4
+ import path8 from "path";
5
+ import { fileURLToPath as fileURLToPath2 } from "url";
6
+
7
+ // src/vite/plugin.ts
8
+ import markoVitePlugin from "@marko/vite";
9
+ import browserslist from "browserslist";
10
+ import createDebug from "debug";
11
+ import { resolveToEsbuildTarget } from "esbuild-plugin-browserslist";
12
+ import fs3 from "fs";
13
+ import { glob } from "glob";
14
+ import path6 from "path";
5
15
  import { fileURLToPath } from "url";
16
+ import {
17
+ buildErrorMessage,
18
+ mergeConfig
19
+ } from "vite";
20
+
21
+ // src/adapter/utils.ts
22
+ import kleur from "kleur";
23
+ import supporsColor from "supports-color";
24
+ function stripAnsi(string) {
25
+ return string.replace(
26
+ /([\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><])/g,
27
+ ""
28
+ );
29
+ }
30
+ function cleanStack(stack) {
31
+ return stack.split(/\n/).filter((l) => /^\s*at/.test(l)).join("\n");
32
+ }
33
+ function prepareError(err) {
34
+ var _a;
35
+ return {
36
+ message: stripAnsi(err.message),
37
+ stack: stripAnsi(cleanStack(err.stack || "")),
38
+ id: err.id,
39
+ frame: stripAnsi(err.frame || ""),
40
+ plugin: err.plugin,
41
+ pluginCode: (_a = err.pluginCode) == null ? void 0 : _a.toString(),
42
+ loc: err.loc
43
+ };
44
+ }
45
+ function logInfoBox(address, explorer) {
46
+ const color = !!supporsColor.stdout;
47
+ let message = kleur.bold("Marko Run");
48
+ if (true) {
49
+ message += ` v${"0.7.3"}`;
50
+ }
51
+ message += "\n\n";
52
+ message += kleur.dim("Server listening at");
53
+ message += "\n";
54
+ message += kleur.cyan(kleur.underline(address));
55
+ if (explorer) {
56
+ message += "\n\n";
57
+ message += kleur.dim("Explore your routes");
58
+ message += "\n";
59
+ message += kleur.dim(kleur.green(kleur.underline(explorer)));
60
+ }
61
+ const lines = drawMarkoBox(message, { color, fill: color });
62
+ console.log(lines.join("\n") + "\n");
63
+ }
64
+ function drawMarkoBox(message, options) {
65
+ const textPaddingWidth = 3;
66
+ const logoPaddingWidth = 2;
67
+ const textPadding = " ".repeat(textPaddingWidth);
68
+ const logoPadding = " ".repeat(logoPaddingWidth);
69
+ const logo = drawMarkoLogo(options);
70
+ const textLines = message.split(/\n/);
71
+ const textWidths = textLines.map(
72
+ (line) => line.replace(/\x1b\[\d+m/g, "").length
73
+ );
74
+ const textWidth = Math.max(...textWidths);
75
+ const height = Math.max(textLines.length + 2, logo.lines.length);
76
+ const width = textPaddingWidth * 2 + logoPaddingWidth + textWidth + logo.width;
77
+ const hBorder = "\u2500".repeat(width);
78
+ const vBorder = "\u2502";
79
+ const lineDiff = logo.lines.length - textLines.length;
80
+ const textStartLine = lineDiff > 0 ? Math.max(Math.floor(lineDiff / 2), 1) : 1;
81
+ const textEndLine = height - (lineDiff > 0 ? Math.ceil(lineDiff / 2) : 1);
82
+ const logoEndLine = logo.lines.length;
83
+ const logoFill = " ".repeat(logo.width);
84
+ const textFill = " ".repeat(textWidth);
85
+ const lines = [`\u256D${hBorder}\u256E`];
86
+ for (let i = 0; i < height; i++) {
87
+ let line = vBorder;
88
+ line += logoPadding;
89
+ if (i < logoEndLine) {
90
+ line += logo.lines[i];
91
+ } else {
92
+ line += logoFill;
93
+ }
94
+ line += textPadding;
95
+ if (i >= textStartLine && i < textEndLine) {
96
+ const index = i - textStartLine;
97
+ line += textLines[index];
98
+ line += " ".repeat(textWidth - textWidths[index]);
99
+ } else {
100
+ line += textFill;
101
+ }
102
+ line += textPadding;
103
+ line += vBorder;
104
+ lines.push(line);
105
+ }
106
+ lines.push(`\u2570${hBorder}\u256F`);
107
+ return lines;
108
+ }
109
+ function drawMarkoLogo(options = {}) {
110
+ const { fill = true, color = true } = options;
111
+ const source = `
112
+ TT____ YY____ R____
113
+ C\u2571T\u2572 \u2572G\u2571Y\u2572 \u2572 R\u2572 \u2572
114
+ C\u2571 T\u2572 G\u2571 Y\u2572 \u2572 R\u2572 \u2572
115
+ C\u2571 \u2571T\u2572G\u2571 \u2571Y\u2572 \u2572 R\u2572 \u2572
116
+ B\u2572 \u2572 GG\u203E\u203E\u203E\u203E O\u2571 \u2571 P\u2571 \u2571
117
+ B\u2572 \u2572 OOO\u2571 \u2571 P\u2571 \u2571
118
+ B\u2572 \u2572 OOO\u2571 \u2571 P\u2571 \u2571
119
+ B\u203E\u203E\u203E\u203E OOO\u203E\u203E\u203E\u203E P\u203E\u203E\u203E\u203E
120
+ `;
121
+ const resetEscape = "\x1B[0m";
122
+ const colorEscapeCodes = Object.entries({
123
+ B: "#06cfe5",
124
+ C: "#05a5f0",
125
+ T: "#19d89c",
126
+ G: "#81dc09",
127
+ Y: "#ffd900",
128
+ O: "#ff9500",
129
+ R: "#f3154d",
130
+ P: "#ce176c"
131
+ }).reduce(
132
+ (acc, [key, hex]) => {
133
+ const r = parseInt(hex.slice(1, 3), 16);
134
+ const g = parseInt(hex.slice(3, 5), 16);
135
+ const b = parseInt(hex.slice(5, 7), 16);
136
+ acc[key] = `\x1B[38;2;${r};${g};${b}m`;
137
+ return acc;
138
+ },
139
+ {}
140
+ );
141
+ const lines = [];
142
+ const lineWidths = [];
143
+ let line = "";
144
+ let lineWidth = 0;
145
+ let width = 0;
146
+ for (let i = 0; i < source.length; i++) {
147
+ let char = source[i];
148
+ if (char === "\n") {
149
+ if (line) {
150
+ if (color) {
151
+ line += resetEscape;
152
+ }
153
+ width = Math.max(lineWidth, width);
154
+ lines.push(line);
155
+ lineWidths.push(lineWidth);
156
+ line = "";
157
+ lineWidth = 0;
158
+ }
159
+ } else if (/[A-Z]/.test(char)) {
160
+ while (source[i + 1] === char) i++;
161
+ if (color) {
162
+ line += colorEscapeCodes[char];
163
+ }
164
+ if (fill) {
165
+ let fillChar = "";
166
+ for (; i < source.length; i++) {
167
+ char = source[i + 1];
168
+ if (fillChar && char !== " ") {
169
+ break;
170
+ } else if (!fillChar) {
171
+ fillChar = char;
172
+ }
173
+ line += fillChar;
174
+ lineWidth++;
175
+ }
176
+ }
177
+ } else {
178
+ line += char;
179
+ lineWidth++;
180
+ }
181
+ }
182
+ for (let i = 0; i < lines.length; i++) {
183
+ const padding = width - lineWidths[i];
184
+ if (padding > 0) {
185
+ lines[i] += " ".repeat(width - lineWidths[i]);
186
+ }
187
+ }
188
+ return { lines, width };
189
+ }
190
+
191
+ // src/vite/codegen/index.ts
192
+ import path2 from "path";
193
+
194
+ // src/vite/constants.ts
195
+ var markoRunFilePrefix = "__marko-run__";
196
+ var virtualFilePrefix = "virtual:marko-run";
197
+ var httpVerbs = [
198
+ "get",
199
+ "head",
200
+ "post",
201
+ "put",
202
+ "delete",
203
+ "patch",
204
+ "options"
205
+ ];
206
+ var RoutableFileTypes = {
207
+ Page: "page",
208
+ Layout: "layout",
209
+ Handler: "handler",
210
+ Middleware: "middleware",
211
+ Meta: "meta",
212
+ NotFound: "404",
213
+ Error: "500"
214
+ };
215
+
216
+ // src/vite/utils/fs.ts
217
+ import path from "path";
218
+ var POSIX_SEP = "/";
219
+ var WINDOWS_SEP = "\\";
220
+ var normalizePath = path.sep === WINDOWS_SEP ? (id) => id.replace(/\\/g, POSIX_SEP) : (id) => id;
221
+
222
+ // src/vite/utils/route.ts
223
+ var httpVerbOrder = httpVerbs.reduce(
224
+ (order, verb, index) => {
225
+ order[verb] = index;
226
+ return order;
227
+ },
228
+ {}
229
+ );
230
+
231
+ // src/vite/routes/builder.ts
232
+ import path3 from "path";
233
+ var markoFiles = `(${RoutableFileTypes.Layout}|${RoutableFileTypes.Page}|${RoutableFileTypes.NotFound}|${RoutableFileTypes.Error})\\.(?:.*\\.)?(marko)`;
234
+ var nonMarkoFiles = `(${RoutableFileTypes.Middleware}|${RoutableFileTypes.Handler}|${RoutableFileTypes.Meta})\\.(?:.*\\.)?(.+)`;
235
+ var routeableFileRegex = new RegExp(
236
+ `[+](?:${markoFiles}|${nonMarkoFiles})$`,
237
+ "i"
238
+ );
239
+
240
+ // src/vite/routes/walk.ts
241
+ import fs from "fs";
242
+ import path4 from "path";
243
+
244
+ // src/vite/utils/ast.ts
245
+ import * as t from "@babel/types";
246
+
247
+ // src/vite/utils/config.ts
248
+ var PluginConfigKey = "__MARKO_RUN_PLUGIN_CONFIG__";
249
+ function getConfig(obj, key) {
250
+ return obj[key];
251
+ }
252
+ var getExternalPluginOptions = (viteConfig) => getConfig(viteConfig, PluginConfigKey);
253
+
254
+ // src/vite/utils/log.ts
255
+ import zlib from "node:zlib";
256
+ import { Blob } from "buffer";
257
+ import Table from "cli-table3";
258
+ import format from "human-format";
259
+ import kleur2 from "kleur";
260
+ var HttpVerbColors = {
261
+ get: kleur2.green,
262
+ head: kleur2.dim().green,
263
+ post: kleur2.magenta,
264
+ put: kleur2.cyan,
265
+ delete: kleur2.red,
266
+ patch: kleur2.yellow,
267
+ options: kleur2.grey
268
+ };
269
+
270
+ // src/vite/utils/read-once-persisted-store.ts
271
+ import { promises as fs2 } from "fs";
272
+ import os from "os";
273
+ import path5 from "path";
274
+ var noop = () => {
275
+ };
276
+ var tmpFile = path5.join(os.tmpdir(), "marko-run-storage.json");
277
+ var values = /* @__PURE__ */ new Map();
278
+ process.once("beforeExit", (code) => {
279
+ if (code === 0 && values.size) {
280
+ fs2.writeFile(tmpFile, JSON.stringify([...values])).catch(noop);
281
+ }
282
+ });
283
+
284
+ // src/vite/plugin.ts
285
+ var debug = createDebug("@marko/run");
286
+ var __dirname = path6.dirname(fileURLToPath(import.meta.url));
287
+ var PLUGIN_NAME_PREFIX = "marko-run-vite";
288
+ var MIDDLEWARE_FILENAME = `${markoRunFilePrefix}middleware.js`;
289
+ var ROUTER_FILENAME = `${markoRunFilePrefix}router.js`;
290
+ var defaultPort = Number(process.env.PORT || 3e3);
291
+ async function getPackageData(dir) {
292
+ do {
293
+ const pkgPath = path6.join(dir, "package.json");
294
+ if (fs3.existsSync(pkgPath)) {
295
+ return JSON.parse(await fs3.promises.readFile(pkgPath, "utf-8"));
296
+ }
297
+ } while (dir !== (dir = path6.dirname(dir)));
298
+ return null;
299
+ }
300
+ async function resolveAdapter(root, options, log) {
301
+ if (options && options.adapter !== void 0) {
302
+ return options.adapter;
303
+ }
304
+ const pkg = await getPackageData(root);
305
+ if (pkg) {
306
+ let dependecies = pkg.dependencies ? Object.keys(pkg.dependencies) : [];
307
+ if (pkg.devDependencies) {
308
+ dependecies = dependecies.concat(Object.keys(pkg.devDependencies));
309
+ }
310
+ for (const name of dependecies) {
311
+ if (name.startsWith("@marko/run-adapter") || name.indexOf("marko-run-adapter") !== -1) {
312
+ try {
313
+ const module2 = await import(
314
+ /* @vite-ignore */
315
+ name
316
+ );
317
+ log && debug(
318
+ `Using adapter ${name} listed in your package.json dependecies`
319
+ );
320
+ return module2.default();
321
+ } catch (err) {
322
+ log && debug(`Attempt to use package '${name}' failed %O`, err);
323
+ }
324
+ }
325
+ }
326
+ }
327
+ const defaultAdapter = "@marko/run/adapter";
328
+ const module = await import(
329
+ /* @vite-ignore */
330
+ defaultAdapter
331
+ );
332
+ log && debug("Using default adapter");
333
+ return module.default();
334
+ }
335
+ var defaultConfigPlugin = {
336
+ name: `${PLUGIN_NAME_PREFIX}:defaults`,
337
+ enforce: "pre",
338
+ config(config2) {
339
+ var _a, _b;
340
+ return {
341
+ server: {
342
+ port: ((_a = config2.server) == null ? void 0 : _a.port) ?? defaultPort
343
+ },
344
+ preview: {
345
+ port: ((_b = config2.preview) == null ? void 0 : _b.port) ?? defaultPort
346
+ }
347
+ };
348
+ }
349
+ };
6
350
 
7
351
  // src/vite/utils/server.ts
8
352
  import cp from "child_process";
9
353
  import cluster from "cluster";
10
354
  import { config, parse } from "dotenv";
11
- import fs from "fs";
355
+ import fs4 from "fs";
12
356
  import net from "net";
13
357
  async function parseEnv(envFile) {
14
- if (fs.existsSync(envFile)) {
15
- const content = await fs.promises.readFile(envFile, "utf8");
358
+ if (fs4.existsSync(envFile)) {
359
+ const content = await fs4.promises.readFile(envFile, "utf8");
16
360
  return parse(content);
17
361
  }
18
362
  }
@@ -168,17 +512,17 @@ function getInspectOptions(args) {
168
512
  }
169
513
 
170
514
  // src/adapter/dev-server.ts
171
- import path from "path";
515
+ import path7 from "path";
172
516
  import {
173
- buildErrorMessage,
517
+ buildErrorMessage as buildErrorMessage2,
174
518
  createServer
175
519
  } from "vite";
176
520
 
177
521
  // src/adapter/logger.ts
178
522
  import DraftLog from "draftlog";
179
- import format from "human-format";
523
+ import format2 from "human-format";
180
524
  import inpspector from "inspector";
181
- import kleur from "kleur";
525
+ import kleur3 from "kleur";
182
526
  if (!inpspector.url()) {
183
527
  DraftLog.into(console);
184
528
  DraftLog.defaults.canReWrite = false;
@@ -199,16 +543,16 @@ var HttpStatusColors = [
199
543
  ];
200
544
  var IdChars = [
201
545
  "",
202
- kleur.cyan("\xB9"),
203
- kleur.magenta("\xB2"),
204
- kleur.green("\xB3"),
205
- kleur.red("\u2074"),
206
- kleur.cyan("\u2075"),
207
- kleur.magenta("\u2076"),
208
- kleur.green("\u2077"),
209
- kleur.red("\u2078"),
210
- kleur.cyan("\u2079"),
211
- kleur.red("\u207A")
546
+ kleur3.cyan("\xB9"),
547
+ kleur3.magenta("\xB2"),
548
+ kleur3.green("\xB3"),
549
+ kleur3.red("\u2074"),
550
+ kleur3.cyan("\u2075"),
551
+ kleur3.magenta("\u2076"),
552
+ kleur3.green("\u2077"),
553
+ kleur3.red("\u2078"),
554
+ kleur3.cyan("\u2079"),
555
+ kleur3.red("\u207A")
212
556
  ];
213
557
  var ArrowSteps = [" ", " \u25C0", " \u25C0\u2501", "\u25C0\u2501\u2501", "\u2501\u2501 ", "\u2501 ", " "];
214
558
  function logger_default(_options = {}) {
@@ -276,13 +620,13 @@ function logger_default(_options = {}) {
276
620
  }
277
621
  var spinners;
278
622
  function logRequest(id, req) {
279
- const info = id + " " + kleur.bold(req.method) + " " + kleur.dim(req.url);
280
- const final = kleur.dim(requestArrow(id)) + info;
623
+ const info = id + " " + kleur3.bold(req.method) + " " + kleur3.dim(req.url);
624
+ const final = kleur3.dim(requestArrow(id)) + info;
281
625
  if (console.draft) {
282
626
  spinners ?? (spinners = createAnimationManager({ steps: ArrowSteps.length }));
283
627
  const update = console.draft();
284
628
  const stop = spinners.add((step) => {
285
- update(kleur.cyan(requestArrow(id, step)) + info);
629
+ update(kleur3.cyan(requestArrow(id, step)) + info);
286
630
  });
287
631
  return () => {
288
632
  stop();
@@ -300,18 +644,18 @@ function logResponse(id, req, res, startTime, contentLength, success) {
300
644
  if (req.method === "HEAD" || [204, 205, 304].includes(status)) {
301
645
  length = "";
302
646
  } else if (!contentLength) {
303
- length = kleur.dim("-");
647
+ length = kleur3.dim("-");
304
648
  } else {
305
649
  length = formatMeasurement(bytes(contentLength));
306
650
  }
307
651
  let arrow = id ? "\u2501" : "\u2501\u2501";
308
652
  if (success) {
309
- arrow = kleur.dim(arrow + "\u25B6");
653
+ arrow = kleur3.dim(arrow + "\u25B6");
310
654
  } else {
311
- arrow = kleur.red(kleur.dim(arrow) + kleur.bold("x"));
655
+ arrow = kleur3.red(kleur3.dim(arrow) + kleur3.bold("x"));
312
656
  }
313
657
  console.log(
314
- arrow + id + " " + kleur.bold(req.method) + " " + kleur.dim(req.url) + " " + kleur[color](status) + " " + formatMeasurement(time(startTime)) + " " + length
658
+ arrow + id + " " + kleur3.bold(req.method) + " " + kleur3.dim(req.url) + " " + kleur3[color](status) + " " + formatMeasurement(time(startTime)) + " " + length
315
659
  );
316
660
  }
317
661
  function requestArrow(id, step = 3) {
@@ -323,11 +667,11 @@ function time(start) {
323
667
  return delta < 5e3 ? [delta, "ms"] : [(delta / 1e3).toFixed(1), "s"];
324
668
  }
325
669
  function bytes(size) {
326
- const { value, prefix } = format.raw(size, { maxDecimals: 2, unit: "b" });
670
+ const { value, prefix } = format2.raw(size, { maxDecimals: 2, unit: "b" });
327
671
  return [value.toFixed(2), (prefix + "b").toLowerCase()];
328
672
  }
329
673
  function formatMeasurement([value, unit]) {
330
- return kleur.dim(value + kleur.yellow(kleur.bold(unit)));
674
+ return kleur3.dim(value + kleur3.yellow(kleur3.bold(unit)));
331
675
  }
332
676
  function createAnimationManager(options = {}) {
333
677
  const { steps = 1e4, ms = 100 } = options;
@@ -500,176 +844,6 @@ var bodyConsumedErrorStream = new ReadableStream({
500
844
  }
501
845
  });
502
846
 
503
- // src/adapter/utils.ts
504
- import kleur2 from "kleur";
505
- import supporsColor from "supports-color";
506
- function stripAnsi(string) {
507
- return string.replace(
508
- /([\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><])/g,
509
- ""
510
- );
511
- }
512
- function cleanStack(stack) {
513
- return stack.split(/\n/).filter((l) => /^\s*at/.test(l)).join("\n");
514
- }
515
- function prepareError(err) {
516
- var _a;
517
- return {
518
- message: stripAnsi(err.message),
519
- stack: stripAnsi(cleanStack(err.stack || "")),
520
- id: err.id,
521
- frame: stripAnsi(err.frame || ""),
522
- plugin: err.plugin,
523
- pluginCode: (_a = err.pluginCode) == null ? void 0 : _a.toString(),
524
- loc: err.loc
525
- };
526
- }
527
- function logInfoBox(address, explorer) {
528
- const color = !!supporsColor.stdout;
529
- let message = kleur2.bold("Marko Run");
530
- if (true) {
531
- message += ` v${"0.7.1"}`;
532
- }
533
- message += "\n\n";
534
- message += kleur2.dim("Server listening at");
535
- message += "\n";
536
- message += kleur2.cyan(kleur2.underline(address));
537
- if (explorer) {
538
- message += "\n\n";
539
- message += kleur2.dim("Explore your routes");
540
- message += "\n";
541
- message += kleur2.dim(kleur2.green(kleur2.underline(explorer)));
542
- }
543
- const lines = drawMarkoBox(message, { color, fill: color });
544
- console.log(lines.join("\n") + "\n");
545
- }
546
- function drawMarkoBox(message, options) {
547
- const textPaddingWidth = 3;
548
- const logoPaddingWidth = 2;
549
- const textPadding = " ".repeat(textPaddingWidth);
550
- const logoPadding = " ".repeat(logoPaddingWidth);
551
- const logo = drawMarkoLogo(options);
552
- const textLines = message.split(/\n/);
553
- const textWidths = textLines.map(
554
- (line) => line.replace(/\x1b\[\d+m/g, "").length
555
- );
556
- const textWidth = Math.max(...textWidths);
557
- const height = Math.max(textLines.length + 2, logo.lines.length);
558
- const width = textPaddingWidth * 2 + logoPaddingWidth + textWidth + logo.width;
559
- const hBorder = "\u2500".repeat(width);
560
- const vBorder = "\u2502";
561
- const lineDiff = logo.lines.length - textLines.length;
562
- const textStartLine = lineDiff > 0 ? Math.max(Math.floor(lineDiff / 2), 1) : 1;
563
- const textEndLine = height - (lineDiff > 0 ? Math.ceil(lineDiff / 2) : 1);
564
- const logoEndLine = logo.lines.length;
565
- const logoFill = " ".repeat(logo.width);
566
- const textFill = " ".repeat(textWidth);
567
- const lines = [`\u256D${hBorder}\u256E`];
568
- for (let i = 0; i < height; i++) {
569
- let line = vBorder;
570
- line += logoPadding;
571
- if (i < logoEndLine) {
572
- line += logo.lines[i];
573
- } else {
574
- line += logoFill;
575
- }
576
- line += textPadding;
577
- if (i >= textStartLine && i < textEndLine) {
578
- const index = i - textStartLine;
579
- line += textLines[index];
580
- line += " ".repeat(textWidth - textWidths[index]);
581
- } else {
582
- line += textFill;
583
- }
584
- line += textPadding;
585
- line += vBorder;
586
- lines.push(line);
587
- }
588
- lines.push(`\u2570${hBorder}\u256F`);
589
- return lines;
590
- }
591
- function drawMarkoLogo(options = {}) {
592
- const { fill = true, color = true } = options;
593
- const source = `
594
- TT____ YY____ R____
595
- C\u2571T\u2572 \u2572G\u2571Y\u2572 \u2572 R\u2572 \u2572
596
- C\u2571 T\u2572 G\u2571 Y\u2572 \u2572 R\u2572 \u2572
597
- C\u2571 \u2571T\u2572G\u2571 \u2571Y\u2572 \u2572 R\u2572 \u2572
598
- B\u2572 \u2572 GG\u203E\u203E\u203E\u203E O\u2571 \u2571 P\u2571 \u2571
599
- B\u2572 \u2572 OOO\u2571 \u2571 P\u2571 \u2571
600
- B\u2572 \u2572 OOO\u2571 \u2571 P\u2571 \u2571
601
- B\u203E\u203E\u203E\u203E OOO\u203E\u203E\u203E\u203E P\u203E\u203E\u203E\u203E
602
- `;
603
- const resetEscape = "\x1B[0m";
604
- const colorEscapeCodes = Object.entries({
605
- B: "#06cfe5",
606
- C: "#05a5f0",
607
- T: "#19d89c",
608
- G: "#81dc09",
609
- Y: "#ffd900",
610
- O: "#ff9500",
611
- R: "#f3154d",
612
- P: "#ce176c"
613
- }).reduce(
614
- (acc, [key, hex]) => {
615
- const r = parseInt(hex.slice(1, 3), 16);
616
- const g = parseInt(hex.slice(3, 5), 16);
617
- const b = parseInt(hex.slice(5, 7), 16);
618
- acc[key] = `\x1B[38;2;${r};${g};${b}m`;
619
- return acc;
620
- },
621
- {}
622
- );
623
- const lines = [];
624
- const lineWidths = [];
625
- let line = "";
626
- let lineWidth = 0;
627
- let width = 0;
628
- for (let i = 0; i < source.length; i++) {
629
- let char = source[i];
630
- if (char === "\n") {
631
- if (line) {
632
- if (color) {
633
- line += resetEscape;
634
- }
635
- width = Math.max(lineWidth, width);
636
- lines.push(line);
637
- lineWidths.push(lineWidth);
638
- line = "";
639
- lineWidth = 0;
640
- }
641
- } else if (/[A-Z]/.test(char)) {
642
- while (source[i + 1] === char) i++;
643
- if (color) {
644
- line += colorEscapeCodes[char];
645
- }
646
- if (fill) {
647
- let fillChar = "";
648
- for (; i < source.length; i++) {
649
- char = source[i + 1];
650
- if (fillChar && char !== " ") {
651
- break;
652
- } else if (!fillChar) {
653
- fillChar = char;
654
- }
655
- line += fillChar;
656
- lineWidth++;
657
- }
658
- }
659
- } else {
660
- line += char;
661
- lineWidth++;
662
- }
663
- }
664
- for (let i = 0; i < lines.length; i++) {
665
- const padding = width - lineWidths[i];
666
- if (padding > 0) {
667
- lines[i] += " ".repeat(width - lineWidths[i]);
668
- }
669
- }
670
- return { lines, width };
671
- }
672
-
673
847
  // src/adapter/dev-server.ts
674
848
  async function createViteDevServer(config2) {
675
849
  const finalConfig = {
@@ -772,7 +946,7 @@ function createErrorMiddleware(devServer) {
772
946
  return function errorMiddleware(error, _req, res, _next) {
773
947
  if (!error.id) {
774
948
  devServer.config.logger.error(
775
- buildErrorMessage(error, [
949
+ buildErrorMessage2(error, [
776
950
  `\x1B[31;1mRequest failed with error: ${error.message}\x1B[0m`
777
951
  ])
778
952
  );
@@ -788,7 +962,7 @@ function createErrorMiddleware(devServer) {
788
962
  <script type="module">
789
963
  const error = ${stripHtml(JSON.stringify(preparedError))}
790
964
  try {
791
- const { ErrorOverlay } = await import(${JSON.stringify(path.posix.join(devServer.config.base, "/@vite/client"))})
965
+ const { ErrorOverlay } = await import(${JSON.stringify(path7.posix.join(devServer.config.base, "/@vite/client"))})
792
966
  document.body.appendChild(new ErrorOverlay(error))
793
967
  } catch {
794
968
  const p = document.createElement('p')
@@ -812,15 +986,13 @@ function stripHtml(string) {
812
986
 
813
987
  // src/adapter/index.ts
814
988
  import parseNodeArgs from "parse-node-args";
815
-
816
- // src/vite/constants.ts
817
- var markoRunFilePrefix = "__marko-run__";
818
- var virtualFilePrefix = "virtual:marko-run";
819
-
820
- // src/adapter/index.ts
821
- var __dirname = path2.dirname(fileURLToPath(import.meta.url));
822
- var defaultEntry = path2.join(__dirname, "default-entry");
823
- var loadDevWorker = path2.join(__dirname, "load-dev-worker.mjs");
989
+ var __dirname2 = path8.dirname(fileURLToPath2(import.meta.url));
990
+ var defaultEntry = path8.join(__dirname2, "default-entry");
991
+ var loadDevWorker = path8.join(__dirname2, "load-dev-worker.mjs");
992
+ async function resolveAdapter2(config2) {
993
+ const options = getExternalPluginOptions(config2);
994
+ return resolveAdapter(config2.root, options);
995
+ }
824
996
  function adapter() {
825
997
  return {
826
998
  name: "base-adapter",
@@ -925,12 +1097,12 @@ function adapter() {
925
1097
  return;
926
1098
  }
927
1099
  const promises = [];
928
- const cacheDir = path2.resolve(__dirname, "../../.cache/explorer");
929
- const codeDir = path2.join(cacheDir, "code");
930
- if (fs2.existsSync(codeDir)) {
931
- await fs2.promises.rm(codeDir, { recursive: true });
1100
+ const cacheDir = path8.resolve(__dirname2, "../../.cache/explorer");
1101
+ const codeDir = path8.join(cacheDir, "code");
1102
+ if (fs5.existsSync(codeDir)) {
1103
+ await fs5.promises.rm(codeDir, { recursive: true });
932
1104
  }
933
- await fs2.promises.mkdir(codeDir, { recursive: true });
1105
+ await fs5.promises.mkdir(codeDir, { recursive: true });
934
1106
  const data = {
935
1107
  meta,
936
1108
  routes: {},
@@ -948,7 +1120,7 @@ function adapter() {
948
1120
  }
949
1121
  if (fileName) {
950
1122
  promises.push(
951
- fs2.promises.writeFile(path2.join(codeDir, fileName), code, {})
1123
+ fs5.promises.writeFile(path8.join(codeDir, fileName), code, {})
952
1124
  );
953
1125
  }
954
1126
  }
@@ -959,8 +1131,8 @@ function adapter() {
959
1131
  data.routes["s" + id] = route;
960
1132
  }
961
1133
  promises.push(
962
- fs2.promises.writeFile(
963
- path2.join(cacheDir, "data.json"),
1134
+ fs5.promises.writeFile(
1135
+ path8.join(cacheDir, "data.json"),
964
1136
  JSON.stringify(data),
965
1137
  {}
966
1138
  )
@@ -981,5 +1153,6 @@ export {
981
1153
  createErrorMiddleware,
982
1154
  createViteDevServer,
983
1155
  adapter as default,
984
- getDevGlobal
1156
+ getDevGlobal,
1157
+ resolveAdapter2 as resolveAdapter
985
1158
  };