@absolutejs/absolute 0.20.0-beta.160 → 0.20.0-beta.162

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.
@@ -52,8 +52,61 @@ import {
52
52
 
53
53
  // src/cli/scripts/start.ts
54
54
  var {env } = globalThis.Bun;
55
- import { existsSync, readFileSync, rmSync } from "fs";
56
- import { basename, join, resolve } from "path";
55
+ import { existsSync as existsSync2, readFileSync as readFileSync2, rmSync } from "fs";
56
+ import { basename, join as join2, resolve } from "path";
57
+
58
+ // src/core/productionRuntime.ts
59
+ import { existsSync, readFileSync, writeFileSync } from "fs";
60
+ import { join } from "path";
61
+ var PRODUCTION_RUNTIME_FILE = "absolute-runtime.json";
62
+ var PRODUCTION_RUNTIME_VERSION = 1;
63
+ var RUNTIME_KEYS = [
64
+ "angularDirectory",
65
+ "assetsDirectory",
66
+ "astroDirectory",
67
+ "emberDirectory",
68
+ "htmlDirectory",
69
+ "htmxDirectory",
70
+ "images",
71
+ "islands",
72
+ "mobile",
73
+ "openapi",
74
+ "publicDirectory",
75
+ "reactDirectory",
76
+ "static",
77
+ "svelteDirectory",
78
+ "telemetry",
79
+ "vueDirectory"
80
+ ];
81
+ var productionRuntimeConfigOf = (config) => {
82
+ const picked = {};
83
+ for (const key of RUNTIME_KEYS)
84
+ if (config[key] !== undefined)
85
+ picked[key] = config[key];
86
+ const runtime = JSON.parse(JSON.stringify(picked));
87
+ return runtime;
88
+ };
89
+ var writeProductionRuntime = (config, buildDirectory) => {
90
+ const file = {
91
+ config: productionRuntimeConfigOf(config),
92
+ version: PRODUCTION_RUNTIME_VERSION
93
+ };
94
+ writeFileSync(join(buildDirectory, PRODUCTION_RUNTIME_FILE), `${JSON.stringify(file)}
95
+ `);
96
+ };
97
+ var isRuntimeFile = (value) => typeof value === "object" && value !== null && ("version" in value) && value.version === PRODUCTION_RUNTIME_VERSION && ("config" in value) && typeof value.config === "object" && value.config !== null;
98
+ var readProductionRuntime = (buildDirectory) => {
99
+ const path = join(buildDirectory, PRODUCTION_RUNTIME_FILE);
100
+ if (!existsSync(path))
101
+ return null;
102
+ const parsed = JSON.parse(readFileSync(path, "utf-8"));
103
+ if (!isRuntimeFile(parsed))
104
+ return null;
105
+ const config = { ...parsed.config, buildDirectory };
106
+ return config;
107
+ };
108
+
109
+ // src/cli/scripts/start.ts
57
110
  var cliTag = (color, message) => `\x1B[2m${formatTimestamp2()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`;
58
111
  var resolvePackageVersion = (candidates) => {
59
112
  for (const candidate of candidates) {
@@ -66,7 +119,7 @@ var resolvePackageVersion = (candidates) => {
66
119
  };
67
120
  var readPackageVersion = (candidate) => {
68
121
  try {
69
- const pkg = JSON.parse(readFileSync(candidate, "utf-8"));
122
+ const pkg = JSON.parse(readFileSync2(candidate, "utf-8"));
70
123
  if (pkg.name !== "@absolutejs/absolute")
71
124
  return null;
72
125
  const ver = pkg.version;
@@ -116,7 +169,7 @@ var resolveJsxDevRuntimeCompatPath = () => {
116
169
  resolve(import.meta.dir, "..", "..", "..", "src", "react", "jsxDevRuntimeCompat.ts")
117
170
  ];
118
171
  for (const candidate of candidates) {
119
- if (existsSync(candidate))
172
+ if (existsSync2(candidate))
120
173
  return candidate;
121
174
  }
122
175
  return resolve(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js");
@@ -156,7 +209,7 @@ var runPreparedServer = async ({
156
209
  serverEntry,
157
210
  totalDuration
158
211
  }) => {
159
- const usesDocker = existsSync(resolve(COMPOSE_PATH));
212
+ const usesDocker = existsSync2(resolve(COMPOSE_PATH));
160
213
  const scripts = usesDocker ? await readDbScripts() : null;
161
214
  if (scripts)
162
215
  await startDatabase(scripts);
@@ -253,7 +306,8 @@ var start2 = async (serverEntry, outdir, configPath, options = {}) => {
253
306
  resolve(import.meta.dir, "..", "..", "..", "package.json"),
254
307
  resolve(import.meta.dir, "..", "..", "package.json")
255
308
  ]);
256
- const buildConfig = await loadConfig(configPath);
309
+ const builtConfig = options.prebuilt ? readProductionRuntime(resolvedOutdir) : null;
310
+ const buildConfig = builtConfig ?? await loadConfig(configPath);
257
311
  buildConfig.buildDirectory = resolvedOutdir;
258
312
  buildConfig.mode = "production";
259
313
  if (buildConfig.mobile)
@@ -268,7 +322,7 @@ var start2 = async (serverEntry, outdir, configPath, options = {}) => {
268
322
  ].filter((val) => Boolean(val));
269
323
  const outputPath = resolve(resolvedOutdir, `${entryName}.js`);
270
324
  if (options.prebuilt) {
271
- if (!existsSync(outputPath)) {
325
+ if (!existsSync2(outputPath)) {
272
326
  throw new Error(`Prepared production server not found: ${outputPath}`);
273
327
  }
274
328
  return runPreparedServer({
@@ -295,7 +349,7 @@ var start2 = async (serverEntry, outdir, configPath, options = {}) => {
295
349
  if (!build)
296
350
  throw new Error("Could not locate build module");
297
351
  await build(buildConfig);
298
- rmSync(join(resolvedOutdir, "_prerendered"), {
352
+ rmSync(join2(resolvedOutdir, "_prerendered"), {
299
353
  force: true,
300
354
  recursive: true
301
355
  });
@@ -400,11 +454,11 @@ var start2 = async (serverEntry, outdir, configPath, options = {}) => {
400
454
  if (!serverBundle.success) {
401
455
  handleBundleFailure(serverBundle, bundleStart, serverEntry);
402
456
  }
403
- if (!existsSync(outputPath)) {
457
+ if (!existsSync2(outputPath)) {
404
458
  console.error(cliTag("\x1B[31m", `Expected output not found: ${outputPath}`));
405
459
  process.exit(1);
406
460
  }
407
- if (existsSync(resolve(resolvedOutdir, "angular", "vendor", "server"))) {
461
+ if (existsSync2(resolve(resolvedOutdir, "angular", "vendor", "server"))) {
408
462
  const { readdirSync } = await import("fs");
409
463
  const vendorDir = resolve(resolvedOutdir, "angular", "vendor", "server");
410
464
  const vendorEntries = readdirSync(vendorDir).filter((fileName) => fileName.endsWith(".js"));
@@ -424,6 +478,7 @@ var start2 = async (serverEntry, outdir, configPath, options = {}) => {
424
478
  await rewriteImports([outputPath], angularServerVendorPaths);
425
479
  }
426
480
  }
481
+ writeProductionRuntime(buildConfig, resolvedOutdir);
427
482
  if (buildConfig.mobile) {
428
483
  await finalizeAbsoluteMobileCompatibilityBuild({
429
484
  buildDirectory: resolvedOutdir,
package/dist/cli/index.js CHANGED
@@ -70,7 +70,7 @@ if (command === "dev") {
70
70
  const configPath = parseNamedArg("--config");
71
71
  const positionalArgs = stripNamedArgs("--outdir", "--config").filter((arg) => arg !== "--prebuilt");
72
72
  const serverEntry = positionalArgs[0] ?? DEFAULT_SERVER_ENTRY;
73
- const { start } = await import("./start-4rpdy8hg.js");
73
+ const { start } = await import("./start-0bx1rkx4.js");
74
74
  await start(serverEntry, outdir, configPath, {
75
75
  prebuilt: args.includes("--prebuilt")
76
76
  });
@@ -80,7 +80,7 @@ if (command === "dev") {
80
80
  const configPath = parseNamedArg("--config");
81
81
  const positionalArgs = stripNamedArgs("--outdir", "--config");
82
82
  const serverEntry = positionalArgs[0] ?? DEFAULT_SERVER_ENTRY;
83
- const { start } = await import("./start-4rpdy8hg.js");
83
+ const { start } = await import("./start-0bx1rkx4.js");
84
84
  await start(serverEntry, outdir, configPath, { prepareOnly: true });
85
85
  } else if (command === "build") {
86
86
  sendTelemetryEvent("cli:command", { command });
@@ -211,7 +211,7 @@ if (command === "dev") {
211
211
  sendTelemetryEvent("cli:command", {
212
212
  command: `mobile:${workspaceCommand ?? "unknown"}`
213
213
  });
214
- const { runMobile } = await import("./mobile-0r1y2hwc.js");
214
+ const { runMobile } = await import("./mobile-2f54v4by.js");
215
215
  try {
216
216
  await runMobile(args);
217
217
  } catch (error) {
@@ -79,7 +79,7 @@ import {
79
79
  import"./index-e6ysp900.js";
80
80
  import {
81
81
  start2
82
- } from "./index-55k7vn84.js";
82
+ } from "./index-f82hvr9c.js";
83
83
  import {
84
84
  captureAbsoluteRemoteMacCommand2,
85
85
  getAbsoluteRemoteMacProfile2,
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  start2
4
- } from "./index-55k7vn84.js";
4
+ } from "./index-f82hvr9c.js";
5
5
  import"./index-j7m8pq48.js";
6
6
  import"./index-e6ysp900.js";
7
7
  import"./index-71gchbzt.js";