@absolutejs/absolute 0.19.0-beta.1053 → 0.19.0-beta.1055

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,7 +1,7 @@
1
1
  // @bun
2
2
  var __require = import.meta.require;
3
3
 
4
- // .angular-partial-tmp-Rac2su/src/core/streamingSlotRegistrar.ts
4
+ // .angular-partial-tmp-Gd36SZ/src/core/streamingSlotRegistrar.ts
5
5
  var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
6
6
  var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
7
7
  var STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  var __require = import.meta.require;
3
3
 
4
- // .angular-partial-tmp-Rac2su/src/core/streamingSlotRegistrar.ts
4
+ // .angular-partial-tmp-Gd36SZ/src/core/streamingSlotRegistrar.ts
5
5
  var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
6
6
  var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
7
7
  var STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
@@ -48,7 +48,7 @@ var warnMissingStreamingSlotCollector = (primitiveName) => {
48
48
  getWarningController()?.maybeWarn(primitiveName);
49
49
  };
50
50
 
51
- // .angular-partial-tmp-Rac2su/src/core/streamingSlotRegistry.ts
51
+ // .angular-partial-tmp-Gd36SZ/src/core/streamingSlotRegistry.ts
52
52
  var STREAMING_SLOT_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotAsyncLocalStorage");
53
53
  var isObjectRecord2 = (value) => Boolean(value) && typeof value === "object";
54
54
  var isAsyncLocalStorage = (value) => isObjectRecord2(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
package/dist/cli/index.js CHANGED
@@ -176805,7 +176805,19 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
176805
176805
  if (relativePath.includes("/server/"))
176806
176806
  return false;
176807
176807
  return true;
176808
- }, tryReadNodePackageJson = (packageDir) => {
176808
+ }, ENV_NAME_RE, resolveCompileNativeAssets = (buildConfig) => (buildConfig.compile?.nativeAssets ?? []).filter((asset) => {
176809
+ if (!asset || typeof asset !== "object")
176810
+ return false;
176811
+ if (typeof asset.import !== "string" || asset.import.length === 0) {
176812
+ console.warn(cliTag4("\x1B[33m", "Ignoring compile.nativeAssets entry with missing import."));
176813
+ return false;
176814
+ }
176815
+ if (typeof asset.env !== "string" || !ENV_NAME_RE.test(asset.env)) {
176816
+ console.warn(cliTag4("\x1B[33m", `Ignoring compile.nativeAssets entry for ${asset.import}: env must be a valid environment variable name.`));
176817
+ return false;
176818
+ }
176819
+ return true;
176820
+ }), tryReadNodePackageJson = (packageDir) => {
176809
176821
  try {
176810
176822
  return JSON.parse(readFileSync33(join31(packageDir, "package.json"), "utf-8"));
176811
176823
  } catch {
@@ -177020,9 +177032,18 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
177020
177032
  });
177021
177033
  const clientFiles = embeddedFiles.filter((file) => shouldEmbedCompiledAsset(relative11(distDir, file), assetSkip));
177022
177034
  const imports = [];
177035
+ const nativeImports = [];
177036
+ const nativeMappings = [];
177023
177037
  const embeddedMappings = [];
177024
177038
  const mappings = [];
177025
177039
  const embeddedVarMap = new Map;
177040
+ const nativeAssets = resolveCompileNativeAssets(buildConfig);
177041
+ nativeAssets.forEach((asset, idx) => {
177042
+ const varName = `__native${idx}`;
177043
+ const importSpecifier = asset.import.startsWith(".") ? resolve21(process.cwd(), asset.import) : asset.import;
177044
+ nativeImports.push(`import ${varName} from ${JSON.stringify(importSpecifier)} with { type: "file" };`);
177045
+ nativeMappings.push(` [${JSON.stringify(asset.env)}, resolveNativeAssetPath(${varName})],`);
177046
+ });
177026
177047
  embeddedFiles.forEach((filePath, idx) => {
177027
177048
  const rel = relative11(distDir, filePath).replace(/\\/g, "/");
177028
177049
  const varName = `__a${idx}`;
@@ -177055,6 +177076,10 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
177055
177076
  const runtimeBuildId = `${version2}-${Date.now().toString(36)}`;
177056
177077
  const runtimeConfigSource = JSON.stringify(buildConfig, (_key, value) => typeof value === "function" || typeof value === "symbol" ? undefined : value, 2);
177057
177078
  return `// Auto-generated compile entrypoint
177079
+ // \u2500\u2500 Native asset imports \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
177080
+ ${nativeImports.join(`
177081
+ `)}
177082
+
177058
177083
  // \u2500\u2500 Embedded asset imports \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
177059
177084
  ${imports.join(`
177060
177085
  `)}
@@ -177065,7 +177090,7 @@ import { basename, dirname, join } from "node:path";
177065
177090
  import { homedir, tmpdir } from "node:os";
177066
177091
  import { createHash } from "node:crypto";
177067
177092
  import { readFileSync, writeFileSync } from "node:fs";
177068
- import { pathToFileURL } from "node:url";
177093
+ import { fileURLToPath, pathToFileURL } from "node:url";
177069
177094
  // Elysia's WebSocket dispatcher (stateless: routes every event through
177070
177095
  // ws.data.*). Wiring it into Bun.serve below is what lets compiled servers
177071
177096
  // serve .ws() routes \u2014 without it every upgrade falls through to a 404.
@@ -177077,6 +177102,19 @@ const RUNTIME_CONFIG_SOURCE = ${JSON.stringify(runtimeConfigSource)};
177077
177102
  const ORIGINAL_BUILD_DIR = ${JSON.stringify(resolve21(distDir))};
177078
177103
  const ORIGINAL_BUILD_DIR_NORMALIZED = ORIGINAL_BUILD_DIR.replace(/\\\\/g, "/");
177079
177104
 
177105
+ const resolveNativeAssetPath = (assetPath: string) => {
177106
+ try {
177107
+ return fileURLToPath(new URL(assetPath, import.meta.url));
177108
+ } catch {
177109
+ return assetPath;
177110
+ }
177111
+ };
177112
+
177113
+ const NATIVE_ASSETS: Array<[string, string]> = [
177114
+ ${nativeMappings.join(`
177115
+ `)}
177116
+ ];
177117
+
177080
177118
  // \u2500\u2500 Asset URL \u2192 embedded path map \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
177081
177119
  const ASSETS: Record<string, string> = {
177082
177120
  ${mappings.join(`
@@ -177211,6 +177249,9 @@ const rewriteRuntimeJsonPaths = (runtimeDir: string, fileName: string) => {
177211
177249
 
177212
177250
  const resolveRuntimeFetch = async () => {
177213
177251
  const { configPath, runtimeDir } = await materializeRuntimeFiles();
177252
+ for (const [envName, assetPath] of NATIVE_ASSETS) {
177253
+ process.env[envName] = assetPath;
177254
+ }
177214
177255
  process.env.ABSOLUTE_BUILD_DIR = runtimeDir;
177215
177256
  process.env.ABSOLUTE_CONFIG = configPath;
177216
177257
  process.env.ABSOLUTE_COMPILED_RUNTIME = "1";
@@ -177632,6 +177673,7 @@ var init_compile = __esm(() => {
177632
177673
  "node_modules"
177633
177674
  ]);
177634
177675
  jsxDevRuntimeCompatPath2 = resolveJsxDevRuntimeCompatPath2();
177676
+ ENV_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
177635
177677
  RUNTIME_JS_EXTENSIONS = [".js", ".mjs", ".cjs"];
177636
177678
  MODULE_SPECIFIER_RE = /(from\s*|import\s*|import\(\s*|require\(\s*)(["'])([^"']+)\2/g;
177637
177679
  FRAMEWORK_EXTERNALS = [
@@ -178580,6 +178622,17 @@ var resolveDevPort = async (requestedPort, options = {}) => {
178580
178622
  init_utils();
178581
178623
  var cliTag = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`;
178582
178624
  var DEFAULT_PORT_RANGE = 10;
178625
+ var NODE_API_IMPORT_ERROR = "To load Node-API modules, use require() or process.dlopen instead of import.";
178626
+ var formatServerBootDiagnostic = (output, serverEntry) => {
178627
+ if (!output.includes(NODE_API_IMPORT_ERROR))
178628
+ return null;
178629
+ return [
178630
+ `Server boot failed while evaluating ${serverEntry}.`,
178631
+ "Bun is trying to load a native Node-API addon from an ESM import.",
178632
+ 'Load `.node` addons with require()/process.dlopen, or gate `with { type: "file" }` asset imports so they only run in compiled builds.'
178633
+ ].join(`
178634
+ `);
178635
+ };
178583
178636
  var HEAP_SNAPSHOT_PRELOAD = `process.on('SIGUSR2', () => {
178584
178637
  try {
178585
178638
  const file = 'heap-' + process.pid + '-' + Date.now() + '.heapsnapshot';
@@ -178890,7 +178943,8 @@ var dev = async (serverEntry, configPath2) => {
178890
178943
  },
178891
178944
  stdio: ["ignore", "pipe", "pipe"]
178892
178945
  });
178893
- const forward = (source, dest) => {
178946
+ let printedBootDiagnostic = false;
178947
+ const forward = (source, dest, sourceName) => {
178894
178948
  if (!source)
178895
178949
  return;
178896
178950
  source.on("data", (chunk) => {
@@ -178899,10 +178953,21 @@ var dev = async (serverEntry, configPath2) => {
178899
178953
  dest.write(chunk);
178900
178954
  writeInstanceLog(chunk.toString());
178901
178955
  handleChunk(chunk);
178956
+ if (sourceName === "stderr" && !printedBootDiagnostic) {
178957
+ const diagnostic = formatServerBootDiagnostic(chunk.toString(), serverEntry);
178958
+ if (diagnostic) {
178959
+ printedBootDiagnostic = true;
178960
+ const formatted = cliTag("\x1B[33m", diagnostic);
178961
+ process.stderr.write(`${formatted}
178962
+ `);
178963
+ writeInstanceLog(`${formatted}
178964
+ `);
178965
+ }
178966
+ }
178902
178967
  });
178903
178968
  };
178904
- forward(proc.stdout, process.stdout);
178905
- forward(proc.stderr, process.stderr);
178969
+ forward(proc.stdout, process.stdout, "stdout");
178970
+ forward(proc.stderr, process.stderr, "stderr");
178906
178971
  return proc;
178907
178972
  };
178908
178973
  let serverProcess = await spawnServer();
@@ -1 +1,2 @@
1
+ export declare const formatServerBootDiagnostic: (output: string, serverEntry: string) => string | null;
1
2
  export declare const dev: (serverEntry: string, configPath?: string) => Promise<void>;
@@ -47,6 +47,7 @@ export declare const loadConfig: (configPath?: string) => Promise<{
47
47
  };
48
48
  };
49
49
  static?: import("..").StaticConfig;
50
+ compile?: import("..").CompileConfig;
50
51
  images?: import("..").ImageConfig;
51
52
  sitemap?: import("..").SitemapConfig;
52
53
  openapi?: boolean | import("..").OpenApiConfig;
@@ -91,6 +91,27 @@ export type StaticConfig = {
91
91
  /** Revalidation interval in seconds. When set, stale pages are re-rendered in the background (ISR). */
92
92
  revalidate?: number;
93
93
  };
94
+ export type CompileNativeAssetConfig = {
95
+ /**
96
+ * Static import specifier for a native asset that Bun must embed only when
97
+ * producing a standalone executable, e.g.
98
+ * "@scope/native-linux-x64/native.node".
99
+ */
100
+ import: string;
101
+ /**
102
+ * Environment variable set to the embedded asset's runtime path before the
103
+ * compiled server bundle is imported.
104
+ */
105
+ env: string;
106
+ };
107
+ export type CompileConfig = {
108
+ /**
109
+ * Native assets to embed with Bun's `with { type: "file" }` compile import.
110
+ * These are injected into Absolute's generated compile entrypoint, so dev
111
+ * and start never evaluate `.node` files as ESM imports.
112
+ */
113
+ nativeAssets?: CompileNativeAssetConfig[];
114
+ };
94
115
  export type HttpReadyConfig = {
95
116
  type?: 'http';
96
117
  path?: string;
@@ -202,6 +223,7 @@ export type BaseBuildConfig = {
202
223
  };
203
224
  };
204
225
  static?: StaticConfig;
226
+ compile?: CompileConfig;
205
227
  images?: ImageConfig;
206
228
  sitemap?: SitemapConfig;
207
229
  openapi?: boolean | OpenApiConfig;
package/package.json CHANGED
@@ -414,7 +414,7 @@
414
414
  ]
415
415
  }
416
416
  },
417
- "version": "0.19.0-beta.1053",
417
+ "version": "0.19.0-beta.1055",
418
418
  "workspaces": [
419
419
  "tests/fixtures/*",
420
420
  "tests/fixtures/_packages/*"