astro 6.0.0-beta.11 → 6.0.0-beta.13

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.
Files changed (83) hide show
  1. package/README.md +1 -1
  2. package/client.d.ts +5 -0
  3. package/components/Code.astro +26 -2
  4. package/components/ResponsiveImage.astro +0 -2
  5. package/components/ResponsivePicture.astro +0 -1
  6. package/dist/assets/consts.d.ts +2 -0
  7. package/dist/assets/consts.js +4 -0
  8. package/dist/assets/fonts/providers/index.d.ts +19 -15
  9. package/dist/assets/fonts/providers/index.js +23 -1
  10. package/dist/assets/internal.d.ts +1 -0
  11. package/dist/assets/internal.js +8 -8
  12. package/dist/assets/utils/generateImageStylesCSS.d.ts +1 -0
  13. package/dist/assets/utils/generateImageStylesCSS.js +38 -0
  14. package/dist/assets/vite-plugin-assets.js +60 -30
  15. package/dist/cli/add/index.js +45 -64
  16. package/dist/cli/index.js +3 -3
  17. package/dist/cli/info/infra/{prompts-prompt.d.ts → clack-prompt.d.ts} +1 -1
  18. package/dist/cli/info/infra/{prompts-prompt.js → clack-prompt.js} +7 -8
  19. package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
  20. package/dist/cli/install-package.js +16 -21
  21. package/dist/container/index.js +1 -0
  22. package/dist/content/content-layer.js +3 -3
  23. package/dist/content/vite-plugin-content-imports.js +2 -1
  24. package/dist/content/vite-plugin-content-virtual-mod.js +2 -1
  25. package/dist/core/app/entrypoints/index.d.ts +7 -0
  26. package/dist/core/app/{index.js → entrypoints/index.js} +6 -6
  27. package/dist/core/app/entrypoints/manifest.d.ts +1 -0
  28. package/dist/core/app/entrypoints/manifest.js +14 -0
  29. package/dist/core/app/entrypoints/node.d.ts +1 -0
  30. package/dist/core/app/entrypoints/node.js +8 -0
  31. package/dist/core/app/entrypoints/virtual/dev.d.ts +2 -0
  32. package/dist/core/app/{entrypoint → entrypoints/virtual}/dev.js +5 -5
  33. package/dist/core/app/entrypoints/virtual/index.d.ts +2 -0
  34. package/dist/core/app/entrypoints/virtual/index.js +5 -0
  35. package/dist/core/app/entrypoints/virtual/prod.d.ts +2 -0
  36. package/dist/core/app/entrypoints/virtual/prod.js +8 -0
  37. package/dist/core/app/node.d.ts +48 -7
  38. package/dist/core/app/node.js +138 -134
  39. package/dist/core/app/types.d.ts +10 -0
  40. package/dist/core/build/app.d.ts +1 -1
  41. package/dist/core/build/app.js +1 -1
  42. package/dist/core/build/pipeline.js +1 -1
  43. package/dist/core/build/plugins/plugin-manifest.js +6 -1
  44. package/dist/core/build/plugins/plugin-ssr.d.ts +6 -0
  45. package/dist/core/build/plugins/plugin-ssr.js +2 -1
  46. package/dist/core/build/static-build.js +7 -7
  47. package/dist/core/config/merge.js +2 -1
  48. package/dist/core/constants.js +1 -1
  49. package/dist/core/create-vite.js +8 -2
  50. package/dist/core/dev/adapter-validation.js +10 -0
  51. package/dist/core/dev/dev.js +2 -1
  52. package/dist/core/dev/restart.d.ts +1 -0
  53. package/dist/core/dev/restart.js +18 -16
  54. package/dist/core/messages.js +2 -2
  55. package/dist/core/render-context.js +12 -8
  56. package/dist/core/routing/manifest/create.js +1 -1
  57. package/dist/manifest/serialized.js +6 -1
  58. package/dist/manifest/virtual-module.js +20 -1
  59. package/dist/runtime/server/render/util.js +4 -1
  60. package/dist/types/public/integrations.d.ts +76 -31
  61. package/dist/types/public/manifest.d.ts +2 -0
  62. package/dist/virtual-modules/i18n.js +1 -1
  63. package/dist/vite-plugin-adapter-config/index.js +1 -1
  64. package/dist/vite-plugin-app/app.d.ts +1 -1
  65. package/dist/vite-plugin-app/app.js +1 -1
  66. package/dist/vite-plugin-astro-server/plugin.js +6 -1
  67. package/dist/vite-plugin-markdown/index.js +6 -3
  68. package/dist/vite-plugin-renderers/index.d.ts +4 -2
  69. package/dist/vite-plugin-renderers/index.js +9 -0
  70. package/dist/vite-plugin-routes/index.js +1 -1
  71. package/dist/vite-plugin-shiki-styles/index.d.ts +9 -0
  72. package/dist/vite-plugin-shiki-styles/index.js +44 -0
  73. package/package.json +16 -19
  74. package/types/content.d.ts +0 -1
  75. package/components/image.css +0 -11
  76. package/dist/assets/utils/imageAttributes.d.ts +0 -2
  77. package/dist/assets/utils/imageAttributes.js +0 -14
  78. package/dist/core/app/entrypoint/dev.d.ts +0 -2
  79. package/dist/core/app/entrypoint/prod.d.ts +0 -2
  80. package/dist/core/app/entrypoint/prod.js +0 -8
  81. package/dist/core/app/entrypoint.d.ts +0 -1
  82. package/dist/core/app/entrypoint.js +0 -4
  83. package/dist/core/app/index.d.ts +0 -7
@@ -2,16 +2,14 @@ import fsMod, { existsSync, promises as fs } from "node:fs";
2
2
  import { createRequire } from "node:module";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath, pathToFileURL } from "node:url";
5
+ import * as clack from "@clack/prompts";
5
6
  import { assertValidPackageName } from "@astrojs/internal-helpers/cli";
6
- import boxen from "boxen";
7
7
  import { diffWords } from "diff";
8
8
  import { builders, generateCode, loadFile } from "magicast";
9
9
  import { getDefaultExportOptions } from "magicast/helpers";
10
10
  import { detect, resolveCommand } from "package-manager-detector";
11
11
  import colors from "piccolore";
12
- import prompts from "prompts";
13
12
  import maxSatisfying from "semver/ranges/max-satisfying.js";
14
- import yoctoSpinner from "yocto-spinner";
15
13
  import {
16
14
  loadTSConfig,
17
15
  resolveConfig,
@@ -435,19 +433,21 @@ ${list}`
435
433
  )
436
434
  );
437
435
  if (integrations.find((integration) => integration.integrationName === "tailwind")) {
438
- const code = boxen(getDiffContent("---\n---", "---\nimport '../styles/global.css'\n---"), {
439
- margin: 0.5,
440
- padding: 0.5,
441
- borderStyle: "round",
442
- title: "src/layouts/Layout.astro"
443
- });
444
436
  logger.warn(
445
437
  "SKIP_FORMAT",
446
438
  msg.actionRequired(
447
439
  "You must import your Tailwind stylesheet, e.g. in a shared layout:\n"
448
440
  )
449
441
  );
450
- logger.info("SKIP_FORMAT", code + "\n");
442
+ clack.box(
443
+ getDiffContent("---\n---", "---\nimport '../styles/global.css'\n---"),
444
+ "src/layouts/Layout.astro",
445
+ {
446
+ rounded: true,
447
+ withGuide: false,
448
+ width: "auto"
449
+ }
450
+ );
451
451
  }
452
452
  }
453
453
  }
@@ -571,20 +571,16 @@ async function updateAstroConfig({
571
571
  if (!diff) {
572
572
  return 0 /* none */;
573
573
  }
574
- const message = `
575
- ${boxen(diff, {
576
- margin: 0.5,
577
- padding: 0.5,
578
- borderStyle: "round",
579
- title: configURL.pathname.split("/").pop()
580
- })}
581
- `;
582
574
  logger.info(
583
575
  "SKIP_FORMAT",
584
576
  `
585
- ${magenta("Astro will make the following changes to your config file:")}
586
- ${message}`
577
+ ${magenta("Astro will make the following changes to your config file:")}`
587
578
  );
579
+ clack.box(diff, configURL.pathname.split("/").pop(), {
580
+ rounded: true,
581
+ withGuide: false,
582
+ width: "auto"
583
+ });
588
584
  if (logAdapterInstructions) {
589
585
  logger.info(
590
586
  "SKIP_FORMAT",
@@ -635,20 +631,16 @@ async function updatePackageJsonScripts({
635
631
  if (!diff) {
636
632
  return 0 /* none */;
637
633
  }
638
- const message = `
639
- ${boxen(diff, {
640
- margin: 0.5,
641
- padding: 0.5,
642
- borderStyle: "round",
643
- title: "package.json"
644
- })}
645
- `;
646
634
  logger.info(
647
635
  "SKIP_FORMAT",
648
636
  `
649
- ${magenta("Astro will add the following scripts to your package.json:")}
650
- ${message}`
637
+ ${magenta("Astro will add the following scripts to your package.json:")}`
651
638
  );
639
+ clack.box(diff, "package.json", {
640
+ rounded: true,
641
+ withGuide: false,
642
+ width: "auto"
643
+ });
652
644
  if (await askToContinue({ flags, logger })) {
653
645
  await fs.writeFile(pkgPath, output, { encoding: "utf-8" });
654
646
  logger.debug("add", "Updated package.json scripts");
@@ -712,24 +704,22 @@ async function tryToInstallIntegrations({
712
704
  (specifiers) => installCommand.command === "deno" ? specifiers.map((specifier) => `npm:${specifier}`) : specifiers
713
705
  );
714
706
  const coloredOutput = `${bold(installCommand.command)} ${installCommand.args.join(" ")} ${cyan(installSpecifiers.join(" "))}`;
715
- const message = `
716
- ${boxen(coloredOutput, {
717
- margin: 0.5,
718
- padding: 0.5,
719
- borderStyle: "round"
720
- })}
721
- `;
722
707
  logger.info(
723
708
  "SKIP_FORMAT",
724
709
  `
725
710
  ${magenta("Astro will run the following command:")}
726
711
  ${dim(
727
712
  "If you skip this step, you can always run it yourself later"
728
- )}
729
- ${message}`
713
+ )}`
730
714
  );
715
+ clack.box(coloredOutput, void 0, {
716
+ rounded: true,
717
+ withGuide: false,
718
+ width: "auto"
719
+ });
731
720
  if (await askToContinue({ flags, logger })) {
732
- const spinner = yoctoSpinner({ text: "Installing dependencies..." }).start();
721
+ const spinner = clack.spinner({ withGuide: false });
722
+ spinner.start("Installing dependencies...");
733
723
  try {
734
724
  await exec(installCommand.command, [...installCommand.args, ...installSpecifiers], {
735
725
  nodeOptions: {
@@ -738,10 +728,10 @@ ${message}`
738
728
  env: { NODE_ENV: void 0 }
739
729
  }
740
730
  });
741
- spinner.success();
731
+ spinner.stop("Dependencies installed.");
742
732
  return 1 /* updated */;
743
733
  } catch (err) {
744
- spinner.error();
734
+ spinner.error("Error installing dependencies.");
745
735
  logger.debug("add", "Error installing dependencies", err);
746
736
  console.error("\n", err.stdout || err.message, "\n");
747
737
  return 3 /* failure */;
@@ -754,7 +744,8 @@ async function validateIntegrations(integrations, flags, logger) {
754
744
  for (const integration of integrations) {
755
745
  assertValidPackageName(integration);
756
746
  }
757
- const spinner = yoctoSpinner({ text: "Resolving packages..." }).start();
747
+ const spinner = clack.spinner({ withGuide: false });
748
+ spinner.start("Resolving packages...");
758
749
  try {
759
750
  const integrationEntries = await Promise.all(
760
751
  integrations.map(async (integration) => {
@@ -771,9 +762,9 @@ async function validateIntegrations(integrations, flags, logger) {
771
762
  const firstPartyPkgCheck = await fetchPackageJson("@astrojs", name, tag);
772
763
  if (firstPartyPkgCheck instanceof Error) {
773
764
  if (firstPartyPkgCheck.message) {
774
- spinner.warning(yellow(firstPartyPkgCheck.message));
765
+ spinner.message(yellow(firstPartyPkgCheck.message));
775
766
  }
776
- spinner.warning(yellow(`${bold(integration)} is not an official Astro package.`));
767
+ spinner.message(yellow(`${bold(integration)} is not an official Astro package.`));
777
768
  if (!await askToContinue({ flags, logger })) {
778
769
  throw new Error(
779
770
  `No problem! Find our official integrations at ${cyan(
@@ -781,7 +772,7 @@ async function validateIntegrations(integrations, flags, logger) {
781
772
  )}`
782
773
  );
783
774
  }
784
- spinner.start("Resolving with third party packages...");
775
+ spinner.message("Resolving with third party packages...");
785
776
  pkgType = "third-party";
786
777
  } else {
787
778
  pkgType = "first-party";
@@ -792,7 +783,7 @@ async function validateIntegrations(integrations, flags, logger) {
792
783
  const thirdPartyPkgCheck = await fetchPackageJson(scope, name, tag);
793
784
  if (thirdPartyPkgCheck instanceof Error) {
794
785
  if (thirdPartyPkgCheck.message) {
795
- spinner.warning(yellow(thirdPartyPkgCheck.message));
786
+ spinner.message(yellow(thirdPartyPkgCheck.message));
796
787
  }
797
788
  throw new Error(`Unable to fetch ${bold(integration)}. Does the package exist?`);
798
789
  } else {
@@ -846,7 +837,7 @@ async function validateIntegrations(integrations, flags, logger) {
846
837
  };
847
838
  })
848
839
  );
849
- spinner.success();
840
+ spinner.stop("Resolved packages.");
850
841
  return integrationEntries;
851
842
  } catch (e) {
852
843
  if (e instanceof Error) {
@@ -895,19 +886,10 @@ async function updateTSConfig(cwd = process.cwd(), logger, integrationsInfo, fla
895
886
  if (!diff) {
896
887
  return 0 /* none */;
897
888
  }
898
- const message = `
899
- ${boxen(diff, {
900
- margin: 0.5,
901
- padding: 0.5,
902
- borderStyle: "round",
903
- title: configFileName
904
- })}
905
- `;
906
889
  logger.info(
907
890
  "SKIP_FORMAT",
908
891
  `
909
- ${magenta(`Astro will make the following changes to your ${configFileName}:`)}
910
- ${message}`
892
+ ${magenta(`Astro will make the following changes to your ${configFileName}:`)}`
911
893
  );
912
894
  if (firstIntegrationWithTSSettings) {
913
895
  const conflictingIntegrations = Array.from(presets.keys()).filter(
@@ -964,13 +946,12 @@ async function askToContinue({
964
946
  hasHintedAboutYesFlag = true;
965
947
  logger.info("SKIP_FORMAT", dim(" To run this command without prompts, pass the --yes flag\n"));
966
948
  }
967
- const response = await prompts({
968
- type: "confirm",
969
- name: "askToContinue",
970
- message: "Continue?",
971
- initial: true
949
+ const response = await clack.confirm({
950
+ message: colors.bold("Continue?"),
951
+ initialValue: true,
952
+ withGuide: false
972
953
  });
973
- return Boolean(response.askToContinue);
954
+ return response === true;
974
955
  }
975
956
  function getDiffContent(input, output) {
976
957
  let changes = [];
package/dist/cli/index.js CHANGED
@@ -74,7 +74,7 @@ async function runCommand(cmd, flags) {
74
74
  { TinyexecCommandExecutor },
75
75
  { getPackageManager },
76
76
  { StyledDebugInfoFormatter },
77
- { PromptsPrompt },
77
+ { ClackPrompt },
78
78
  { CliClipboard },
79
79
  { PassthroughTextStyler },
80
80
  { infoCommand }
@@ -87,7 +87,7 @@ async function runCommand(cmd, flags) {
87
87
  import("./infra/tinyexec-command-executor.js"),
88
88
  import("./info/core/get-package-manager.js"),
89
89
  import("./info/infra/styled-debug-info-formatter.js"),
90
- import("./info/infra/prompts-prompt.js"),
90
+ import("./info/infra/clack-prompt.js"),
91
91
  import("./info/infra/cli-clipboard.js"),
92
92
  import("./infra/passthrough-text-styler.js"),
93
93
  import("./info/core/info.js")
@@ -107,7 +107,7 @@ async function runCommand(cmd, flags) {
107
107
  }),
108
108
  nodeVersionProvider
109
109
  });
110
- const prompt = new PromptsPrompt({ force: flags.copy });
110
+ const prompt = new ClackPrompt({ force: flags.copy });
111
111
  const clipboard = new CliClipboard({
112
112
  commandExecutor,
113
113
  logger,
@@ -1,5 +1,5 @@
1
1
  import type { Prompt } from '../definitions.js';
2
- export declare class PromptsPrompt implements Prompt {
2
+ export declare class ClackPrompt implements Prompt {
3
3
  #private;
4
4
  constructor({ force }: {
5
5
  force: boolean;
@@ -1,5 +1,5 @@
1
- import prompts from "prompts";
2
- class PromptsPrompt {
1
+ import { confirm } from "@clack/prompts";
2
+ class ClackPrompt {
3
3
  #force;
4
4
  constructor({ force }) {
5
5
  this.#force = force;
@@ -11,15 +11,14 @@ class PromptsPrompt {
11
11
  if (this.#force) {
12
12
  return true;
13
13
  }
14
- const { value } = await prompts({
15
- type: "confirm",
16
- name: "value",
14
+ const response = await confirm({
17
15
  message,
18
- initial: defaultValue
16
+ initialValue: defaultValue,
17
+ withGuide: false
19
18
  });
20
- return value;
19
+ return response === true;
21
20
  }
22
21
  }
23
22
  export {
24
- PromptsPrompt
23
+ ClackPrompt
25
24
  };
@@ -1,6 +1,6 @@
1
1
  class BuildTimeAstroVersionProvider {
2
2
  // Injected during the build through esbuild define
3
- version = "6.0.0-beta.11";
3
+ version = "6.0.0-beta.13";
4
4
  }
5
5
  export {
6
6
  BuildTimeAstroVersionProvider
@@ -1,10 +1,8 @@
1
1
  import { createRequire } from "node:module";
2
- import boxen from "boxen";
2
+ import * as clack from "@clack/prompts";
3
3
  import ci from "ci-info";
4
4
  import { detect, resolveCommand } from "package-manager-detector";
5
5
  import colors from "piccolore";
6
- import prompts from "prompts";
7
- import yoctoSpinner from "yocto-spinner";
8
6
  import { exec } from "./exec.js";
9
7
  const require2 = createRequire(import.meta.url);
10
8
  const { bold, cyan, dim, magenta } = colors;
@@ -48,35 +46,32 @@ async function installPackage(packageNames, options, logger) {
48
46
  packageNames = packageNames.map((name) => `npm:${name}`);
49
47
  }
50
48
  const coloredOutput = `${bold(installCommand.command)} ${installCommand.args.join(" ")} ${cyan(packageNames.join(" "))}`;
51
- const message = `
52
- ${boxen(coloredOutput, {
53
- margin: 0.5,
54
- padding: 0.5,
55
- borderStyle: "round"
56
- })}
57
- `;
58
49
  logger.info(
59
50
  "SKIP_FORMAT",
60
51
  `
61
52
  ${magenta("Astro will run the following command:")}
62
53
  ${dim(
63
54
  "If you skip this step, you can always run it yourself later"
64
- )}
65
- ${message}`
55
+ )}`
66
56
  );
57
+ clack.box(coloredOutput, void 0, {
58
+ rounded: true,
59
+ withGuide: false,
60
+ width: "auto"
61
+ });
67
62
  let response;
68
63
  if (options.skipAsk) {
69
64
  response = true;
70
65
  } else {
71
- response = (await prompts({
72
- type: "confirm",
73
- name: "askToContinue",
74
- message: "Continue?",
75
- initial: true
76
- })).askToContinue;
66
+ response = await clack.confirm({
67
+ message: colors.bold("Continue?"),
68
+ initialValue: true,
69
+ withGuide: false
70
+ }) === true;
77
71
  }
78
72
  if (Boolean(response)) {
79
- const spinner = yoctoSpinner({ text: "Installing dependencies..." }).start();
73
+ const spinner = clack.spinner({ withGuide: false });
74
+ spinner.start("Installing dependencies...");
80
75
  try {
81
76
  await exec(installCommand.command, [...installCommand.args, ...packageNames], {
82
77
  nodeOptions: {
@@ -85,11 +80,11 @@ ${message}`
85
80
  env: { NODE_ENV: void 0 }
86
81
  }
87
82
  });
88
- spinner.success();
83
+ spinner.stop("Dependencies installed.");
89
84
  return true;
90
85
  } catch (err) {
91
86
  logger.debug("add", "Error installing dependencies", err);
92
- spinner.error();
87
+ spinner.error("Failed to install dependencies.");
93
88
  return false;
94
89
  }
95
90
  } else {
@@ -50,6 +50,7 @@ function createManifest(manifest, renderers, middleware) {
50
50
  middleware: manifest?.middleware ?? middlewareInstance,
51
51
  key: createKey(),
52
52
  csp: manifest?.csp,
53
+ image: manifest?.image ?? {},
53
54
  shouldInjectCspMetaTags: false,
54
55
  devToolbar: {
55
56
  enabled: false,
@@ -181,7 +181,7 @@ ${contentConfig.error.message}`
181
181
  logger.info("Content config changed");
182
182
  shouldClear = true;
183
183
  }
184
- if (previousAstroVersion && previousAstroVersion !== "6.0.0-beta.11") {
184
+ if (previousAstroVersion && previousAstroVersion !== "6.0.0-beta.13") {
185
185
  logger.info("Astro version changed");
186
186
  shouldClear = true;
187
187
  }
@@ -189,8 +189,8 @@ ${contentConfig.error.message}`
189
189
  logger.info("Clearing content store");
190
190
  this.#store.clearAll();
191
191
  }
192
- if ("6.0.0-beta.11") {
193
- await this.#store.metaStore().set("astro-version", "6.0.0-beta.11");
192
+ if ("6.0.0-beta.13") {
193
+ await this.#store.metaStore().set("astro-version", "6.0.0-beta.13");
194
194
  }
195
195
  if (currentConfigDigest) {
196
196
  await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -122,6 +122,7 @@ export const _internal = {
122
122
  viteServer.watcher.on("all", async (event, entry) => {
123
123
  if (CHOKIDAR_MODIFIED_EVENTS.includes(event)) {
124
124
  const environment = viteServer.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr];
125
+ const timestamp = Date.now();
125
126
  const entryType = getEntryType(entry, contentPaths, contentEntryExts, dataEntryExts);
126
127
  if (!COLLECTION_TYPES_TO_INVALIDATE_ON.includes(entryType)) return;
127
128
  if (entryType === "content" || entryType === "data") {
@@ -136,7 +137,7 @@ export const _internal = {
136
137
  try {
137
138
  const mod = await environment.moduleGraph.getModuleByUrl(modUrl);
138
139
  if (mod) {
139
- environment.moduleGraph.invalidateModule(mod);
140
+ environment.moduleGraph.invalidateModule(mod, void 0, timestamp, true);
140
141
  }
141
142
  } catch (e) {
142
143
  if (e.code === "ERR_CLOSED_SERVER") break;
@@ -27,7 +27,8 @@ function invalidateDataStore(viteServer) {
27
27
  const environment = viteServer.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr];
28
28
  const module = environment.moduleGraph.getModuleById(RESOLVED_DATA_STORE_VIRTUAL_ID);
29
29
  if (module) {
30
- environment.moduleGraph.invalidateModule(module);
30
+ const timestamp = Date.now();
31
+ environment.moduleGraph.invalidateModule(module, void 0, timestamp, true);
31
32
  }
32
33
  viteServer.environments.client.hot.send({
33
34
  type: "full-reload",
@@ -0,0 +1,7 @@
1
+ export type { RoutesList } from '../../../types/astro.js';
2
+ export { App } from '../app.js';
3
+ export { BaseApp, type RenderErrorOptions, type RenderOptions } from '../base.js';
4
+ export { fromRoutingStrategy, toRoutingStrategy } from '../common.js';
5
+ export { createConsoleLogger } from '../logging.js';
6
+ export { deserializeManifest, deserializeRouteData, deserializeRouteInfo, serializeRouteData, serializeRouteInfo, } from '../manifest.js';
7
+ export { AppPipeline } from '../pipeline.js';
@@ -1,15 +1,15 @@
1
- import { App } from "./app.js";
2
- import { BaseApp } from "./base.js";
3
- import { fromRoutingStrategy, toRoutingStrategy } from "./common.js";
4
- import { createConsoleLogger } from "./logging.js";
1
+ import { App } from "../app.js";
2
+ import { BaseApp } from "../base.js";
3
+ import { fromRoutingStrategy, toRoutingStrategy } from "../common.js";
4
+ import { createConsoleLogger } from "../logging.js";
5
5
  import {
6
6
  deserializeManifest,
7
7
  deserializeRouteData,
8
8
  deserializeRouteInfo,
9
9
  serializeRouteData,
10
10
  serializeRouteInfo
11
- } from "./manifest.js";
12
- import { AppPipeline } from "./pipeline.js";
11
+ } from "../manifest.js";
12
+ import { AppPipeline } from "../pipeline.js";
13
13
  export {
14
14
  App,
15
15
  AppPipeline,
@@ -0,0 +1 @@
1
+ export { type SerializedRouteData, deserializeManifest, deserializeRouteData, deserializeRouteInfo, serializeRouteData, serializeRouteInfo, } from '../manifest.js';
@@ -0,0 +1,14 @@
1
+ import {
2
+ deserializeManifest,
3
+ deserializeRouteData,
4
+ deserializeRouteInfo,
5
+ serializeRouteData,
6
+ serializeRouteInfo
7
+ } from "../manifest.js";
8
+ export {
9
+ deserializeManifest,
10
+ deserializeRouteData,
11
+ deserializeRouteInfo,
12
+ serializeRouteData,
13
+ serializeRouteInfo
14
+ };
@@ -0,0 +1 @@
1
+ export { NodeApp, loadApp, loadManifest, createRequest, writeResponse } from '../node.js';
@@ -0,0 +1,8 @@
1
+ import { NodeApp, loadApp, loadManifest, createRequest, writeResponse } from "../node.js";
2
+ export {
3
+ NodeApp,
4
+ createRequest,
5
+ loadApp,
6
+ loadManifest,
7
+ writeResponse
8
+ };
@@ -0,0 +1,2 @@
1
+ import type { CreateApp } from '../../types.js';
2
+ export declare const createApp: CreateApp;
@@ -1,10 +1,10 @@
1
1
  import { manifest } from "virtual:astro:manifest";
2
- import { DevApp } from "../dev/app.js";
3
- import { createConsoleLogger } from "../logging.js";
2
+ import { DevApp } from "../../dev/app.js";
3
+ import { createConsoleLogger } from "../../logging.js";
4
4
  let currentDevApp = null;
5
- function createApp() {
5
+ const createApp = ({ streaming } = {}) => {
6
6
  const logger = createConsoleLogger(manifest.logLevel);
7
- currentDevApp = new DevApp(manifest, true, logger);
7
+ currentDevApp = new DevApp(manifest, streaming, logger);
8
8
  if (import.meta.hot) {
9
9
  import.meta.hot.on("astro:routes-updated", async () => {
10
10
  if (!currentDevApp) return;
@@ -21,7 +21,7 @@ function createApp() {
21
21
  });
22
22
  }
23
23
  return currentDevApp;
24
- }
24
+ };
25
25
  export {
26
26
  createApp
27
27
  };
@@ -0,0 +1,2 @@
1
+ import type { CreateApp } from '../../types.js';
2
+ export declare const createApp: CreateApp;
@@ -0,0 +1,5 @@
1
+ import { createApp as _createApp } from "virtual:astro:app";
2
+ const createApp = _createApp;
3
+ export {
4
+ createApp
5
+ };
@@ -0,0 +1,2 @@
1
+ import type { CreateApp } from '../../types.js';
2
+ export declare const createApp: CreateApp;
@@ -0,0 +1,8 @@
1
+ import { manifest } from "virtual:astro:manifest";
2
+ import { App } from "../../app.js";
3
+ const createApp = ({ streaming } = {}) => {
4
+ return new App(manifest, streaming);
5
+ };
6
+ export {
7
+ createApp
8
+ };
@@ -1,7 +1,7 @@
1
1
  import type { IncomingMessage, ServerResponse } from 'node:http';
2
2
  import type { RemotePattern } from '../../types/public/config.js';
3
- import type { RenderOptions } from './index.js';
4
- import { App } from './index.js';
3
+ import type { RenderOptions } from './base.js';
4
+ import { App } from './app.js';
5
5
  import type { NodeAppHeadersJson, SSRManifest } from './types.js';
6
6
  /**
7
7
  * Allow the request body to be explicitly overridden. For example, this
@@ -10,6 +10,48 @@ import type { NodeAppHeadersJson, SSRManifest } from './types.js';
10
10
  interface NodeRequest extends IncomingMessage {
11
11
  body?: unknown;
12
12
  }
13
+ /**
14
+ * Converts a NodeJS IncomingMessage into a web standard Request.
15
+ * ```js
16
+ * import { createApp } from 'astro/app/entrypoint';
17
+ * import { createRequest } from 'astro/app/node';
18
+ * import { createServer } from 'node:http';
19
+ *
20
+ * const app = createApp();
21
+ *
22
+ * const server = createServer(async (req, res) => {
23
+ * const request = createRequest(req);
24
+ * const response = await app.render(request);
25
+ * })
26
+ * ```
27
+ */
28
+ export declare function createRequest(req: NodeRequest, { skipBody, allowedDomains, }?: {
29
+ skipBody?: boolean;
30
+ allowedDomains?: Partial<RemotePattern>[];
31
+ }): Request;
32
+ /**
33
+ * Streams a web-standard Response into a NodeJS Server Response.
34
+ * ```js
35
+ * import { createApp } from 'astro/app/entrypoint';
36
+ * import { createRequest, writeResponse } from 'astro/app/node';
37
+ * import { createServer } from 'node:http';
38
+ *
39
+ * const app = createApp();
40
+ *
41
+ * const server = createServer(async (req, res) => {
42
+ * const request = createRequest(req);
43
+ * const response = await app.render(request);
44
+ * await writeResponse(response, res);
45
+ * })
46
+ * ```
47
+ * @param source WhatWG Response
48
+ * @param destination NodeJS ServerResponse
49
+ */
50
+ export declare function writeResponse(source: Response, destination: ServerResponse): Promise<ServerResponse<IncomingMessage> | undefined>;
51
+ /**
52
+ * @deprecated Use `App` or `createApp()` instead, and use in conjunction with `convertRequest()`
53
+ * and `writeResponse()` helpers. This will be removed in a future major version.
54
+ */
13
55
  export declare class NodeApp extends App {
14
56
  headersMap: NodeAppHeadersJson | undefined;
15
57
  setHeadersMap(headers: NodeAppHeadersJson): void;
@@ -28,10 +70,7 @@ export declare class NodeApp extends App {
28
70
  * })
29
71
  * ```
30
72
  */
31
- static createRequest(req: NodeRequest, { skipBody, allowedDomains, }?: {
32
- skipBody?: boolean;
33
- allowedDomains?: Partial<RemotePattern>[];
34
- }): Request;
73
+ static createRequest: typeof createRequest;
35
74
  /**
36
75
  * Streams a web-standard Response into a NodeJS Server Response.
37
76
  * ```js
@@ -47,8 +86,10 @@ export declare class NodeApp extends App {
47
86
  * @param source WhatWG Response
48
87
  * @param destination NodeJS ServerResponse
49
88
  */
50
- static writeResponse(source: Response, destination: ServerResponse): Promise<ServerResponse<IncomingMessage> | undefined>;
89
+ static writeResponse: typeof writeResponse;
51
90
  }
91
+ /** @deprecated This will be removed in a future major version. */
52
92
  export declare function loadManifest(rootFolder: URL): Promise<SSRManifest>;
93
+ /** @deprecated This will be removed in a future major version. */
53
94
  export declare function loadApp(rootFolder: URL): Promise<NodeApp>;
54
95
  export {};