@absolutejs/absolute 0.19.0-beta.1044 → 0.19.0-beta.1045

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-eZDCPd/src/core/streamingSlotRegistrar.ts
4
+ // .angular-partial-tmp-uw7ILL/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-eZDCPd/src/core/streamingSlotRegistrar.ts
4
+ // .angular-partial-tmp-uw7ILL/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-eZDCPd/src/core/streamingSlotRegistry.ts
51
+ // .angular-partial-tmp-uw7ILL/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
@@ -173871,144 +173871,80 @@ var exports_api = {};
173871
173871
  __export(exports_api, {
173872
173872
  runApi: () => runApi
173873
173873
  });
173874
- var METHOD_COLOR2, printDim2 = (message) => process.stdout.write(`${colors.dim}${message}${colors.reset}
173875
- `), fetchRoutes = async (url) => {
173874
+ var METHOD_COLOR2, HTTP_METHODS, printDim2 = (message) => process.stdout.write(`${colors.dim}${message}${colors.reset}
173875
+ `), isInternal = (path) => path.startsWith("/__absolute") || path.startsWith("/openapi") || path.startsWith("/hmr"), fetchSpec = async (url) => {
173876
173876
  try {
173877
- const response = await fetch(`${url}__absolute/routes`);
173877
+ const response = await fetch(`${url}openapi/json`);
173878
173878
  if (!response.ok)
173879
173879
  return null;
173880
- const data = await response.json();
173881
- if (!Array.isArray(data))
173882
- return null;
173883
- return data.map((entry) => ({
173884
- method: String(entry.method ?? "").toUpperCase(),
173885
- path: String(entry.path ?? ""),
173886
- schema: {
173887
- body: entry.schema?.body ?? null,
173888
- params: entry.schema?.params ?? null,
173889
- query: entry.schema?.query ?? null,
173890
- response: entry.schema?.response ?? null
173891
- }
173892
- }));
173880
+ return await response.json();
173893
173881
  } catch {
173894
173882
  return null;
173895
173883
  }
173896
- }, ASSET_PATH, isInternal = (path) => path === "*" || path.startsWith("/_") || path.startsWith("/.") || path.startsWith("/@") || path.startsWith("/chunk-") || path.startsWith("/node_modules") || path.startsWith("/hmr") || ASSET_PATH.test(path), getProp = (value, key) => typeof value === "object" && value !== null ? Reflect.get(value, key) : undefined, propertyNames = (schema) => {
173884
+ }, getProp = (value, key) => typeof value === "object" && value !== null ? Reflect.get(value, key) : undefined, propertyNames = (schema) => {
173897
173885
  const properties = getProp(schema, "properties");
173898
173886
  return typeof properties === "object" && properties !== null ? Object.keys(properties) : [];
173899
- }, schemaHint = (route) => {
173887
+ }, summarize = (operation) => {
173888
+ const parameters = getProp(operation, "parameters");
173889
+ const names = Array.isArray(parameters) ? parameters.map((param) => getProp(param, "name")).filter((name) => typeof name === "string") : [];
173890
+ const json = getProp(getProp(operation, "requestBody"), "content");
173891
+ const body = propertyNames(getProp(getProp(json, "application/json"), "schema"));
173900
173892
  const parts = [];
173901
- const params = propertyNames(route.schema.params);
173902
- const body = propertyNames(route.schema.body);
173903
- const query = propertyNames(route.schema.query);
173904
- if (params.length > 0)
173905
- parts.push(`params: ${params.join(", ")}`);
173906
- if (query.length > 0)
173907
- parts.push(`query: ${query.join(", ")}`);
173893
+ if (names.length > 0)
173894
+ parts.push(`params: ${names.join(", ")}`);
173908
173895
  if (body.length > 0)
173909
173896
  parts.push(`body: ${body.join(", ")}`);
173910
173897
  return parts.length > 0 ? ` ${colors.dim}${parts.join(" \xB7 ")}${colors.reset}` : "";
173911
- }, toOpenApiPath = (path) => path.replace(/:([A-Za-z0-9_]+)/g, "{$1}"), paramObjects = (schema, location) => {
173912
- const properties = getProp(schema, "properties");
173913
- if (typeof properties !== "object" || properties === null)
173898
+ }, surfaceRows = (spec) => {
173899
+ const paths = Reflect.get(spec ?? {}, "paths");
173900
+ if (typeof paths !== "object" || paths === null)
173914
173901
  return [];
173915
- const required = getProp(schema, "required");
173916
- const requiredList = Array.isArray(required) ? required : [];
173917
- return Object.entries(properties).map(([name, propSchema]) => ({
173918
- in: location,
173919
- name,
173920
- required: requiredList.includes(name),
173921
- schema: propSchema
173922
- }));
173923
- }, buildResponses = (response) => {
173924
- if (typeof response !== "object" || response === null) {
173925
- return { "200": { description: "OK" } };
173926
- }
173927
- if (typeof getProp(response, "type") === "string") {
173928
- return {
173929
- "200": {
173930
- content: { "application/json": { schema: response } },
173931
- description: "OK"
173932
- }
173933
- };
173934
- }
173935
- const responses = {};
173936
- for (const [status2, schema] of Object.entries(response)) {
173937
- responses[status2] = {
173938
- content: { "application/json": { schema } },
173939
- description: "Response"
173940
- };
173941
- }
173942
- return responses;
173943
- }, operationFor = (route) => {
173944
- const operation = {
173945
- operationId: `${route.method.toLowerCase()}${route.path.replace(/[^a-zA-Z0-9]+/g, "_")}`,
173946
- parameters: [
173947
- ...paramObjects(route.schema.params, "path"),
173948
- ...paramObjects(route.schema.query, "query")
173949
- ],
173950
- responses: buildResponses(route.schema.response)
173951
- };
173952
- if (route.schema.body !== null) {
173953
- operation.requestBody = {
173954
- content: { "application/json": { schema: route.schema.body } }
173955
- };
173956
- }
173957
- return operation;
173958
- }, buildOpenApi = (routes) => {
173959
- const paths = {};
173960
- for (const route of routes) {
173961
- const openApiPath = toOpenApiPath(route.path);
173962
- paths[openApiPath] = paths[openApiPath] ?? {};
173963
- paths[openApiPath][route.method.toLowerCase()] = operationFor(route);
173964
- }
173965
- return {
173966
- info: { title: "AbsoluteJS API", version: "1.0.0" },
173967
- openapi: "3.0.3",
173968
- paths
173969
- };
173970
- }, printSurface = (routes, serverName) => {
173971
- const sorted = [...routes].sort((left, right) => left.path.localeCompare(right.path) || left.method.localeCompare(right.method));
173972
- const methodWidth = Math.max(...sorted.map((route) => route.method.length));
173973
- const lines = sorted.map((route) => {
173974
- const color = METHOD_COLOR2[route.method] ?? colors.dim;
173975
- return ` ${color}${padLine(route.method, methodWidth)}${colors.reset} ${route.path}${schemaHint(route)}`;
173976
- });
173977
- process.stdout.write(`${lines.join(`
173978
- `)}
173979
-
173980
- ${colors.dim}${sorted.length} routes \xB7 ${serverName} \xB7 \`absolute api --openapi\` for a spec${colors.reset}
173981
- `);
173902
+ return Object.entries(paths).filter(([path]) => !isInternal(path)).flatMap(([path, methods]) => Object.entries(methods ?? {}).filter(([method]) => HTTP_METHODS.has(method)).map(([method, operation]) => ({
173903
+ method: method.toUpperCase(),
173904
+ path,
173905
+ summary: summarize(operation)
173906
+ })));
173982
173907
  }, runApi = async (args) => {
173983
173908
  const server2 = await findServer();
173984
173909
  if (!server2 || server2.url === null) {
173985
173910
  printDim2("No running server found. Start one with `absolute dev`, then run `absolute api`.");
173986
173911
  return;
173987
173912
  }
173988
- const routes = (await fetchRoutes(server2.url))?.filter((route) => !isInternal(route.path));
173989
- if (!routes) {
173990
- printDim2(`Could not read routes from ${server2.name} \u2014 the API surface needs a dev server.`);
173913
+ if (args.includes("--open")) {
173914
+ openUrlInBrowser(`${server2.url}openapi`, printDim2);
173915
+ printDim2(`Opening ${server2.url}openapi`);
173991
173916
  return;
173992
173917
  }
173993
- if (args.includes("--openapi")) {
173994
- process.stdout.write(`${JSON.stringify(buildOpenApi(routes), null, 2)}
173995
- `);
173918
+ const spec = await fetchSpec(server2.url);
173919
+ if (!spec) {
173920
+ printDim2("OpenAPI is not enabled. Set `openapi: true` in absolute.config.ts (on by default in dev).");
173996
173921
  return;
173997
173922
  }
173998
173923
  if (args.includes("--json")) {
173999
- process.stdout.write(`${JSON.stringify(routes, null, 2)}
173924
+ process.stdout.write(`${JSON.stringify(spec, null, 2)}
174000
173925
  `);
174001
173926
  return;
174002
173927
  }
174003
- if (routes.length === 0) {
174004
- printDim2("No routes registered.");
173928
+ const rows = surfaceRows(spec).sort((left, right) => left.path.localeCompare(right.path) || left.method.localeCompare(right.method));
173929
+ if (rows.length === 0) {
173930
+ printDim2("No documented routes yet.");
174005
173931
  return;
174006
173932
  }
174007
- printSurface(routes, server2.name);
173933
+ const methodWidth = Math.max(...rows.map((row) => row.method.length));
173934
+ const lines = rows.map((row) => {
173935
+ const color = METHOD_COLOR2[row.method] ?? colors.dim;
173936
+ return ` ${color}${padLine(row.method, methodWidth)}${colors.reset} ${row.path}${row.summary}`;
173937
+ });
173938
+ process.stdout.write(`${lines.join(`
173939
+ `)}
173940
+
173941
+ ${colors.dim}${rows.length} routes \xB7 ${server2.name} \xB7 \`absolute api --open\` for the UI${colors.reset}
173942
+ `);
174008
173943
  };
174009
173944
  var init_api = __esm(() => {
174010
173945
  init_inspectData();
174011
173946
  init_tuiPrimitives();
173947
+ init_utils();
174012
173948
  METHOD_COLOR2 = {
174013
173949
  DELETE: colors.red,
174014
173950
  GET: colors.green,
@@ -174016,7 +173952,15 @@ var init_api = __esm(() => {
174016
173952
  POST: colors.cyan,
174017
173953
  PUT: colors.yellow
174018
173954
  };
174019
- ASSET_PATH = /\.[a-z0-9]+$/i;
173955
+ HTTP_METHODS = new Set([
173956
+ "delete",
173957
+ "get",
173958
+ "head",
173959
+ "options",
173960
+ "patch",
173961
+ "post",
173962
+ "put"
173963
+ ]);
174020
173964
  });
174021
173965
 
174022
173966
  // src/cli/scripts/remove.ts
@@ -174494,7 +174438,7 @@ var METHOD_COLOR3, printDim4 = (message) => {
174494
174438
  }, pickServer2 = (instances) => {
174495
174439
  const withUrl = instances.filter((instance) => instance.url !== null);
174496
174440
  return withUrl.find((instance) => instance.source === "dev") ?? withUrl.find((instance) => instance.source !== "untracked") ?? withUrl[0];
174497
- }, fetchRoutes2 = async (url) => {
174441
+ }, fetchRoutes = async (url) => {
174498
174442
  try {
174499
174443
  const response = await fetch(`${url}__absolute/routes`);
174500
174444
  if (!response.ok)
@@ -174516,7 +174460,7 @@ var METHOD_COLOR3, printDim4 = (message) => {
174516
174460
  printDim4("No running server found. Start one with `absolute dev`, then run `absolute routes`.");
174517
174461
  return;
174518
174462
  }
174519
- const routes = await fetchRoutes2(server2.url);
174463
+ const routes = await fetchRoutes(server2.url);
174520
174464
  if (!routes) {
174521
174465
  printDim4(`Could not read routes from ${server2.name} \u2014 route introspection needs a dev server.`);
174522
174466
  return;
@@ -175027,7 +174971,7 @@ var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.
175027
174971
  }
175028
174972
  return lines.join(`
175029
174973
  `);
175030
- }, summarize = (islands) => {
174974
+ }, summarize2 = (islands) => {
175031
174975
  const frameworks3 = new Set(islands.map((island) => island.framework));
175032
174976
  const mounts = islands.reduce((sum, island) => sum + island.mounts.length, 0);
175033
174977
  const crossFramework = islands.reduce((sum, island) => sum + island.mounts.filter((mount) => mount.crossFramework).length, 0);
@@ -175066,7 +175010,7 @@ var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.
175066
175010
 
175067
175011
  `)}
175068
175012
 
175069
- ${colors.dim}${summarize(islands)}${colors.reset}
175013
+ ${colors.dim}${summarize2(islands)}${colors.reset}
175070
175014
  `);
175071
175015
  };
175072
175016
  var init_islands2 = __esm(() => {
@@ -175347,9 +175291,9 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
175347
175291
  if (buildConfig.vueDirectory) {
175348
175292
  copyPackageToBuild("vue", outdir, seen);
175349
175293
  copyPackageToBuild("@vue/server-renderer", outdir, seen);
175350
- copyPackageToBuild("vue-demi", outdir, seen);
175351
175294
  }
175352
175295
  copyAngularRuntimePackages(buildConfig, outdir);
175296
+ copyChunkReferencedPackages(outdir, seen);
175353
175297
  }, collectRuntimePackageSpecifiers = (distDir) => {
175354
175298
  const nodeModulesDir = join27(distDir, "node_modules");
175355
175299
  if (!existsSync30(nodeModulesDir))
@@ -175438,7 +175382,18 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
175438
175382
  if (!entry)
175439
175383
  return null;
175440
175384
  return join27(packageDir, entry);
175441
- }, collectRuntimeRewriteRoots = (distDir) => collectFiles2(distDir).filter((filePath) => isRuntimeJsFile(filePath) && !isNodeModulesPath(filePath)), rewriteRuntimeModuleSpecifiers = (distDir) => {
175385
+ }, collectRuntimeRewriteRoots = (distDir) => collectFiles2(distDir).filter((filePath) => isRuntimeJsFile(filePath) && !isNodeModulesPath(filePath)), toTopLevelPackage = (specifier) => specifier.split("/").slice(0, specifier.startsWith("@") ? 2 : 1).join("/"), copyChunkReferencedPackages = (distDir, seen) => {
175386
+ for (const filePath of collectRuntimeRewriteRoots(distDir)) {
175387
+ const source = readFileSync28(filePath, "utf-8");
175388
+ for (const match of source.matchAll(MODULE_SPECIFIER_RE)) {
175389
+ const specifier = match[3];
175390
+ if (!specifier || specifier.startsWith(".") || specifier.startsWith("/") || specifier.startsWith("#") || specifier.startsWith("node:") || specifier.startsWith("bun:")) {
175391
+ continue;
175392
+ }
175393
+ copyPackageToBuild(toTopLevelPackage(specifier), distDir, seen);
175394
+ }
175395
+ }
175396
+ }, rewriteRuntimeModuleSpecifiers = (distDir) => {
175442
175397
  const packageSpecifiers = collectRuntimePackageSpecifiers(distDir);
175443
175398
  if (packageSpecifiers.length === 0)
175444
175399
  return;
@@ -180109,7 +180064,7 @@ if (command === "dev") {
180109
180064
  console.error(" env [--check] [--json] Report env vars the app reads (getEnv) and which are missing");
180110
180065
  console.error(" add <framework> [--no-install] Add a framework (deps, config, starter page)");
180111
180066
  console.error(" analyze [--save] [--json] Bundle size breakdown + diff vs a saved baseline");
180112
- console.error(" api [--openapi] [--json] Show the API surface (or emit OpenAPI) from a running dev server");
180067
+ console.error(" api [--open] [--json] Show the API surface or open the OpenAPI UI (@elysiajs/openapi)");
180113
180068
  console.error(" eslint Run ESLint (cached)");
180114
180069
  console.error(" generate <page|api|component> <name> [--framework <fw>] Scaffold a page, API plugin, or component");
180115
180070
  console.error(" htmx [version] Self-host htmx \u2014 report or install/upgrade the pinned copy");