@absolutejs/absolute 0.19.0-beta.946 → 0.19.0-beta.947

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
@@ -8337,6 +8337,114 @@ var init_staticIslandPages = __esm(() => {
8337
8337
  HTMX_STREAM_SLOT_TAG_RE = /<abs-htmx-stream-slot\b([^>]*?)(?:\/>|>([\s\S]*?)<\/abs-htmx-stream-slot>)/gi;
8338
8338
  });
8339
8339
 
8340
+ // src/utils/loadConfig.ts
8341
+ var exports_loadConfig = {};
8342
+ __export(exports_loadConfig, {
8343
+ loadRawConfig: () => loadRawConfig,
8344
+ loadConfig: () => loadConfig,
8345
+ isWorkspaceConfig: () => isWorkspaceConfig,
8346
+ getWorkspaceServices: () => getWorkspaceServices
8347
+ });
8348
+ import { resolve as resolve8 } from "path";
8349
+ var RESERVED_TOP_LEVEL_KEYS, isObject = (value) => typeof value === "object" && value !== null, isCommandService = (service) => service.kind === "command" || Array.isArray(service.command), isServiceCandidate = (value) => isObject(value) && (typeof value.entry === "string" || Array.isArray(value.command)), isWorkspaceConfig = (config) => {
8350
+ if (!isObject(config)) {
8351
+ return false;
8352
+ }
8353
+ const entries = Object.entries(config);
8354
+ if (entries.length === 0) {
8355
+ return false;
8356
+ }
8357
+ if (entries.some(([key]) => RESERVED_TOP_LEVEL_KEYS.has(key))) {
8358
+ return false;
8359
+ }
8360
+ return entries.every(([, value]) => isServiceCandidate(value));
8361
+ }, isConfigInput = (value) => isObject(value), getWorkspaceServices = (config) => {
8362
+ if (!isWorkspaceConfig(config)) {
8363
+ throw new Error("absolute.config.ts is not a multi-service config. Define top-level named services with `entry` or `command` before using `absolute workspace dev`.");
8364
+ }
8365
+ return config;
8366
+ }, projectServiceConfig = (config, serviceName) => {
8367
+ const services = getWorkspaceServices(config);
8368
+ const service = services[serviceName];
8369
+ if (!service) {
8370
+ throw new Error(`Config file does not define service "${serviceName}".`);
8371
+ }
8372
+ if (isCommandService(service)) {
8373
+ throw new Error(`Service "${serviceName}" is a command service and cannot be loaded as an AbsoluteJS app config.`);
8374
+ }
8375
+ const {
8376
+ command: _command,
8377
+ config: _config,
8378
+ cwd: _cwd,
8379
+ dependsOn: _dependsOn,
8380
+ env: _env,
8381
+ kind: _kind,
8382
+ port: _port,
8383
+ ready: _ready,
8384
+ visibility: _visibility,
8385
+ ...serviceConfig
8386
+ } = service;
8387
+ return serviceConfig;
8388
+ }, loadConfig = async (configPath) => {
8389
+ const config = await loadRawConfig(configPath);
8390
+ const serviceName = process.env.ABSOLUTE_WORKSPACE_SERVICE_NAME;
8391
+ if (typeof serviceName === "string" && serviceName.length > 0) {
8392
+ return projectServiceConfig(config, serviceName);
8393
+ }
8394
+ if (isWorkspaceConfig(config)) {
8395
+ throw new Error("absolute.config.ts defines multiple services. Use `absolute workspace dev` or set ABSOLUTE_WORKSPACE_SERVICE_NAME before loading a specific service config.");
8396
+ }
8397
+ return config;
8398
+ }, loadRawConfig = async (configPath) => {
8399
+ const resolved = resolve8(configPath ?? process.env.ABSOLUTE_CONFIG ?? "absolute.config.ts");
8400
+ const mod = await import(resolved);
8401
+ const config = mod.default ?? mod.config;
8402
+ if (!config) {
8403
+ throw new Error(`Config file "${resolved}" does not export a valid configuration.
8404
+ Expected: export default defineConfig({ ... })`);
8405
+ }
8406
+ if (!isConfigInput(config)) {
8407
+ throw new Error(`Config file "${resolved}" must export an object configuration.`);
8408
+ }
8409
+ return config;
8410
+ };
8411
+ var init_loadConfig = __esm(() => {
8412
+ RESERVED_TOP_LEVEL_KEYS = new Set([
8413
+ "assetsDirectory",
8414
+ "astroDirectory",
8415
+ "buildDirectory",
8416
+ "bunBuild",
8417
+ "command",
8418
+ "config",
8419
+ "cwd",
8420
+ "dependsOn",
8421
+ "dev",
8422
+ "emberDirectory",
8423
+ "entry",
8424
+ "env",
8425
+ "htmlDirectory",
8426
+ "htmxDirectory",
8427
+ "images",
8428
+ "incrementalFiles",
8429
+ "islands",
8430
+ "kind",
8431
+ "mode",
8432
+ "options",
8433
+ "port",
8434
+ "postcss",
8435
+ "publicDirectory",
8436
+ "reactDirectory",
8437
+ "sitemap",
8438
+ "static",
8439
+ "stylesConfig",
8440
+ "svelteDirectory",
8441
+ "tailwind",
8442
+ "ready",
8443
+ "visibility",
8444
+ "vueDirectory"
8445
+ ]);
8446
+ });
8447
+
8340
8448
  // src/build/scanEntryPoints.ts
8341
8449
  import { existsSync as existsSync6 } from "fs";
8342
8450
  var {Glob } = globalThis.Bun;
@@ -12076,7 +12184,7 @@ var traceAngularPhase = async (name, fn2, metadata2) => {
12076
12184
  if (fileName.startsWith(outDir))
12077
12185
  return fileName.substring(outDir.length + 1);
12078
12186
  return fileName;
12079
- }, hasJsLikeExtension = (path) => /\.(js|ts|mjs|cjs)$/.test(path), splitSpecifierAndQuery = (specifier) => {
12187
+ }, hasJsLikeExtension = (path) => /\.(js|ts|mjs|cjs|json)$/.test(path), splitSpecifierAndQuery = (specifier) => {
12080
12188
  const separator = specifier.indexOf("?");
12081
12189
  if (separator === -1) {
12082
12190
  return {
@@ -12636,11 +12744,12 @@ ${fields}
12636
12744
  });
12637
12745
  const tsconfigAliases = readTsconfigPathAliases();
12638
12746
  const resolveSourceFile2 = (candidate) => {
12639
- const candidates = candidate.match(/\.[cm]?[tj]sx?$/) ? [candidate] : [
12747
+ const candidates = candidate.match(/\.(?:[cm]?[tj]sx?|json)$/) ? [candidate] : [
12640
12748
  `${candidate}.ts`,
12641
12749
  `${candidate}.tsx`,
12642
12750
  `${candidate}.js`,
12643
12751
  `${candidate}.jsx`,
12752
+ `${candidate}.json`,
12644
12753
  join19(candidate, "index.ts"),
12645
12754
  join19(candidate, "index.tsx"),
12646
12755
  join19(candidate, "index.js"),
@@ -12718,6 +12827,16 @@ ${fields}
12718
12827
  if (visited.has(resolved))
12719
12828
  return;
12720
12829
  visited.add(resolved);
12830
+ if (resolved.endsWith(".json") && existsSync17(resolved)) {
12831
+ const inputDir2 = dirname14(resolved);
12832
+ const relativeDir2 = inputDir2.startsWith(baseDir) ? inputDir2.substring(baseDir.length + 1) : inputDir2;
12833
+ const targetDir2 = join19(outDir, relativeDir2);
12834
+ const targetPath2 = join19(targetDir2, basename7(resolved));
12835
+ await fs.mkdir(targetDir2, { recursive: true });
12836
+ await fs.copyFile(resolved, targetPath2);
12837
+ allOutputs.push(targetPath2);
12838
+ return;
12839
+ }
12721
12840
  let actualPath = resolved;
12722
12841
  if (!actualPath.endsWith(".ts"))
12723
12842
  actualPath += ".ts";
@@ -20853,6 +20972,54 @@ export default {};
20853
20972
  }, transformAndCache = async (filePath, ext, projectRoot, rewriter, vueDir, stylePreprocessors) => {
20854
20973
  if (ext === ".css")
20855
20974
  return jsResponse(handleCssRequest(filePath));
20975
+ if (ext === ".json") {
20976
+ try {
20977
+ const { readFile: readFile6, stat: stat4 } = await import("fs/promises");
20978
+ const fileExists = async (p2) => {
20979
+ try {
20980
+ await stat4(p2);
20981
+ return true;
20982
+ } catch {
20983
+ return false;
20984
+ }
20985
+ };
20986
+ let sourcePath = filePath;
20987
+ if (!await fileExists(sourcePath)) {
20988
+ const { getFrameworkGeneratedDir: getFrameworkGeneratedDir2 } = await Promise.resolve().then(() => (init_generatedDir(), exports_generatedDir));
20989
+ const generatedAngularRoot = getFrameworkGeneratedDir2("angular").replace(/\\/g, "/");
20990
+ const normalized = filePath.replace(/\\/g, "/");
20991
+ if (normalized.startsWith(generatedAngularRoot + "/") || normalized.startsWith(generatedAngularRoot)) {
20992
+ const tail = normalized.slice(generatedAngularRoot.length + 1);
20993
+ const absoluteCandidate = "/" + tail.replace(/^\/+/, "");
20994
+ const candidates = [
20995
+ absoluteCandidate,
20996
+ resolve35(projectRoot, tail)
20997
+ ];
20998
+ try {
20999
+ const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_loadConfig(), exports_loadConfig));
21000
+ const cfg = await loadConfig2();
21001
+ const angularDir = cfg.angularDirectory && resolve35(projectRoot, cfg.angularDirectory);
21002
+ if (angularDir)
21003
+ candidates.push(resolve35(angularDir, tail));
21004
+ } catch {}
21005
+ for (const candidate of candidates) {
21006
+ if (await fileExists(candidate)) {
21007
+ sourcePath = candidate;
21008
+ break;
21009
+ }
21010
+ }
21011
+ }
21012
+ }
21013
+ const text = await readFile6(sourcePath, "utf-8");
21014
+ JSON.parse(text);
21015
+ return jsResponse(`export default ${text};`);
21016
+ } catch (err) {
21017
+ return new Response(`console.error('[ModuleServer] JSON load error in ${filePath}:', ${JSON.stringify(String(err))});`, {
21018
+ headers: { "Content-Type": "application/javascript" },
21019
+ status: 500
21020
+ });
21021
+ }
21022
+ }
20856
21023
  const isSvelte = ext === ".svelte" || filePath.endsWith(".svelte.ts") || filePath.endsWith(".svelte.js");
20857
21024
  const cached = getTransformed(filePath);
20858
21025
  if (cached)
@@ -21591,28 +21758,41 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
21591
21758
  return;
21592
21759
  }
21593
21760
  const publicDir = state.resolvedPaths.publicDir;
21594
- if (publicDir && resolve39(filePath).replace(/\\/g, "/").startsWith(publicDir + "/")) {
21761
+ const assetsDir = state.resolvedPaths.assetsDir;
21762
+ const handleStaticMirror = async (sourceDir, urlPrefix) => {
21763
+ const absSource = resolve39(filePath);
21764
+ const normalizedSource = absSource.replace(/\\/g, "/");
21765
+ const normalizedDir = sourceDir.replace(/\\/g, "/");
21766
+ if (!normalizedSource.startsWith(normalizedDir + "/"))
21767
+ return false;
21595
21768
  try {
21596
- const absSource = resolve39(filePath);
21597
- const relFromPublic = absSource.replace(/\\/g, "/").slice(publicDir.length + 1);
21769
+ const relFromDir = normalizedSource.slice(normalizedDir.length + 1);
21598
21770
  const buildDir = state.resolvedPaths.buildDir;
21599
- const destPath = resolve39(buildDir, relFromPublic);
21771
+ const destPath = resolve39(buildDir, urlPrefix ? `${urlPrefix}/${relFromDir}` : relFromDir);
21600
21772
  const { mkdir: mkdir7, copyFile, readFile: readFile6 } = await import("fs/promises");
21601
21773
  const { dirname: dirname23 } = await import("path");
21602
21774
  await mkdir7(dirname23(destPath), { recursive: true });
21603
21775
  await copyFile(absSource, destPath);
21604
21776
  const bytes = await readFile6(destPath);
21605
- state.assetStore.set(`/${relFromPublic}`, new Uint8Array(bytes));
21777
+ const webPath = urlPrefix ? `/${urlPrefix}/${relFromDir}` : `/${relFromDir}`;
21778
+ state.assetStore.set(webPath, new Uint8Array(bytes));
21606
21779
  state.fileHashes.set(absSource, currentHash);
21607
21780
  logHmrUpdate(relative16(process.cwd(), filePath));
21608
21781
  broadcastToClients(state, {
21609
- data: { framework: "public", manifest: state.manifest },
21610
- message: "Public asset updated",
21782
+ data: {
21783
+ framework: urlPrefix || "public",
21784
+ manifest: state.manifest
21785
+ },
21786
+ message: `${urlPrefix || "Public"} asset updated`,
21611
21787
  type: "style-update"
21612
21788
  });
21613
21789
  } catch {}
21790
+ return true;
21791
+ };
21792
+ if (publicDir && await handleStaticMirror(publicDir, ""))
21793
+ return;
21794
+ if (assetsDir && await handleStaticMirror(assetsDir, "assets"))
21614
21795
  return;
21615
- }
21616
21796
  if (framework === "unknown") {
21617
21797
  invalidate(resolve39(filePath));
21618
21798
  const relPath = relative16(process.cwd(), filePath);
@@ -21897,7 +22077,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
21897
22077
  tier: 1
21898
22078
  };
21899
22079
  }
21900
- if (owners.length === 0 && editedFile.endsWith(".ts") && !editedFile.endsWith(".d.ts")) {
22080
+ if (owners.length === 0 && (editedFile.endsWith(".ts") || editedFile.endsWith(".json")) && !editedFile.endsWith(".d.ts")) {
21901
22081
  const normalized = editedFile.replace(/\\/g, "/");
21902
22082
  const angularDirAbs = resolve39(angularDir).replace(/\\/g, "/");
21903
22083
  if (normalized.startsWith(angularDirAbs + "/")) {
@@ -25195,117 +25375,11 @@ var handleHTMXPageRequest = async (pagePath) => {
25195
25375
  });
25196
25376
  };
25197
25377
  // src/core/prepare.ts
25378
+ init_loadConfig();
25198
25379
  import { existsSync as existsSync30, readdirSync as readdirSync3, readFileSync as readFileSync23 } from "fs";
25199
25380
  import { basename as basename13, join as join34, relative as relative17, resolve as resolve43 } from "path";
25200
25381
  import { Elysia as Elysia5 } from "elysia";
25201
25382
 
25202
- // src/utils/loadConfig.ts
25203
- import { resolve as resolve8 } from "path";
25204
- var RESERVED_TOP_LEVEL_KEYS = new Set([
25205
- "assetsDirectory",
25206
- "astroDirectory",
25207
- "buildDirectory",
25208
- "bunBuild",
25209
- "command",
25210
- "config",
25211
- "cwd",
25212
- "dependsOn",
25213
- "dev",
25214
- "emberDirectory",
25215
- "entry",
25216
- "env",
25217
- "htmlDirectory",
25218
- "htmxDirectory",
25219
- "images",
25220
- "incrementalFiles",
25221
- "islands",
25222
- "kind",
25223
- "mode",
25224
- "options",
25225
- "port",
25226
- "postcss",
25227
- "publicDirectory",
25228
- "reactDirectory",
25229
- "sitemap",
25230
- "static",
25231
- "stylesConfig",
25232
- "svelteDirectory",
25233
- "tailwind",
25234
- "ready",
25235
- "visibility",
25236
- "vueDirectory"
25237
- ]);
25238
- var isObject = (value) => typeof value === "object" && value !== null;
25239
- var isCommandService = (service) => service.kind === "command" || Array.isArray(service.command);
25240
- var isServiceCandidate = (value) => isObject(value) && (typeof value.entry === "string" || Array.isArray(value.command));
25241
- var isWorkspaceConfig = (config) => {
25242
- if (!isObject(config)) {
25243
- return false;
25244
- }
25245
- const entries = Object.entries(config);
25246
- if (entries.length === 0) {
25247
- return false;
25248
- }
25249
- if (entries.some(([key]) => RESERVED_TOP_LEVEL_KEYS.has(key))) {
25250
- return false;
25251
- }
25252
- return entries.every(([, value]) => isServiceCandidate(value));
25253
- };
25254
- var isConfigInput = (value) => isObject(value);
25255
- var getWorkspaceServices = (config) => {
25256
- if (!isWorkspaceConfig(config)) {
25257
- throw new Error("absolute.config.ts is not a multi-service config. Define top-level named services with `entry` or `command` before using `absolute workspace dev`.");
25258
- }
25259
- return config;
25260
- };
25261
- var projectServiceConfig = (config, serviceName) => {
25262
- const services = getWorkspaceServices(config);
25263
- const service = services[serviceName];
25264
- if (!service) {
25265
- throw new Error(`Config file does not define service "${serviceName}".`);
25266
- }
25267
- if (isCommandService(service)) {
25268
- throw new Error(`Service "${serviceName}" is a command service and cannot be loaded as an AbsoluteJS app config.`);
25269
- }
25270
- const {
25271
- command: _command,
25272
- config: _config,
25273
- cwd: _cwd,
25274
- dependsOn: _dependsOn,
25275
- env: _env,
25276
- kind: _kind,
25277
- port: _port,
25278
- ready: _ready,
25279
- visibility: _visibility,
25280
- ...serviceConfig
25281
- } = service;
25282
- return serviceConfig;
25283
- };
25284
- var loadConfig = async (configPath) => {
25285
- const config = await loadRawConfig(configPath);
25286
- const serviceName = process.env.ABSOLUTE_WORKSPACE_SERVICE_NAME;
25287
- if (typeof serviceName === "string" && serviceName.length > 0) {
25288
- return projectServiceConfig(config, serviceName);
25289
- }
25290
- if (isWorkspaceConfig(config)) {
25291
- throw new Error("absolute.config.ts defines multiple services. Use `absolute workspace dev` or set ABSOLUTE_WORKSPACE_SERVICE_NAME before loading a specific service config.");
25292
- }
25293
- return config;
25294
- };
25295
- var loadRawConfig = async (configPath) => {
25296
- const resolved = resolve8(configPath ?? process.env.ABSOLUTE_CONFIG ?? "absolute.config.ts");
25297
- const mod = await import(resolved);
25298
- const config = mod.default ?? mod.config;
25299
- if (!config) {
25300
- throw new Error(`Config file "${resolved}" does not export a valid configuration.
25301
- Expected: export default defineConfig({ ... })`);
25302
- }
25303
- if (!isConfigInput(config)) {
25304
- throw new Error(`Config file "${resolved}" must export an object configuration.`);
25305
- }
25306
- return config;
25307
- };
25308
-
25309
25383
  // src/core/loadIslandRegistry.ts
25310
25384
  init_islandEntries();
25311
25385
  import { resolve as resolve9 } from "path";
@@ -32573,5 +32647,5 @@ export {
32573
32647
  ANGULAR_INIT_TIMEOUT_MS
32574
32648
  };
32575
32649
 
32576
- //# debugId=955376BF8D8A029164756E2164756E21
32650
+ //# debugId=20AB647BED125D3764756E2164756E21
32577
32651
  //# sourceMappingURL=index.js.map