@orieljs/framework 0.1.0-alpha.10 → 0.1.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -22,12 +22,13 @@ import {
22
22
  renderToString,
23
23
  styleString,
24
24
  view
25
- } from "./chunk-VOYW3R5J.js";
25
+ } from "./chunk-24673JQF.js";
26
26
  import {
27
27
  API_ROUTES_STUB,
28
28
  Application as Application2,
29
29
  ApplicationBuilder,
30
30
  BusFake,
31
+ ClassNameMap,
31
32
  ClosureKernel,
32
33
  Component,
33
34
  Computed,
@@ -38,6 +39,7 @@ import {
38
39
  ErrorHandler,
39
40
  EventFake,
40
41
  ExceptionsConfiguration,
42
+ ExportError,
41
43
  FileNotPreviewableError,
42
44
  FormUploadedFile,
43
45
  HttpException,
@@ -70,6 +72,7 @@ import {
70
72
  ProviderBootError,
71
73
  ProviderRegisterError,
72
74
  QueueFake,
75
+ RenameClasses,
73
76
  Repository,
74
77
  StorageFake,
75
78
  TEMPORARY_UPLOAD_DEFAULTS,
@@ -106,6 +109,7 @@ import {
106
109
  env,
107
110
  escapeHtml,
108
111
  exceedsJsonDepth,
112
+ exportSite,
109
113
  extensionFromMime,
110
114
  filterRouteList,
111
115
  formatRouteList,
@@ -115,6 +119,7 @@ import {
115
119
  live,
116
120
  mergeRecursive,
117
121
  minimalPage,
122
+ nodeRequestHandler,
118
123
  normalizeLists,
119
124
  optionalCookieJar,
120
125
  optionalSession,
@@ -143,7 +148,7 @@ import {
143
148
  vite,
144
149
  viteReactRefresh,
145
150
  writeResponse
146
- } from "./chunk-OXAATQA6.js";
151
+ } from "./chunk-KDE5BLI3.js";
147
152
  import {
148
153
  Arr,
149
154
  BindingResolutionError,
@@ -170,7 +175,7 @@ import {
170
175
  retry,
171
176
  tap,
172
177
  value
173
- } from "./chunk-7ZQZYDOC.js";
178
+ } from "./chunk-MURTCTRH.js";
174
179
  import {
175
180
  Application,
176
181
  AuthFactory,
@@ -212,7 +217,7 @@ import {
212
217
  ValidationFactory,
213
218
  ViewFactory,
214
219
  token
215
- } from "./chunk-GVNLZZTN.js";
220
+ } from "./chunk-HTJKT2R2.js";
216
221
 
217
222
  // ../Auth/dist/index.js
218
223
  import { createHash } from "crypto";
@@ -3313,7 +3318,7 @@ var NodeConsoleInput = class {
3313
3318
  const line = this.lines.shift();
3314
3319
  if (line !== void 0) return line;
3315
3320
  if (this.ended) throw new Error("Aborted.");
3316
- return new Promise((resolve4, reject) => this.waiting.push({ resolve: resolve4, reject }));
3321
+ return new Promise((resolve5, reject) => this.waiting.push({ resolve: resolve5, reject }));
3317
3322
  }
3318
3323
  close() {
3319
3324
  const rl = this.rl;
@@ -4741,7 +4746,7 @@ var ScheduleRunCommand = class extends Command {
4741
4746
  async handle() {
4742
4747
  const clock = {
4743
4748
  now: this.clock.now ?? Date.now,
4744
- sleep: this.clock.sleep ?? ((ms) => new Promise((resolve4) => setTimeout(resolve4, ms)))
4749
+ sleep: this.clock.sleep ?? ((ms) => new Promise((resolve5) => setTimeout(resolve5, ms)))
4745
4750
  };
4746
4751
  const now5 = new Date(clock.now());
4747
4752
  const due = inject(Schedule).dueEvents(now5);
@@ -4763,7 +4768,7 @@ var ScheduleWorkCommand = class extends Command {
4763
4768
  description = "Start the schedule worker";
4764
4769
  async handle() {
4765
4770
  const schedule = inject(Schedule);
4766
- const sleep5 = this.workOptions.sleep ?? ((ms) => new Promise((resolve4) => setTimeout(resolve4, ms)));
4771
+ const sleep5 = this.workOptions.sleep ?? ((ms) => new Promise((resolve5) => setTimeout(resolve5, ms)));
4767
4772
  const clock = this.workOptions.now ?? Date.now;
4768
4773
  this.info("Running scheduled tasks every minute.");
4769
4774
  let lastMinute;
@@ -4800,13 +4805,13 @@ var TestCommand = class extends Command {
4800
4805
  if (typeof filter === "string") args.push("--testNamePattern", filter);
4801
4806
  const extra = this.argument("args");
4802
4807
  if (Array.isArray(extra)) args.push(...extra);
4803
- return new Promise((resolve4) => {
4808
+ return new Promise((resolve5) => {
4804
4809
  const child = this.spawner("npx", args);
4805
4810
  child.on("error", (error) => {
4806
4811
  this.error(error.message);
4807
- resolve4(1);
4812
+ resolve5(1);
4808
4813
  });
4809
- child.on("exit", (code) => resolve4(code ?? 1));
4814
+ child.on("exit", (code) => resolve5(code ?? 1));
4810
4815
  });
4811
4816
  }
4812
4817
  };
@@ -4821,10 +4826,10 @@ var TinkerCommand = class extends Command {
4821
4826
  handle() {
4822
4827
  const app2 = inject(Application);
4823
4828
  const startRepl = this.tinkerOptions.start ?? ((options) => start2(options));
4824
- return new Promise((resolve4) => {
4829
+ return new Promise((resolve5) => {
4825
4830
  const repl = startRepl({ prompt: "oriel> " });
4826
4831
  repl.context.app = app2;
4827
- repl.on("exit", () => resolve4(0));
4832
+ repl.on("exit", () => resolve5(0));
4828
4833
  });
4829
4834
  }
4830
4835
  };
@@ -13887,19 +13892,19 @@ function uniqueSpecOf(cls, instance, name, data) {
13887
13892
  if (statics[key] !== void 0) return { value: statics[key], on: cls };
13888
13893
  return void 0;
13889
13894
  };
13890
- const resolve4 = (key) => {
13895
+ const resolve5 = (key) => {
13891
13896
  const found = read2(key);
13892
13897
  if (found === void 0) return void 0;
13893
13898
  return typeof found.value === "function" ? found.value.apply(found.on, data) : found.value;
13894
13899
  };
13895
13900
  const declared = typeof read2("uniqueId")?.value === "function" || read2("uniqueFor") !== void 0 || read2("uniqueUntilProcessing")?.value === true || typeof read2("uniqueVia")?.value === "function";
13896
13901
  if (!declared) return void 0;
13897
- const id = typeof read2("uniqueId")?.value === "function" ? resolve4("uniqueId") : void 0;
13902
+ const id = typeof read2("uniqueId")?.value === "function" ? resolve5("uniqueId") : void 0;
13898
13903
  const spec = { name, id: id === void 0 || id === null ? "" : String(id) };
13899
- const uniqueFor = resolve4("uniqueFor");
13904
+ const uniqueFor = resolve5("uniqueFor");
13900
13905
  if (typeof uniqueFor === "number") spec.for = uniqueFor;
13901
13906
  if (read2("uniqueUntilProcessing")?.value === true) spec.untilProcessing = true;
13902
- const via = typeof read2("uniqueVia")?.value === "function" ? resolve4("uniqueVia") : void 0;
13907
+ const via = typeof read2("uniqueVia")?.value === "function" ? resolve5("uniqueVia") : void 0;
13903
13908
  if (typeof via === "string") spec.via = via;
13904
13909
  return spec;
13905
13910
  }
@@ -15833,11 +15838,11 @@ function inertiaBody(page, id = "app") {
15833
15838
  }
15834
15839
  var excluded = /* @__PURE__ */ new WeakSet();
15835
15840
  function withoutSsr(request2, paths) {
15836
- const matches2 = paths.some((pattern) => {
15841
+ const matches3 = paths.some((pattern) => {
15837
15842
  const trimmed = pattern === "/" ? pattern : pattern.replace(/^\/+|\/+$/g, "");
15838
15843
  return Str.is(trimmed, request2.fullUrl()) || request2.is(trimmed);
15839
15844
  });
15840
- if (matches2) excluded.add(request2);
15845
+ if (matches3) excluded.add(request2);
15841
15846
  }
15842
15847
  function isExcludedFromSsr(request2) {
15843
15848
  return excluded.has(request2);
@@ -16216,11 +16221,11 @@ function registerInertiaCommands(kernel, app2, gateway, options = {}) {
16216
16221
  }
16217
16222
  const runtime = optionText(this.option("runtime")) ?? config2("inertia.ssr.runtime", "node");
16218
16223
  const child = (options.spawn ?? spawn2)(runtime, [bundle], { stdio: "inherit", env: { ...process.env, INERTIA_SSR_PORT: port } });
16219
- return await new Promise((resolve4) => {
16220
- child.on("exit", (code) => resolve4(code ?? 0));
16224
+ return await new Promise((resolve5) => {
16225
+ child.on("exit", (code) => resolve5(code ?? 0));
16221
16226
  child.on("error", (error) => {
16222
16227
  this.error(`Could not start the SSR server: ${error.message}`);
16223
- resolve4(1);
16228
+ resolve5(1);
16224
16229
  });
16225
16230
  });
16226
16231
  }).purpose("Start the Inertia SSR server");
@@ -16626,16 +16631,16 @@ var DailyRotatingStream = class extends Writable {
16626
16631
  }
16627
16632
  };
16628
16633
  function destinationCloser(destination) {
16629
- const opened = new Promise((resolve4) => {
16634
+ const opened = new Promise((resolve5) => {
16630
16635
  const onReady = () => {
16631
16636
  destination.off("error", onError);
16632
- resolve4(true);
16637
+ resolve5(true);
16633
16638
  };
16634
16639
  const onError = () => {
16635
16640
  destination.off("ready", onReady);
16636
16641
  destination.flushSync = () => {
16637
16642
  };
16638
- resolve4(false);
16643
+ resolve5(false);
16639
16644
  };
16640
16645
  destination.once("ready", onReady);
16641
16646
  destination.once("error", onError);
@@ -16643,9 +16648,9 @@ function destinationCloser(destination) {
16643
16648
  let closing;
16644
16649
  const close = async () => {
16645
16650
  if (!await opened) return;
16646
- await new Promise((resolve4) => {
16647
- destination.once("close", () => resolve4());
16648
- destination.once("error", () => resolve4());
16651
+ await new Promise((resolve5) => {
16652
+ destination.once("close", () => resolve5());
16653
+ destination.once("error", () => resolve5());
16649
16654
  destination.end();
16650
16655
  });
16651
16656
  };
@@ -16653,10 +16658,10 @@ function destinationCloser(destination) {
16653
16658
  }
16654
16659
  function writableCloser(stream) {
16655
16660
  let closing;
16656
- const close = () => new Promise((resolve4) => {
16657
- if (stream.writableFinished || stream.destroyed) return resolve4();
16658
- stream.once("finish", () => resolve4());
16659
- stream.once("error", () => resolve4());
16661
+ const close = () => new Promise((resolve5) => {
16662
+ if (stream.writableFinished || stream.destroyed) return resolve5();
16663
+ stream.once("finish", () => resolve5());
16664
+ stream.once("error", () => resolve5());
16660
16665
  stream.end();
16661
16666
  });
16662
16667
  return () => closing ??= close();
@@ -19923,7 +19928,7 @@ var Listener = class _Listener {
19923
19928
  runProcess([command, ...args], timeout) {
19924
19929
  const output = this.config.output ?? (() => {
19925
19930
  });
19926
- return new Promise((resolve4, reject) => {
19931
+ return new Promise((resolve5, reject) => {
19927
19932
  const child = (this.config.spawn ?? spawnProcess)(command, args, { cwd: this.config.commandPath, env: process.env, stdio: ["ignore", "pipe", "pipe"] });
19928
19933
  this.child = child;
19929
19934
  const stdout = lineSplitter((line) => output("out", line));
@@ -19945,7 +19950,7 @@ var Listener = class _Listener {
19945
19950
  return true;
19946
19951
  };
19947
19952
  child.once("error", (error) => settle() && reject(error));
19948
- child.once("close", () => settle() && resolve4());
19953
+ child.once("close", () => settle() && resolve5());
19949
19954
  });
19950
19955
  }
19951
19956
  async rest(seconds) {
@@ -20227,6 +20232,7 @@ var QueueServiceProvider = class extends ServiceProvider {
20227
20232
  import { createHmac as createHmac4, timingSafeEqual as timingSafeEqual4 } from "crypto";
20228
20233
  import { pathToFileURL as pathToFileURL7 } from "url";
20229
20234
  import { createHash as createHash10 } from "crypto";
20235
+ import { createHash as createHash23 } from "crypto";
20230
20236
  var NotFoundHttpError = class extends Error {
20231
20237
  kind = "Http";
20232
20238
  status = 404;
@@ -21341,6 +21347,61 @@ var ThrottleRequests = class {
21341
21347
  return sha12(`|${request2.ip() ?? ""}`);
21342
21348
  }
21343
21349
  };
21350
+ var DIRECTIVES = /* @__PURE__ */ new Set([
21351
+ "public",
21352
+ "private",
21353
+ "no_cache",
21354
+ "no_store",
21355
+ "no_transform",
21356
+ "must_revalidate",
21357
+ "proxy_revalidate",
21358
+ "immutable",
21359
+ "max_age",
21360
+ "s_maxage",
21361
+ "stale_while_revalidate",
21362
+ "stale_if_error"
21363
+ ]);
21364
+ var SetCacheHeaders = class {
21365
+ async handle(request2, next, ...parameters) {
21366
+ const response2 = await next(request2);
21367
+ const method = request2.method();
21368
+ if (method !== "GET" && method !== "HEAD") return response2;
21369
+ if (response2.headers.has("set-cookie") || /\bno-store\b/i.test(response2.headers.get("cache-control") ?? "")) return response2;
21370
+ const options = parameters.join(",").split(";").map((option) => option.trim()).filter((option) => option !== "");
21371
+ const headers = new Headers(response2.headers);
21372
+ const directives = [];
21373
+ let etag = false;
21374
+ for (const option of options) {
21375
+ const [name = "", value2] = option.split("=", 2);
21376
+ if (name === "etag") {
21377
+ etag = true;
21378
+ continue;
21379
+ }
21380
+ if (!DIRECTIVES.has(name)) throw new Error(`cache.headers: unknown option "${name}".`);
21381
+ const directive = name.replace(/_/g, "-");
21382
+ directives.push(value2 === void 0 ? directive : `${directive}=${value2}`);
21383
+ }
21384
+ if (directives.length > 0) headers.set("cache-control", directives.join(", "));
21385
+ if (!etag) return new Response(response2.body, { status: response2.status, statusText: response2.statusText, headers });
21386
+ const body = new Uint8Array(await response2.arrayBuffer());
21387
+ const tag = `"${createHash23("md5").update(body).digest("hex")}"`;
21388
+ headers.set("etag", tag);
21389
+ if (matches(request2.header("if-none-match"), tag)) {
21390
+ const notModified = new Headers({ etag: tag });
21391
+ const cacheControl = headers.get("cache-control");
21392
+ if (cacheControl !== null) notModified.set("cache-control", cacheControl);
21393
+ return new Response(null, { status: 304, headers: notModified });
21394
+ }
21395
+ return new Response(body, { status: response2.status, statusText: response2.statusText, headers });
21396
+ }
21397
+ };
21398
+ function matches(header, tag) {
21399
+ if (header === void 0) return false;
21400
+ return header.split(",").some((candidate) => {
21401
+ const value2 = candidate.trim();
21402
+ return value2 === "*" || value2 === tag || value2 === `W/${tag}`;
21403
+ });
21404
+ }
21344
21405
  var ValidateSignature = class {
21345
21406
  async handle(request2, next, ...parameters) {
21346
21407
  const absolute = parameters[0] !== "relative";
@@ -21365,7 +21426,7 @@ var RoutingServiceProvider = class extends ServiceProvider {
21365
21426
  * when the route files run.
21366
21427
  */
21367
21428
  boot() {
21368
- this.app.make(Router).aliasMiddleware("signed", ValidateSignature).aliasMiddleware("throttle", ThrottleRequests);
21429
+ this.app.make(Router).aliasMiddleware("signed", ValidateSignature).aliasMiddleware("throttle", ThrottleRequests).aliasMiddleware("cache.headers", SetCacheHeaders);
21369
21430
  this.app.booted(async () => {
21370
21431
  if (!this.app.bound(RoutingPaths)) return;
21371
21432
  const { web, api, health, apiPrefix } = this.app.make(RoutingPaths);
@@ -22530,7 +22591,7 @@ function alike(a, b, strict = false) {
22530
22591
  return false;
22531
22592
  }
22532
22593
  var listed = (values) => ({ values: values.join(", ") });
22533
- function matches(value2, other, comparison3) {
22594
+ function matches2(value2, other, comparison3) {
22534
22595
  if (comparison3 === "strict") return value2 === other;
22535
22596
  if (comparison3 === "loose") return alike(value2, other);
22536
22597
  return (typeof other === "string" || typeof other === "number") && String(other).toLowerCase() === String(value2).toLowerCase();
@@ -22623,7 +22684,7 @@ var arrayRules = {
22623
22684
  distinct: {
22624
22685
  validate: (ctx) => {
22625
22686
  const comparison3 = ctx.parameters.includes("ignore_case") ? "ignore_case" : ctx.parameters.includes("strict") ? "strict" : "loose";
22626
- const own = Arr.has(ctx.data, ctx.attribute) && matches(ctx.value, Arr.get(ctx.data, ctx.attribute), comparison3) ? 1 : 0;
22687
+ const own = Arr.has(ctx.data, ctx.attribute) && matches2(ctx.value, Arr.get(ctx.data, ctx.attribute), comparison3) ? 1 : 0;
22627
22688
  return PatternValues.of(ctx, ctx.pattern ?? ctx.attribute).count(ctx.value, comparison3) - own === 0;
22628
22689
  },
22629
22690
  messageKey: () => "distinct"
@@ -23026,8 +23087,8 @@ function resolveDateParam(ctx, rule, param, format2) {
23026
23087
  const parsed = readDate(fieldValue, ctx.getRule?.(param, "date_format")?.[0] ?? format2);
23027
23088
  if (!Number.isNaN(parsed)) return parsed;
23028
23089
  }
23029
- const relative8 = relativeDate(param);
23030
- if (relative8 !== void 0) return relative8;
23090
+ const relative9 = relativeDate(param);
23091
+ if (relative9 !== void 0) return relative9;
23031
23092
  const literal = readDate(param, format2);
23032
23093
  if (!Number.isNaN(literal)) return literal;
23033
23094
  if (FIELD_REFERENCE_RE.test(param)) return null;
@@ -24220,7 +24281,8 @@ var Rule = {
24220
24281
  /** Laravel's Password::defaults(): the application's password rule (at least 8 characters unless PasswordRule.defaults() changed it). */
24221
24282
  password: () => PasswordRule.defaults()
24222
24283
  };
24223
- var SKIPPED_MODIFIERS = /* @__PURE__ */ new Set(["bail", "nullable", "sometimes"]);
24284
+ var RULE_FLAGS = ["bail", "nullable", "sometimes"];
24285
+ var SKIPPED_MODIFIERS = new Set(RULE_FLAGS);
24224
24286
  var DEPENDENT_RULES = /* @__PURE__ */ new Set([
24225
24287
  "after",
24226
24288
  "after_or_equal",
@@ -24592,7 +24654,7 @@ var ValidationFactoryImpl = class {
24592
24654
  }
24593
24655
  /** Every rule this factory knows, built-in and extend()ed, sorted (for editors: `oriel ide:info`). */
24594
24656
  ruleNames() {
24595
- return [.../* @__PURE__ */ new Set([...Object.keys(builtinRules), ...Object.keys(this.extended)])].sort();
24657
+ return [.../* @__PURE__ */ new Set([...Object.keys(builtinRules), ...RULE_FLAGS, ...Object.keys(this.extended)])].sort();
24596
24658
  }
24597
24659
  extend(name, callback, message) {
24598
24660
  this.extended[name] = {
@@ -24610,13 +24672,181 @@ var ValidationServiceProvider = class extends ServiceProvider {
24610
24672
  }
24611
24673
  };
24612
24674
 
24675
+ // ../Vercel/dist/index.js
24676
+ import { existsSync as existsSync9, readdirSync as readdirSync8, readFileSync as readFileSync3, realpathSync, statSync as statSync4 } from "fs";
24677
+ import { cp, mkdir as mkdir7, rm as rm4, writeFile as writeFile8 } from "fs/promises";
24678
+ import { basename as basename3, dirname as dirname7, join as join15, relative as relative6, resolve as resolve4 } from "path";
24679
+ var LAUNCHER = `// Oriel on Vercel: boots the app once per function instance and hands it each request.
24680
+ import { fileURLToPath } from 'node:url'
24681
+
24682
+ let ready
24683
+
24684
+ async function boot() {
24685
+ // Vercel's disk is read-only, so a log file can't open; stderr is what Vercel's log view shows.
24686
+ process.env.LOG_CHANNEL ??= 'stderr'
24687
+ if (!process.versions.bun) {
24688
+ const { register } = await import('tsx/esm/api')
24689
+ register({ tsconfig: fileURLToPath(new URL('./tsconfig.json', import.meta.url)) })
24690
+ }
24691
+ const { createApplication } = await import('./bootstrap/app.ts')
24692
+ const { nodeRequestHandler } = await import('@orieljs/framework')
24693
+ const { ConfigRepository } = await import('@orieljs/framework/contracts')
24694
+ const app = await createApplication()
24695
+ await app.boot()
24696
+ // Every request comes through Vercel's proxy, which sets the X-Forwarded-* headers itself: trust it, unless the app
24697
+ // lists its own proxies, so that URLs keep the browser's https and ip() is the visitor's.
24698
+ const config = app.make(ConfigRepository)
24699
+ const proxies = config.get('http.trusted_proxies', [])
24700
+ if (proxies === undefined || proxies === null || proxies.length === 0) config.set('http.trusted_proxies', '*')
24701
+ return nodeRequestHandler(app, { fallbackHost: 'localhost' })
24702
+ }
24703
+
24704
+ export default async function handler(req, res) {
24705
+ let handle
24706
+ try {
24707
+ ready ??= boot()
24708
+ handle = await ready
24709
+ } catch (error) {
24710
+ ready = undefined
24711
+ console.error(error)
24712
+ if (!res.headersSent) {
24713
+ res.statusCode = 500
24714
+ res.setHeader('content-type', 'text/plain; charset=utf-8')
24715
+ }
24716
+ res.end('Internal Server Error')
24717
+ return
24718
+ }
24719
+ await handle(req, res)
24720
+ }
24721
+ `;
24722
+ var VERCEL_FUNCTION_LIMIT = 250 * 1024 * 1024;
24723
+ var APP_FOLDERS = ["app", "bootstrap", "config", "routes", "resources", "lang", "database"];
24724
+ var APP_FILES = ["package.json", "tsconfig.json"];
24725
+ var BUILD_FILES = ["manifest.json"];
24726
+ var VITE_CONFIGS = ["vite.config.ts", "vite.config.mts", "vite.config.js", "vite.config.mjs"];
24727
+ var isEnvFile = (path) => /^\.env(\..*)?$/.test(basename3(path));
24728
+ var isSqliteFile = (path) => /\.(sqlite3?|db)(-wal|-shm|-journal)?$/.test(basename3(path));
24729
+ var PLATFORM_NAMES = { darwin: "macOS", win32: "Windows" };
24730
+ async function buildVercelOutput(app2, options = {}) {
24731
+ const base = app2.basePath();
24732
+ const publicPath = app2.publicPath();
24733
+ if (existsSync9(join15(publicPath, "hot"))) {
24734
+ throw new Error("The Vite dev server is running (public/hot exists): stop `npm run dev` and build the assets with `npm run build` first.");
24735
+ }
24736
+ if (VITE_CONFIGS.some((file) => existsSync9(join15(base, file))) && !existsSync9(join15(publicPath, "build/manifest.json"))) {
24737
+ throw new Error("The assets aren't built (public/build/manifest.json is missing): run `npm run build` first.");
24738
+ }
24739
+ const output = resolve4(base, options.output ?? ".vercel/output");
24740
+ await rm4(output, { recursive: true, force: true });
24741
+ const staticFolder = join15(output, "static");
24742
+ await mkdir7(staticFolder, { recursive: true });
24743
+ if (existsSync9(publicPath)) {
24744
+ await cp(publicPath, staticFolder, { recursive: true, filter: (source) => basename3(source) !== "hot" && !isEnvFile(source) });
24745
+ }
24746
+ const fn = join15(output, "functions/index.func");
24747
+ for (const folder of APP_FOLDERS) {
24748
+ const filter = (source) => !isEnvFile(source) && !(folder === "database" && isSqliteFile(source));
24749
+ if (existsSync9(join15(base, folder))) await cp(join15(base, folder), join15(fn, folder), { recursive: true, filter });
24750
+ }
24751
+ for (const file of APP_FILES) if (existsSync9(join15(base, file))) await cp(join15(base, file), join15(fn, file));
24752
+ for (const file of BUILD_FILES) {
24753
+ const source = join15(publicPath, "build", file);
24754
+ if (existsSync9(source)) await cp(source, join15(fn, relative6(base, publicPath), "build", file));
24755
+ }
24756
+ await copyDependencies(base, fn);
24757
+ await writeFile8(join15(fn, "index.mjs"), LAUNCHER);
24758
+ const vcConfig = { runtime: options.runtime ?? "nodejs22.x", handler: "index.mjs", launcherType: "Nodejs", shouldAddHelpers: false, supportsResponseStreaming: true };
24759
+ await writeFile8(join15(fn, ".vc-config.json"), `${JSON.stringify(vcConfig, null, 2)}
24760
+ `);
24761
+ const config2 = {
24762
+ version: 3,
24763
+ routes: [
24764
+ // The built assets' names change with their content, so they're cached for a year, as serve() does.
24765
+ { src: "^/build/assets/(.*)$", headers: { "cache-control": "public, max-age=31536000, immutable" }, continue: true },
24766
+ { handle: "filesystem" },
24767
+ { src: "/(.*)", dest: "/index" }
24768
+ ]
24769
+ };
24770
+ await writeFile8(join15(output, "config.json"), `${JSON.stringify(config2, null, 2)}
24771
+ `);
24772
+ const functionBytes = sizeOf2(fn);
24773
+ const limit = options.maxFunctionBytes ?? VERCEL_FUNCTION_LIMIT;
24774
+ if (functionBytes > limit) {
24775
+ throw new Error(`The function is ${megabytes(functionBytes)}, larger than Vercel allows (${megabytes(limit)}): move what it doesn't need at run time to devDependencies.`);
24776
+ }
24777
+ const platform = options.platform ?? process.platform;
24778
+ const warnings = platform === "linux" ? [] : [
24779
+ `Built on ${PLATFORM_NAMES[platform] ?? platform}: the function's native packages (such as esbuild, which tsx needs) only run on this kind of machine, and Vercel's functions run on Linux. Let Vercel run the build, or build on Linux.`
24780
+ ];
24781
+ return { functionBytes, staticFiles: countFiles(staticFolder), warnings };
24782
+ }
24783
+ async function copyDependencies(base, fn) {
24784
+ const manifest = JSON.parse(readFileSync3(join15(base, "package.json"), "utf8"));
24785
+ const topLevel = /* @__PURE__ */ new Map();
24786
+ const copied = /* @__PURE__ */ new Set();
24787
+ const visit = async (name, from, into) => {
24788
+ const found = locate(name, from);
24789
+ if (found === void 0) return;
24790
+ const real = realpathSync(found);
24791
+ let destination = join15(fn, "node_modules", name);
24792
+ const top = topLevel.get(name);
24793
+ if (top === void 0) topLevel.set(name, real);
24794
+ else if (top !== real) destination = join15(into, name);
24795
+ if (copied.has(destination)) return;
24796
+ copied.add(destination);
24797
+ await cp(real, destination, {
24798
+ recursive: true,
24799
+ dereference: true,
24800
+ filter: (source) => source === real || !["node_modules", ".bin", ".git"].includes(basename3(source))
24801
+ });
24802
+ const pkg = JSON.parse(readFileSync3(join15(real, "package.json"), "utf8"));
24803
+ for (const dependency of [...Object.keys(pkg.dependencies ?? {}), ...Object.keys(pkg.optionalDependencies ?? {})]) {
24804
+ await visit(dependency, real, join15(destination, "node_modules"));
24805
+ }
24806
+ };
24807
+ for (const name of [...Object.keys(manifest.dependencies ?? {}), "tsx"]) await visit(name, base, join15(fn, "node_modules"));
24808
+ }
24809
+ function locate(name, from) {
24810
+ for (let dir = from; ; dir = dirname7(dir)) {
24811
+ const candidate = basename3(dir) === "node_modules" ? join15(dir, name) : join15(dir, "node_modules", name);
24812
+ if (existsSync9(join15(candidate, "package.json"))) return candidate;
24813
+ if (dirname7(dir) === dir) return void 0;
24814
+ }
24815
+ }
24816
+ function sizeOf2(folder) {
24817
+ return readdirSync8(folder, { withFileTypes: true, recursive: true }).filter((entry) => entry.isFile()).reduce((total, entry) => total + statSync4(join15(entry.parentPath, entry.name)).size, 0);
24818
+ }
24819
+ function countFiles(folder) {
24820
+ return readdirSync8(folder, { withFileTypes: true, recursive: true }).filter((entry) => entry.isFile()).length;
24821
+ }
24822
+ var megabytes = (bytes) => `${(bytes / 1024 / 1024).toFixed(1)} MB`;
24823
+ var megabytes2 = (bytes) => `${(bytes / 1024 / 1024).toFixed(1)} MB`;
24824
+ var VercelServiceProvider = class extends ServiceProvider {
24825
+ boot() {
24826
+ if (!this.app.bound(ConsoleKernel)) return;
24827
+ const app2 = this.app;
24828
+ this.app.make(ConsoleKernel).command("vercel:build", async function() {
24829
+ try {
24830
+ const { staticFiles, functionBytes, warnings } = await buildVercelOutput(app2);
24831
+ const files3 = staticFiles === 1 ? "1 static file" : `${staticFiles} static files`;
24832
+ this.info(`Wrote .vercel/output: ${files3}, a function of ${megabytes2(functionBytes)}.`);
24833
+ for (const warning of warnings) this.warn(warning);
24834
+ return 0;
24835
+ } catch (error) {
24836
+ this.error(error instanceof Error ? error.message : String(error));
24837
+ return 1;
24838
+ }
24839
+ }).purpose("Write Vercel's build output (.vercel/output) for the application");
24840
+ }
24841
+ };
24842
+
24613
24843
  // ide/IdeInfoCommand.ts
24614
- import { existsSync as existsSync10, readdirSync as readdirSync9, readFileSync as readFileSync3 } from "fs";
24615
- import { join as join16, relative as relative7, sep as sep6 } from "path";
24844
+ import { existsSync as existsSync11, readdirSync as readdirSync10, readFileSync as readFileSync4 } from "fs";
24845
+ import { join as join17, relative as relative8, sep as sep6 } from "path";
24616
24846
 
24617
24847
  // ide/sections.ts
24618
- import { existsSync as existsSync9, readdirSync as readdirSync8 } from "fs";
24619
- import { join as join15, relative as relative6, sep as sep5 } from "path";
24848
+ import { existsSync as existsSync10, readdirSync as readdirSync9 } from "fs";
24849
+ import { join as join16, relative as relative7, sep as sep5 } from "path";
24620
24850
  import { parse as parse2 } from "dotenv";
24621
24851
  var SECRET = /key|secret|password|token|credential|salt|private/i;
24622
24852
  var CREDENTIALS = /^[a-z][a-z0-9+.-]*:\/\/[^/?#\s]*@/i;
@@ -24657,14 +24887,14 @@ function envSection(env3, example) {
24657
24887
  function viewSection(paths, hints, extensions, basePath) {
24658
24888
  const views = /* @__PURE__ */ new Map();
24659
24889
  const collect2 = (root, prefix) => {
24660
- if (!existsSync9(root)) return;
24661
- for (const item of readdirSync8(root, { recursive: true, withFileTypes: true })) {
24890
+ if (!existsSync10(root)) return;
24891
+ for (const item of readdirSync9(root, { recursive: true, withFileTypes: true })) {
24662
24892
  if (!item.isFile()) continue;
24663
24893
  const extension = extensions.find((candidate) => item.name.endsWith(`.${candidate}`));
24664
24894
  if (extension === void 0) continue;
24665
- const file = join15(item.parentPath, item.name);
24666
- const name = prefix + posix2(relative6(root, file)).slice(0, -(extension.length + 1)).split("/").join(".");
24667
- if (!views.has(name)) views.set(name, posix2(relative6(basePath, file)));
24895
+ const file = join16(item.parentPath, item.name);
24896
+ const name = prefix + posix2(relative7(root, file)).slice(0, -(extension.length + 1)).split("/").join(".");
24897
+ if (!views.has(name)) views.set(name, posix2(relative7(basePath, file)));
24668
24898
  }
24669
24899
  };
24670
24900
  for (const path of paths) collect2(path, "");
@@ -24674,7 +24904,7 @@ function viewSection(paths, hints, extensions, basePath) {
24674
24904
 
24675
24905
  // ide/IdeInfoCommand.ts
24676
24906
  var posix3 = (path) => path.split(sep6).join("/");
24677
- var read = (file) => existsSync10(file) ? readFileSync3(file, "utf8") : null;
24907
+ var read = (file) => existsSync11(file) ? readFileSync4(file, "utf8") : null;
24678
24908
  var IdeInfoCommand = class extends Command {
24679
24909
  signature = "ide:info {--pretty : Indent the JSON}";
24680
24910
  description = "Describe the application for editors, as JSON";
@@ -24705,9 +24935,9 @@ function describe(app2, container) {
24705
24935
  const basePath = app2.basePath();
24706
24936
  const config2 = optional(ConfigRepository);
24707
24937
  const get = (key, fallback) => config2 ? config2.get(key, fallback) : fallback;
24708
- const relativeTo = (file) => posix3(relative7(basePath, file));
24938
+ const relativeTo = (file) => posix3(relative8(basePath, file));
24709
24939
  const configDirectory = app2.configPath();
24710
- const configFiles = existsSync10(configDirectory) ? readdirSync9(configDirectory).filter((file) => /\.(ts|js|mjs)$/.test(file)).map((file) => relativeTo(join16(configDirectory, file))) : [];
24940
+ const configFiles = existsSync11(configDirectory) ? readdirSync10(configDirectory).filter((file) => /\.(ts|js|mjs)$/.test(file)).map((file) => relativeTo(join17(configDirectory, file))) : [];
24711
24941
  const factory = optional(ViewFactory);
24712
24942
  const finder = factory instanceof Factory ? factory.getFinder() : void 0;
24713
24943
  const registry2 = optional(ClassRegistry);
@@ -24717,18 +24947,18 @@ function describe(app2, container) {
24717
24947
  if (!registry2.has(name)) return [];
24718
24948
  const cls = registry2.resolve(name);
24719
24949
  if (typeof cls !== "function" || !(cls.prototype instanceof Component)) return [];
24720
- return [{ name, file: relativeTo(join16(classPath, file)), ...describeSafely(name, cls) }];
24950
+ return [{ name, file: relativeTo(join17(classPath, file)), ...describeSafely(name, cls) }];
24721
24951
  }) : [];
24722
24952
  const validation = optional(ValidationFactory);
24723
24953
  const pagePaths = get("inertia.pages.paths", []);
24724
- const inertia2 = pagePaths.some((path) => existsSync10(path)) ? { pages: pageNames(pagePaths, get("inertia.pages.extensions", [])).map((page) => ({ name: page.name, file: relativeTo(page.file) })) } : null;
24954
+ const inertia2 = pagePaths.some((path) => existsSync11(path)) ? { pages: pageNames(pagePaths, get("inertia.pages.extensions", [])).map((page) => ({ name: page.name, file: relativeTo(page.file) })) } : null;
24725
24955
  return {
24726
24956
  schema: 1,
24727
24957
  oriel: { version: app2.version, runtime: process.versions.bun ? "bun" : "node", runtimeVersion: process.versions.bun ?? process.versions.node, environment: app2.environment(), basePath },
24728
24958
  commands: commandSection(inject(ConsoleKernel).all()),
24729
24959
  routes: container.bound(Router) ? routeListRows(container.make(Router).getRoutes()) : [],
24730
24960
  config: config2 ? configSection(config2.all(), configFiles) : [],
24731
- env: envSection(read(join16(basePath, ".env")), read(join16(basePath, ".env.example"))),
24961
+ env: envSection(read(join17(basePath, ".env")), read(join17(basePath, ".env.example"))),
24732
24962
  views: finder ? viewSection(finder.getPaths(), finder.getHints(), FileViewFinder.defaultExtensions, basePath) : [],
24733
24963
  live: live2,
24734
24964
  rules: typeof validation?.ruleNames === "function" ? validation.ruleNames() : Object.keys(builtinRules).sort(),
@@ -24768,7 +24998,8 @@ function defaultProviders() {
24768
24998
  RoutingServiceProvider,
24769
24999
  HttpServiceProvider,
24770
25000
  ConsoleServiceProvider,
24771
- IdeServiceProvider
25001
+ IdeServiceProvider,
25002
+ VercelServiceProvider
24772
25003
  ];
24773
25004
  }
24774
25005
 
@@ -24856,6 +25087,7 @@ export {
24856
25087
  CallQueuedHandler,
24857
25088
  CallQueuedListener,
24858
25089
  CircularDependencyError,
25090
+ ClassNameMap,
24859
25091
  ClassRegistry2 as ClassRegistry,
24860
25092
  ClosureCommand,
24861
25093
  ClosureKernel,
@@ -24926,6 +25158,7 @@ export {
24926
25158
  EventsNeedBusDispatcherError,
24927
25159
  EventsNeedClassRegistryError,
24928
25160
  ExceptionsConfiguration,
25161
+ ExportError,
24929
25162
  Expression,
24930
25163
  Factory2 as Factory,
24931
25164
  Failed,
@@ -25148,6 +25381,7 @@ export {
25148
25381
  Relation,
25149
25382
  RelationNotFoundError,
25150
25383
  RelationNotLoadedError,
25384
+ RenameClasses,
25151
25385
  Repository,
25152
25386
  ResetPassword,
25153
25387
  Route,
@@ -25188,6 +25422,7 @@ export {
25188
25422
  SessionMessageBag,
25189
25423
  SessionServiceProvider,
25190
25424
  Store as SessionStore,
25425
+ SetCacheHeaders,
25191
25426
  SmtpTransport,
25192
25427
  SoftDeletingScope,
25193
25428
  SqliteSchemaGrammar,
@@ -25242,6 +25477,7 @@ export {
25242
25477
  UnsupportedOperationError,
25243
25478
  UploadValidationError,
25244
25479
  UrlGenerationError,
25480
+ VERCEL_FUNCTION_LIMIT,
25245
25481
  ValidateSignature,
25246
25482
  Validated,
25247
25483
  ValidationErrorImpl,
@@ -25250,6 +25486,7 @@ export {
25250
25486
  ValidationServiceProvider,
25251
25487
  Validator,
25252
25488
  ValidatorImpl,
25489
+ VercelServiceProvider,
25253
25490
  Verified,
25254
25491
  VerifyCsrfToken,
25255
25492
  VerifyEmail,
@@ -25280,6 +25517,7 @@ export {
25280
25517
  auth,
25281
25518
  back,
25282
25519
  bcrypt3 as bcrypt,
25520
+ buildVercelOutput,
25283
25521
  builtinRules,
25284
25522
  bunRuntime,
25285
25523
  cache,
@@ -25340,6 +25578,7 @@ export {
25340
25578
  event,
25341
25579
  exceedsJsonDepth,
25342
25580
  expandWildcardKeys,
25581
+ exportSite,
25343
25582
  extensionFromMime,
25344
25583
  facade,
25345
25584
  fake,
@@ -25396,6 +25635,7 @@ export {
25396
25635
  minimalPage,
25397
25636
  modelEventName,
25398
25637
  morphMap,
25638
+ nodeRequestHandler,
25399
25639
  normalizeAddress,
25400
25640
  normalizeAddresses,
25401
25641
  normalizeBackoff,