@absolutejs/absolute 0.19.0-beta.945 → 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/cli/index.js CHANGED
@@ -2905,6 +2905,53 @@ var dev = async (serverEntry, configPath2) => {
2905
2905
  };
2906
2906
  let serverProcess = spawnServer();
2907
2907
  const sessionStart = Date.now();
2908
+ let serverRestartPending = false;
2909
+ const scheduleServerRestart = (filePath) => {
2910
+ if (serverRestartPending)
2911
+ return;
2912
+ serverRestartPending = true;
2913
+ const relPath = filePath.startsWith(process.cwd()) ? filePath.slice(process.cwd().length + 1) : filePath;
2914
+ console.log(cliTag("\x1B[36m", `Server file changed: ${relPath} \u2014 restarting...`));
2915
+ setTimeout(() => {
2916
+ serverRestartPending = false;
2917
+ restartServer().catch((err) => {
2918
+ console.error(cliTag("\x1B[31m", `Restart failed: ${err}`));
2919
+ });
2920
+ }, 80);
2921
+ };
2922
+ try {
2923
+ const { watch, existsSync: existsSync6 } = await import("fs");
2924
+ const { dirname: dirname3, basename } = await import("path");
2925
+ const absServerEntry = resolve3(serverEntry);
2926
+ const serverEntryDir = dirname3(absServerEntry);
2927
+ const serverEntryBase = basename(absServerEntry);
2928
+ const fsWatcher = watch(serverEntryDir, { persistent: false }, (eventType, filename) => {
2929
+ if (eventType !== "change" && eventType !== "rename")
2930
+ return;
2931
+ if (filename !== serverEntryBase)
2932
+ return;
2933
+ scheduleServerRestart(absServerEntry);
2934
+ });
2935
+ fsWatcher.unref();
2936
+ const configCandidates = ["absolute.config.ts", "absolute.config.js"];
2937
+ const projectRoot = process.cwd();
2938
+ for (const candidate of configCandidates) {
2939
+ const absCandidate = resolve3(projectRoot, candidate);
2940
+ if (!existsSync6(absCandidate))
2941
+ continue;
2942
+ const candidateBase = basename(absCandidate);
2943
+ const configWatcher = watch(dirname3(absCandidate), { persistent: false }, (eventType, filename) => {
2944
+ if (eventType !== "change" && eventType !== "rename")
2945
+ return;
2946
+ if (filename !== candidateBase)
2947
+ return;
2948
+ scheduleServerRestart(absCandidate);
2949
+ });
2950
+ configWatcher.unref();
2951
+ }
2952
+ } catch (err) {
2953
+ console.error(cliTag("\x1B[33m", `Failed to set up server entry watcher: ${err}`));
2954
+ }
2908
2955
  let frameworks = [];
2909
2956
  try {
2910
2957
  const cfg = await loadConfig(configPath2);
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";
@@ -19144,6 +19263,7 @@ var resolveBuildPaths = (config) => {
19144
19263
  emberDir: optional(config.emberDirectory),
19145
19264
  htmlDir: optional(config.htmlDirectory),
19146
19265
  htmxDir: optional(config.htmxDirectory),
19266
+ publicDir: optional(config.publicDirectory),
19147
19267
  reactDir: optional(config.reactDirectory),
19148
19268
  stylesDir: optional(typeof config.stylesConfig === "string" ? config.stylesConfig : config.stylesConfig?.path),
19149
19269
  svelteDir: optional(config.svelteDirectory),
@@ -20852,6 +20972,54 @@ export default {};
20852
20972
  }, transformAndCache = async (filePath, ext, projectRoot, rewriter, vueDir, stylePreprocessors) => {
20853
20973
  if (ext === ".css")
20854
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
+ }
20855
21023
  const isSvelte = ext === ".svelte" || filePath.endsWith(".svelte.ts") || filePath.endsWith(".svelte.js");
20856
21024
  const cached = getTransformed(filePath);
20857
21025
  if (cached)
@@ -21589,6 +21757,42 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
21589
21757
  if (!hasFileChanged(filePath, currentHash, state.fileHashes)) {
21590
21758
  return;
21591
21759
  }
21760
+ const publicDir = state.resolvedPaths.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;
21768
+ try {
21769
+ const relFromDir = normalizedSource.slice(normalizedDir.length + 1);
21770
+ const buildDir = state.resolvedPaths.buildDir;
21771
+ const destPath = resolve39(buildDir, urlPrefix ? `${urlPrefix}/${relFromDir}` : relFromDir);
21772
+ const { mkdir: mkdir7, copyFile, readFile: readFile6 } = await import("fs/promises");
21773
+ const { dirname: dirname23 } = await import("path");
21774
+ await mkdir7(dirname23(destPath), { recursive: true });
21775
+ await copyFile(absSource, destPath);
21776
+ const bytes = await readFile6(destPath);
21777
+ const webPath = urlPrefix ? `/${urlPrefix}/${relFromDir}` : `/${relFromDir}`;
21778
+ state.assetStore.set(webPath, new Uint8Array(bytes));
21779
+ state.fileHashes.set(absSource, currentHash);
21780
+ logHmrUpdate(relative16(process.cwd(), filePath));
21781
+ broadcastToClients(state, {
21782
+ data: {
21783
+ framework: urlPrefix || "public",
21784
+ manifest: state.manifest
21785
+ },
21786
+ message: `${urlPrefix || "Public"} asset updated`,
21787
+ type: "style-update"
21788
+ });
21789
+ } catch {}
21790
+ return true;
21791
+ };
21792
+ if (publicDir && await handleStaticMirror(publicDir, ""))
21793
+ return;
21794
+ if (assetsDir && await handleStaticMirror(assetsDir, "assets"))
21795
+ return;
21592
21796
  if (framework === "unknown") {
21593
21797
  invalidate(resolve39(filePath));
21594
21798
  const relPath = relative16(process.cwd(), filePath);
@@ -21873,7 +22077,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
21873
22077
  tier: 1
21874
22078
  };
21875
22079
  }
21876
- 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")) {
21877
22081
  const normalized = editedFile.replace(/\\/g, "/");
21878
22082
  const angularDirAbs = resolve39(angularDir).replace(/\\/g, "/");
21879
22083
  if (normalized.startsWith(angularDirAbs + "/")) {
@@ -25171,117 +25375,11 @@ var handleHTMXPageRequest = async (pagePath) => {
25171
25375
  });
25172
25376
  };
25173
25377
  // src/core/prepare.ts
25378
+ init_loadConfig();
25174
25379
  import { existsSync as existsSync30, readdirSync as readdirSync3, readFileSync as readFileSync23 } from "fs";
25175
25380
  import { basename as basename13, join as join34, relative as relative17, resolve as resolve43 } from "path";
25176
25381
  import { Elysia as Elysia5 } from "elysia";
25177
25382
 
25178
- // src/utils/loadConfig.ts
25179
- import { resolve as resolve8 } from "path";
25180
- var RESERVED_TOP_LEVEL_KEYS = new Set([
25181
- "assetsDirectory",
25182
- "astroDirectory",
25183
- "buildDirectory",
25184
- "bunBuild",
25185
- "command",
25186
- "config",
25187
- "cwd",
25188
- "dependsOn",
25189
- "dev",
25190
- "emberDirectory",
25191
- "entry",
25192
- "env",
25193
- "htmlDirectory",
25194
- "htmxDirectory",
25195
- "images",
25196
- "incrementalFiles",
25197
- "islands",
25198
- "kind",
25199
- "mode",
25200
- "options",
25201
- "port",
25202
- "postcss",
25203
- "publicDirectory",
25204
- "reactDirectory",
25205
- "sitemap",
25206
- "static",
25207
- "stylesConfig",
25208
- "svelteDirectory",
25209
- "tailwind",
25210
- "ready",
25211
- "visibility",
25212
- "vueDirectory"
25213
- ]);
25214
- var isObject = (value) => typeof value === "object" && value !== null;
25215
- var isCommandService = (service) => service.kind === "command" || Array.isArray(service.command);
25216
- var isServiceCandidate = (value) => isObject(value) && (typeof value.entry === "string" || Array.isArray(value.command));
25217
- var isWorkspaceConfig = (config) => {
25218
- if (!isObject(config)) {
25219
- return false;
25220
- }
25221
- const entries = Object.entries(config);
25222
- if (entries.length === 0) {
25223
- return false;
25224
- }
25225
- if (entries.some(([key]) => RESERVED_TOP_LEVEL_KEYS.has(key))) {
25226
- return false;
25227
- }
25228
- return entries.every(([, value]) => isServiceCandidate(value));
25229
- };
25230
- var isConfigInput = (value) => isObject(value);
25231
- var getWorkspaceServices = (config) => {
25232
- if (!isWorkspaceConfig(config)) {
25233
- 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`.");
25234
- }
25235
- return config;
25236
- };
25237
- var projectServiceConfig = (config, serviceName) => {
25238
- const services = getWorkspaceServices(config);
25239
- const service = services[serviceName];
25240
- if (!service) {
25241
- throw new Error(`Config file does not define service "${serviceName}".`);
25242
- }
25243
- if (isCommandService(service)) {
25244
- throw new Error(`Service "${serviceName}" is a command service and cannot be loaded as an AbsoluteJS app config.`);
25245
- }
25246
- const {
25247
- command: _command,
25248
- config: _config,
25249
- cwd: _cwd,
25250
- dependsOn: _dependsOn,
25251
- env: _env,
25252
- kind: _kind,
25253
- port: _port,
25254
- ready: _ready,
25255
- visibility: _visibility,
25256
- ...serviceConfig
25257
- } = service;
25258
- return serviceConfig;
25259
- };
25260
- var loadConfig = async (configPath) => {
25261
- const config = await loadRawConfig(configPath);
25262
- const serviceName = process.env.ABSOLUTE_WORKSPACE_SERVICE_NAME;
25263
- if (typeof serviceName === "string" && serviceName.length > 0) {
25264
- return projectServiceConfig(config, serviceName);
25265
- }
25266
- if (isWorkspaceConfig(config)) {
25267
- 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.");
25268
- }
25269
- return config;
25270
- };
25271
- var loadRawConfig = async (configPath) => {
25272
- const resolved = resolve8(configPath ?? process.env.ABSOLUTE_CONFIG ?? "absolute.config.ts");
25273
- const mod = await import(resolved);
25274
- const config = mod.default ?? mod.config;
25275
- if (!config) {
25276
- throw new Error(`Config file "${resolved}" does not export a valid configuration.
25277
- Expected: export default defineConfig({ ... })`);
25278
- }
25279
- if (!isConfigInput(config)) {
25280
- throw new Error(`Config file "${resolved}" must export an object configuration.`);
25281
- }
25282
- return config;
25283
- };
25284
-
25285
25383
  // src/core/loadIslandRegistry.ts
25286
25384
  init_islandEntries();
25287
25385
  import { resolve as resolve9 } from "path";
@@ -32549,5 +32647,5 @@ export {
32549
32647
  ANGULAR_INIT_TIMEOUT_MS
32550
32648
  };
32551
32649
 
32552
- //# debugId=0AB756D9EEFF95BC64756E2164756E21
32650
+ //# debugId=20AB647BED125D3764756E2164756E21
32553
32651
  //# sourceMappingURL=index.js.map